<?php
$fn=date('d-m-y-H-i-s');
mkdir('\\\192.168.0.3\e$\EMS Scanner Backup\Scanner/'.$fn);

copy_directory('uploads','\\\192.168.0.3\e$\EMS Scanner Backup\Scanner/'.$fn);

function copy_directory($src,$dst) {
    $dir = opendir($src);
    @mkdir($dst);
    while(false !== ( $file = readdir($dir)) ) {
        if (( $file != '.' ) && ( $file != '..' )) {
            if ( is_dir($src . '/' . $file) ) {
                copy_directory($src . '/' . $file,$dst . '/' . $file);
            }
            else {
                copy($src . '/' . $file,$dst . '/' . $file);
            }
        }
    }
    closedir($dir);
}
echo "<h1 style='text-align:center'>Document Backup Done</h1>";
echo "<a href='home'>Back To Home</a>";
?>

<!--set max_execution_time = 2000 -->
