resourcepush.inc.php
1.57 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: resourcepush.inc.php 35024 2014-10-14 07:43:43Z nemohou $
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_G['adminid'] != 1) {
showmessage('undefined_action');
}
require_once libfile('function/forum');
require_once libfile('function/post');
$thread = get_thread_by_tid($_GET['tid']);
if(!$thread) {
showmessage('undefined_action');
}
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['tid']);
if($thread['cover']) {
$picurl = getthreadcover($thread['tid'], $thread['cover']);
} else {
$attach = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_GET['tid'], 'pid', array($post['pid']), '', true);
$picurl = '';
if($attach) {
$attach = array_shift($attach);
$picurl = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
}
}
$data = array(
'name' => lang('plugin/wechat', 'resource_thread_push').': '.$thread['subject'],
'data' => array(
'title' => $thread['subject'],
'pic' => $picurl ? (preg_match('/^http:/', $picurl) ? '' : $_G['siteurl']).$picurl : '',
'desc' => messagecutstr($post['message'], 0, 120),
'content' => nl2br(messagecutstr($post['message'])),
'url' => $_G['siteurl'].'forum.php?mod=viewthread&tid='.$_GET['tid'],
),
);
C::t('#wechat#mobile_wechat_resource')->insert($data);
showmessage('wechat:resource_msg_pushed', '', array(), array('alert' => 'right'));