/** * 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'] . ')'); } } }
<?php $dir = dirname(__FILE__); require $_SERVER['DOCUMENT_ROOT'] . '/phpsvnclient/phpsvnclient.php'; $sources = array(); $dom = extractElements($dir . '/config.xml', $sources); foreach ($sources['SOURCE'] as $source) { $user = $source->hasAttribute('user') ? $source->getAttribute('user') : NULL; $pass = $source->hasAttribute('pass') ? $source->getAttribute('pass') : NULL; $phpsvnclient = new phpsvnclient($source->getAttribute('url'), $user, $password); for ($i = 0; $i < $source->childNodes->length; ++$i) { if ($source->childNodes->item($i)->nodeType == 1) { $dir = $source->childNodes->item($i); $phpsvnclient->checkOut($dir->getAttribute('remote'), $dir->getAttribute('local')); } } }
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>"; }
* svn_wordpress.php * * Gets WordPress via SVN. * * Usage: Call svn_wordpress.php, enter repository URL and local installation path. * Check version and revision & click yes to checkout from repoository. * * @author Kevin Schmitt */ require_once 'phpsvnclient.php'; $svn_memory_limit = '128M'; $wp_repository = 'http://core.svn.wordpress.org/'; $wp_version = '3.0.1'; $wp_revision = ''; $wp_local_dir = $_SERVER['DOCUMENT_ROOT'] . '/wordpress'; $svn = new phpsvnclient($wp_repository); $wp_revision_latest = $svn->getVersion(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>parched-art</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="de-de" /> <meta http-equiv="author" content="Kevin Schmitt" /> <meta name="language" content="de-de" /> <meta name="robots" content="noindex,nofollow" />
$UserSettings->set('svn_upgrade_user', $svn_user); $UserSettings->set('svn_upgrade_revision', $svn_revision); $UserSettings->dbupdate(); $success = param_check_not_empty('svn_url', T_('Please enter the URL of repository')); $success = $success && param_check_regexp('svn_folder', '#/blogs/$#', T_('A correct SVN folder path must ends with "/blogs/')); if (!$success) { $action = 'start'; break; } $success = prepare_maintenance_dir($upgrade_path, true); if ($success) { // Set maximum execution time set_max_execution_time(2400); // 60 minutes load_class('_ext/phpsvnclient/phpsvnclient.php', 'phpsvnclient'); $phpsvnclient = new phpsvnclient($svn_url, $svn_user, $svn_password); // Get an error if it was during connecting to svn server $svn_error = $phpsvnclient->getError(); if (!empty($svn_error) || $phpsvnclient->getVersion() < 1) { // Some errors or Incorrect version echo '<p class="red">' . T_('Unable to get a repository version, probably URL of repository is incorrect.') . '</p>'; evo_flush(); $action = 'start'; break; // Stop an upgrade from SVN } if ($svn_revision > 0) { // Set revision from request if ($phpsvnclient->getVersion() < $svn_revision) { // Incorrect revision number echo '<p class="red">' . sprintf(T_('Please select a correct revision number. The latest revision is %s.'), $phpsvnclient->getVersion()) . '</p>';
<?php define('BILD_VERSION', file_get_contents(BASE_DIR . '/inc/current_revision.txt')); if (SVN_ACTIVE == true) { include_once "phpsvnclient.php"; $svn = new phpsvnclient(SVN_URL); $svn->setAuth(SVN_LOGIN, SVN_PASSWORD); $last_rev = $svn->getVersion(); if ($last_rev > BILD_VERSION) { $log_svn = $svn->getRepositoryLogs("", (int) BILD_VERSION + 1, $last_rev); $AVE_Template->assign('log_svn', $log_svn); $AVE_Template->assign('svn_link', SVN_LINK); $AVE_Template->assign('svn_url', SVN_URL); } }