Repository is temporary not responding. Try again later."); fwrite($handle, emergency_html()); fclose($handle); readfile($cacheFile); return; } $items = publish_rss20($repository, $contents, $rss); $handle = fopen($cacheFile, "w+"); for($i = 0; $i < count($items) && $i < 3; $i++) { fwrite($handle, $items[count($items) - $i - 1]["html_description"]); } if (count($items) == 0) { fwrite($handle, "repository is temporary not responding. try again later."); } fclose($handle); readfile($cacheFile); } function publish_rss20($repository, $contents, $rss) { if (preg_match_all("/
  • (.*\..*\..*)(<\/a>)<\/li>/", $contents, $matches)) { $items = array(); $index = 0; for($i = 0; $i < count($matches[1]); $i++) { $build = $matches[1][$i]; $changelog_url = $repository . $build . "/changelog.txt"; $test_url = $repository . $build . "/tests.log"; $test_results_xml_url = $repository . $build . "/svnkit-test/python-tests-log.xml"; $changelog = read_contents($changelog_url); if (!$changelog) { continue; } $standalone_name = "org.tmatesoft.svn_" . $build . ".standalone.zip"; $eclipse_name = "org.tmatesoft.svn_" . $build . ".eclipse.zip"; $src_name = "org.tmatesoft.svn_" . $build . ".src.zip"; $standalone_file = $_SERVER["DOCUMENT_ROOT"] . "/" . $standalone_name; if (!file_exists($standalone_file)) { continue; } $svn_url = $repository . $build . "/"; $standalone_link = $rss . $standalone_name; $src_url = $rss . $src_name; $eclipse_url = $rss . $eclipse_name; $eclipse_update_url = $rss; ereg("^=[^\n]+\n([^=]+).*$", $changelog, $m); $changelog_str = trim($m[1]); $date_string = date("j M Y, H:i", filemtime($standalone_file)); $item_description = "" . $date_string . ", version: " . $build . "

    "; $item_description .= ""; $item_description .= ""; $item_description .= ""; $item_description .= ""; $item_description .= "
    standalone version: " . $standalone_name . "
    source code archive: " . $src_name . "
    source code: @svn repository
    eclipse update site archive: " . $eclipse_name . "
    eclipse update site location: " . $eclipse_update_url . "

    "; $item_description .= "
    ChangeLog
    " . $changelog_str . "
    "; $item_description .= "
    full changelog up to this build"; $item_description .= "tests results"; $item_description .= "
    Contact

    Your questions and feedback are welcome at support@svnkit.com

    "; $html_description = " " . $date_string . ", version " . $build . ""; $html_description .= " Changelog:"; $html_description .= "
    " . $changelog_str . "
    "; $python_tests_url = "/download/test-results.php?fileurl=" . $test_results_xml_url . "&build=" . $build; $html_description .= "full changelog up to this build  tests results"; $html_description .= " Standalone Version " . $standalone_name . ""; $html_description .= " Source Code Archive " . $src_name . " "; $html_description .= " Eclipse Update Site Archive " . $eclipse_name . ""; $html_description .= " Eclipse Update Site Location " . $eclipse_update_url . ""; $html_description .= " Source Code @svn repository"; $item = array(); $item["title"] = "Build '" . $build . "' published"; $item["source"] = "http://svnkit.com/"; $item["link"] = "http://svnkit.com/"; $item["author"] = "TMate Software"; $item["date"] = filemtime($standalone_file); $item["rss_description"] = $item_description; $item["html_description"] = $html_description; $items[$index++] = $item; } } return $items; } function read_contents($url) { $fp = fsockopen("svn.svnkit.com", 8080, $errno, $errstr, 1); if (!$fp) { return false; } fclose($fp); $handle = fopen($url, "rb"); if (!$handle) { return false; } $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); return $contents; } function emergency_html() { // Open a known directory, and proceed to read its contents $dir = $_SERVER["DOCUMENT_ROOT"] . "/"; $result = ""; if (is_dir($dir)) { if ($dh = opendir($dir)) { $entries = array(); $index = 0; while (($file = readdir($dh)) !== false) { $matches = array(); ereg("^.+_([0-9]+)\.standalone\.zip$", $file, $matches); if (count($matches) > 1) { $entries[$index++] = $matches[1]; } } closedir($dh); sort($entries); if (count($entries) > 0) { $result = $entries[count($entries) - 1]; $result = "Latest binary version is org.tmatesoft.svn_" . $result .".standalone.zip"; } } } return $result; } ?>