Ejemplo n.º 1
0
     $dest = SERVDIR . '/' . $file;
     if (is_writable(SERVDIR . '/' . $file) || !file_exists(SERVDIR . '/' . $file)) {
         // Make Folder
         $path = explode('/', $file);
         $upth = SERVDIR;
         foreach ($path as $f => $d) {
             $upth .= '/' . $d;
             if (strpos($d, '.') !== false) {
                 continue;
             }
             if (!is_dir($upth)) {
                 $upfail += mkdir($upth);
             }
         }
         // Write File
         $dn = cwget('https://raw.github.com/CuteNews/cute-news-repo/master/CuteNews/' . $file);
         if ($dn) {
             $w = fopen($dest, 'w');
             fwrite($w, $dn);
             fclose($w);
         } else {
             $upfail++;
         }
     } else {
         $upfail++;
     }
 }
 $end = time();
 if (file_exists($update_file)) {
     unlink($update_file);
 }
Ejemplo n.º 2
0
 if ($stat) {
     $rev = explode("\n", $statext);
     list(, $revid) = explode('=', array_shift($rev));
     // check files
     if (!function_exists('md5')) {
         create_html_template("Function `md5_file` not found: update php version'");
     }
     $hashes = array();
     foreach ($rev as $files) {
         if (empty($files)) {
             continue;
         }
         list($hash_rec, $file) = explode('|', $files, 2);
         $hashes[$file] = $hash_rec;
     }
     $dn = cwget('https://github.com/CuteNews/cute-news-repo/archive/master.zip');
     if ($dn) {
         $w = fopen($update_file_source, 'w');
         if (!$w) {
             create_html_template('Cannot upload the update file ' . $update_file_source);
         }
         if (!fwrite($w, $dn)) {
             create_html_template('Cannot write the update file ' . $update_file_source);
         }
         fclose($w);
     } else {
         create_html_template('Cannot download the update file: https://github.com/CuteNews/cute-news-repo/archive/master.zip');
     }
     $zipfile = new zipfile();
     $zipfile->read_zip($update_file_source);
     foreach ($zipfile->files as $filea) {