//替换前缀定义 $buffer = str_replace('{shopexdump_table_prefix}', $GLOBALS['_tbpre'], $buffer); if (defined("MYSQL_CHARSET_NAME")) { $buffer = str_replace('{shopexdump_create_specification}', ' DEFAULT CHARACTER SET ' . MYSQL_CHARSET_NAME, $buffer); } else { $buffer = str_replace('{shopexdump_create_specification}', '', $buffer); } if (!mysql_query($buffer, $link)) { echo mysql_error($link) . "<br>"; } usleep(5); $i++; } } fclose($fp); rptout("数据文件" . $bakfile . "恢复成功!\n"); $fileid++; mysql_close($link); jsjmp($_SERVER['PHP_SELF'] . "?action=restore&fileid={$fileid}"); } function rptout($str) { echo $str . "<br><script>s();</script>"; flush(); } function jsjmp($url) { echo <<<EOF \t<script language="JavaScript"> \t<!-- \t\t\t\tlocation= '{$url}';
$fileid++; } rptout("同步订单中的商品id....\n<hr>"); $aMap = getMap(); if ($syncnum = count($aMap) > 0) { //$aMap 是$old_gid=>$new_gid foreach ($aMap as $key => $value) { rptout("同步 {$value} 为 {$key}"); $sql .= "update {$GLOBALS['_tbpre']}mall_items set gid='" . $value . "' where gid='" . $key . "';"; } mysql_query($sql); } else { rptout("没有需要同步的商品"); } mysql_close($link); rptout("<hr><font color=green>全部工作结束</font>"); } function rptout($str) { echo $str . "<br><script>s();</script>"; flush(); } function fgetline($handle, &$line) { $buffer = fgets($handle, 4096); if (!$buffer) { return false; } if (4095 > strlen($buffer) || 4095 == strlen($buffer) && '\\n' == $buffer[4094]) { $line = $buffer; } else {
if ($_REQUEST['submit'] != '' && $_REQUEST['act'] == '') { if (!file_exists(TARGET)) { printForm('Folder not exists!'); } # Create File List $filelist = array(); $filelist = GetFileList(TARGET); # Put all files from file list in ZIP archive foreach ($filelist as $val) { $content .= $val . "\r\n"; } $fp = fopen("tmp/filelist.log", "w+"); fwrite($fp, $content, strlen($content)); fclose($fp); $totalvol = ceil(count($filelist) / LENGTH); rptout("应该有 " . $totalvol . " 个备份,现在开始备份...<hr>"); //备份从这里起跳 jump('?act=do&vol=0&total=' . $totalvol); } else { ?> <form><input type=submit name=submit value='开始'></form> <?php } ?> </body> </html> <?php #
function translate_local2utf($key, $fields, $table) { $str_fields = $key . ',' . implode(',', $fields); $str_query = "select {$str_fields} from {$table}"; $result = mysql_query($str_query); report_mysql_errors($str_query); $i = 0; while ($row = mysql_fetch_array($result)) { // print_r( $row); unset($arr_fields); foreach ($fields as $v) { // if ($row[$v]!='') $arr_fields[$v] = addslashes(stripslashes(local2utf($row[$v], 'zh'))); } // echo "<pre>"; // print_r($arr_fields); // echo "<pre>"; $db_string = compile_db_update_string($arr_fields); $str_query = "UPDATE {$table} SET {$db_string} WHERE {$key}='" . $row[$key] . "'"; // rptout($str_query); mysql_query($str_query); report_mysql_errors($str_query); $i++; if ($i % 60 == 0) { rptout($i); } } rptout($i); }
function vuptree($dir, $remote) { global $ftp, $dirs_num, $files_num, $filefail_num; $dirhandle = @opendir($dir); while ($file_name = @readdir($dirhandle)) { if ($file_name != "." && $file_name != ".." && $file_name != "mall_config.php") { if (is_dir("{$dir}/{$file_name}")) { @$ftp->mkdir($remote . "/" . $file_name); rptout("<font color=green>" . $remote . "/" . $file_name . "目录已建立</font>"); if (!strstr($remote . "/" . $file_name, 'home/cache/1')) { //取消cache uptree($dir . "/" . $file_name, $remote . "/" . $file_name); } } else { if (filesize($dir . "/" . $file_name) < 5000000) { if ($ftp->write($remote . "/" . $file_name, $dir . "/" . $file_name)) { rptout($remote . "/" . $file_name . " 成功上传"); usleep(100); } else { rptout("<font color=red>" . $remote . "/" . $file_name . " 上传失败</font>"); } } } } } @closedir($dirhandle); }