diff --git a/src/common.php b/src/common.php index e066fee..78b26db 100644 --- a/src/common.php +++ b/src/common.php @@ -2,7 +2,7 @@ /* This file is part of myTinyTodo. - (C) Copyright 2009-2010 Max Pozdeev + (C) Copyright 2009-2010,2020 Max Pozdeev Licensed under the GNU GPL v2 license. See file COPYRIGHT for details. */ @@ -32,14 +32,26 @@ function htmlarray_ref(&$a, $exclude=null) function stop_gpc(&$arr) { - if (!is_array($arr)) return 1; + if (!is_array($arr)) { + return 1; + } + + // Since PHP v5.4.0 magic quotes feature was removed from PHP + // In PHP v7.4 get_magic_quotes_gpc is deprecated + // TODO: do not use get_magic_quotes_gpc() and stop_gpc() + if (!@get_magic_quotes_gpc()) { + return 1; + } - if (!get_magic_quotes_gpc()) return 1; reset($arr); - foreach($arr as $k=>$v) + foreach ($arr as $k=>$v) { - if(is_array($arr[$k])) stop_gpc($arr[$k]); - elseif(is_string($arr[$k])) $arr[$k] = stripslashes($v); + if (is_array($arr[$k])) { + stop_gpc($arr[$k]); + } + elseif (is_string($arr[$k])) { + $arr[$k] = stripslashes($v); + } } return 1; diff --git a/src/init.php b/src/init.php index 550f46a..98ded63 100644 --- a/src/init.php +++ b/src/init.php @@ -1,10 +1,15 @@ + (C) Copyright 2009-2010,2020 Max Pozdeev Licensed under the GNU GPL v2 license. See file COPYRIGHT for details. */ +##### MyTinyTodo requires php 5.4.0 and above! ##### +if (version_compare(PHP_VERSION, '5.4.0') < 0) { + die("PHP 5.4+ is required"); +} + if(!defined('MTTPATH')) define('MTTPATH', dirname(__FILE__) .'/'); require_once(MTTPATH. 'common.php'); @@ -46,7 +51,7 @@ else { $db->prefix = Config::get('prefix'); //User can override language setting by cookies -if(isset($_COOKIE['lang']) && preg_match("/^[a-z-]+$/i", $_COOKIE['lang']) && file_exists('lang/'. $_COOKIE['lang']. '.php')) { +if(isset($_COOKIE['lang']) && preg_match("/^[a-z-]+$/i", $_COOKIE['lang']) && file_exists(MTTPATH. 'lang/'. $_COOKIE['lang']. '.php')) { Config::set('lang', $_COOKIE['lang']); }