spacecp_magic.php
4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: spacecp_magic.php 26763 2011-12-22 09:28:20Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$space['credit'] = $space['credits'];
$op = empty($_GET['op']) ? "view" : $_GET['op'];
$mid = empty($_GET['mid']) ? '' : trim($_GET['mid']);
if(!checkperm('allowmagics')) {
showmessage('magic_groupid_not_allowed');
}
if($op == 'cancelflicker') {
$mid = 'flicker';
$_GET['idtype'] = 'cid';
$_GET['id'] = intval($_GET['id']);
$value = C::t('home_comment')->fetch($_GET['id'], $_G['uid']);
if(!$value || !$value['magicflicker']) {
showmessage('no_flicker_yet');
}
if(submitcheck('cancelsubmit')) {
C::t('home_comment')->update('', array('magicflicker'=>0), $_G['uid']);
showmessage('do_success', dreferer(), array(), array('showdialog' => 1, 'closetime' => true));
}
} elseif($op == 'cancelcolor') {
$mid = 'color';
$_GET['id'] = intval($_GET['id']);
$mapping = array('blogid'=>'blogfield', 'tid'=>'thread');
$tablename = $mapping[$_GET['idtype']];
if(empty($tablename)) {
showmessage('no_color_yet');
}
$value = C::t($tablename)->fetch($_GET['id']);
if(!$value || $value['uid'] != $_G['uid'] || !$value['magiccolor']) {
showmessage('no_color_yet');
}
if(submitcheck('cancelsubmit')) {
DB::update($tablename, array('magiccolor'=>0), array($_GET['idtype']=>$_GET[id]));
$feed = C::t('home_feed')->fetch($_GET['id'], $_GET['idtype']);
if($feed) {
$feed['body_data'] = dunserialize($feed['body_data']);
if($feed['body_data']['magic_color']) {
unset($feed['body_data']['magic_color']);
}
$feed['body_data'] = serialize($feed['body_data']);
C::t('home_feed')->update('', array('body_data'=>$feed['body_data']), '', '', $feed['feedid']);
}
showmessage('do_success', dreferer(), 0);
}
} elseif($op == 'receivegift') {
$uid = intval($_GET['uid']);
$mid = 'gift';
$memberfieldhome = C::t('common_member_field_home')->fetch($uid);
$info = $memberfieldhome['magicgift'] ? dunserialize($memberfieldhome['magicgift']) : array();
unset($memberfieldhome);
if(!empty($info['left'])) {
$info['receiver'] = is_array($info['receiver']) ? $info['receiver'] : array();
if(in_array($_G['uid'], $info['receiver'])) {
showmessage('haved_red_bag');
}
$percredit = min($info['left'], $info['percredit']);
$info['receiver'][] = $_G['uid'];
$info['left'] = $info['left'] - $percredit;
C::t('common_member_field_home')->update($uid, array('magicgift' => ($info['left'] > 0 ? serialize($info) : '')));
$credittype = '';
if(preg_match('/^extcredits[1-8]$/', $info['credittype'])) {
$extcredits = str_replace('extcredits', '', $info['credittype']);
updatemembercount($_G['uid'], array($extcredits => $percredit), 1, 'AGC', $info['magicid']);
$credittype = $_G['setting']['extcredits'][$extcredits]['title'];
}
showmessage('haved_red_bag_gain', dreferer(), array('percredit' => $percredit, 'credittype' => $credittype), array('showdialog' => 1, 'locationtime' => true));
}
showmessage('space_no_red_bag', dreferer(), array(), array('showdialog' => 1, 'locationtime' => true));
} elseif($op == 'retiregift') {
$mid = 'gift';
$memberfieldhome = C::t('common_member_field_home')->fetch($_G['uid']);
$info = $memberfieldhome['magicgift'] ? dunserialize($memberfieldhome['magicgift']) : array();
unset($memberfieldhome);
$leftcredit = intval($info['left']);
if($leftcredit<=0) {
C::t('common_member_field_home')->update($_G['uid'], array('magicgift' => ''));
showmessage('red_bag_no_credits');
}
$extcredits = str_replace('extcredits', '', $info['credittype']);
$credittype = $_G['setting']['extcredits'][$extcredits]['title'];
if(submitcheck('cancelsubmit')) {
C::t('common_member_field_home')->update($_G['uid'], array('magicgift' => ''));
if(preg_match('/^extcredits[1-8]$/', $info['credittype'])) {
updatemembercount($_G['uid'], array($extcredits => $leftcredit), 1, 'RGC', $info['magicid']);
}
showmessage('return_red_bag', dreferer(), array('leftcredit' => $leftcredit, 'credittype' => $credittype), array('showdialog' => 1, 'locationtime' => true));
}
}
include_once template('home/spacecp_magic');
?>