-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
49 lines (36 loc) · 1.23 KB
/
index.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
41
42
43
44
45
46
47
48
49
<?php
// Return a $_GET param, $default if it's not existing.
function param($key, $default = false) {
if (isset($_GET[$key])) {
return htmlspecialchars($_GET[$key], ENT_COMPAT, 'UTF-8');
} else {
return $default;
}
}
// We return a simple text file (script).
header('Content-Type: text/plain; charset=utf-8');
$versions = require('versions.php');
$version = param('v', false);
// No version specified! You must do it with thê $_GET['v'] param.
if ($version === false) {
echo 'NO_VERSION_SPECIFIED';
return;
}
// Version specified is not in the versions array, so it is not supported!
if (!array_key_exists($version, $versions)) {
echo 'INVALID_VERSION ' . $version;
return;
}
$update_version = $versions[$version];
$filename_update = 'scripts/update_to_' . $update_version . '.php';
// Current version have no update because not specified or script doesn't exist.
if (is_null($update_version) || !file_exists($filename_update)) {
echo 'NO_UPDATE ' . $version;
return;
}
$content_util = file_get_contents('scripts/update_util.php');
$content = file_get_contents($filename_update);
// First line gives the version number, others correspond to the script.
echo 'UPDATE ' . $update_version . "\n";
echo $content_util;
echo $content;