spacecp_top.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: spacecp_top.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $operation = in_array($_GET['op'], array('modify')) ? trim($_GET['op']) : '';
  12. if($_G['setting']['creditstransextra'][6]) {
  13. $key = 'extcredits'.intval($_G['setting']['creditstransextra'][6]);
  14. } elseif ($_G['setting']['creditstrans']) {
  15. $key = 'extcredits'.intval($_G['setting']['creditstrans']);
  16. } else {
  17. showmessage('trade_credit_invalid', '', array(), array('return' => 1));
  18. }
  19. space_merge($space, 'count');
  20. if(submitcheck('friendsubmit')) {
  21. $showcredit = intval($_POST['stakecredit']);
  22. if($showcredit > $space[$key]) $showcredit = $space[$key];
  23. if($showcredit < 1) {
  24. showmessage('showcredit_error');
  25. }
  26. $_POST['fusername'] = trim($_POST['fusername']);
  27. $friend = C::t('home_friend')->fetch_all_by_uid_username($space['uid'], $_POST['fusername'], 0, 1);
  28. $friend = $friend[0];
  29. $fuid = $friend['fuid'];
  30. if(empty($_POST['fusername']) || empty($fuid) || $fuid == $space['uid']) {
  31. showmessage('showcredit_fuid_error', '', array(), array('return' => 1));
  32. }
  33. $count = getcount('home_show', array('uid'=>$fuid));
  34. if($count) {
  35. C::t('home_show')->update_credit_by_uid($fuid, $showcredit, false);
  36. } else {
  37. C::t('home_show')->insert(array('uid'=>$fuid, 'username'=>$_POST['fusername'], 'credit'=>$showcredit), false, true);
  38. }
  39. updatemembercount($space['uid'], array($_G['setting']['creditstransextra'][6] => (0-$showcredit)), true, 'RKC', $space['uid']);
  40. notification_add($fuid, 'credit', 'showcredit', array('credit'=>$showcredit));
  41. if(ckprivacy('show', 'feed')) {
  42. require_once libfile('function/feed');
  43. feed_add('show', 'feed_showcredit', array(
  44. 'fusername' => "<a href=\"home.php?mod=space&uid=$fuid\">{$friend[fusername]}</a>",
  45. 'credit' => $showcredit));
  46. }
  47. showmessage('showcredit_friend_do_success', "misc.php?mod=ranklist&type=member");
  48. } elseif(submitcheck('showsubmit')) {
  49. $showcredit = intval($_POST['showcredit']);
  50. $unitprice = intval($_POST['unitprice']);
  51. if($showcredit > $space[$key]) $showcredit = $space[$key];
  52. if($showcredit < 1 || $unitprice < 1) {
  53. showmessage('showcredit_error', '', array(), array('return' => 1));
  54. }
  55. $_POST['note'] = getstr($_POST['note'], 100);
  56. $_POST['note'] = censor($_POST['note']);
  57. $showarr = C::t('home_show')->fetch($_G['uid']);
  58. if($showarr) {
  59. $notesql = $_POST['note'] ? $_POST['note'] : false;
  60. $unitprice = $unitprice > $showarr['credit']+$showcredit ? $showarr['credit']+$showcredit : $unitprice;
  61. C::t('home_show')->update_credit_by_uid($_G['uid'], $showcredit, false, $unitprice, $notesql);
  62. } else {
  63. $unitprice = $unitprice > $showcredit ? $showcredit : $unitprice;
  64. C::t('home_show')->insert(array('uid'=>$_G['uid'], 'username'=>$_G['username'], 'unitprice' => $unitprice, 'credit'=>$showcredit, 'note'=>$_POST['note']), false, true);
  65. }
  66. updatemembercount($space['uid'], array($_G['setting']['creditstransextra'][6] => (0-$showcredit)), true, 'RKC', $space['uid']);
  67. if(ckprivacy('show', 'feed')) {
  68. require_once libfile('function/feed');
  69. feed_add('show', 'feed_showcredit_self', array('credit'=>$showcredit), '', array(), $_POST['note']);
  70. }
  71. showmessage('showcredit_do_success', dreferer());
  72. }
  73. ?>