尊重作者,轉貼本文章請貼上來源http://phpbb-tw.net/phpbb/viewtopic.php?t=44663,謝謝
1.輸出phpbb的資料庫,建議將phpbb_search_* table內的record刪除以減低db size
2.把以下code另傳成abc.php,記住修改$t (剛才輸出的db),$filename(經過處理後的檔案),改完記得把$filename和$t和abc放到同一目錄下還有chmod 777 $filename,之後打開ie打上http://xxx/abc.php,如執行成功會出現Success, wrote to file test.txt的字樣
代碼: 選擇全部
<?php
$t = 'dbname.sql';
$filename = 'test.txt';
(!$f=file_get_contents($t))? die("Fail to open target link!!") : NULL ;
$somecontent = Fix_Backslash($f);
$somecontent = iconv("big5","utf-8",$somecontent);
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
exit;
function Fix_Backslash($org_str) {
// if ( mysql_client_encoding() != "big5" ) return $org_str;
$tmp_length = strlen($org_str);
for ( $tmp_i=0; $tmp_i<$tmp_length; $tmp_i++ ) {
$ascii_str_a = substr($org_str, $tmp_i , 1);
$ascii_str_b = substr($org_str, $tmp_i+1, 1);
$ascii_value_a = ord($ascii_str_a);
$ascii_value_b = ord($ascii_str_b);
if ( $ascii_value_a > 128 ) {
if ( $ascii_value_b == 92 ) {
$org_str = substr($org_str, 0, $tmp_i+2) . substr($org_str,$tmp_i+3);
$tmp_length = strlen($org_str);
}
$tmp_i++;
}
}
$tmp_length = strlen($org_str);
if ( substr($org_str, ($tmp_length-1), 1) == "\\" ) $org_str .= chr(32);
$org_str = str_replace("\\0", "\ 0", $org_str);
return $org_str;
}
?>