Le samedi 24 juin 2006 à 20:06 +0200, Jacek Caban a écrit :
Hi,
[...]
- We need php script redirecting to SourceForge similar to one that
forwards to Mozilla ActiveX control.
Here you are.
--- /dev/null 2006-01-19 01:09:08.0 +0100
+++ winegecko.php 2006-06-25 11:37:20.0 +0200
@@ -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 h2List 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 \nbr /;
+}
+} else {
+while(!is_downloadable($sUrl)) {
+$iRand = rand(0, (sizeof($aList)-1));
+$sUrl = $aList[$iRand].$sFileName;
+}
+header(Location: .$sUrl);
+}
+?
signature.asc
Description: Ceci est une partie de message numériquement signée