showactivity.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: showactivity.php 35113 2014-11-26 03:31:52Z anezhou $
  7. */
  8. if (!defined('IN_MOBILE_API')) {
  9. exit('Access Denied');
  10. }
  11. $_GET['mod'] = 'misc';
  12. $_GET['action'] = 'commentmore';
  13. $_GET['inajax'] = 1;
  14. include_once 'forum.php';
  15. class mobile_api {
  16. function common() {
  17. global $_G;
  18. if($_GET['do'] == 'recommend') {
  19. if(!$_GET['hash'] || FORMHASH != $_GET['hash'] || !$_GET['pid'] || !$_GET['tid'] || !$_G['uid']) {
  20. mobile_core::result(mobile_core::variable(array('result' => -1)));
  21. }
  22. $_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']);
  23. if(!$_G['wechat']['setting']['wsq_allow'] || !in_array($_GET['tid'], (array)$_G['wechat']['setting']['showactivity']['tids'])) {
  24. mobile_core::result(mobile_core::variable(array('result' => -2)));
  25. }
  26. $postinfo = C::t('forum_post')->fetch('tid:'.$_GET['tid'], $_GET['pid']);
  27. if(!$postinfo) {
  28. mobile_core::result(mobile_core::variable(array('result' => -3)));
  29. }
  30. $activity = C::t('forum_activity')->fetch($_G['tid']);
  31. if($activity['starttimeto'] && $activity['starttimeto'] < TIMESTAMP) {
  32. mobile_core::result(mobile_core::variable(array('result' => -4)));
  33. }
  34. $post = C::t('forum_debatepost')->fetch($_GET['pid']);
  35. if(!$post) {
  36. C::t('forum_debatepost')->insert(array(
  37. 'pid' => $_GET['pid'],
  38. 'tid' => $_GET['tid'],
  39. 'dateline' => TIMESTAMP,
  40. 'stand' => 0,
  41. 'voters' => 1,
  42. 'voterids' => "$_G[uid]\t",
  43. ));
  44. mobile_core::result(mobile_core::variable(array('result' => 1)));
  45. } elseif(strpos("\t".$post['voterids'], "\t$_G[uid]\t") === FALSE) {
  46. C::t('forum_debatepost')->update_voters($_GET['pid'], $_G['uid']);
  47. mobile_core::result(mobile_core::variable(array('result' => 1)));
  48. } else {
  49. mobile_core::result(mobile_core::variable(array('result' => 0)));
  50. }
  51. }
  52. }
  53. function output() {
  54. $comments = array();
  55. foreach($GLOBALS['comments'] as $comment) {
  56. $comments[] = array(
  57. 'author' => $comment['author'],
  58. 'authorid' => $comment['authorid'],
  59. 'avatar' => avatar($comment['authorid'], 'small', 1),
  60. 'message' => $comment['comment'],
  61. 'dateline' => strip_tags($comment['dateline']),
  62. );
  63. }
  64. $variable = array(
  65. 'tid' => $_GET['tid'],
  66. 'pid' => $_GET['pid'],
  67. 'postlist' => $comments,
  68. );
  69. mobile_core::result(mobile_core::variable($variable));
  70. }
  71. }
  72. ?>