From e88a981a4041b61057045467d47aa6bddee7f8e1 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Thu, 10 Oct 2013 18:06:29 +0000 Subject: [PATCH] Use Sourceforge official downloads system --- index.php | 57 ++++++++++++++++++++++++++++++++++++++-------------- lib/init.php | 2 ++ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/index.php b/index.php index 3efca8c..9feeddb 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,33 @@ error_reporting(E_ALL); define("SITE_ROOT", realpath(dirname(__file__))); require_once SITE_ROOT . "/lib/init.php"; +function get_downloads() +{ + global $DB; + + $ret = array(); + + if (!$res = $DB->query("select file_name from downloads")) return; + + while ($row = $DB->fetchRow($res)) { + $ret[] = $row["file_name"]; + } + + return $ret; +} + +$all_downloads = get_downloads(); + +function download_exists($file_name) +{ + global $all_downloads; + return in_array($file_name, $all_downloads); +} + +function download_link($file_name) +{ + return "http://sourceforge.net/projects/singularityview/files/alphas/{$file_name}/download"; +} function parse_email($email) { @@ -119,30 +146,30 @@ Function print_build($current, $next, $buildNr, $chan) "; if ($current->file) { - print "\"Download Windows   -           Build Log"; + print "\"Download Windows   +           Build Log"; } if ($current->linux_file) { - print "
\"Download Linux (32 bit)"; - if (file_exists($current->linux_file . ".log")) { - print "      Build Log"; + print "
\"Download Linux (32 bit)"; + if (download_exists($current->linux_file . ".log")) { + print "      Build Log"; } } if ($current->linux64_file) { - print "
\"Download Linux (64 bit)"; - if (file_exists($current->linux64_file . ".log")) { - print "      Build Log"; + print "
\"Download Linux (64 bit)"; + if (download_exists($current->linux64_file . ".log")) { + print "      Build Log"; } } if ($current->osx_file) { - print "
\"Download Mac OS X"; - if (file_exists($current->osx_file . ".log")) { - print "            Build Log"; + print "
\"Download Mac OS X"; + if (download_exists($current->osx_file . ".log")) { + print "            Build Log"; } } @@ -205,16 +232,16 @@ if ($res = $DB->query(kl_str_sql("select * from builds_all where chan=!s $where $DB->loadFromDbRow($build, $res, $row); $file = "{$chan}_" . str_replace(".", "-", $build->version) . "_Setup.exe"; - $build->file = file_exists($file) ? $file : false; + $build->file = download_exists($file) ? $file : false; $linux_file = "{$chan}-i686-{$build->version}.tar.bz2"; - $build->linux_file = file_exists($linux_file) ? $linux_file : false; + $build->linux_file = download_exists($linux_file) ? $linux_file : false; $linux64_file = "{$chan}-x86_64-{$build->version}.tar.bz2"; - $build->linux64_file = file_exists($linux64_file) ? $linux64_file : false; + $build->linux64_file = download_exists($linux64_file) ? $linux64_file : false; $osx_file = "{$chan}_" . str_replace(".", "_", $build->version) . ".dmg"; - $build->osx_file = file_exists($osx_file) ? $osx_file : false; + $build->osx_file = download_exists($osx_file) ? $osx_file : false; $builds[] = $build; } diff --git a/lib/init.php b/lib/init.php index 9e56155..d451427 100644 --- a/lib/init.php +++ b/lib/init.php @@ -15,6 +15,8 @@ function __autoload($class) require_once(SITE_ROOT . '/lib/' . $class . '.php'); } +date_default_timezone_set("UTC"); + /* Directory relative to server root * No leading or trailing slash. * Example: http://www.example.com/applications/app1/