使用PHP,我正在开发一个CMS。这需要支持网站备份。
务必:
压缩的ZIP文件夹
必须至少在Linux和Windows上工作
必须在PHP 5.0上工作,PHP 4会很好
我只需要一个函数/类,不要链接我的开源软件,因为我需要自己做这件事
由于CMS支持XML,所以CMS不需要MySQL备份
我已经在PHP中检入ZipArchive。这是我迄今为止所做的。但是,当我尝试去它所创建的服务器上的ZIP文件时,我得到一个404?它不工作,我不知道为什么。
$filename = CONTENT_DIR . 'backups/' . date( 'm-d-Y_H-i-s' ) . '.zip';
if ( $handle = opendir( ABS_PATH ) ) {
$zip = new ZipArchive();
if ( $zip->open( $filename, ZIPARCHIVE::CREATE ) !== true ) {
exit( "cannot open \n" );
}
$string = '';
while ( ( $file = readdir( $handle ) ) !== false ) {
$zip->addFile( $file );
$string .= "$file\n
";
}
closedir( $handle );
$string .= "Status of the Zip Archive: " . $zip->status;
$string .= "
System status of the Zip Archive: " . $zip->statusSys;
$string .= "
Number of files in archive: " . $zip->numFiles;
$string .= "
File name in the file system: " . $zip->filename;
$string .= "
Comment for the archive: " . $zip->comment;
$zip->close();
echo $string;
}
?>