tools/. winegecko.php
Jeremy Newman
jnewman at wine.codeweavers.com
Wed Jun 28 15:43:37 CDT 2006
ChangeSet ID: 26109
CVSROOT: /opt/cvs-commit
Module name: tools
Changes by: jnewman at winehq.org 2006/06/28 15:43:37
Added files:
. : winegecko.php
Log message:
Jonathan Ernst <jonathan at ernstfamily.ch>
Gecko installer redirection script
Patch: http://cvs.winehq.org/patch.py?id=26109
Old revision New revision Changes Path
Added 1.1 +0 -0 tools/winegecko.php
Index: tools/winegecko.php
diff -u -p /dev/null tools/winegecko.php:1.1
--- /dev/null 28 Jun 2006 20:43:37 -0000
+++ tools/winegecko.php 28 Jun 2006 20:43:37 -0000
@@ -0,0 +1,90 @@
+<?php
+/**
+ * Redirects to one of many URLs that have the Wine Gecko installer available.
+ *
+ * Usage:
+ * winegecko.php
+ * (main usage, redirects to one of many URLs that have the Wine Gecko installer available)
+ *
+ * winegecko.php?action=showlist
+ * (display a list of server and tells if the file is available for each server)
+ *
+ * Copyright (c) 2006 Jonathan Ernst
+ */
+
+
+// Name of the file
+$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/"
+ );
+
+
+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);
+}
+?>
More information about the wine-cvs
mailing list