spacecp_top.php
3.37 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: spacecp_top.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$operation = in_array($_GET['op'], array('modify')) ? trim($_GET['op']) : '';
if($_G['setting']['creditstransextra'][6]) {
$key = 'extcredits'.intval($_G['setting']['creditstransextra'][6]);
} elseif ($_G['setting']['creditstrans']) {
$key = 'extcredits'.intval($_G['setting']['creditstrans']);
} else {
showmessage('trade_credit_invalid', '', array(), array('return' => 1));
}
space_merge($space, 'count');
if(submitcheck('friendsubmit')) {
$showcredit = intval($_POST['stakecredit']);
if($showcredit > $space[$key]) $showcredit = $space[$key];
if($showcredit < 1) {
showmessage('showcredit_error');
}
$_POST['fusername'] = trim($_POST['fusername']);
$friend = C::t('home_friend')->fetch_all_by_uid_username($space['uid'], $_POST['fusername'], 0, 1);
$friend = $friend[0];
$fuid = $friend['fuid'];
if(empty($_POST['fusername']) || empty($fuid) || $fuid == $space['uid']) {
showmessage('showcredit_fuid_error', '', array(), array('return' => 1));
}
$count = getcount('home_show', array('uid'=>$fuid));
if($count) {
C::t('home_show')->update_credit_by_uid($fuid, $showcredit, false);
} else {
C::t('home_show')->insert(array('uid'=>$fuid, 'username'=>$_POST['fusername'], 'credit'=>$showcredit), false, true);
}
updatemembercount($space['uid'], array($_G['setting']['creditstransextra'][6] => (0-$showcredit)), true, 'RKC', $space['uid']);
notification_add($fuid, 'credit', 'showcredit', array('credit'=>$showcredit));
if(ckprivacy('show', 'feed')) {
require_once libfile('function/feed');
feed_add('show', 'feed_showcredit', array(
'fusername' => "<a href=\"home.php?mod=space&uid=$fuid\">{$friend[fusername]}</a>",
'credit' => $showcredit));
}
showmessage('showcredit_friend_do_success', "misc.php?mod=ranklist&type=member");
} elseif(submitcheck('showsubmit')) {
$showcredit = intval($_POST['showcredit']);
$unitprice = intval($_POST['unitprice']);
if($showcredit > $space[$key]) $showcredit = $space[$key];
if($showcredit < 1 || $unitprice < 1) {
showmessage('showcredit_error', '', array(), array('return' => 1));
}
$_POST['note'] = getstr($_POST['note'], 100);
$_POST['note'] = censor($_POST['note']);
$showarr = C::t('home_show')->fetch($_G['uid']);
if($showarr) {
$notesql = $_POST['note'] ? $_POST['note'] : false;
$unitprice = $unitprice > $showarr['credit']+$showcredit ? $showarr['credit']+$showcredit : $unitprice;
C::t('home_show')->update_credit_by_uid($_G['uid'], $showcredit, false, $unitprice, $notesql);
} else {
$unitprice = $unitprice > $showcredit ? $showcredit : $unitprice;
C::t('home_show')->insert(array('uid'=>$_G['uid'], 'username'=>$_G['username'], 'unitprice' => $unitprice, 'credit'=>$showcredit, 'note'=>$_POST['note']), false, true);
}
updatemembercount($space['uid'], array($_G['setting']['creditstransextra'][6] => (0-$showcredit)), true, 'RKC', $space['uid']);
if(ckprivacy('show', 'feed')) {
require_once libfile('function/feed');
feed_add('show', 'feed_showcredit_self', array('credit'=>$showcredit), '', array(), $_POST['note']);
}
showmessage('showcredit_do_success', dreferer());
}
?>