]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/ApplicationUtils.php
application: move checkPHPVersion from Utils to ApplicationUtils
[github/shaarli/Shaarli.git] / application / ApplicationUtils.php
index 6fb07f36fb3ff828b4ca1e6400fc705818ef93b3..b0e94e24429cedbbd1645773e8d5e5525b5d6ae7 100644 (file)
@@ -5,6 +5,26 @@
 class ApplicationUtils
 {
 
+    /**
+     * Checks the PHP version to ensure Shaarli can run
+     *
+     * @param string $minVersion minimum PHP required version
+     * @param string $curVersion current PHP version (use PHP_VERSION)
+     *
+     * @throws Exception the PHP version is not supported
+     */
+    public static function checkPHPVersion($minVersion, $curVersion)
+    {
+        if (version_compare($curVersion, $minVersion) < 0) {
+            throw new Exception(
+                'Your PHP version is obsolete!'
+                .' Shaarli requires at least PHP '.$minVersion.', and thus cannot run.'
+                .' Your PHP version has known security vulnerabilities and should be'
+                .' updated as soon as possible.'
+            );
+        }
+    }
+
     /**
      * Checks Shaarli has the proper access permissions to its resources
      *