aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/HttpUtils.php4
-rw-r--r--application/TimeZone.php4
-rw-r--r--application/Url.php2
-rw-r--r--index.php20
-rw-r--r--tests/TimeZoneTest.php2
-rw-r--r--tests/Url/UrlTest.php4
6 files changed, 18 insertions, 18 deletions
diff --git a/application/HttpUtils.php b/application/HttpUtils.php
index 0e1ce879..c84ba6f0 100644
--- a/application/HttpUtils.php
+++ b/application/HttpUtils.php
@@ -27,7 +27,7 @@
27function get_http_response($url, $timeout = 30, $maxBytes = 4194304) 27function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
28{ 28{
29 $urlObj = new Url($url); 29 $urlObj = new Url($url);
30 $cleanUrl = $urlObj->indToAscii(); 30 $cleanUrl = $urlObj->idnToAscii();
31 31
32 if (! filter_var($cleanUrl, FILTER_VALIDATE_URL) || ! $urlObj->isHttp()) { 32 if (! filter_var($cleanUrl, FILTER_VALIDATE_URL) || ! $urlObj->isHttp()) {
33 return array(array(0 => 'Invalid HTTP Url'), false); 33 return array(array(0 => 'Invalid HTTP Url'), false);
@@ -70,7 +70,7 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
70 * Retrieve HTTP headers, following n redirections (temporary and permanent ones). 70 * Retrieve HTTP headers, following n redirections (temporary and permanent ones).
71 * 71 *
72 * @param string $url initial URL to reach. 72 * @param string $url initial URL to reach.
73 * @param int $redirectionLimit max redirection follow.. 73 * @param int $redirectionLimit max redirection follow.
74 * 74 *
75 * @return array HTTP headers, or false if it failed. 75 * @return array HTTP headers, or false if it failed.
76 */ 76 */
diff --git a/application/TimeZone.php b/application/TimeZone.php
index e363d90a..26f2232d 100644
--- a/application/TimeZone.php
+++ b/application/TimeZone.php
@@ -101,10 +101,6 @@ function generateTimeZoneForm($preselectedTimezone='')
101 */ 101 */
102function isTimeZoneValid($continent, $city) 102function isTimeZoneValid($continent, $city)
103{ 103{
104 if ($continent == 'UTC' && $city == 'UTC') {
105 return true;
106 }
107
108 return in_array( 104 return in_array(
109 $continent.'/'.$city, 105 $continent.'/'.$city,
110 timezone_identifiers_list() 106 timezone_identifiers_list()
diff --git a/application/Url.php b/application/Url.php
index 61a30a78..77447c8d 100644
--- a/application/Url.php
+++ b/application/Url.php
@@ -240,7 +240,7 @@ class Url
240 * 240 *
241 * @return string converted cleaned up URL. 241 * @return string converted cleaned up URL.
242 */ 242 */
243 public function indToAscii() 243 public function idnToAscii()
244 { 244 {
245 $out = $this->cleanup(); 245 $out = $this->cleanup();
246 if (! function_exists('idn_to_ascii') || ! isset($this->parts['host'])) { 246 if (! function_exists('idn_to_ascii') || ! isset($this->parts['host'])) {
diff --git a/index.php b/index.php
index e9b0bf40..47bae6e8 100644
--- a/index.php
+++ b/index.php
@@ -1277,11 +1277,15 @@ function renderPage()
1277 { 1277 {
1278 if (!empty($_POST['title']) ) 1278 if (!empty($_POST['title']) )
1279 { 1279 {
1280 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! 1280 if (!tokenOk($_POST['token'])) {
1281 die('Wrong token.'); // Go away!
1282 }
1281 $tz = 'UTC'; 1283 $tz = 'UTC';
1282 if (!empty($_POST['continent']) && !empty($_POST['city'])) 1284 if (!empty($_POST['continent']) && !empty($_POST['city'])
1283 if (isTimeZoneValid($_POST['continent'],$_POST['city'])) 1285 && isTimeZoneValid($_POST['continent'], $_POST['city'])
1284 $tz = $_POST['continent'].'/'.$_POST['city']; 1286 ) {
1287 $tz = $_POST['continent'] . '/' . $_POST['city'];
1288 }
1285 $GLOBALS['timezone'] = $tz; 1289 $GLOBALS['timezone'] = $tz;
1286 $GLOBALS['title']=$_POST['title']; 1290 $GLOBALS['title']=$_POST['title'];
1287 $GLOBALS['titleLink']=$_POST['titleLink']; 1291 $GLOBALS['titleLink']=$_POST['titleLink'];
@@ -2108,10 +2112,10 @@ function install()
2108 if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) 2112 if (!empty($_POST['setlogin']) && !empty($_POST['setpassword']))
2109 { 2113 {
2110 $tz = 'UTC'; 2114 $tz = 'UTC';
2111 if (!empty($_POST['continent']) && !empty($_POST['city'])) { 2115 if (!empty($_POST['continent']) && !empty($_POST['city'])
2112 if (isTimeZoneValid($_POST['continent'], $_POST['city'])) { 2116 && isTimeZoneValid($_POST['continent'], $_POST['city'])
2113 $tz = $_POST['continent'].'/'.$_POST['city']; 2117 ) {
2114 } 2118 $tz = $_POST['continent'].'/'.$_POST['city'];
2115 } 2119 }
2116 $GLOBALS['timezone'] = $tz; 2120 $GLOBALS['timezone'] = $tz;
2117 // Everything is ok, let's create config file. 2121 // Everything is ok, let's create config file.
diff --git a/tests/TimeZoneTest.php b/tests/TimeZoneTest.php
index b219030a..2976d116 100644
--- a/tests/TimeZoneTest.php
+++ b/tests/TimeZoneTest.php
@@ -67,7 +67,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
67 { 67 {
68 $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia')); 68 $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
69 $this->assertTrue(isTimeZoneValid('Europe', 'Oslo')); 69 $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
70 $this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
71 } 70 }
72 71
73 /** 72 /**
@@ -78,5 +77,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
78 $this->assertFalse(isTimeZoneValid('CEST', 'CEST')); 77 $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
79 $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis')); 78 $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
80 $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria')); 79 $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
80 $this->assertFalse(isTimeZoneValid('UTC', 'UTC'));
81 } 81 }
82} 82}
diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php
index 5fdc8617..ce82265e 100644
--- a/tests/Url/UrlTest.php
+++ b/tests/Url/UrlTest.php
@@ -190,10 +190,10 @@ class UrlTest extends PHPUnit_Framework_TestCase
190 $ind = 'http://www.académie-française.fr/'; 190 $ind = 'http://www.académie-française.fr/';
191 $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/'; 191 $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/';
192 $url = new Url($ind); 192 $url = new Url($ind);
193 $this->assertEquals($expected, $url->indToAscii()); 193 $this->assertEquals($expected, $url->idnToAscii());
194 194
195 $notInd = 'http://www.academie-francaise.fr/'; 195 $notInd = 'http://www.academie-francaise.fr/';
196 $url = new Url($notInd); 196 $url = new Url($notInd);
197 $this->assertEquals($notInd, $url->indToAscii()); 197 $this->assertEquals($notInd, $url->idnToAscii());
198 } 198 }
199} 199}