forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownload_beta.php
40 lines (34 loc) · 1.44 KB
/
download_beta.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?
function is_available($url, $timeout = 30) {
$ch = curl_init(); // get cURL handle
// set cURL options
$opts = array(CURLOPT_RETURNTRANSFER => true, // do not output to browser
CURLOPT_URL => $url, // set URL
CURLOPT_NOBODY => false, // do a HEAD request only
CURLOPT_TIMEOUT => $timeout); // set timeout
curl_setopt_array($ch, $opts);
curl_exec($ch); // do it!
$test = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$retval = $test == 200; // check if HTTP OK
curl_close($ch); // close handle
return $retval;
}
if (!$platform) $platform = "win";
$version = trim(file_get_contents("REALRELEASE_BETA$platform"));
$new = trim(file_get_contents("FRESHRELEASE_BETA"));
if ($version != $new) {
if ($platform == "win") $filename = "simc-$new-win32.zip";
else if ($platform == "mac") $filename = "simc-$new-osx-x86.dmg";
if (is_available("http://simulationcraft.googlecode.com/files/$filename")) {
copy("FRESHRELEASE_BETA", "REALRELEASE_BETA$platform");
$version = $new;
}
}
if ($platform == "win") $filename = "simc-$version-win32.zip";
else if ($platform == "mac") $filename = "simc-$version-osx-x86.dmg";
else {
header("HTTP/1.0 404 Not Found");
exit;
}
header("Location: http://simulationcraft.googlecode.com/files/$filename");
?>