]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #551 from ArthurHoaro/hotfix/timezone
authorArthur <arthur@hoa.ro>
Thu, 5 May 2016 11:21:36 +0000 (13:21 +0200)
committerArthur <arthur@hoa.ro>
Thu, 5 May 2016 11:21:36 +0000 (13:21 +0200)
Use correct 'UTC' timezone

application/TimeZone.php
index.php
tests/TimeZoneTest.php

index e363d90a789207b821493a98a65270ba63b1ae97..26f2232d45c1a5961d45380acf52de0beafd5b70 100644 (file)
@@ -101,10 +101,6 @@ function generateTimeZoneForm($preselectedTimezone='')
  */
 function isTimeZoneValid($continent, $city)
 {
-    if ($continent == 'UTC' && $city == 'UTC') {
-        return true;
-    }
-
     return in_array(
         $continent.'/'.$city,
         timezone_identifiers_list()
index e9b0bf4058e52f9843a9ecfd3408211abe3724b3..47bae6e87a943a1b26d5af2d1558053e2909f2fb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1277,11 +1277,15 @@ function renderPage()
     {
         if (!empty($_POST['title']) )
         {
-            if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away!
+            if (!tokenOk($_POST['token'])) {
+                die('Wrong token.'); // Go away!
+            }
             $tz = 'UTC';
-            if (!empty($_POST['continent']) && !empty($_POST['city']))
-                if (isTimeZoneValid($_POST['continent'],$_POST['city']))
-                    $tz = $_POST['continent'].'/'.$_POST['city'];
+            if (!empty($_POST['continent']) && !empty($_POST['city'])
+                && isTimeZoneValid($_POST['continent'], $_POST['city'])
+            ) {
+                $tz = $_POST['continent'] . '/' . $_POST['city'];
+            }
             $GLOBALS['timezone'] = $tz;
             $GLOBALS['title']=$_POST['title'];
             $GLOBALS['titleLink']=$_POST['titleLink'];
@@ -2108,10 +2112,10 @@ function install()
     if (!empty($_POST['setlogin']) && !empty($_POST['setpassword']))
     {
         $tz = 'UTC';
-        if (!empty($_POST['continent']) && !empty($_POST['city'])) {
-            if (isTimeZoneValid($_POST['continent'], $_POST['city'])) {
-                $tz = $_POST['continent'].'/'.$_POST['city'];
-            }
+        if (!empty($_POST['continent']) && !empty($_POST['city'])
+            && isTimeZoneValid($_POST['continent'], $_POST['city'])
+        ) {
+            $tz = $_POST['continent'].'/'.$_POST['city'];
         }
         $GLOBALS['timezone'] = $tz;
         // Everything is ok, let's create config file.
index b219030a3a4da19f3c73b53d9a845723b4fb1352..2976d11612765dde427242073320c4d7f32bdb97 100644 (file)
@@ -67,7 +67,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
     {
         $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
         $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
-        $this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
     }
 
     /**
@@ -78,5 +77,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
         $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
         $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
         $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
+        $this->assertFalse(isTimeZoneValid('UTC', 'UTC'));
     }
 }