用着10年的老程序,最近升级了PHP7一下各种报错全来了。自己百度解决了大部份问题。
备份表的自己解决了,可是备份内容的实在找不到方法了,文件内容如下,各位大大帮看下
- public function list_fields($dbname,$tbname){return mysqli_list_fields($dbname,$tbname,$this->link_id);}
复制代码
- if(!IsNum($size))
- $size=1024;
- $bakStr='';
- $tabelresult=$db->list_tables(cd_sqldbname);
- if($tabelresult){
- while($tabelrow=mysql_fetch_row($tabelresult)){
- $ycms_ID=explode("_",$tabelrow[0]);
- if($ycms_ID[0]==ReplaceStr(cd_tablename, "_", "")){
- $intable="INSERT INTO `$tabelrow[0]` VALUES(";
- $fieldresult = $db->list_fields(cd_sqldbname, $tabelrow[0]);
- $i=0;
- if($fieldresult) {
- //分析表里的字段信息
- while($fieldrow=mysql_fetch_field($fieldresult)){
- $fs[$i]=trim($fieldrow->name);
- $i++;
- }
- $fsd=$i-1;
- ////读取表的内容
- $sql="select * from `$tabelrow[0]`";
- $result=$db->getAll($sql);
- for($j=0;$j<count($result);$j++){
- $line=$intable;
- for($k=0; $k<=$fsd; $k++){
- if($k<$fsd) {
- $line.="'".mysql_escape_string($result[$j][$fs[$k]])."',";
- }else{
- $line.="'".mysql_escape_string($result[$j][$fs[$k]])."');\r\n";
- }
- }
- $bakStr.=$line;
- if(strlen($bakStr)>$size*1024){
- $a=$a+1;
- $b=$b+1;
- $bkfile="../backup/".date('Ymd-H')."/tables_datas_".substr(md5(time().mt_rand(1000,5000)),0,16).".txt";
- $fp=fopen($bkfile, "w");
- fwrite($fp, $bakStr);
- fclose($fp);
- echo " <font style="font-size:10pt;">数据库:<font color=red>../backup/".date('Ymd-H')."/".rand(1000,5000)."".rand(1000,5000)."".rand(1000,5000).".txt</font> 文件备份成功...</font></font><br/>";
- $bakStr='';
- }
- }
- }
- }
- }
- if(!empty($bakStr) && strlen($bakStr)<$size*1024){
- $bkfile="../backup/".date('Ymd-H')."/tables_datas_".substr(md5(time().mt_rand(1000,5000)),0,16).".txt";
- $fp=fopen($bkfile,"w");
- fwrite($fp,$bakStr);
- fwrite(fopen("../backup/".date('Ymd-H')."/Atime.txt", "wb"),"".date('Y-m-d H:i:s')." / ".$_COOKIE['CD_AdminUserName']."");
- fwrite(fopen("../tools/bftime.txt", "wb"),"".date('Y-m-d H:i:s')."");
- if($b){$backupsize=formatsize($b*1048576);}else{$backupsize='1MB';}
- exit("<br/><br/> <font style="font-size:10pt;"><b>恭喜您,数据库已全部备份完毕!</b></font> <font style="font-size:10pt;"><b>备份".$a."个文件,占用空间:".$backupsize."</b></font><script language='javascript'>alert('恭喜您,数据库已全部备份完毕!共备份".$a."个文件,占用空间:".$backupsize."');top.frames['main'].location.reload();</script>");
- fclose($fp);
- }
- }
复制代码 |