diff options
author | Andrew Dolgov <[email protected]> | 2019-12-20 18:05:55 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-12-20 18:05:55 +0300 |
commit | 4b44103b849912714e2f044b62d158c8188f3a81 (patch) | |
tree | 2e7bf0ef01a34f4c89ddcf8db052a813ec57c55a /include | |
parent | 573784c316c44280fef319117720479c3dc052ed (diff) | |
parent | 63ee91c82e3fa17f5ade147aff8d319104b9e52e (diff) |
Merge branch 'master' of git.fakecake.org:tt-rss into weblate-integration
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.php | 54 | ||||
-rw-r--r-- | include/sessions.php | 1 | ||||
-rw-r--r-- | include/version.php | 36 |
3 files changed, 52 insertions, 39 deletions
diff --git a/include/functions.php b/include/functions.php index 9cd352833..f244b47b8 100644 --- a/include/functions.php +++ b/include/functions.php @@ -27,6 +27,9 @@ error_reporting(E_ALL & ~E_NOTICE); } + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + require_once 'config.php'; /** @@ -151,10 +154,9 @@ } require_once 'db-prefs.php'; - require_once 'version.php'; require_once 'controls.php'; - define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)'); + define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)'); ini_set('user_agent', SELF_USER_AGENT); $schema_version = false; @@ -1882,3 +1884,51 @@ return $ts; } + + /* for package maintainers who don't use git: if version_static.txt exists in tt-rss root + directory, its contents are displayed instead of git commit-based version, this could be generated + based on source git tree commit used when creating the package */ + + function get_version(&$git_commit = false, &$git_timestamp = false) { + global $ttrss_version; + + if (isset($ttrss_version)) + return $ttrss_version; + + $ttrss_version = "UNKNOWN (Unsupported)"; + + date_default_timezone_set('UTC'); + $root_dir = dirname(dirname(__FILE__)); + + if ('\\' === DIRECTORY_SEPARATOR) { + $ttrss_version = "UNKNOWN (Unsupported, Windows)"; + } else if (PHP_OS === "Darwin") { + $ttrss_version = "UNKNOWN (Unsupported, Darwin)"; + } else if (file_exists("$root_dir/version_static.txt")) { + $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; + } else if (is_dir("$root_dir/.git")) { + $rc = 0; + $output = []; + + $cwd = getcwd(); + + chdir($root_dir); + exec('git log --pretty='.escapeshellarg('%ct %h').' -n1 HEAD 2>&1', $output, $rc); + chdir($cwd); + + if ($rc == 0) { + if (is_array($output) && count($output) > 0) { + list ($timestamp, $commit) = explode(" ", $output[0], 2); + + $git_commit = $commit; + $git_timestamp = $timestamp; + + $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit"; + } + } else { + user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING); + } + } + + return $ttrss_version; + } diff --git a/include/sessions.php b/include/sessions.php index ca9f169d8..73be1e403 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -7,7 +7,6 @@ require_once "errorhandler.php"; require_once "lib/accept-to-gettext.php"; require_once "lib/gettext/gettext.inc"; - require_once "version.php"; $session_expire = min(2147483647 - time() - 1, max(SESSION_COOKIE_LIFETIME, 86400)); $session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME; diff --git a/include/version.php b/include/version.php deleted file mode 100644 index d1c5e03b5..000000000 --- a/include/version.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - - /* for package maintainers who don't use git: if version_static.txt exists in tt-rss root - directory, its contents are displayed instead of git commit-based version, this could be generated - based on source git tree commit used when creating the package */ - - function get_version(&$git_commit = false, &$git_timestamp = false) { - $version = "UNKNOWN (Unsupported)"; - - date_default_timezone_set('UTC'); - $root_dir = dirname(dirname(__FILE__)); - - if (file_exists("$root_dir/version_static.txt")) { - $version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; - } else if (is_dir("$root_dir/.git")) { - $rc = 0; - $output = []; - - exec("git log --pretty='%ct %h' -n1 HEAD " . escapeshellarg($root_dir), $output, $rc); - - if ($rc == 0) { - if (is_array($output) && count($output) > 0) { - list ($timestamp, $commit) = explode(" ", $output[0], 2); - - $git_commit = $commit; - $git_timestamp = $timestamp; - - $version = strftime("%y.%m", $timestamp) . "-$commit"; - } - } - } - - return $version; - } - - define('VERSION', get_version()); |