Files and Directories
|
|
|
|
<?php /*
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' File: xcopy.php
' Description: Xcopy in PHP (For Taking Backup of your Web site)
' Written by: Imran Khalid imranlink@hotmail.com
' Date Written: June 14, 2004
' Platform: Windows 2000 / IIS / PHP
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
*/
$dirPathSource = "c:/inetpub/wwwroot/mysite/home/"; // change to your Web Home Directory.
$dirPathTarget = "c:/inetpub/wwwroot/mysite/backup/"; // edit the root path according to your target Directory.
xcopy($dirPathSource,$dirPathTarget);
function xcopy($dirPathSource,$dirPathTarget)
{
if ($handle = @opendir($dirPathSource))
{
while (false !== ($dir = readdir($handle)))
{
if ($dir != '.' && $dir != '..')
{
$pos = strpos ( $dirPathSource, "/");
$newdir = substr($dirPathSource, $pos);
$pos = strpos ( $newdir, "/");
$newdir = substr($newdir, $pos+1);
$pos = strpos ( $newdir, "/");
$fromDir = $dirPathSource . $dir;
$toDir = $dirPathTarget . $dir;
if (is_dir($fromDir))
{
$mkSuccess = mkdir($toDir);
xcopy($fromDir . '/', $toDir . '/');
}
else
{
copy($fromDir,$toDir);
echo "rn<br><br> From: $fromDir rn<br> TO: $toDir";
}
} // if not . .. close
} // while close
closedir($handle);
} // if handle close } //////////////////////////////////////////////////////////////////////////////////////////////// ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|