function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
{
$urlObj = new Url($url);
- $cleanUrl = $urlObj->indToAscii();
+ $cleanUrl = $urlObj->idnToAscii();
if (! filter_var($cleanUrl, FILTER_VALIDATE_URL) || ! $urlObj->isHttp()) {
return array(array(0 => 'Invalid HTTP Url'), false);
* Retrieve HTTP headers, following n redirections (temporary and permanent ones).
*
* @param string $url initial URL to reach.
- * @param int $redirectionLimit max redirection follow..
+ * @param int $redirectionLimit max redirection follow.
*
* @return array HTTP headers, or false if it failed.
*/
*/
function isTimeZoneValid($continent, $city)
{
- if ($continent == 'UTC' && $city == 'UTC') {
- return true;
- }
-
return in_array(
$continent.'/'.$city,
timezone_identifiers_list()
*
* @return string converted cleaned up URL.
*/
- public function indToAscii()
+ public function idnToAscii()
{
$out = $this->cleanup();
if (! function_exists('idn_to_ascii') || ! isset($this->parts['host'])) {
{
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'];
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.
{
$this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
$this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
- $this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
}
/**
$this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
$this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
$this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
+ $this->assertFalse(isTimeZoneValid('UTC', 'UTC'));
}
}
$ind = 'http://www.académie-française.fr/';
$expected = 'http://www.xn--acadmie-franaise-npb1a.fr/';
$url = new Url($ind);
- $this->assertEquals($expected, $url->indToAscii());
+ $this->assertEquals($expected, $url->idnToAscii());
$notInd = 'http://www.academie-francaise.fr/';
$url = new Url($notInd);
- $this->assertEquals($notInd, $url->indToAscii());
+ $this->assertEquals($notInd, $url->idnToAscii());
}
}