checkupdate.inc.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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: checkupdate.inc.php 35224 2015-03-03 09:48:38Z nemohou $
  7. */
  8. define('PLUGIN_RELEASE', '20150303');
  9. if(!defined('IN_DISCUZ')) {
  10. exit('Access Denied');
  11. }
  12. $pluginupdated = false;
  13. $setting = $_G['setting']['mobilewechat'] ? (array)unserialize($_G['setting']['mobilewechat']) : array();
  14. if($setting['RELEASE'] != PLUGIN_RELEASE) {
  15. $sql = <<<EOF
  16. CREATE TABLE IF NOT EXISTS pre_common_member_wechat (
  17. `uid` mediumint(8) unsigned NOT NULL,
  18. `openid` char(32) NOT NULL default '',
  19. `status` tinyint(1) NOT NULL DEFAULT 0,
  20. `isregister` tinyint(1) unsigned NOT NULL default '0',
  21. PRIMARY KEY (`uid`),
  22. UNIQUE KEY `openid` (`openid`)
  23. ) ENGINE=MYISAM;
  24. CREATE TABLE IF NOT EXISTS pre_mobile_wechat_authcode (
  25. `sid` char(6) NOT NULL,
  26. `code` int(10) unsigned NOT NULL,
  27. `uid` mediumint(8) unsigned NOT NULL,
  28. `status` tinyint(1) NOT NULL DEFAULT 0,
  29. `createtime` int(10) unsigned NOT NULL,
  30. PRIMARY KEY (`sid`),
  31. UNIQUE KEY `code` (`code`),
  32. KEY `createtime` (`createtime`)
  33. ) ENGINE=MEMORY;
  34. CREATE TABLE IF NOT EXISTS pre_common_member_wechatmp (
  35. `uid` mediumint(8) unsigned NOT NULL,
  36. `openid` char(32) NOT NULL default '',
  37. `status` tinyint(1) NOT NULL DEFAULT 0,
  38. PRIMARY KEY (`uid`),
  39. KEY `openid` (`openid`)
  40. ) ENGINE=MYISAM;
  41. CREATE TABLE IF NOT EXISTS pre_mobile_wsq_threadlist (
  42. `skey` int(10) unsigned NOT NULL,
  43. `svalue` text NOT NULL,
  44. PRIMARY KEY (`skey`)
  45. ) ENGINE=MyISAM;
  46. CREATE TABLE IF NOT EXISTS pre_mobile_wechat_resource (
  47. `id` int(10) unsigned NOT NULL auto_increment,
  48. `name` varchar(255) NOT NULL default '',
  49. `dateline` int(10) unsigned NOT NULL,
  50. `type` tinyint(1) NOT NULL DEFAULT 0,
  51. `data` text NOT NULL,
  52. PRIMARY KEY (`id`),
  53. KEY `type` (`type`)
  54. ) ENGINE=MYISAM;
  55. CREATE TABLE IF NOT EXISTS pre_mobile_wechat_masssend (
  56. `id` int(10) unsigned NOT NULL auto_increment,
  57. `type` char(5) NOT NULL,
  58. `name` varchar(255) NOT NULL,
  59. `resource_id` int(10) unsigned NOT NULL,
  60. `group_id` int(10) unsigned NOT NULL,
  61. `text` text,
  62. `media_id` char(64) DEFAULT '',
  63. `created_at` int(10) unsigned NOT NULL,
  64. `sent_at` int(10) unsigned,
  65. `msg_id` int(10) unsigned,
  66. `res_status` varchar(50),
  67. `res_totalcount` int(10),
  68. `res_filtercount` int(10),
  69. `res_sentcount` int(10),
  70. `res_errorcount` int(10),
  71. `res_finish_at` int(10),
  72. PRIMARY KEY (`id`)
  73. ) ENGINE=MyISAM;
  74. EOF;
  75. if(!defined('DISCUZ_VERSION')) {
  76. require './source/discuz_version.php';
  77. }
  78. $settingdefault = array (
  79. 'wechat_mtype' => '0',
  80. 'wechat_qrtype' => '3',
  81. 'wechat_token' => random(16),
  82. 'wechat_allowregister' => '1',
  83. 'wechat_allowfastregister' => '1',
  84. 'wechat_disableregrule' => '1',
  85. 'wechat_float_qrcode' => '1',
  86. 'wechat_confirmtype' => '0',
  87. 'wechat_newusergroupid' => $_G['setting']['newusergroupid'],
  88. 'wsq_wapdefault' => 1,
  89. 'wsq_global_banner' => 1,
  90. );
  91. require_once DISCUZ_ROOT.'./source/plugin/wechat/install/update.func.php';
  92. runquery($sql);
  93. updatetable($sql);
  94. foreach($settingdefault as $_key => $_default) {
  95. if(!isset($setting[$_key])) {
  96. $setting[$_key] = $_default;
  97. }
  98. }
  99. $setting['RELEASE'] = PLUGIN_RELEASE;
  100. $settings = array('mobilewechat' => serialize($setting));
  101. C::t('common_setting')->update_batch($settings);
  102. C::t('common_plugin')->delete_by_identifier('mobileoem');
  103. require_once DISCUZ_ROOT.'./source/plugin/wechat/wechat.lib.class.php';
  104. $hook = WeChatHook::getAPIHook('wechat');
  105. if(!$hook) {
  106. WeChatHook::updateAPIHook(array(
  107. array('forumdisplay_variables' => array('plugin' => 'wechat', 'include' => 'wsqapi.class.php', 'class' => 'WSQAPI', 'method' => 'forumdisplay_variables')),
  108. array('viewthread_variables' => array('plugin' => 'wechat', 'include' => 'wsqapi.class.php', 'class' => 'WSQAPI', 'method' => 'viewthread_variables')),
  109. ));
  110. } elseif($hook['wsqindex']) {
  111. WeChatHook::updateAPIHook(array(
  112. array('wsqindex_variables' => array('plugin' => 'wechat')),
  113. ));
  114. }
  115. DB::query("ALTER TABLE ".DB::table('forum_debatepost')." ADD INDEX `voters` (`tid`,`voters`)", 'SILENT');
  116. $pluginupdated = true;
  117. }
  118. ?>