]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | define('VERSION_STATIC', '18.8'); | |
3 | ||
4 | function get_version() { | |
5 | date_default_timezone_set('UTC'); | |
6 | $root_dir = dirname(dirname(__FILE__)); | |
7 | ||
8 | if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/HEAD")) { | |
9 | $head = trim(file_get_contents("$root_dir/.git/HEAD")); | |
10 | ||
11 | if ($head) { | |
12 | $matches = array(); | |
13 | ||
14 | if (preg_match("/^ref: (.*)/", $head, $matches)) { | |
15 | $ref = $matches[1]; | |
16 | ||
17 | if (!file_exists("$root_dir/.git/$ref")) | |
18 | return VERSION_STATIC; | |
19 | $suffix = substr(trim(file_get_contents("$root_dir/.git/$ref")), 0, 7); | |
20 | $timestamp = filemtime("$root_dir/.git/$ref"); | |
21 | ||
22 | define("GIT_VERSION_HEAD", $suffix); | |
23 | define("GIT_VERSION_TIMESTAMP", $timestamp); | |
24 | ||
25 | return VERSION_STATIC . " ($suffix)"; | |
26 | ||
27 | } else { | |
28 | $suffix = substr(trim($head), 0, 7); | |
29 | $timestamp = filemtime("$root_dir/.git/HEAD"); | |
30 | ||
31 | define("GIT_VERSION_HEAD", $suffix); | |
32 | define("GIT_VERSION_TIMESTAMP", $timestamp); | |
33 | ||
34 | return VERSION_STATIC . " ($suffix)"; | |
35 | } | |
36 | } | |
37 | } | |
38 | ||
39 | return VERSION_STATIC; | |
40 | ||
41 | } | |
42 | ||
43 | define('VERSION', get_version()); |