spacecp_poke.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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_poke.php 34369 2014-04-01 02:00:04Z jeffjzhang $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $uid = empty($_GET['uid'])?0:intval($_GET['uid']);
  12. if($uid == $_G['uid']) {
  13. showmessage('not_to_their_own_greeted');
  14. }
  15. if($op == 'send' || $op == 'reply') {
  16. if(!checkperm('allowpoke')) {
  17. showmessage('no_privilege_poke');
  18. }
  19. cknewuser();
  20. $tospace = array();
  21. if($uid) {
  22. $tospace = getuserbyuid($uid);
  23. } elseif ($_POST['username']) {
  24. $tospace = C::t('common_member')->fetch_uid_by_username($_POST['username']);
  25. }
  26. if($tospace && isblacklist($tospace['uid'])) {
  27. showmessage('is_blacklist');
  28. }
  29. if(submitcheck('pokesubmit')) {
  30. if(empty($tospace)) {
  31. showmessage('space_does_not_exist');
  32. }
  33. $notetext = censor(htmlspecialchars(cutstr($_POST['note'], strtolower(CHARSET) == 'utf-8' ? 30 : 20, '')));
  34. $setarr = array(
  35. 'pokeuid' => $uid+$_G['uid'],
  36. 'uid' => $uid,
  37. 'fromuid' => $_G['uid'],
  38. 'note' => $notetext, //need to do
  39. 'dateline' => $_G['timestamp'],
  40. 'iconid' => intval($_POST['iconid'])
  41. );
  42. C::t('home_pokearchive')->insert($setarr);
  43. $setarr = array(
  44. 'uid' => $uid,
  45. 'fromuid' => $_G['uid'],
  46. 'fromusername' => $_G['username'],
  47. 'note' => $notetext,
  48. 'dateline' => $_G['timestamp'],
  49. 'iconid' => intval($_POST['iconid'])
  50. );
  51. C::t('home_poke')->insert($setarr, false, true);
  52. require_once libfile('function/friend');
  53. friend_addnum($tospace['uid']);
  54. if($op == 'reply') {
  55. C::t('home_poke')->delete_by_uid_fromuid($_G['uid'], $uid);
  56. C::t('common_member')->increase($_G['uid'], array('newprompt' => -1));
  57. }
  58. updatecreditbyaction('poke', 0, array(), $uid);
  59. if($setarr['iconid']) {
  60. require_once libfile('function/spacecp');
  61. $pokemsg = makepokeaction($setarr['iconid']);
  62. } else {
  63. $pokemsg = lang('home/template', 'say_hi');
  64. }
  65. if(!empty($setarr['note'])) {
  66. $pokemsg .= ', '.lang('home/template', 'say').':'.$setarr['note'];
  67. }
  68. $note = array(
  69. 'fromurl' => 'home.php?mod=space&uid='.$_G['uid'],
  70. 'fromusername' => $_G['username'],
  71. 'fromuid' => $_G['uid'],
  72. 'from_id' => $_G['uid'],
  73. 'from_idtype' => 'pokequery',
  74. 'pokemsg' => $pokemsg
  75. );
  76. notification_add($uid, 'poke', 'poke_request', $note);
  77. include_once libfile('function/stat');
  78. updatestat('poke');
  79. showmessage('poke_success', dreferer(), array('username' => $tospace['username'], 'uid' => $uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true));
  80. }
  81. } elseif($op == 'ignore') {
  82. if(submitcheck('ignoresubmit')) {
  83. $where = empty($uid)?'':"AND fromuid='$uid'";
  84. C::t('home_poke')->delete_by_uid_fromuid($_G['uid'], $uid);
  85. C::t('home_notification')->delete_by_uid_type_authorid($_G['uid'], 'poke', $uid);
  86. showmessage('has_been_hailed_overlooked', '', array('uid' => $uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true, 'alert' => 'right'));
  87. }
  88. } elseif($op == 'view') {
  89. $_GET['uid'] = intval($_GET['uid']);
  90. $list = array();
  91. foreach(C::t('home_poke')->fetch_all_by_uid_fromuid($space['uid'], $_GET['uid']) as $value) {
  92. $pokeuid = $value['uid']+$value['fromuid'];
  93. $value['uid'] = $value['fromuid'];
  94. $value['username'] = $value['fromusername'];
  95. require_once libfile('function/friend');
  96. $value['isfriend'] = $value['uid']==$space['uid'] || friend_check($value['uid']) ? 1 : 0;
  97. foreach(C::t('home_pokearchive')->fetch_all_by_pokeuid($pokeuid) as $subvalue) {
  98. $list[$subvalue['pid']] = $subvalue;
  99. }
  100. }
  101. } else {
  102. $perpage = 20;
  103. $perpage = mob_perpage($perpage);
  104. $page = empty($_GET['page'])?0:intval($_GET['page']);
  105. if($page<1) $page = 1;
  106. $start = ($page-1)*$perpage;
  107. ckstart($start, $perpage);
  108. $fuids = $list = array();
  109. $count = C::t('home_poke')->count_by_uid($space['uid']);
  110. if($count) {
  111. foreach(C::t('home_poke')->fetch_all_by_uid($space['uid'], $start, $perpage) as $value) {
  112. $value['uid'] = $value['fromuid'];
  113. $value['username'] = $value['fromusername'];
  114. $fuids[$value['uid']] = $value['uid'];
  115. $list[$value['uid']] = $value;
  116. }
  117. if($fuids) {
  118. require_once libfile('function/friend');
  119. friend_check($fuids);
  120. $value = array();
  121. foreach($fuids as $key => $fuid) {
  122. $value['isfriend'] = $fuid==$space['uid'] || $_G["home_friend_".$space['uid'].'_'.$fuid] ? 1 : 0;
  123. $list[$fuid] = array_merge($list[$fuid], $value);
  124. }
  125. }
  126. }
  127. $multi = multi($count, $perpage, $page, "home.php?mod=spacecp&ac=poke");
  128. }
  129. $actives = array($op=='send'?'send':'poke' =>' class="a"');
  130. include_once template('home/spacecp_poke');
  131. ?>