version.php 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. define('VERSION_STATIC', '17.4');
  3. function get_version() {
  4. date_default_timezone_set('UTC');
  5. $root_dir = dirname(dirname(__FILE__));
  6. if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/HEAD")) {
  7. $head = trim(file_get_contents("$root_dir/.git/HEAD"));
  8. if ($head) {
  9. $matches = array();
  10. if (preg_match("/^ref: (.*)/", $head, $matches)) {
  11. $ref = $matches[1];
  12. $suffix = substr(trim(file_get_contents("$root_dir/.git/$ref")), 0, 7);
  13. $timestamp = filemtime("$root_dir/.git/$ref");
  14. define("GIT_VERSION_HEAD", $suffix);
  15. define("GIT_VERSION_TIMESTAMP", $timestamp);
  16. return VERSION_STATIC . " ($suffix)";
  17. } else {
  18. $suffix = substr(trim($head), 0, 7);
  19. $timestamp = filemtime("$root_dir/.git/HEAD");
  20. define("GIT_VERSION_HEAD", $suffix);
  21. define("GIT_VERSION_TIMESTAMP", $timestamp);
  22. return VERSION_STATIC . " ($suffix)";
  23. }
  24. }
  25. }
  26. return VERSION_STATIC;
  27. }
  28. define('VERSION', get_version());