PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/source/plugin/security/install.php

https://github.com/jinbo51/DiscuzX
PHP | 123 lines | 107 code | 10 blank | 6 comment | 11 complexity | 77b8d20cc05fd23cdb5f19cf16c67970 MD5 | raw file
Possible License(s): BSD-3-Clause
  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: install.php 33344 2013-05-30 04:37:03Z jeffjzhang $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $sql = <<<EOF
  12. CREATE TABLE IF NOT EXISTS `pre_security_evilpost` (
  13. `pid` int(10) unsigned NOT NULL COMMENT '帖子ID',
  14. `tid` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '主题ID',
  15. `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '帖子类型',
  16. `evilcount` int(10) NOT NULL DEFAULT '0' COMMENT '恶意次数',
  17. `eviltype` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '恶意类型',
  18. `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  19. `operateresult` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '操作结果:1 通过 2 删除 3 忽略',
  20. `isreported` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已经上报',
  21. `censorword` char(50) NOT NULL,
  22. PRIMARY KEY (`pid`),
  23. KEY `type` (`tid`,`type`),
  24. KEY `operateresult` (`operateresult`,`createtime`)
  25. ) ENGINE=MyISAM;
  26. CREATE TABLE IF NOT EXISTS `pre_security_eviluser` (
  27. `uid` int(10) unsigned NOT NULL COMMENT '用户ID',
  28. `evilcount` int(10) NOT NULL DEFAULT '0' COMMENT '恶意次数',
  29. `eviltype` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '恶意类型',
  30. `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  31. `operateresult` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '操作结果:1 恢复 2 删除 3 忽略',
  32. `isreported` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已经上报',
  33. PRIMARY KEY (`uid`),
  34. KEY `operateresult` (`operateresult`,`createtime`)
  35. ) ENGINE=MyISAM;
  36. CREATE TABLE IF NOT EXISTS `pre_security_failedlog` (
  37. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  38. `reporttype` char(20) NOT NULL COMMENT '上报类型',
  39. `tid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'TID',
  40. `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'PID',
  41. `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'UID',
  42. `failcount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '计数',
  43. `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '失败时间',
  44. `posttime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发帖时间/上次发帖时间',
  45. `delreason` char(255) NOT NULL COMMENT '处理原因',
  46. `scheduletime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '计划重试时间',
  47. `lastfailtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上次失败时间',
  48. `extra1` int(10) unsigned NOT NULL COMMENT '整型的扩展字段',
  49. `extra2` char(255) NOT NULL DEFAULT '0' COMMENT '字符类型的扩展字段',
  50. PRIMARY KEY (`id`),
  51. KEY `pid` (`pid`),
  52. KEY `uid` (`uid`)
  53. ) ENGINE=MyISAM;
  54. EOF;
  55. runquery($sql);
  56. $cronId_security_daily = $cronId_security_lastpost = 0;
  57. if(file_exists(DISCUZ_ROOT . './source/include/cron/cron_security_cleanup_lastpost.php') || file_exists(DISCUZ_ROOT . './source/include/cron/cron_security_daily.php')) {
  58. $count = C::t('common_cron')->count();
  59. $oldData = C::t('common_cron')->range(0, $count);
  60. foreach ($oldData as $value) {
  61. if ($value['filename'] == 'cron_security_daily.php') {
  62. $cronId_security_daily = $value['cronid'];
  63. }elseif ($value['filename'] == 'cron_security_cleanup_lastpost.php') {
  64. $cronId_security_lastpost = $value['cronid'];
  65. }
  66. }
  67. }
  68. include DISCUZ_ROOT . 'source/language/lang_admincp_cloud.php';
  69. if(file_exists(DISCUZ_ROOT . './source/include/cron/cron_security_cleanup_lastpost.php') && empty($cronId_security_lastpost)) {
  70. $data = array(
  71. 'available' => 0,
  72. 'type' => 'user',
  73. 'name' => $extend_lang['security_cron_lastpost'],
  74. 'filename' => 'cron_security_cleanup_lastpost.php',
  75. 'weekday' => -1,
  76. 'day' => -1,
  77. 'hour' => -1,
  78. 'minute' => 0,
  79. );
  80. C::t('common_cron')->insert($data, true, false, false);
  81. }
  82. if (file_exists(DISCUZ_ROOT . './source/include/cron/cron_security_daily.php')) {
  83. if (empty($cronId_security_daily)) {
  84. $data = array(
  85. 'available' => 1,
  86. 'type' => 'user',
  87. 'name' => $extend_lang['security_cron_daily'],
  88. 'filename' => 'cron_security_daily.php',
  89. 'weekday' => -1,
  90. 'day' => -1,
  91. 'hour' => 2,
  92. 'minute' => 0,
  93. );
  94. $cronId_security_daily = C::t('common_cron')->insert($data, true, false, false);
  95. } else {
  96. C::t('common_cron')->update($cronId_security_daily, array(
  97. 'available' => 1,
  98. 'weekday' => -1,
  99. 'day' => -1,
  100. 'hour' => 2,
  101. 'minute' => 0,
  102. ));
  103. }
  104. updatecache('setting');
  105. discuz_cron::run($cronId_security_daily);
  106. }
  107. $updateData = array(
  108. 'security_usergroups_white_list' => serialize(array(1, 2, 3)),
  109. 'security_safelogin' => 1,
  110. );
  111. C::t('common_setting')->update_batch($updateData);
  112. updatecache('setting');
  113. $finish = true;