rendered paste body<?
// backup the selected directories
// WEBSITE Backup version 1.0
// AB Webservices, Albert
// july 2004
ini_set("max_execution_time",0);
extract($_POST);
// create a backupdir
$path1 = $path."dump";
if (isset($dobackup)) {
$tst=@mkdir($path1,0766);
if ($tst==false) header("location: error.php?error=1");
else @chmod($path1, 0777);
} elseif (file_exists($path1) && !isset($submit)) {
header("location: error.php?error=1");
}
if (!isset($dobackup)) {
$c=0;
$files=array();
do {
// check whether selected
$chk ='select'.$c;
$ddir ='dirs'.$c;
if (!isset($$ddir)) {
break;
}
if ($$chk=='on') {
// get the files in the directory into an array
if ($$ddir=="--Server Root--") {
$dirs0='../';
$ddir = 'dirs0';
}
if ($handle = opendir($$ddir) ) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." ) {
if ($$ddir=="../") {
if (!is_dir($$ddir.$file)) {
$files[]=$$ddir.$file;
}
} else {
$files[]=$$ddir."/".$file;
}
}
}
}
if ($handle!=false) closedir($handle);
}
$c++;
} while(isset($$ddir));
if (count($files)==0) header("location: error.php?error=2");
} else {
// start the timer
$starttime=time();
$c=0;
$files=array();
do {
// recreate array
$ffiles ='bfiles'.$c;
if (!isset($$ffiles)) {
break;
}
$files[]=$$ffiles;
$c++;
} while(isset($$ffiles));
}
?>
<HTML>
<HEAD>
<TITLE>PHP Website Backup Helper :: Backup</TITLE>
<STYLE type="text/css">
BODY {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
}
.textbox {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
background-color: #BDD7F7;
border: 1px solid #000000;
color: #000000;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#F4F4F4">
<CENTER>
<TABLE WIDTH="80%" bgcolor="#8BA5C5" border="0" cellspacing="0">
<TR>
<TD bgcolor="#BDD7F7"><h3><font color="#6699CC">PHP Website Backup :: Backup</font></h3></TD>
</TR>
<?
if (!isset($dobackup)) {
echo "
<TR>
<TD valign='top'>
<ul>
<li>
<div align='left'><font color='#66FFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'>
Pear.php must be available.<br>
The following files have been selected and will be backed up now.<br>
This process can take a long time, so be patient.
</font></div>
</li>
</ul>
</TD></TR>";
}
?>
<TR><TD>
<ul>
<li>
<?
if (!isset($dobackup)) {
sort($files);reset($files);
clearstatcache();
for ($c=0; $c<count($files); $c++) {
echo "<font size=1>".($c+1)."</font> $nbsp";
if (is_dir($files[$c])) {
echo "<font color=#66EEEE>«subdir»</font>";
}
echo $files[$c]."<br>";
}
} else {
echo "Total number of backup files: ".count($files);
}
?>
</li>
</ul>
</TD></TR>
<TR><TD align=center>
<Form name="startbackup" METHOD="post" ACTION="backup.php" style="display:inline">
<?
if (!isset($dobackup)) {
for ($c=0; $c<count($files); $c++) {
echo '<input type="hidden" name="bfiles' .$c. '" value="'.$files[$c].'">';
}
echo '<input type="hidden" name="path" value="'.$path.'">';
echo '<input type="submit" name="dobackup" value="Start Backup" class="textbox">';
}
?>
</Form>
</TD></TR>
<?
if (isset($dobackup)) {
// here we go
// include class
require("Tar.php");
// create Archive_Tar() object
// specify filename for output file and compression method
$filename1=date("d-m-Y_h_i").".tar.gz";
$filename=$path."dump/backup_".$filename1;
echo "
<TR><TD>
<ul>
<li>
Backup file: backup_$filename1
</li>
</ul>
</TD></TR>";
$tar = new Archive_Tar($filename, "gz");
// set up file list... done above
// build archive
$tar->create($files) or die("Could not create archive!");
echo "
<TR><TD>
<ul>
<li><font color=red>";
$endtime=time();
$mins=floor((time()-$starttime)/60);
$mins2=round((time()-$starttime)/60,2);
$sec =($mins2-$mins)*60;
echo "
Backup File has been created!</font><br>
In directory: ".$path."dump<br>
</li></ul><ul><li>
File size: ".round((filesize($filename)/1024),1)." kB.
Time used: ";
if ($mins>0) {
echo $mins. " minutes and ";
}
echo $sec." seconds.";
echo "
</li>
</ul>
</TD></TR>";
// done!
}
?>
<tr><td align=left>
<br><font size=1> <a href="websitebackup.php">Return to Main</a>.<br><br>
</td.</tr>
<TR><TD bgcolor="#FFFFFF" align=right>
<font color="#6699CC" face="Arial, Helvetica, sans-serif" style="font-size:6Pt">
Php Website Backup Version 1.1 © 2004 by <a href="http://www.absoft-my.com" target="_blank">AB
Webservices</a></font> </TD>
</TR>
</TABLE>