I am trying to write a PHP Script that when called allows me to backup a database, put the contents into a zipped folder which is saved to the server and also allow the user to download the file. I have all this working fine, there are no problems at all.
My problem comes thou when i try to password protect this zipped folder. I dont want just anybody to be able to download it and use it. I would like to add a passoword to the folder in the php script, but im unsure on how to do this, any suggestions ?
Here is my code
Code: Select all
<?php
ini_set("memory_limit","40M");
$dbhost = "localhost";
$dbuser = "dbname";
$dbpass = "pw";
$dbname = "dbuser";
$backupfile = $dbname . date("Y-m-d") . '.sql';
$backupzip = $backupfile . '.tar.gz';
echo "Backup file created. File name is - " ;
system("mysqldump -h $dbhost -u $dbuser -p$dbpass $dbname > $backupfile");
system("tar -czvf $backupzip $backupfile");
header("Location: $backupzip");
unlink($backupfile);
?>
David