Esempio n. 1
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkUpdatesSVN(&$out)
 {
     include_once DIR_MODULES . 'saverestore/phpsvnclient.php';
     $url = 'http://majordomo-sl.googlecode.com/svn/';
     $phpsvnclient = new phpsvnclient($url);
     set_time_limit(0);
     //$phpsvnclient->createOrUpdateWorkingCopy('trunk/', ROOT.'saverestore/temp', true);
     $cached_name = ROOT . 'saverestore/svn_tree.txt';
     if (!file_exists($cached_name) || time() - filemtime($cached_name) > 8 * 60 * 60) {
         $directory_tree = $phpsvnclient->getDirectoryTree('/trunk/');
         SaveFile($cached_name, serialize($directory_tree));
     } else {
         $directory_tree = unserialize(LoadFile($cached_name));
     }
     $updated = array();
     $total = count($directory_tree);
     for ($i = 0; $i < $total; $i++) {
         $item = $directory_tree[$i];
         if ($item['type'] != 'file' || $item['path'] == 'trunk/config.php') {
             continue;
         }
         $filename = str_replace('trunk/', ROOT, $item['path']);
         @($fsize = filesize($filename));
         $r_rfsize = $item['size'];
         if ($fsize != $r_rfsize || !file_exists($filename)) {
             $updated[] = $item;
         }
     }
     $out['OK_CHECK'] = 1;
     if (!$updated[0]) {
         $out['NO_UPDATES'] = 1;
     } else {
         foreach ($updated as $item) {
             $item['path'] = str_replace('trunk/', '', $item['path']);
             $out['TO_UPDATE'][] = array('FILE' => $item['path'], 'VERSION' => $item['version'] . ' (' . $item['last-mod'] . ')');
         }
     }
 }
Esempio n. 2
0
function dosvn()
{
    global $app_tmppath;
    $svntemppath = $app_tmppath . "svn/";
    $sv = $_SESSION['setup_conf']['svn'];
    $root = $_SESSION['setup_conf']['conf']['app_root'];
    if (count($sv) > 0) {
        //deldir($svntemppath);
        foreach ($sv as $v => $s) {
            $temppath = $svntemppath . "{$v}/";
            msg('正在从' . $s['SVN_URL'] . '上下载文件,请耐心等待……<br>');
            $svn = new phpsvnclient($s['SVN_URL'], $s['SVN_USER'], $s['SVN_PWD']);
            $files = $svn->getDirectoryTree($s['SVN_DIR']);
            foreach ($files as $k => $f) {
                if ($f['type'] == 'file') {
                    $content = $svn->getFile($f['path']);
                    $file = str_replace($s['SVN_DIR'], $temppath, $f['path']);
                    write_file($file, $content);
                }
            }
        }
        foreach ($sv as $v => $s) {
            $temppath = $svntemppath . "{$v}/";
            copydir($temppath, $root . $s['DIR_PATH']);
        }
    }
    remark_setup(1);
    echo "<script language='JavaScript'>top.godourl(4);</script>";
}