pballz
New Member
- Messages
- 24
- Reaction score
- 0
- Points
- 1
I tried to run my backup script and got the following error.
I'm guessing the update of php has something to do with this but the newer version shouldn't have broken it.
Posting script in case that helps
I did not make this.
Code:
[B]Fatal error[/B]: Class 'ZipArchive' not found in [B]/home/......../zip.php[/B] on line [B]21[/B]
Posting script in case that helps
Code:
//how to call zip function
include 'zip.php';
zip('/home/pballz/public_html');
//zip.php contents
<?php
function recurse_zip($src,&$zip,$path_length) {
$dir = opendir($src);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_zip($src . '/' . $file,$zip,$path_length);
}
else {
$zip->addFile($src . '/' . $file,substr($src . '/' . $file,$path_length));
}
}
}
closedir($dir);
}
//Call this function with argument = absolute path of file or directory name.
function zip($src)
{
global $zip_fname;
$zip_fname='backup_'.date("Y-m-d_H-i-s").'.zip';
$zip = new ZipArchive;
$res = $zip->open($zip_fname, ZipArchive::CREATE);
if($res !== TRUE){
echo 'Error: Unable to create zip file';
exit;
}
if(is_file($src)){$zip->addFile($src,substr($src,$path_length));}
else{
if(!is_dir($src)){
$zip->close();
@unlink($zip_fname);
echo 'Error: File not found';
exit;
}
recurse_zip($src,$zip,$path_length);
}
$zip->close();
}
?>
I did not make this.