aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-07-11 01:29:12 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-07-13 13:06:06 +0200
commitd1e2f8e52c931f84c11d4f54f32959710d528182 (patch)
treebe5ad2fcfeb31136e7afca0603a3cd3da3d76b57 /application/Utils.php
parent5b0ebbc5de06b8a0e9679b78b45d0dc755db7986 (diff)
downloadShaarli-d1e2f8e52c931f84c11d4f54f32959710d528182.tar.gz
Shaarli-d1e2f8e52c931f84c11d4f54f32959710d528182.tar.zst
Shaarli-d1e2f8e52c931f84c11d4f54f32959710d528182.zip
PHP: ensure 5.3 compatibility, refactor timezone utilities
Relates to #250 Modifications - supported version - bump required version from 5.1.0 to 5.3.x - update README - add PHP 5.3 to Travis environments - rewrite array declarations: explicitely use array() instead of [] - move checkPHPVersion to application/Utils.php - move timezone functions to application/TimeZone.php - cleanup code - improve test coverage Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 658b97bc..cd4724fa 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -48,7 +48,7 @@ function endsWith($haystack, $needle, $case=true)
48 */ 48 */
49function nl2br_escaped($html) 49function nl2br_escaped($html)
50{ 50{
51 return str_replace('>','&gt;',str_replace('<','&lt;',nl2br($html))); 51 return str_replace('>', '&gt;', str_replace('<', '&lt;', nl2br($html)));
52} 52}
53 53
54/** 54/**
@@ -117,3 +117,24 @@ function generateLocation($referer, $host, $loopTerms = array())
117 117
118 return $final_referer; 118 return $final_referer;
119} 119}
120
121/**
122 * Checks the PHP version to ensure Shaarli can run
123 *
124 * @param string $minVersion minimum PHP required version
125 * @param string $curVersion current PHP version (use PHP_VERSION)
126 *
127 * @throws Exception the PHP version is not supported
128 */
129function checkPHPVersion($minVersion, $curVersion)
130{
131 if (version_compare($curVersion, $minVersion) < 0) {
132 throw new Exception(
133 'Your PHP version is obsolete!'
134 .' Shaarli requires at least PHP '.$minVersion.', and thus cannot run.'
135 .' Your PHP version has known security vulnerabilities and should be'
136 .' updated as soon as possible.'
137 );
138 }
139}
140?>