信呼OA版本v2.3.8
This commit is contained in:
235
webmain/system/beifen/beifenAction.php
Normal file
235
webmain/system/beifen/beifenAction.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
@set_time_limit(3600);
|
||||
class beifenClassAction extends Action
|
||||
{
|
||||
|
||||
public function chushuaAjax()
|
||||
{
|
||||
$myext = $this->getsession('adminallmenuid');
|
||||
if(getconfig('systype')=='demo')return '演示请勿操作';
|
||||
if($myext!='-1')return '只有管理员才可以用';
|
||||
|
||||
$tabstr = 'daily,file,files,flow_log,flow_todos,flow_checks,im_history,im_mess,im_messzt,infor,infors,log,logintoken,meet,reads,sjoin,work,todo,flow_chao,flow_bill,flow_remind,goodm,goodn,goodss,goods,kqanay,kqdkjl,kqerr,kqout,kqinfo,location,official,officialfa,officialhong,schedule,scheduld,project,userinfo,userinfos,userract,hrpositive,word,hrredund,hrsalary,customer,custsale,custract,custfina,custappy,assetm,book,bookborrow,carm,carms,carmang,carmrese,email_cont,emailm,emails,sealapl,vcard,tovoid,editrecord,wouser,dailyfx,knowtraim,knowtrais,fininfom,fininfos,hrtrsalary,hrtransfer,hrdemint,reward,offyuebd,repair,knowtiku,kqdisv,knowledge,kqjcmd,kqjuser,kqjsn,hrcheck,receipt,hrcheckn,hrchecks,hrkaohem,hrkaohes,hrkaohen,demo,finpiao,wordxie,wordeil,subscribe,subscribeinfo,news,finzhang,finkemu,finount,finjibook,custplan,wenjuan,wenjuat,wenjuau,dangan,danganjy,wotpl,seal,godepot,im_tonghua,bianjian';
|
||||
$mrows = m('mode')->getall('`id`>=108');
|
||||
foreach($mrows as $k1=>$rs1){
|
||||
if(!isempt($rs1['table']))$tabstr.=','.$rs1['table'].'';
|
||||
if(!isempt($rs1['tables']))$tabstr.=','.$rs1['tables'].'';
|
||||
}
|
||||
$tables = explode(',', $tabstr);
|
||||
$alltabls = $this->db->getalltable();
|
||||
foreach($tables as $tabs){
|
||||
$_tabs = ''.PREFIX.''.$tabs.'';
|
||||
$yunbo = false;
|
||||
if(in_array($_tabs, $alltabls) || !$alltabls)$yunbo = true;
|
||||
if($yunbo){
|
||||
$sql1 = "delete from `$_tabs`";
|
||||
$sql2 = "alter table `$_tabs` AUTO_INCREMENT=1";
|
||||
$this->db->query($sql1, false);
|
||||
$this->db->query($sql2, false);
|
||||
}
|
||||
}
|
||||
$this->option->delpid('-2,-102'); //收信的清空
|
||||
if(!getconfig('platdwnum')){
|
||||
m('company')->delete('id>1');
|
||||
$sql2 = "alter table `[Q]company` AUTO_INCREMENT=1";
|
||||
$this->db->query($sql2, false);
|
||||
}
|
||||
echo 'ok';
|
||||
}
|
||||
|
||||
public function beifenAjax()
|
||||
{
|
||||
m('beifen')->start();
|
||||
echo 'ok';
|
||||
}
|
||||
|
||||
public function getdataAjax()
|
||||
{
|
||||
if(getconfig('systype')=='demo')exit('演示请勿操作');
|
||||
$carr = c('file')->getfolderrows(''.UPDIR.'/data');
|
||||
$rows = array();
|
||||
$len = count($carr);
|
||||
$oux = 0;
|
||||
for($k=$len-1;$k>=0;$k--){
|
||||
if($oux>100)break;
|
||||
$fils = $carr[$k];
|
||||
$fils['xu'] = $k;
|
||||
$rows[] = $fils;
|
||||
$oux++;
|
||||
}
|
||||
if($rows)$rows = c('array')->order($rows, 'filename');
|
||||
$arr['rows'] = $rows;
|
||||
$this->returnjson($arr);
|
||||
}
|
||||
|
||||
public function getdatssssAjax()
|
||||
{
|
||||
if(getconfig('systype')=='demo')exit('演示请勿操作');
|
||||
$rows = array();
|
||||
$folder = $this->post('folder');
|
||||
$path = ''.UPDIR.'/data/'.$folder.'';
|
||||
$carr = c('file')->getfilerows($path);
|
||||
foreach($carr as $k=>$rs){
|
||||
$id = $rs['filename'];
|
||||
$ids = substr($id,0,-5);
|
||||
$ida = explode('_', $ids);
|
||||
$len = count($ida);
|
||||
$fieldshu = $ida[$len-2];
|
||||
$total = $ida[$len-1];
|
||||
$fields = str_replace('_'.$fieldshu.'_'.$total.'.json','', $id);
|
||||
$filepath = $path.'/'.$id.'';
|
||||
if(file_exists($filepath)){
|
||||
$filesize = filesize($filepath);
|
||||
$rows[] = array(
|
||||
'fields' => $fields,
|
||||
'fieldshu' => $fieldshu,
|
||||
'total' => $total,
|
||||
'id' => $id,
|
||||
'filesizecn'=> $this->rock->formatsize($filesize)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$arr['rows'] = $rows;
|
||||
$this->returnjson($arr);
|
||||
}
|
||||
|
||||
public function huifdatanewAjax()
|
||||
{
|
||||
if(getconfig('systype')=='demo')exit();
|
||||
if($this->adminid!=1)return '只有ID=1的管理员才可以用';
|
||||
$folder = $this->post('folder');
|
||||
$sida = explode(',', $this->post('sid'));
|
||||
$alltabls = $this->db->getalltable();
|
||||
$shul = 0;
|
||||
$tablss = '';
|
||||
foreach($sida as $id){
|
||||
$ids = substr($id,0,-5);
|
||||
$ida = explode('_', $ids);
|
||||
$len = count($ida);
|
||||
$fieldshu = $ida[$len-2];
|
||||
$total = $ida[$len-1];
|
||||
$tab = str_replace('_'.$fieldshu.'_'.$total.'.json','', $id); //表
|
||||
|
||||
if(!in_array($tab, $alltabls))continue; //表不存在
|
||||
|
||||
$filepath = ''.UPDIR.'/data/'.$folder.'/'.$id.'';
|
||||
if(!file_exists($filepath))continue;
|
||||
|
||||
$data = m('beifen')->getbfdata('',$filepath);
|
||||
if(!$data)continue;
|
||||
|
||||
|
||||
$dataall = $data[$tab]['data'];
|
||||
if(count($dataall)<=0)continue; //没有数据
|
||||
|
||||
$allfields = $this->db->getallfields($tab);
|
||||
$fistdata = $dataall[0];
|
||||
$xufarr = array();
|
||||
foreach($fistdata as $f=>$v){
|
||||
if(in_array($f, $allfields)){
|
||||
$xufarr[] = $f;
|
||||
}
|
||||
}
|
||||
$uparr = array();
|
||||
foreach($dataall as $k=>$rs){
|
||||
$str1 = '';
|
||||
$upa = array();
|
||||
foreach($xufarr as $f){
|
||||
$upa[$f] = $rs[$f];
|
||||
}
|
||||
$uparr[] = $upa;
|
||||
}
|
||||
|
||||
$sql1 = "delete from `$tab`";
|
||||
$sql2 = "alter table `$tab` AUTO_INCREMENT=1";
|
||||
$bo = $this->db->query($sql1, false);
|
||||
$bo = $this->db->query($sql2, false);
|
||||
foreach($uparr as $k=>$upas){
|
||||
$bo = $this->db->record($tab, $upas);
|
||||
}
|
||||
$shul++;
|
||||
$tablss.=','.$tab.'';
|
||||
}
|
||||
return ''.$tablss.'表已恢复';
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原数据操作(2017-08-27弃用)
|
||||
*/
|
||||
public function huifdataAjax()
|
||||
{
|
||||
if(getconfig('systype')=='demo')exit('演示请勿操作');
|
||||
$xu = (int)$this->post('xu');
|
||||
$carr = c('file')->getfilerows(''.UPDIR.'/data');
|
||||
$sida = explode(',', $this->post('sid'));
|
||||
$rows = array();
|
||||
if(isset($carr[$xu])){
|
||||
$file = $carr[$xu]['filename'];
|
||||
$data = m('beifen')->getbfdata($file);
|
||||
if($data){
|
||||
$alltabls = $this->db->getalltable();
|
||||
foreach($sida as $tab){
|
||||
if(!isset($data[$tab]))continue;
|
||||
if(!in_array($tab, $alltabls))continue; //表不存在
|
||||
$dataall = $data[$tab]['data'];
|
||||
if(count($dataall)<=0)continue;
|
||||
|
||||
$allfields = $this->db->getallfields($tab);
|
||||
$fistdata = $dataall[0];
|
||||
$xufarr = array();
|
||||
foreach($fistdata as $f=>$v){
|
||||
if(in_array($f, $allfields)){
|
||||
$xufarr[] = $f;
|
||||
}
|
||||
}
|
||||
$uparr = array();
|
||||
foreach($dataall as $k=>$rs){
|
||||
$str1 = '';
|
||||
$upa = array();
|
||||
foreach($xufarr as $f){
|
||||
$upa[$f] = $rs[$f];
|
||||
}
|
||||
$uparr[] = $upa;
|
||||
}
|
||||
|
||||
$sql1 = "delete from `$tab`";
|
||||
$sql2 = "alter table `$tab` AUTO_INCREMENT=1";
|
||||
$bo = $this->db->query($sql1, false);
|
||||
$bo = $this->db->query($sql2, false);
|
||||
foreach($uparr as $k=>$upas){
|
||||
$bo = $this->db->record($tab, $upas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo 'ok';
|
||||
}
|
||||
|
||||
public function chushuserAjax()
|
||||
{
|
||||
|
||||
if(getconfig('systype')=='demo')return '演示请勿操作';
|
||||
if($this->adminid!=1)return '只有ID=1的管理员才可以用';
|
||||
|
||||
$users = "'diaochan','zhangfei','daqiao','xiaoqiao','zhaozl','rock','xinhu'";
|
||||
$dbs = m('admin');
|
||||
$dba = m('dept');
|
||||
|
||||
//默认可以多次初始化
|
||||
if($this->option->getval('sysuserinit', '是') != '是')
|
||||
if($dbs->rows("`user` in($users)")==0)return '可能你已初始化过用户和部门了,要开启可到【流程模块→数据选项】系统选项下开启';
|
||||
|
||||
$dbs->delete('id>1');
|
||||
$this->db->query('alter table `[Q]admin` AUTO_INCREMENT=2', false);
|
||||
|
||||
$dba->delete('id>1');
|
||||
$this->db->query('alter table `[Q]dept` AUTO_INCREMENT=2', false);
|
||||
|
||||
$this->db->query('delete from `[Q]userinfo`', false);
|
||||
$this->db->query('delete from `[Q]userinfos`', false);
|
||||
$this->db->query('alter table `[Q]userinfos` AUTO_INCREMENT=1', false);
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
}
|
||||
89
webmain/system/beifen/rock_beifen.php
Normal file
89
webmain/system/beifen/rock_beifen.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
var c={
|
||||
chush:function(o1){
|
||||
js.confirm('确定要初始化系统数据嘛?<font color=red>慎重!</font>',function(bt){
|
||||
if(bt=='yes'){
|
||||
o1.disabled=true;
|
||||
c.chushss(o1);
|
||||
}
|
||||
});
|
||||
},
|
||||
chushss:function(o1){
|
||||
js.msg('wait','初始中...');
|
||||
js.ajax(js.getajaxurl('chushua','{mode}','{dir}'),{}, function(s){
|
||||
if(s=='ok'){
|
||||
js.confirm('初始化成功,请重新登录',function(){
|
||||
js.location('?m=login&a=exit');
|
||||
});
|
||||
}else{
|
||||
js.msg('msg', s);
|
||||
o1.disabled=false;
|
||||
}
|
||||
});
|
||||
},
|
||||
beifen:function(o1,lx){
|
||||
js.msg('wait','备份中...');
|
||||
js.ajax(js.getajaxurl('beifen','{mode}','{dir}'),{lx:lx}, function(s){
|
||||
if(s=='ok'){
|
||||
js.msg('success', '备份成功请到目录<?=UPDIR?>/data下查看');
|
||||
}else{
|
||||
js.msg('msg', s);
|
||||
}
|
||||
});
|
||||
},
|
||||
huifu:function(){
|
||||
js.confirm('建议:恢复数据前请先备份一下数据啊!是否去备份?',function(jg){
|
||||
if(jg=='yes'){
|
||||
c.beifen();
|
||||
}else{
|
||||
addtabs({name:'数据恢复',num:'huifu',url:'system,beifen,huifu'});
|
||||
}
|
||||
});
|
||||
},
|
||||
deluser:function(o1){
|
||||
js.confirm('确定要初始化部门和用户数据嘛?<font color=red>慎重!</font>',function(bt){
|
||||
if(bt=='yes'){
|
||||
o1.disabled=true;
|
||||
c.delusers(o1);
|
||||
}
|
||||
});
|
||||
},
|
||||
delusers:function(o1){
|
||||
js.msg('wait','初始中...');
|
||||
js.ajax(js.getajaxurl('chushuser','{mode}','{dir}'),{}, function(s){
|
||||
js.msg();
|
||||
if(s=='ok'){
|
||||
js.alert('部门和用户已初始,请到用户管理导入用户。');
|
||||
}else{
|
||||
js.msg('msg', s);
|
||||
o1.disabled=false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div align="left">
|
||||
<div>
|
||||
<button click="beifen,0" class="btn btn-success" type="button">系统数据备份</button>
|
||||
</div>
|
||||
<div class="tishi">数据备份会备份到系统目录<?=UPDIR?>/data文件下,建议每天备份一次!</div>
|
||||
|
||||
<div class="blank10"></div>
|
||||
<div><button click="huifu" class="btn btn-info" type="button">系统数据恢复</button></div>
|
||||
<div class="tishi">恢复你备份过的数据!</div>
|
||||
|
||||
|
||||
<div class="blank20"></div>
|
||||
<div><button click="chush" class="btn btn-danger" type="button">系统数据初始化</button></div>
|
||||
<div class="tishi">初始化将会清空系统上所有数据(除了人员、组织结构、模块配置权限),请谨慎使用!</div>
|
||||
|
||||
<div class="blank20"></div>
|
||||
<div><button click="deluser" class="btn btn-danger" type="button">初始化部门和用户</button></div>
|
||||
<div class="tishi">初始化部门和用户,将会删除你创建的用户和部门,为了防止误删只能使用一次,请备份好数据谨慎使用!</div>
|
||||
|
||||
</div>
|
||||
93
webmain/system/beifen/rock_beifen_huifu.php
Normal file
93
webmain/system/beifen/rock_beifen_huifu.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
var folder='';
|
||||
var at = $('#viewss_{rand}').bootstable({
|
||||
tablename:'option',celleditor:false,url:js.getajaxurl('getdata', '{mode}', '{dir}'),
|
||||
columns:[{
|
||||
text:'备份时间',dataIndex:'filename'
|
||||
},{
|
||||
text:'操作',dataIndex:'opt',renderer:function(v,d,i){
|
||||
return '<a href="javascript:;" onclick="huifww{rand}('+i+')">恢复</a>';
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
var a = $('#view_{rand}').bootstable({
|
||||
tablename:'option',celleditor:true,checked:true,url:js.getajaxurl('getdatssss', '{mode}', '{dir}'),
|
||||
autoLoad:false,params:{xu:0},
|
||||
columns:[{
|
||||
text:'表名',dataIndex:'fields'
|
||||
},{
|
||||
text:'字段数',dataIndex:'fieldshu'
|
||||
},{
|
||||
text:'记录数',dataIndex:'total'
|
||||
},{
|
||||
text:'文件大小',dataIndex:'filesizecn'
|
||||
}],
|
||||
load:function(){
|
||||
get('btnss_{rand}').focus();
|
||||
}
|
||||
});
|
||||
|
||||
huifww{rand}=function(i){
|
||||
c.huifu(i);
|
||||
}
|
||||
|
||||
var c = {
|
||||
huifu:function(f){
|
||||
var d = at.getData(f);
|
||||
folder= d.filename;
|
||||
a.setparams({'folder':d.filename},true);//恢复的文件夹
|
||||
},
|
||||
clickwin:function(){
|
||||
var sid = a.getchecked();
|
||||
if(sid==''){
|
||||
js.msg('msg','没有选中记录');
|
||||
return;
|
||||
}
|
||||
js.confirm('确定要恢复选中的数据库表吗?恢复了现有的数据就没有了!',function(jg){
|
||||
if(jg=='yes'){
|
||||
setTimeout(function(){
|
||||
c.huifusss(sid);
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
},
|
||||
huifusss:function(sid){
|
||||
js.wait('恢复中请不要关闭...');
|
||||
js.ajax(js.getajaxurl('huifdatanew', '{mode}', '{dir}'),{sid:sid,'folder':folder},function(s){
|
||||
setTimeout(function(){
|
||||
js.tanclose('confirm');
|
||||
js.msg('success','恢复'+s+'');
|
||||
}, 1000);
|
||||
},'post');
|
||||
},
|
||||
reload:function(){
|
||||
at.reload();
|
||||
}
|
||||
};
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<table width="100%">
|
||||
<tr valign="top">
|
||||
<td width="30%">
|
||||
<div>
|
||||
<button class="btn btn-default" click="reload,0" type="button">刷新</button>
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="viewss_{rand}"></div>
|
||||
</td>
|
||||
<td width="10"></td>
|
||||
<td>
|
||||
<div align="right"><font color="#888888">系统只会恢复数据并不会恢复字段,建议选择单表恢复,以免超时。</font>
|
||||
<button class="btn btn-default" id="btnss_{rand}" click="clickwin,0" type="button">恢复选中表</button>
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="view_{rand}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
Reference in New Issue
Block a user