diff --git a/include/class/mysql.php b/include/class/mysql.php index 42d9734..fb9ae0d 100644 --- a/include/class/mysql.php +++ b/include/class/mysql.php @@ -279,13 +279,13 @@ abstract class mysql{ return $this->getall($sql); } - public function getall($sql, $call=null) + public function getall($sql, $call=null, $cans=array()) { $res=$this->query($sql); $arr=array(); if($res){ while($row=$this->fetch_array($res)){ - if($call != null)$row = $call($row); + if($call != null)$row = $call($row, $cans); $arr[] = $row; $this->count++; } diff --git a/js/jswx.js b/js/jswx.js index 008de9b..32d6cde 100644 --- a/js/jswx.js +++ b/js/jswx.js @@ -84,7 +84,11 @@ js.wx.unload=function(){ js.unloading(); } js.wx.msgok=function(txt,fun,ms){ - js.msgok(txt,fun,ms); + if(js.msgok){ + js.msgok(txt,fun, ms); + }else{ + js.alert(txt,'', fun); + } } js.showmenu=function(d){ diff --git a/webmain/index/indexscript.js b/webmain/index/indexscript.js index aee6e87..fc02530 100644 --- a/webmain/index/indexscript.js +++ b/webmain/index/indexscript.js @@ -26,9 +26,9 @@ function initbody(){ },{ name:' 切换主题',num:'theme','icon':'adjust' },{ - name:' 新版首页1',num:'jiu','icon':'laptop' + name:' 背景首页',num:'jiu','icon':'laptop' },{ - name:' 新版首页2',num:'jiu2','icon':'laptop' + name:' 列表首页',num:'jiu2','icon':'laptop' },{ name:' 帐号('+adminuser+')',num:'user' }]; diff --git a/webmain/task/runt/beifenAction.php b/webmain/task/runt/beifenAction.php index 1630799..ebe18a4 100644 --- a/webmain/task/runt/beifenAction.php +++ b/webmain/task/runt/beifenAction.php @@ -54,4 +54,55 @@ class beifenClassAction extends runtAction return 'success'; } + /** + * 备份数据库 + * php task.php beifen,create + */ + public function createAction() + { + if(PHP_SAPI != 'cli') return 'plase cli run'; + $alltabls = $this->db->getalltable(); + ob_end_clean(); + $path = ''.ROOT_PATH.'/'.DB_BASE.'_'.date('YmdHis').'.sql'; + $file = fopen($path, 'ab+'); + + $nobeifne = array(''.PREFIX.'log',''.PREFIX.'logintoken',''.PREFIX.'kqanay',''.PREFIX.'email_cont',''.PREFIX.'dailyfx',''.PREFIX.'reads',''.PREFIX.'todo',''.PREFIX.'city'); //不备份的表; + + foreach($alltabls as $tabs){ + $sqla = $this->db->getall('show create table `'.$tabs.'`'); + $createsql = $sqla[0]['Create Table']; + $createsql = str_replace('`'.$tabs.'`', 'IF NOT EXISTS `'.$tabs.'`', $createsql).";\n"; + if(!in_array($tabs, $nobeifne)){ + $strstr = "\nDROP TABLE IF EXISTS `$tabs`;\n"; + $strstr .= $createsql; + fwrite($file,$strstr); + + $rows = $this->db->getall('select * from `'.$tabs.'`', function($rs, $cans){ + $vstr = ''; + foreach($rs as $k1=>$v1){ + if(!isempt($v1))$v1 = str_replace("\n",'\n', $v1); + $v1 = ($v1===null) ? 'NULL' : "'$v1'"; + $vstr.=",$v1"; + } + $vstr = substr($vstr,1); + $tabs = $cans['tabs']; + $strstr = "INSERT INTO `$tabs` VALUES($vstr);\n"; + fwrite($cans['file'], $strstr); + return $vstr; + }, array( + 'file' => $file, + 'tabs' => $tabs + )); + + echo ''.$tabs.' success count('.count($rows).')'.PHP_EOL; + }else{ + fwrite($file,$createsql); + echo ''.$tabs.' break'.PHP_EOL; + } + } + fclose($file); + + echo 'success'.PHP_EOL; + } + } \ No newline at end of file diff --git a/webmain/we/index/tpl_index_editpass.html b/webmain/we/index/tpl_index_editpass.html index 2937644..5573555 100644 --- a/webmain/we/index/tpl_index_editpass.html +++ b/webmain/we/index/tpl_index_editpass.html @@ -50,7 +50,9 @@ function loginsubmit(){ }); } function initbody(){ - + js.wx.msgok('密码修改成功',function(){ + js.msg('msg','呵呵'); + },1); }