ChangeSet ID: 30233 CVSROOT: /opt/cvs-commit Module name: tools Changes by: jnewman@winehq.org 2006/12/01 10:33:57
Modified files: . : mozactivex.php winegecko.php
Log message: Jonathan Ernst jonathan@ernstfamily.ch - refactor Wine downloader scripts
Patch: http://cvs.winehq.org/patch.py?id=30233
Old revision New revision Changes Path 1.2 1.3 +5 -61 tools/mozactivex.php 1.1 1.2 +4 -67 tools/winegecko.php
Index: tools/mozactivex.php diff -u -p tools/mozactivex.php:1.2 tools/mozactivex.php:1.3 --- tools/mozactivex.php:1.2 1 Dec 2006 16:33:57 -0000 +++ tools/mozactivex.php 1 Dec 2006 16:33:57 -0000 @@ -9,7 +9,7 @@ * mozactivex.php?action=showlist * (display a list of server and tells if the file is available for each server) * - * Copyright (c) 2005 Jonathan Ernst + * Copyright (c) 2005-2006 Jonathan Ernst */
@@ -19,65 +19,9 @@ $sFileName = "MozillaControl1712-ReactOS // Exact size of the file: $iFileSize = 4735160;
-// List of locations -$aList = array("http://switch.dl.sourceforge.net/sourceforge/reactos/", - "http://surfnet.dl.sourceforge.net/sourceforge/reactos/", - "http://citkit.dl.sourceforge.net/sourceforge/reactos/", - "http://keihanna.dl.sourceforge.net/sourceforge/reactos/", - "http://heanet.dl.sourceforge.net/sourceforge/reactos/", - "http://easynews.dl.sourceforge.net/sourceforge/reactos/", - "http://ovh.dl.sourceforge.net/sourceforge/reactos/", - "http://jaist.dl.sourceforge.net/sourceforge/reactos/", - "http://puzzle.dl.sourceforge.net/sourceforge/reactos/", - "http://nchc.dl.sourceforge.net/sourceforge/reactos/", - "http://switch.dl.sourceforge.net/sourceforge/reactos/", - "http://kent.dl.sourceforge.net/sourceforge/reactos/", - "http://optusnet.dl.sourceforge.net/sourceforge/reactos/", - "http://mesh.dl.sourceforge.net/sourceforge/reactos/", - "http://internap.dl.sourceforge.net/sourceforge/reactos/" - ); +// List of additional locations (commonly used locations are already in download.inc.php) +$aList = array();
- -function is_downloadable($sUrl){ - global $iFileSize; - $parse = parse_url($sUrl); - // open a socket connection - if($fp = @fsockopen($parse['host'], 80, $errno, $errstr, 10)){ - // set request - $get = "HEAD ".$parse['path']." HTTP/1.1\r\n". - "Host: ".$parse['host']."\r\n". - "Connection: close\r\n\r\n"; - fputs($fp, $get); - while(!feof($fp)){ - // get ONLY header informations - $header .= fgets($fp, 128); - } - fclose($fp); - // match file size - preg_match('/Content-Length:\s([0-9].+?)\s/', $header, $matches); - $iSize = intval($matches[1]); - if($iSize == $iFileSize) return TRUE; - } - return FALSE; -} - - -if($_REQUEST['action']=="showlist") { - echo "<h2>List of mirrors available for file ".$sFileName." (".$iFileSize." bytes)</h2>"; - foreach($aList as $sLocation) { - echo $sLocation.": "; - if(is_downloadable($sLocation.$sFileName)) { - echo "<font color="green">online</font>"; - } else { - echo "<font color="red">offline</font>"; - } - echo "\n<br />"; - } -} else { - while(!is_downloadable($sUrl)) { - $iRand = rand(0, (sizeof($aList)-1)); - $sUrl = $aList[$iRand].$sFileName; - } - header("Location: ".$sUrl); -} +// Common code for Wine downloader scripts +require("download.inc.php"); ?> Index: tools/winegecko.php diff -u -p tools/winegecko.php:1.1 tools/winegecko.php:1.2 --- tools/winegecko.php:1.1 1 Dec 2006 16:33:57 -0000 +++ tools/winegecko.php 1 Dec 2006 16:33:57 -0000 @@ -19,72 +19,9 @@ $sFileName = "wine_gecko.cab"; // Exact size of the file: $iFileSize = 5219822;
-// List of locations -$aList = array("http://switch.dl.sourceforge.net/sourceforge/wine/", - "http://surfnet.dl.sourceforge.net/sourceforge/wine/", - "http://citkit.dl.sourceforge.net/sourceforge/wine/", - "http://keihanna.dl.sourceforge.net/sourceforge/wine/", - "http://heanet.dl.sourceforge.net/sourceforge/wine/", - "http://easynews.dl.sourceforge.net/sourceforge/wine/", - "http://ovh.dl.sourceforge.net/sourceforge/wine/", - "http://jaist.dl.sourceforge.net/sourceforge/wine/", - "http://puzzle.dl.sourceforge.net/sourceforge/wine/", - "http://nchc.dl.sourceforge.net/sourceforge/wine/", - "http://switch.dl.sourceforge.net/sourceforge/wine/", - "http://kent.dl.sourceforge.net/sourceforge/wine/", - "http://optusnet.dl.sourceforge.net/sourceforge/wine/", - "http://mesh.dl.sourceforge.net/sourceforge/wine/", - "http://internap.dl.sourceforge.net/sourceforge/wine/", - "http://superb-east.dl.sourceforge.net/sourceforge/wine/", - "http://optusnet.dl.sourceforge.net/sourceforge/wine/", - "http://superb-west.dl.sourceforge.net/sourceforge/wine/", - "http://nchc.dl.sourceforge.net/sourceforge/wine/", - "http://umn.dl.sourceforge.net/sourceforge/wine/", - "http://belnet.dl.sourceforge.net/sourceforge/wine/", - "http://ufpr.dl.sourceforge.net/sourceforge/wine/" - ); +// List of additional locations (commonly used locations are already in download.inc.php) +$aList = array();
- -function is_downloadable($sUrl){ - global $iFileSize; - $parse = parse_url($sUrl); - // open a socket connection - if($fp = @fsockopen($parse['host'], 80, $errno, $errstr, 10)){ - // set request - $get = "HEAD ".$parse['path']." HTTP/1.1\r\n". - "Host: ".$parse['host']."\r\n". - "Connection: close\r\n\r\n"; - fputs($fp, $get); - while(!feof($fp)){ - // get ONLY header informations - $header .= fgets($fp, 128); - } - fclose($fp); - // match file size - preg_match('/Content-Length:\s([0-9].+?)\s/', $header, $matches); - $iSize = intval($matches[1]); - if($iSize == $iFileSize) return TRUE; - } - return FALSE; -} - - -if($_REQUEST['action']=="showlist") { - echo "<h2>List of mirrors available for file ".$sFileName." (".$iFileSize." bytes)</h2>"; - foreach($aList as $sLocation) { - echo $sLocation.": "; - if(is_downloadable($sLocation.$sFileName)) { - echo "<font color="green">online</font>"; - } else { - echo "<font color="red">offline</font>"; - } - echo "\n<br />"; - } -} else { - while(!is_downloadable($sUrl)) { - $iRand = rand(0, (sizeof($aList)-1)); - $sUrl = $aList[$iRand].$sFileName; - } - header("Location: ".$sUrl); -} +// Common code for Wine downloader scripts +require("download.inc.php"); ?>