beifenAction.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. @set_time_limit(3600);
  3. class beifenClassAction extends Action
  4. {
  5. public function chushuaAjax()
  6. {
  7. $myext = $this->getsession('adminallmenuid');
  8. if(getconfig('systype')=='demo')return '演示请勿操作';
  9. if($myext!='-1')return '只有管理员才可以用';
  10. $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';
  11. $mrows = m('mode')->getall('`id`>=108');
  12. foreach($mrows as $k1=>$rs1){
  13. if(!isempt($rs1['table']))$tabstr.=','.$rs1['table'].'';
  14. if(!isempt($rs1['tables']))$tabstr.=','.$rs1['tables'].'';
  15. }
  16. $tables = explode(',', $tabstr);
  17. $alltabls = $this->db->getalltable();
  18. foreach($tables as $tabs){
  19. $_tabs = ''.PREFIX.''.$tabs.'';
  20. $yunbo = false;
  21. if(in_array($_tabs, $alltabls) || !$alltabls)$yunbo = true;
  22. if($yunbo){
  23. $sql1 = "delete from `$_tabs`";
  24. $sql2 = "alter table `$_tabs` AUTO_INCREMENT=1";
  25. $this->db->query($sql1, false);
  26. $this->db->query($sql2, false);
  27. }
  28. }
  29. $this->option->delpid('-2,-102'); //收信的清空
  30. if(!getconfig('platdwnum')){
  31. m('company')->delete('id>1');
  32. $sql2 = "alter table `[Q]company` AUTO_INCREMENT=1";
  33. $this->db->query($sql2, false);
  34. }
  35. echo 'ok';
  36. }
  37. public function beifenAjax()
  38. {
  39. m('beifen')->start();
  40. echo 'ok';
  41. }
  42. public function getdataAjax()
  43. {
  44. if(getconfig('systype')=='demo')exit('演示请勿操作');
  45. $carr = c('file')->getfolderrows(''.UPDIR.'/data');
  46. $rows = array();
  47. $len = count($carr);
  48. $oux = 0;
  49. for($k=$len-1;$k>=0;$k--){
  50. if($oux>100)break;
  51. $fils = $carr[$k];
  52. $fils['xu'] = $k;
  53. $rows[] = $fils;
  54. $oux++;
  55. }
  56. if($rows)$rows = c('array')->order($rows, 'filename');
  57. $arr['rows'] = $rows;
  58. $this->returnjson($arr);
  59. }
  60. public function getdatssssAjax()
  61. {
  62. if(getconfig('systype')=='demo')exit('演示请勿操作');
  63. $rows = array();
  64. $folder = $this->post('folder');
  65. $path = ''.UPDIR.'/data/'.$folder.'';
  66. $carr = c('file')->getfilerows($path);
  67. foreach($carr as $k=>$rs){
  68. $id = $rs['filename'];
  69. $ids = substr($id,0,-5);
  70. $ida = explode('_', $ids);
  71. $len = count($ida);
  72. $fieldshu = $ida[$len-2];
  73. $total = $ida[$len-1];
  74. $fields = str_replace('_'.$fieldshu.'_'.$total.'.json','', $id);
  75. $filepath = $path.'/'.$id.'';
  76. if(file_exists($filepath)){
  77. $filesize = filesize($filepath);
  78. $rows[] = array(
  79. 'fields' => $fields,
  80. 'fieldshu' => $fieldshu,
  81. 'total' => $total,
  82. 'id' => $id,
  83. 'filesizecn'=> $this->rock->formatsize($filesize)
  84. );
  85. }
  86. }
  87. $arr['rows'] = $rows;
  88. $this->returnjson($arr);
  89. }
  90. public function huifdatanewAjax()
  91. {
  92. if(getconfig('systype')=='demo')exit();
  93. if($this->adminid!=1)return '只有ID=1的管理员才可以用';
  94. $folder = $this->post('folder');
  95. $sida = explode(',', $this->post('sid'));
  96. $alltabls = $this->db->getalltable();
  97. $shul = 0;
  98. $tablss = '';
  99. foreach($sida as $id){
  100. $ids = substr($id,0,-5);
  101. $ida = explode('_', $ids);
  102. $len = count($ida);
  103. $fieldshu = $ida[$len-2];
  104. $total = $ida[$len-1];
  105. $tab = str_replace('_'.$fieldshu.'_'.$total.'.json','', $id); //表
  106. if(!in_array($tab, $alltabls))continue; //表不存在
  107. $filepath = ''.UPDIR.'/data/'.$folder.'/'.$id.'';
  108. if(!file_exists($filepath))continue;
  109. $data = m('beifen')->getbfdata('',$filepath);
  110. if(!$data)continue;
  111. $dataall = $data[$tab]['data'];
  112. if(count($dataall)<=0)continue; //没有数据
  113. $allfields = $this->db->getallfields($tab);
  114. $fistdata = $dataall[0];
  115. $xufarr = array();
  116. foreach($fistdata as $f=>$v){
  117. if(in_array($f, $allfields)){
  118. $xufarr[] = $f;
  119. }
  120. }
  121. $uparr = array();
  122. foreach($dataall as $k=>$rs){
  123. $str1 = '';
  124. $upa = array();
  125. foreach($xufarr as $f){
  126. $upa[$f] = $rs[$f];
  127. }
  128. $uparr[] = $upa;
  129. }
  130. $sql1 = "delete from `$tab`";
  131. $sql2 = "alter table `$tab` AUTO_INCREMENT=1";
  132. $bo = $this->db->query($sql1, false);
  133. $bo = $this->db->query($sql2, false);
  134. foreach($uparr as $k=>$upas){
  135. $bo = $this->db->record($tab, $upas);
  136. }
  137. $shul++;
  138. $tablss.=','.$tab.'';
  139. }
  140. return ''.$tablss.'表已恢复';
  141. }
  142. /**
  143. * 还原数据操作(2017-08-27弃用)
  144. */
  145. public function huifdataAjax()
  146. {
  147. if(getconfig('systype')=='demo')exit('演示请勿操作');
  148. $xu = (int)$this->post('xu');
  149. $carr = c('file')->getfilerows(''.UPDIR.'/data');
  150. $sida = explode(',', $this->post('sid'));
  151. $rows = array();
  152. if(isset($carr[$xu])){
  153. $file = $carr[$xu]['filename'];
  154. $data = m('beifen')->getbfdata($file);
  155. if($data){
  156. $alltabls = $this->db->getalltable();
  157. foreach($sida as $tab){
  158. if(!isset($data[$tab]))continue;
  159. if(!in_array($tab, $alltabls))continue; //表不存在
  160. $dataall = $data[$tab]['data'];
  161. if(count($dataall)<=0)continue;
  162. $allfields = $this->db->getallfields($tab);
  163. $fistdata = $dataall[0];
  164. $xufarr = array();
  165. foreach($fistdata as $f=>$v){
  166. if(in_array($f, $allfields)){
  167. $xufarr[] = $f;
  168. }
  169. }
  170. $uparr = array();
  171. foreach($dataall as $k=>$rs){
  172. $str1 = '';
  173. $upa = array();
  174. foreach($xufarr as $f){
  175. $upa[$f] = $rs[$f];
  176. }
  177. $uparr[] = $upa;
  178. }
  179. $sql1 = "delete from `$tab`";
  180. $sql2 = "alter table `$tab` AUTO_INCREMENT=1";
  181. $bo = $this->db->query($sql1, false);
  182. $bo = $this->db->query($sql2, false);
  183. foreach($uparr as $k=>$upas){
  184. $bo = $this->db->record($tab, $upas);
  185. }
  186. }
  187. }
  188. }
  189. echo 'ok';
  190. }
  191. public function chushuserAjax()
  192. {
  193. if(getconfig('systype')=='demo')return '演示请勿操作';
  194. if($this->adminid!=1)return '只有ID=1的管理员才可以用';
  195. $users = "'diaochan','zhangfei','daqiao','xiaoqiao','zhaozl','rock','xinhu'";
  196. $dbs = m('admin');
  197. $dba = m('dept');
  198. //默认可以多次初始化
  199. if($this->option->getval('sysuserinit', '是') != '是')
  200. if($dbs->rows("`user` in($users)")==0)return '可能你已初始化过用户和部门了,要开启可到【流程模块→数据选项】系统选项下开启';
  201. $dbs->delete('id>1');
  202. $this->db->query('alter table `[Q]admin` AUTO_INCREMENT=2', false);
  203. $dba->delete('id>1');
  204. $this->db->query('alter table `[Q]dept` AUTO_INCREMENT=2', false);
  205. $this->db->query('delete from `[Q]userinfo`', false);
  206. $this->db->query('delete from `[Q]userinfos`', false);
  207. $this->db->query('alter table `[Q]userinfos` AUTO_INCREMENT=1', false);
  208. return 'ok';
  209. }
  210. }
粤ICP备19079148号