PageRenderTime 26ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 10ms app.codeStats 1ms

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