resourcepush.inc.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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: resourcepush.inc.php 34814 2014-08-07 01:46:48Z nemohou $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if($_G['adminid'] != 1) {
  12. showmessage('undefined_action');
  13. }
  14. require_once libfile('function/forum');
  15. require_once libfile('function/post');
  16. $thread = get_thread_by_tid($_GET['tid']);
  17. if(!$thread) {
  18. showmessage('undefined_action');
  19. }
  20. $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['tid']);
  21. if($thread['cover']) {
  22. $picurl = getthreadcover($thread['tid'], $thread['cover']);
  23. } else {
  24. $attach = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_GET['tid'], 'pid', array($post['pid']), '', true);
  25. $picurl = '';
  26. if($attach) {
  27. $attach = array_shift($attach);
  28. $picurl = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
  29. }
  30. }
  31. $data = array(
  32. 'name' => lang('plugin/wechat', 'resource_thread_push').': '.$thread['subject'],
  33. 'data' => array(
  34. 'title' => $thread['subject'],
  35. 'pic' => $picurl ? (preg_match('/^http:/', $picurl) ? '' : $_G['siteurl']).$picurl : '',
  36. 'desc' => messagecutstr($post['message'], 0, 120),
  37. 'content' => nl2br(messagecutstr($post['message'])),
  38. 'url' => $_G['siteurl'].'forum.php?mod=viewthread&tid='.$_GET['tid'],
  39. ),
  40. );
  41. C::t('#wechat#mobile_wechat_resource')->insert($data);
  42. showmessage('wechat:resource_msg_pushed', '', array(), array('alert' => 'right'));