2017-08-23 19:40:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 隐藏插件,默认开启
|
|
|
|
*/
|
|
|
|
class toolsCommonPlugin extends PluginBase{
|
|
|
|
function __construct(){
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
public function regiest(){
|
|
|
|
$this->hookRegiest(array(
|
2017-08-30 14:19:01 +00:00
|
|
|
'user.commonJs.insert' => 'toolsCommonPlugin.echoJs'
|
2017-08-23 19:40:27 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
public function echoJs($st,$act){
|
2017-08-30 14:19:01 +00:00
|
|
|
$this->systemBackup();
|
2017-08-23 19:40:27 +00:00
|
|
|
$this->echoFile('static/main.js');
|
|
|
|
}
|
2017-08-30 14:19:01 +00:00
|
|
|
public function systemBackup(){
|
|
|
|
$system = DATA_PATH.'system/';
|
|
|
|
$bakcupLast = $system.'backup/last/';
|
|
|
|
$backupLastDay = $system.'backup/day/'.date('Ymd',time()).'/';
|
2017-09-07 11:48:56 +00:00
|
|
|
|
|
|
|
//每N天备份一次;首次备份当天
|
|
|
|
$backupRepeat = 5;
|
|
|
|
$day = intval(date('d',time()));
|
|
|
|
if( !@file_exists($bakcupLast) ||
|
|
|
|
(!@file_exists($backupLastDay) && $day % $backupRepeat == 0)
|
|
|
|
){
|
|
|
|
mk_dir($backupLastDay);
|
|
|
|
$this->backupTo($backupLastDay);
|
|
|
|
}
|
2017-08-30 14:19:01 +00:00
|
|
|
|
|
|
|
//每天覆盖备份一次
|
|
|
|
if(!@file_exists($bakcupLast)){
|
|
|
|
mk_dir($bakcupLast);
|
|
|
|
$this->backupTo($bakcupLast);
|
|
|
|
}
|
|
|
|
$lastTime = @filemtime($bakcupLast.'/system_member.php');
|
|
|
|
if(time() - $lastTime > 60*60*24){
|
|
|
|
$this->backupTo($bakcupLast);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private function backupTo($folder){
|
|
|
|
$system = DATA_PATH.'system/';
|
|
|
|
$backFile = array(
|
|
|
|
'apps.php',
|
|
|
|
'system_group.php',
|
|
|
|
'system_member.php',
|
|
|
|
'system_role.php',
|
|
|
|
'system_role_group.php',
|
|
|
|
'system_setting.php',
|
|
|
|
'desktop_app.php'
|
|
|
|
);
|
|
|
|
foreach ($backFile as $file) {
|
|
|
|
if(file_exists($folder.$file)){
|
|
|
|
@unlink($folder.$file);
|
|
|
|
}
|
|
|
|
@copy($system.$file,$folder.$file);
|
|
|
|
}
|
|
|
|
}
|
2017-08-23 19:40:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ie8 css hack;
|
|
|
|
* @return [type] [description]
|
|
|
|
*/
|
|
|
|
public function pie(){
|
|
|
|
header('Content-type: text/x-component');
|
|
|
|
include($this->pluginPath.'/static/pie/pie.htc');
|
|
|
|
}
|
|
|
|
}
|