14 changed files with 848 additions and 0 deletions
@ -0,0 +1,41 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
namespace addons\info\controller; |
||||
|
|
||||
|
use think\addons\Base; |
||||
|
use app\common\model\Addon as AddonModel; |
||||
|
|
||||
|
class Admin extends Base |
||||
|
{ |
||||
|
protected function _initialize() |
||||
|
{ |
||||
|
//调用admin/Base控制器的初始化 |
||||
|
action('admin/Base/_initialize'); |
||||
|
} |
||||
|
/* |
||||
|
* 设置 |
||||
|
*/ |
||||
|
public function config() |
||||
|
{ |
||||
|
$model=new AddonModel; |
||||
|
if(request()->isAjax()){ |
||||
|
$display=input('display',0,'intval'); |
||||
|
$rst=$model->setConfig('info.display',$display); |
||||
|
if($rst){ |
||||
|
$this->success('更新设置成功',url('admin/Addons/addons_list')); |
||||
|
}else{ |
||||
|
$this->error('更新设置失败',url('admin/Addons/addons_list')); |
||||
|
} |
||||
|
}else{ |
||||
|
$config=$model->getConfig('info'); |
||||
|
$this->assign('config',$config); |
||||
|
return $this->fetch(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
<div class="widget-box sl-indextop10 text-left"> |
||||
|
<div class="widget-header"> |
||||
|
<h5 class="widget-title"><span style="font-size:14px; font-family:Microsoft YaHei">框架&系统信息</span></h5> |
||||
|
|
||||
|
</div> |
||||
|
<div class="widget-body"> |
||||
|
<div class="widget-main"> |
||||
|
<p class="alert alert-danger sl-line-height25"> |
||||
|
YFCMF版本:{$Think.config.yfcmf_version} |
||||
|
{if condition="!empty($update_check)"} |
||||
|
{if condition="empty($ver_last)"} |
||||
|
<button class="btn btn-xs btn-success"><i class="ace-icon fa fa-check"></i>{$ver_str}</button> |
||||
|
{else /} |
||||
|
<a href="{:url('admin/Update/index')}" title="在线更新"><button class="btn btn-xs btn-danger"><i class="ace-icon fa fa-bolt bigger-110"></i>{$ver_str}</button></a> |
||||
|
{/if} |
||||
|
{/if} |
||||
|
<br /> |
||||
|
框架版本:ThinkPHP{$info.ThinkPHPTYE} 上传附件限制:{$info.ONLOAD}<br /> |
||||
|
系统版本:{$info.RUNTYPE}<br /> |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,47 @@ |
|||||
|
{extend name="admin@public/base" /} |
||||
|
{block name="main-content"} |
||||
|
<div class="page-content"> |
||||
|
<!--主题--> |
||||
|
<div class="page-header"> |
||||
|
<h1> |
||||
|
您当前操作 |
||||
|
<small> |
||||
|
<i class="ace-icon fa fa-angle-double-right"></i> |
||||
|
插件设置 |
||||
|
</small> |
||||
|
</h1> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<div class="col-xs-12"> |
||||
|
<form class="form-horizontal ajaxForm2" method="post" action="{:addon_url('info://Admin/config')}"> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 是否显示: </label> |
||||
|
<div class="col-sm-9" style="padding-top:5px;"> |
||||
|
<input name="display" {if condition='$config.display eq 1'}checked{/if} value="1" class="ace ace-switch ace-switch-4 btn-flat" type="checkbox" /> |
||||
|
<span class="lbl"></span> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="space-4"></div> |
||||
|
|
||||
|
|
||||
|
<div class="clearfix form-actions"> |
||||
|
<div class="col-sm-offset-3 col-sm-9"> |
||||
|
<button class="btn btn-info" type="submit"> |
||||
|
<i class="ace-icon fa fa-check bigger-110"></i> |
||||
|
保存 |
||||
|
</button> |
||||
|
|
||||
|
<button class="btn" type="reset"> |
||||
|
<i class="ace-icon fa fa-undo bigger-110"></i> |
||||
|
重置 |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div><!-- /.page-content --> |
||||
|
{/block} |
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,128 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
namespace addons\maintain; |
||||
|
|
||||
|
use think\Addons; |
||||
|
|
||||
|
/** |
||||
|
* 显示日常维护 |
||||
|
*/ |
||||
|
class Maintain extends Addons |
||||
|
{ |
||||
|
public $info = [ |
||||
|
'name' => 'Maintain', |
||||
|
'title' => '日常维护', |
||||
|
'description' => '后台首页日常维护', |
||||
|
'status' => 0, |
||||
|
'author' => 'rainfer', |
||||
|
'version' => '0.1', |
||||
|
'admin'=>'0' |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* @var array 插件钩子 |
||||
|
*/ |
||||
|
public $hooks = [ |
||||
|
// 钩子名称 => 钩子说明 |
||||
|
'maintain'=>'日常维护钩子' |
||||
|
]; |
||||
|
/** |
||||
|
* @var array 插件管理方法,格式:['控制器/操作方法',[参数数组]]) |
||||
|
*/ |
||||
|
public $admin_actions = [ |
||||
|
'index'=>[],//管理首页 |
||||
|
'config'=>[],//设置页 |
||||
|
'edit' => [],//编辑页 |
||||
|
'add'=>[],//增加页 |
||||
|
]; |
||||
|
/** |
||||
|
* 插件安装方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function install() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 插件卸载方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function uninstall() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 实现的maintain钩子方法 |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function maintain() |
||||
|
{ |
||||
|
$config=$this->getConfig(); |
||||
|
if($config['display']) |
||||
|
{ |
||||
|
//安全检测 |
||||
|
$system_safe = true; |
||||
|
//调试模式 |
||||
|
$danger_mode_debug = config('app_debug'); |
||||
|
if ($danger_mode_debug) { |
||||
|
$system_safe = false; |
||||
|
} |
||||
|
$this->assign('danger_mode_debug',$danger_mode_debug); |
||||
|
|
||||
|
//数据库密码 |
||||
|
$weak_setting_db_password = false; |
||||
|
$weak_pwd_reg = array( |
||||
|
'/^[0-9]{0,6}$/', |
||||
|
'/^[a-z]{0,6}$/', |
||||
|
'/^[A-Z]{0,6}$/' |
||||
|
); |
||||
|
foreach ($weak_pwd_reg as $reg) { |
||||
|
if (preg_match($reg, config('database.password'))) { |
||||
|
$weak_setting_db_password = true; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if ($weak_setting_db_password) { |
||||
|
$system_safe = false; |
||||
|
} |
||||
|
$this->assign('weak_setting_db_password',$weak_setting_db_password); |
||||
|
|
||||
|
//密码修改时间 |
||||
|
$weak_setting_admin_last_change_password = (session('admin_auth.admin_last_change_pwd_time') < time() - 3600 * 24 * 30); |
||||
|
if ($weak_setting_admin_last_change_password) { |
||||
|
$system_safe = false; |
||||
|
} |
||||
|
$this->assign('weak_setting_admin_last_change_password',$weak_setting_admin_last_change_password); |
||||
|
|
||||
|
//整体安全性 |
||||
|
$this->assign('system_safe',$system_safe); |
||||
|
|
||||
|
//页面调试 |
||||
|
$this->assign('system_pageshow',config('app_trace')); |
||||
|
//日志分析 |
||||
|
$log_size = 0; |
||||
|
$log_file_cnt = 0; |
||||
|
foreach (list_file(LOG_PATH) as $f) { |
||||
|
if ($f ['isDir']) { |
||||
|
foreach (list_file($f ['pathname'] . '/', '*.log') as $ff) { |
||||
|
if ($ff ['isFile']) { |
||||
|
$log_size += $ff ['size']; |
||||
|
$log_file_cnt++; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
$this->assign('log_size',$log_size); |
||||
|
$this->assign('log_file_cnt',$log_file_cnt); |
||||
|
return $this->fetch('maintain'); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
'display' => [ |
||||
|
'title' => '是否显示:', |
||||
|
'type' => 'radio', |
||||
|
'options' => [ |
||||
|
'1' => '显示', |
||||
|
'0' => '不显示' |
||||
|
], |
||||
|
'value' => '1' |
||||
|
] |
||||
|
]; |
||||
@ -0,0 +1,88 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
namespace addons\maintain\controller; |
||||
|
|
||||
|
use app\admin\controller\Base; |
||||
|
use think\Cache; |
||||
|
|
||||
|
class Action extends Base |
||||
|
{ |
||||
|
/* |
||||
|
* 日常维护 |
||||
|
*/ |
||||
|
public function maintain() |
||||
|
{ |
||||
|
$action=input('action'); |
||||
|
switch ($action) { |
||||
|
case 'download_log' : |
||||
|
case 'view_log': |
||||
|
$logs = array(); |
||||
|
foreach (list_file(LOG_PATH) as $f) { |
||||
|
if ($f ['isDir']) { |
||||
|
foreach (list_file($f ['pathname'] . '/', '*.log') as $ff) { |
||||
|
if ($ff ['isFile']) { |
||||
|
$spliter = '=========================='; |
||||
|
$logs [] = $spliter . ' ' . $f ['filename'] . '/' . $ff ['filename'] . ' ' . $spliter . "\n\n" . file_get_contents($ff ['pathname']); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if ('download_log' == $action) { |
||||
|
force_download_content('log_' . date('Ymd_His') . '.log', join("\n\n\n\n", $logs)); |
||||
|
} else { |
||||
|
echo '<pre>' . htmlspecialchars(join("\n\n\n\n", $logs)) . '</pre>'; |
||||
|
} |
||||
|
break; |
||||
|
case 'clear_log' : |
||||
|
remove_dir(LOG_PATH); |
||||
|
$this->success ('清除日志成功',url('admin/Index/index')); |
||||
|
break; |
||||
|
case 'debug_on' : |
||||
|
$data = array('app_debug'=>true); |
||||
|
$res=sys_config_setbyarr($data); |
||||
|
if($res === false){ |
||||
|
$this->error('打开调试失败',url('admin/Index/index')); |
||||
|
}else{ |
||||
|
Cache::clear(); |
||||
|
$this->success('已打开调试',url('admin/Index/index')); |
||||
|
} |
||||
|
break; |
||||
|
case 'debug_off' : |
||||
|
$data = array('app_debug'=>false); |
||||
|
$res=sys_config_setbyarr($data); |
||||
|
if($res === false){ |
||||
|
$this->error('关闭调试失败',url('admin/Index/index')); |
||||
|
}else{ |
||||
|
Cache::clear(); |
||||
|
$this->success('已关闭调试',url('admin/Index/index')); |
||||
|
} |
||||
|
break; |
||||
|
case 'trace_on' : |
||||
|
$data = array('app_trace'=>true); |
||||
|
$res=sys_config_setbyarr($data); |
||||
|
if($res === false){ |
||||
|
$this->error('打开Trace失败',url('admin/Index/index')); |
||||
|
}else{ |
||||
|
Cache::clear(); |
||||
|
$this->success('已打开Trace',url('admin/Index/index')); |
||||
|
} |
||||
|
break; |
||||
|
case 'trace_off' : |
||||
|
$data = array('app_trace'=>false); |
||||
|
$res=sys_config_setbyarr($data); |
||||
|
if($res === false){ |
||||
|
$this->error('关闭Trace失败',url('admin/Index/index')); |
||||
|
}else{ |
||||
|
Cache::clear(); |
||||
|
$this->success('已关闭Trace',url('admin/Index/index')); |
||||
|
} |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,61 @@ |
|||||
|
<!-- 安全检测开始 --> |
||||
|
<div class="panel {if condition='$system_safe'}panel-default{else /}panel-danger{/if}"> |
||||
|
<div class="panel-heading"> |
||||
|
<i class="ace-icon fa fa-bolt"></i> |
||||
|
<span class="icon-dashboard"></span> 系统安全检测 |
||||
|
</div> |
||||
|
<div class="panel-body"> |
||||
|
{if condition="$system_safe"} |
||||
|
<p class="text-success"><span class="glyphicon glyphicon-ok-sign"></span> 当前系统安全!</p> |
||||
|
{/if} |
||||
|
{if condition="$weak_setting_db_password"} |
||||
|
<p class="text-danger"><span class="glyphicon glyphicon-info-sign"></span> 数据库连接密码为弱密码,安全起见,增强密码!</p> |
||||
|
{/if} |
||||
|
{if condition="$danger_mode_debug"} |
||||
|
<p class="text-warning"><span class="glyphicon glyphicon-info-sign"></span> 当前系统运行在调试模式,可能会影响运行性能及安全!</p> |
||||
|
{/if} |
||||
|
{if condition="$system_pageshow"} |
||||
|
<p class="text-warning"><span class="glyphicon glyphicon-info-sign"></span> 当前系统已开SHOW_PAGE_TRACE</p> |
||||
|
{/if} |
||||
|
{if condition="$weak_setting_admin_last_change_password"} |
||||
|
<p class="text-warning"><span class="glyphicon glyphicon-info-sign"></span> 您太久没有更换登陆密码了,请定期更换后台登陆密码!</p> |
||||
|
{/if} |
||||
|
<!--[if lte IE 8]> |
||||
|
<p class="text-warning"> |
||||
|
<span class="glyphicon glyphicon-info-sign"></span> 浏览器版本过低! |
||||
|
</p> |
||||
|
<![endif]--> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!-- 安全检测结束 --> |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"> |
||||
|
<i class="ace-icon fa fa-wrench"></i> |
||||
|
<span class="icon-desktop"></span> 日常维护 |
||||
|
</div> |
||||
|
<table class="table"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td colspan="2"> |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'download_log'))}" target="_blank" class="btn btn-default maintain">下载日志</a> |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'view_log'))}" target="_blank" class="btn btn-default maintain">查看日志</a> |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'clear_log'))}" class="btn btn-default rst-url-btn maintain">清除日志</a> |
||||
|
{if condition="$danger_mode_debug"} |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'debug_off'))}" class="btn btn-default rst-url-btn maintain">关闭调试</a> |
||||
|
{else /} |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'debug_on'))}" class="btn btn-default rst-url-btn maintain">打开调试</a> |
||||
|
{/if} |
||||
|
{if condition="$system_pageshow"} |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'trace_off'))}" class="btn btn-default rst-url-btn maintain">关闭Trace</a> |
||||
|
{else /} |
||||
|
<a href="{:addon_url('maintain://Action/maintain',array('action'=>'trace_on'))}" class="btn btn-default rst-url-btn maintain">打开Trace</a> |
||||
|
{/if} |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td>日志大小 : {$log_size|format_bytes}</td> |
||||
|
<td>日志数 : {$log_file_cnt}</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
@ -0,0 +1,53 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
namespace addons\security; |
||||
|
|
||||
|
use think\Addons; |
||||
|
|
||||
|
/** |
||||
|
* 安全检测 |
||||
|
*/ |
||||
|
class Security extends Addons |
||||
|
{ |
||||
|
public $info = [ |
||||
|
'name' => 'Security', |
||||
|
'title' => '安全检测', |
||||
|
'description' => '网站安全检测', |
||||
|
'status' => 0, |
||||
|
'author' => 'rainfer', |
||||
|
'version' => '0.1', |
||||
|
'admin'=>'1' |
||||
|
]; |
||||
|
/** |
||||
|
* @var array 插件管理方法,格式:['控制器/操作方法',[参数数组]]) |
||||
|
*/ |
||||
|
public $admin_actions = [ |
||||
|
'index'=>['Admin/security_list'],//管理首页 |
||||
|
'config'=>[],//设置页 |
||||
|
'edit' => [],//编辑页 |
||||
|
'add'=>[],//增加页 |
||||
|
]; |
||||
|
/** |
||||
|
* 插件安装方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function install() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 插件卸载方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function uninstall() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,166 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
namespace addons\security\controller; |
||||
|
|
||||
|
use think\addons\Base; |
||||
|
|
||||
|
class Admin extends Base |
||||
|
{ |
||||
|
protected function _initialize() |
||||
|
{ |
||||
|
//调用admin/Base控制器的初始化 |
||||
|
action('admin/Base/_initialize'); |
||||
|
} |
||||
|
/* |
||||
|
* 安全文件列表 |
||||
|
*/ |
||||
|
public function security_list() |
||||
|
{ |
||||
|
$security_dir=ROOT_PATH.'data/security/'; |
||||
|
if (!file_exists($security_dir)) { |
||||
|
@mkdir($security_dir); |
||||
|
} |
||||
|
$finger_files = list_file($security_dir, '*.finger'); |
||||
|
$this->assign('finger_files',$finger_files); |
||||
|
return $this->fetch(); |
||||
|
} |
||||
|
/* |
||||
|
* 安全文件生成 |
||||
|
*/ |
||||
|
public function security_generate() |
||||
|
{ |
||||
|
$security_dir=ROOT_PATH.'data/security/'; |
||||
|
if (!file_exists($security_dir)) { |
||||
|
@mkdir($security_dir); |
||||
|
} |
||||
|
$filename = $security_dir . 'file_finger_' . date('YmdHi') . '_' . random(10) . '.finger'; |
||||
|
$f = fopen($filename, 'w'); |
||||
|
fwrite($f, "GENE: RCF V" . THINK_VERSION . "\n"); |
||||
|
fwrite($f, "TIME: " . date('Y-m-d H:i:s') . "\n"); |
||||
|
fwrite($f, "ROOT: \n"); |
||||
|
$files_md5 = array(); |
||||
|
foreach (array( |
||||
|
//检测目录 |
||||
|
'vendor', |
||||
|
'app', |
||||
|
'extend', |
||||
|
'public', |
||||
|
'thinkphp', |
||||
|
'addons' |
||||
|
) as $dir) { |
||||
|
foreach ($this->security_filefingergenerate('./' . $dir . '/', $dir . '/') as $file_md5) { |
||||
|
$files_md5 [] = $file_md5; |
||||
|
fwrite($f, $file_md5 [1] . '|' . $file_md5 [0] . "\n"); |
||||
|
} |
||||
|
} |
||||
|
fclose($f); |
||||
|
$this->success('成功生成安全文件',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
/* |
||||
|
* 安全文件删除 |
||||
|
*/ |
||||
|
public function security_delete() |
||||
|
{ |
||||
|
$security_dir=ROOT_PATH.'data/security/'; |
||||
|
if (!file_exists($security_dir)) { |
||||
|
$this->error('文件不存在',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
$file=input('file'); |
||||
|
foreach (list_file($security_dir, '*.finger') as $f) { |
||||
|
if (md5($f ['filename']) == $file) { |
||||
|
@unlink($f ['pathname']); |
||||
|
} |
||||
|
} |
||||
|
$this->success('成功删除',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
/* |
||||
|
* 安全检测 |
||||
|
*/ |
||||
|
public function security_check() |
||||
|
{ |
||||
|
$security_dir=ROOT_PATH.'data/security/'; |
||||
|
if (!file_exists($security_dir)) { |
||||
|
$this->error('文件不存在',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
$md5_file = null; |
||||
|
$file=input('file'); |
||||
|
foreach (list_file($security_dir, '*.finger') as $f) { |
||||
|
if (md5($f ['filename']) == $file) { |
||||
|
$md5_file = $f ['pathname']; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if (null != $md5_file) { |
||||
|
if (!file_exists($md5_file) || !is_file($md5_file)) { |
||||
|
$this->error('文件不存在',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
$lines = explode("\n", file_get_contents($md5_file)); |
||||
|
if (count($lines) < 3) { |
||||
|
$this->error('安全文件错误',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
if (!preg_match('/^GENE: RCF V.*?$/', $lines [0]) || !preg_match('/^TIME: \\d+\\-\\d+\\-\\d+ \\d+:\\d+:\\d+$/', $lines [1]) || !preg_match('/^ROOT: ([\\/\\.]*)/', $lines [2])) { |
||||
|
$this->error('安全文件错误',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
$finger_file_root = trim(substr($lines [2], 5)); |
||||
|
$basedir = str_replace('\\', '/', rtrim(realpath($finger_file_root), '\\/')) . '/'; |
||||
|
unset ($lines [0], $lines [1], $lines [2]); |
||||
|
$error_msgs = array(); |
||||
|
$file_should_exists = array(); |
||||
|
foreach ($lines as $line) { |
||||
|
$line = trim($line); |
||||
|
if ($line) { |
||||
|
$l = explode('|', $line); |
||||
|
if (count($l) == 2) { |
||||
|
$file = trim($l [1]); |
||||
|
$md5 = trim($l [0]); |
||||
|
$file_should_exists [$file] = $md5; |
||||
|
if (file_exists($filename = $basedir . $file)) { |
||||
|
if ($md5 != md5_file($filename)) { |
||||
|
$error_msgs [] = '文件被篡改 : ' . $file; |
||||
|
} |
||||
|
} else { |
||||
|
$error_msgs [] = '缺少文件 : ' . $file; |
||||
|
} |
||||
|
} else { |
||||
|
$error_msgs [] = '错误行 : ' . $line; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
$this->assign('error_msgs',$error_msgs); |
||||
|
return $this->fetch(); |
||||
|
}else{ |
||||
|
$this->error('文件不存在',addon_url('security://Admin/security_list')); |
||||
|
} |
||||
|
} |
||||
|
//安全文件生成 |
||||
|
private function security_filefingergenerate($dir = '', $prefix = '') |
||||
|
{ |
||||
|
static $allow_file_exts = array( |
||||
|
'php' => true, |
||||
|
'js' => true, |
||||
|
'html' => true, |
||||
|
'htm' => true |
||||
|
); |
||||
|
$file_arrs = array(); |
||||
|
foreach (list_file($dir) as $file) { |
||||
|
if ($file ['isDir']) { |
||||
|
$file_arrs = array_merge($file_arrs, $this->security_filefingergenerate($file ['pathname'] . '/', $prefix . $file ['filename'] . '/')); |
||||
|
} else if ($file ['isFile']) { |
||||
|
if (isset ($allow_file_exts [$file ['ext']])) { |
||||
|
$file_saved = $prefix . str_replace('\\', '/', $file ['filename']); |
||||
|
$file_arrs [] = array( |
||||
|
$file_saved, |
||||
|
md5_file($file ['pathname']) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return $file_arrs; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
{extend name="admin@public/base" /} |
||||
|
{block name="main-content"} |
||||
|
<div class="page-content"> |
||||
|
<div class="row maintop"> |
||||
|
<div class="col-xs-12 col-sm-8"> |
||||
|
<a href="{:addon_url('security://Admin/security_list')}"> |
||||
|
<button class="btn btn-xs btn-danger"> |
||||
|
<i class="ace-icon fa fa-rotate-left bigger-110"></i> |
||||
|
返回安全文件列表 |
||||
|
</button> |
||||
|
</a> |
||||
|
<a href="{:addon_url('security://Admin/security_generate')}" id="security_generate"> |
||||
|
<button class="btn btn-xs btn-danger"> |
||||
|
<i class="ace-icon fa fa-bolt bigger-110"></i> |
||||
|
<span class="tip">重新生成安全文件</span> |
||||
|
</button> |
||||
|
</a> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<div class="col-xs-12"> |
||||
|
<div> |
||||
|
<table class="table table-striped table-bordered table-hover" id="dynamic-table"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>文件检测情况</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
|
||||
|
<tbody> |
||||
|
{if condition="empty($error_msgs)"} |
||||
|
<tr> |
||||
|
<td>当前系统没有发生文件被修改问题。</td> |
||||
|
</tr> |
||||
|
{else /} |
||||
|
{foreach name="error_msgs" item="v"} |
||||
|
<tr> |
||||
|
<td>{$v}</td> |
||||
|
</tr> |
||||
|
{/foreach} |
||||
|
{/if} |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div><!-- /.page-content --> |
||||
|
{/block} |
||||
|
|
||||
@ -0,0 +1,79 @@ |
|||||
|
{extend name="admin@public/base" /} |
||||
|
{block name="main-content"} |
||||
|
<div class="page-content"> |
||||
|
<div class="row maintop"> |
||||
|
<div class="col-xs-4 col-sm-3 margintop5"> |
||||
|
<a href="{:addon_url('security://Admin/security_generate')}" id="security_generate"> |
||||
|
<button class="btn btn-xs btn-danger"> |
||||
|
<i class="ace-icon fa fa-bolt bigger-110"></i> |
||||
|
<span class="tip">重新生成安全文件</span> |
||||
|
</button> |
||||
|
</a> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="row"> |
||||
|
<div class="col-xs-12"> |
||||
|
<div> |
||||
|
<table class="table table-striped table-bordered table-hover" id="dynamic-table"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>文件名称</th> |
||||
|
<th>文件大小</th> |
||||
|
<th>上传时间</th> |
||||
|
<th>查看</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
|
||||
|
<tbody> |
||||
|
{foreach name="finger_files" item="v"} |
||||
|
<tr> |
||||
|
<td>{$v.filename}</td> |
||||
|
<td>{$v.size}</td> |
||||
|
<td>{$v.mtime|date="Y-m-d H:i:s",###}</td> |
||||
|
<td> |
||||
|
<div class="action-buttons"> |
||||
|
<a class="red" data-info="检测需要花一点时间,要执行吗?" href="{:addon_url('security://Admin/security_check',array('file'=>md5($v['filename'])))}" title="检测"> |
||||
|
<i class="ace-icon fa fa-check bigger-130"></i> |
||||
|
</a> |
||||
|
<a class="red confirm-rst-url-btn" data-info="你确定要彻底删除安全文件吗?" href="{:addon_url('security://Admin/security_delete',array('file'=>md5($v['filename'])))}" title="删除"> |
||||
|
<i class="ace-icon fa fa-close bigger-130"></i> |
||||
|
</a> |
||||
|
</div> |
||||
|
<div class="hidden-md hidden-lg hidden-sm hidden-xs"> |
||||
|
<div class="inline position-relative"> |
||||
|
<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto"> |
||||
|
<i class="ace-icon fa fa-cog icon-only bigger-110"></i> |
||||
|
</button> |
||||
|
<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close"> |
||||
|
<li> |
||||
|
<a href="{:addon_url('security://Admin/security_check',array('file'=>md5($v['filename'])))}" class="tooltip-success confirm-rst-url-btn" data-info="检测需要花一点时间,要执行吗?" data-rel="tooltip" title="" data-original-title="检测"> |
||||
|
<span class="green"> |
||||
|
<i class="ace-icon fa fa-check bigger-120"></i> |
||||
|
</span> |
||||
|
</a> |
||||
|
</li> |
||||
|
|
||||
|
<li> |
||||
|
<a href="{:addon_url('security://Admin/security_delete',array('file'=>md5($v['filename'])))}" class="tooltip-error confirm-rst-url-btn" data-info="你确定要彻底删除安全文件吗?" data-rel="tooltip" title="" data-original-title="删除"> |
||||
|
<span class="red"> |
||||
|
<i class="ace-icon fa fa-close bigger-120"></i> |
||||
|
</span> |
||||
|
</a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
</div> |
||||
|
</td> |
||||
|
</tr> |
||||
|
{/foreach} |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
</div><!-- /.page-content --> |
||||
|
{/block} |
||||
|
|
||||
@ -0,0 +1,56 @@ |
|||||
|
<?php |
||||
|
namespace addons\team; |
||||
|
|
||||
|
use think\Addons; |
||||
|
|
||||
|
/** |
||||
|
* 显示团队 |
||||
|
*/ |
||||
|
class Team extends Addons |
||||
|
{ |
||||
|
public $info = [ |
||||
|
'name' => 'Team', |
||||
|
'title' => '企业介绍', |
||||
|
'description' => '后台首页企业介绍显示', |
||||
|
'status' => 0, |
||||
|
'author' => '深圳市花园里教育科技有限公司', |
||||
|
'version' => '0.1', |
||||
|
'admin'=>'0' |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* @var array 插件钩子 |
||||
|
*/ |
||||
|
public $hooks = [ |
||||
|
// 钩子名称 => 钩子说明 |
||||
|
'team'=>'团队钩子' |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* 插件安装方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function install() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 插件卸载方法 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function uninstall() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 实现的team钩子方法 |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function team() |
||||
|
{ |
||||
|
$config=$this->getConfig(); |
||||
|
if($config['display']) return $this->fetch('team'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: rainfer <81818832@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
'display' => [ |
||||
|
'title' => '是否显示:', |
||||
|
'type' => 'radio', |
||||
|
'options' => [ |
||||
|
'1' => '显示', |
||||
|
'0' => '不显示' |
||||
|
], |
||||
|
'value' => '1' |
||||
|
] |
||||
|
]; |
||||
@ -0,0 +1,19 @@ |
|||||
|
<div class="widget-box sl-indextop10 text-left"> |
||||
|
<div class="widget-header"> |
||||
|
<h5 class="widget-title"><span style="font-size:14px; font-family:Microsoft YaHei">企业信息</span></h5> |
||||
|
</div> |
||||
|
<div class="widget-body"> |
||||
|
<div class="widget-main"> |
||||
|
<p class="alert alert-info sl-line-height25"> |
||||
|
公司网站:<a href="http://www.szcaee.cn" target="_blank" alt="YFCMF">www.szcaee.cn</a><br /> |
||||
|
公司名称:深圳文化产权交易所<br /> |
||||
|
公司地址:深圳市福田区滨河大道5008号<br /> |
||||
|
</p> |
||||
|
<p class="alert alert-success"> |
||||
|
电话:0755-88266839 |
||||
|
<br/> |
||||
|
邮箱:<a href="mailto:szcaee@163.com">szcaee@163.com</a> |
||||
|
</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
Loading…
Reference in new issue