X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=1439ec2f708b66d41b9381c895a835faddd0932e;hb=96db105e4c0833324f7168edb5673278de8ccd54;hp=bf0b99e043b7492f8402cd2c62aa8b5b29b13f66;hpb=5b0ebbc5de06b8a0e9679b78b45d0dc755db7986;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index bf0b99e0..1439ec2f 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,9 @@ /shaarli/ define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); @@ -59,7 +59,6 @@ ini_set('max_input_time','60'); // High execution time in case of problematic i ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). ini_set('post_max_size', '16M'); ini_set('upload_max_filesize', '16M'); -checkphpversion(); error_reporting(E_ALL^E_WARNING); // See all error except warnings. //error_reporting(-1); // See all errors (for debugging only) @@ -70,9 +69,19 @@ if (is_file($GLOBALS['config']['CONFIG_FILE'])) { // Shaarli library require_once 'application/LinkDB.php'; +require_once 'application/TimeZone.php'; require_once 'application/Utils.php'; require_once 'application/Config.php'; +// Ensure the PHP version is supported +try { + checkPHPVersion('5.3', PHP_VERSION); +} catch(Exception $e) { + header('Content-Type: text/plain; charset=utf-8'); + echo $e->getMessage(); + exit; +} + include "inc/rain.tpl.class.php"; //include Rain TPL raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory raintpl::$cache_dir = $GLOBALS['config']['RAINTPL_TMP']; // cache directory @@ -164,21 +173,7 @@ function setup_login_state() { return $userIsLoggedIn; } -//================================================================================================== $userIsLoggedIn = setup_login_state(); -//================================================================================================== -//================================================================================================== - -// Check PHP version -function checkphpversion() -{ - if (version_compare(PHP_VERSION, '5.1.0') < 0) - { - header('Content-Type: text/plain; charset=utf-8'); - echo 'Your PHP version is obsolete! Shaarli requires at least php 5.1.0, and thus cannot run. Sorry. Your PHP version has known security vulnerabilities and should be updated as soon as possible.'; - exit; - } -} // Checks if an update is available for Shaarli. // (at most once a day, and only for registered user.) @@ -982,7 +977,7 @@ function showDaily() $linksToDisplay = $LINKSDB->filterDay($day); } catch (Exception $exc) { error_log($exc); - $linksToDisplay = []; + $linksToDisplay = array(); } // We pre-format some fields for proper output. @@ -1288,7 +1283,7 @@ function renderPage() if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! $tz = 'UTC'; if (!empty($_POST['continent']) && !empty($_POST['city'])) - if (isTZvalid($_POST['continent'],$_POST['city'])) + if (isTimeZoneValid($_POST['continent'],$_POST['city'])) $tz = $_POST['continent'].'/'.$_POST['city']; $GLOBALS['timezone'] = $tz; $GLOBALS['title']=$_POST['title']; @@ -1322,8 +1317,8 @@ function renderPage() $PAGE->assign('token',getToken()); $PAGE->assign('title', empty($GLOBALS['title']) ? '' : $GLOBALS['title'] ); $PAGE->assign('redirector', empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector'] ); - list($timezone_form,$timezone_js) = templateTZform($GLOBALS['timezone']); - $PAGE->assign('timezone_form',$timezone_form); // FIXME: Put entire tz form generation in template? + list($timezone_form, $timezone_js) = generateTimeZoneForm($GLOBALS['timezone']); + $PAGE->assign('timezone_form', $timezone_form); $PAGE->assign('timezone_js',$timezone_js); $PAGE->renderPage('configure'); exit; @@ -2059,9 +2054,11 @@ function install() if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) { $tz = 'UTC'; - if (!empty($_POST['continent']) && !empty($_POST['city'])) - if (isTZvalid($_POST['continent'],$_POST['city'])) + if (!empty($_POST['continent']) && !empty($_POST['city'])) { + if (isTimeZoneValid($_POST['continent'], $_POST['city'])) { $tz = $_POST['continent'].'/'.$_POST['city']; + } + } $GLOBALS['timezone'] = $tz; // Everything is ok, let's create config file. $GLOBALS['login'] = $_POST['setlogin']; @@ -2087,8 +2084,11 @@ function install() } // Display config form: - list($timezone_form,$timezone_js) = templateTZform(); - $timezone_html=''; if ($timezone_form!='') $timezone_html='