Use correct 'UTC' timezone

This commit is contained in:
ArthurHoaro 2016-05-03 20:09:24 +02:00
parent 9ad2950deb
commit 12ff86c961
3 changed files with 13 additions and 13 deletions

View file

@ -101,10 +101,6 @@ function generateTimeZoneForm($preselectedTimezone='')
*/ */
function isTimeZoneValid($continent, $city) function isTimeZoneValid($continent, $city)
{ {
if ($continent == 'UTC' && $city == 'UTC') {
return true;
}
return in_array( return in_array(
$continent.'/'.$city, $continent.'/'.$city,
timezone_identifiers_list() timezone_identifiers_list()

View file

@ -1276,11 +1276,15 @@ function renderPage()
{ {
if (!empty($_POST['title']) ) if (!empty($_POST['title']) )
{ {
if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! if (!tokenOk($_POST['token'])) {
die('Wrong token.'); // Go away!
}
$tz = 'UTC'; $tz = 'UTC';
if (!empty($_POST['continent']) && !empty($_POST['city'])) if (!empty($_POST['continent']) && !empty($_POST['city'])
if (isTimeZoneValid($_POST['continent'],$_POST['city'])) && isTimeZoneValid($_POST['continent'], $_POST['city'])
$tz = $_POST['continent'].'/'.$_POST['city']; ) {
$tz = $_POST['continent'] . '/' . $_POST['city'];
}
$GLOBALS['timezone'] = $tz; $GLOBALS['timezone'] = $tz;
$GLOBALS['title']=$_POST['title']; $GLOBALS['title']=$_POST['title'];
$GLOBALS['titleLink']=$_POST['titleLink']; $GLOBALS['titleLink']=$_POST['titleLink'];
@ -2113,11 +2117,11 @@ function install()
if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) if (!empty($_POST['setlogin']) && !empty($_POST['setpassword']))
{ {
$tz = 'UTC'; $tz = 'UTC';
if (!empty($_POST['continent']) && !empty($_POST['city'])) { if (!empty($_POST['continent']) && !empty($_POST['city'])
if (isTimeZoneValid($_POST['continent'], $_POST['city'])) { && isTimeZoneValid($_POST['continent'], $_POST['city'])
) {
$tz = $_POST['continent'].'/'.$_POST['city']; $tz = $_POST['continent'].'/'.$_POST['city'];
} }
}
$GLOBALS['timezone'] = $tz; $GLOBALS['timezone'] = $tz;
// Everything is ok, let's create config file. // Everything is ok, let's create config file.
$GLOBALS['login'] = $_POST['setlogin']; $GLOBALS['login'] = $_POST['setlogin'];

View file

@ -67,7 +67,6 @@ public function testValidTimeZone()
{ {
$this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia')); $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
$this->assertTrue(isTimeZoneValid('Europe', 'Oslo')); $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
$this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
} }
/** /**
@ -78,5 +77,6 @@ public function testInvalidTimeZone()
$this->assertFalse(isTimeZoneValid('CEST', 'CEST')); $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
$this->assertFalse(isTimeZoneValid('Europe', 'Atlantis')); $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
$this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria')); $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
$this->assertFalse(isTimeZoneValid('UTC', 'UTC'));
} }
} }