checkupdate.inc.php
4.23 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: checkupdate.inc.php 35226 2015-03-04 06:56:12Z nemohou $
*/
define('PLUGIN_RELEASE', '20150303');
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$pluginupdated = false;
$setting = $_G['setting']['mobilewechat'] ? (array)unserialize($_G['setting']['mobilewechat']) : array();
if($setting['RELEASE'] != PLUGIN_RELEASE) {
$sql = <<<EOF
CREATE TABLE IF NOT EXISTS pre_common_member_wechat (
`uid` mediumint(8) unsigned NOT NULL,
`openid` char(32) NOT NULL default '',
`status` tinyint(1) NOT NULL DEFAULT 0,
`isregister` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`uid`),
UNIQUE KEY `openid` (`openid`)
) ENGINE=MYISAM;
CREATE TABLE IF NOT EXISTS pre_mobile_wechat_authcode (
`sid` char(6) NOT NULL,
`code` int(10) unsigned NOT NULL,
`uid` mediumint(8) unsigned NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT 0,
`createtime` int(10) unsigned NOT NULL,
PRIMARY KEY (`sid`),
UNIQUE KEY `code` (`code`),
KEY `createtime` (`createtime`)
) ENGINE=MEMORY;
CREATE TABLE IF NOT EXISTS pre_common_member_wechatmp (
`uid` mediumint(8) unsigned NOT NULL,
`openid` char(32) NOT NULL default '',
`status` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`uid`),
KEY `openid` (`openid`)
) ENGINE=MYISAM;
CREATE TABLE IF NOT EXISTS pre_mobile_wsq_threadlist (
`skey` int(10) unsigned NOT NULL,
`svalue` text NOT NULL,
PRIMARY KEY (`skey`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS pre_mobile_wechat_resource (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`dateline` int(10) unsigned NOT NULL,
`type` tinyint(1) NOT NULL DEFAULT 0,
`data` text NOT NULL,
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=MYISAM;
CREATE TABLE IF NOT EXISTS pre_mobile_wechat_masssend (
`id` int(10) unsigned NOT NULL auto_increment,
`type` char(5) NOT NULL,
`name` varchar(255) NOT NULL,
`resource_id` int(10) unsigned NOT NULL,
`group_id` int(10) unsigned NOT NULL,
`text` text,
`media_id` char(64) DEFAULT '',
`created_at` int(10) unsigned NOT NULL,
`sent_at` int(10) unsigned,
`msg_id` int(10) unsigned,
`res_status` varchar(50),
`res_totalcount` int(10),
`res_filtercount` int(10),
`res_sentcount` int(10),
`res_errorcount` int(10),
`res_finish_at` int(10),
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
EOF;
if(!defined('DISCUZ_VERSION')) {
require './source/discuz_version.php';
}
$settingdefault = array (
'wechat_mtype' => '0',
'wechat_qrtype' => '3',
'wechat_token' => random(16),
'wechat_allowregister' => '1',
'wechat_allowfastregister' => '1',
'wechat_disableregrule' => '1',
'wechat_float_qrcode' => '1',
'wechat_confirmtype' => '0',
'wechat_newusergroupid' => $_G['setting']['newusergroupid'],
'wsq_wapdefault' => 1,
'wsq_global_banner' => 1,
);
require_once DISCUZ_ROOT.'./source/plugin/wechat/install/update.func.php';
runquery($sql);
updatetable($sql);
foreach($settingdefault as $_key => $_default) {
if(!isset($setting[$_key])) {
$setting[$_key] = $_default;
}
}
$setting['RELEASE'] = PLUGIN_RELEASE;
$settings = array('mobilewechat' => serialize($setting));
C::t('common_setting')->update_batch($settings);
C::t('common_plugin')->delete_by_identifier('mobileoem');
require_once DISCUZ_ROOT.'./source/plugin/wechat/wechat.lib.class.php';
$hook = WeChatHook::getAPIHook('wechat');
if(!$hook) {
WeChatHook::updateAPIHook(array(
array('forumdisplay_variables' => array('plugin' => 'wechat', 'include' => 'wsqapi.class.php', 'class' => 'WSQAPI', 'method' => 'forumdisplay_variables')),
array('viewthread_variables' => array('plugin' => 'wechat', 'include' => 'wsqapi.class.php', 'class' => 'WSQAPI', 'method' => 'viewthread_variables')),
));
} elseif($hook['wsqindex']) {
WeChatHook::updateAPIHook(array(
array('wsqindex_variables' => array('plugin' => 'wechat')),
));
}
DB::query("ALTER TABLE ".DB::table('forum_debatepost')." ADD INDEX `voters` (`tid`,`voters`)", 'SILENT');
$pluginupdated = true;
}
?>