Hello again. I have this backup script to grab files/folders rar them and save them. What i have been tring to do is ignore certain files. ignore test.php within folder.
Thank you
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
function submitform(){
$('#myForm').post("backup.php", $("#myForm").serialize());
}
</script> </head>
<form action="backup.php" method="post" id"myForm">
<input type="hidden" name="txt"/>
<input type="submit" value="Backup" />
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$directory = '../data';
// the name of your zip archive to be created
$zipfile = 'backup.rar';
$filenames = array();
// function that browse the directory and all subdirectories inside
function browse($dir) {
global $filenames;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir.'/'.$file)) {
$filenames[] = $dir.'/'.$file;
}
else if ($file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
browse($dir.'/'.$file);
}
}
closedir($handle);
}
return $filenames;
}
browse($directory);
// creating zip archive, adding browsed files
$zip = new ZipArchive();
if ($zip->open($zipfile, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$zipfile>\n");
}
foreach ($filenames as $filename) {
echo "Adding " . $filename . "<br/>";
$zip->addFile($filename,$filename);
}
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "<br/>";
$zip->close();
echo 'Backup Complete. <a href="./backup.rar">Download Backup</a>'. "<br/>";
} else {
}
?>