Exemple #1
0
function copy_the_file($from, $to)
{
    debug_no_info();
    global $backup_dir, $log_file;
    $newdir = explode('/', $backup_dir . $to);
    unset($newdir[sizeof($newdir) - 1]);
    make_the_dir($newdir);
    //fputs($log_file,"download ".$from." and save as ".$backup_dir.$to."\n");
    if (!is_file($backup_dir . $to)) {
        if (!@copy($from, $backup_dir . $to)) {
            //echo "bad file $from => $backup_dir$to\n";
        }
    }
}
Exemple #2
0
function read_and_put($dir, &$prefix)
{
    global $backupdir;
    global $server;
    $server = 'maletti';
    if (!isset($prefix)) {
        $prefix = $dir;
    }
    $dir_name = $dir;
    $dir = opendir($dir);
    while ($file = readdir($dir)) {
        if ($file != "." && $file != "..") {
            if (is_file($dir_name . $file)) {
                //unlink($dir_name.$file);
            } else {
                read_and_put($dir_name . $file . "/", $prefix);
            }
        }
    }
    closedir($dir);
    $download_path = "http://" . $server . "/" . substr($dir_name . $file, strlen($prefix)) . "/";
    $txt = file_get_contents($download_path);
    $result = wget($txt, $download_path, "http://maletti");
    $txt = $result->str;
    $download_path = del_from_right($download_path);
    for ($i = 0; $i < sizeof($result->need_name); $i++) {
        //echo "need file ".$result->need_link[$i]." and save it as ".del_from_right($backupdir).$result->need_name[$i]."\n\n";
        $file_mas = explode('/', $result->need_name[$i]);
        unset($file_mas[sizeof($file_mas) - 1]);
        $file_mas = implode('/', $file_mas);
        make_the_dir($file_mas);
        if ($result->need_name[$i] == '/main.css' && !is_file(del_from_right($backupdir) . $result->need_name[$i])) {
            echo "\nMAINCSS\n";
            echo "\n ==> " . $download_path . " <==\n";
            $css_text = file_get_contents($result->need_link[$i]);
            //$css_result=wget($css_text,$result->need_link[$i],"http://maletti");
            $css_result = go_inside_www($css_text, $result->need_link[$i], "http://maletti", 'background-image: url');
            //echo $css_result->str;
            $css_file = fopen(del_from_right($backupdir) . $result->need_name[$i], "w");
            fputs($css_file, $css_result->str);
            fclose($css_file);
        } else {
            copy($result->need_link[$i], del_from_right($backupdir) . $result->need_name[$i]);
        }
        //echo(is_file($del_from_right($backupdir).$result->need_name[$i]));
        //if(substr($result->need_name[$i],0,1)=='/'){$result->need_name[$i]=substr($result->need_name[$i],1);};
        //};
        //make_the_dir();
        //if(($result->need_name[$i]=='/main.css')&&(!is_file(del_from_right($backupdir).$result->need_name[$i]))){
        //	echo "\nMAINCSS\n";
        //}
    }
    $newfile = fopen($dir_name . $file . "/index.html", "w");
    fputs($newfile, $txt);
    fclose($newfile);
}