<?php |
<?php |
|
|
/* |
/* |
* Copyright 2010,2011 Alexander Sadleir |
* Copyright 2010,2011 Alexander Sadleir |
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
Licensed under the Apache License, Version 2.0 (the "License"); |
you may not use this file except in compliance with the License. |
you may not use this file except in compliance with the License. |
You may obtain a copy of the License at |
You may obtain a copy of the License at |
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
http://www.apache.org/licenses/LICENSE-2.0 |
|
|
Unless required by applicable law or agreed to in writing, software |
Unless required by applicable law or agreed to in writing, software |
distributed under the License is distributed on an "AS IS" BASIS, |
distributed under the License is distributed on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
See the License for the specific language governing permissions and |
See the License for the specific language governing permissions and |
limitations under the License. |
limitations under the License. |
*/ |
*/ |
|
|
function getPage($url) { |
function getPage($url) { |
debug($url, "json"); |
debug($url, "json"); |
$ch = curl_init($url); |
$ch = curl_init($url); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
curl_setopt($ch, CURLOPT_HEADER, 0); |
curl_setopt($ch, CURLOPT_HEADER, 0); |
curl_setopt($ch, CURLOPT_TIMEOUT, 45); |
curl_setopt($ch, CURLOPT_TIMEOUT, 45); |
$page = curl_exec($ch); |
$page = curl_exec($ch); |
if (curl_errno($ch)) { |
if (curl_errno($ch)) { |
echo "<font color=red> Database temporarily unavailable: "; |
echo "<font color=red> Database temporarily unavailable: "; |
echo curl_errno($ch) . " " . curl_error($ch); |
echo curl_errno($ch) . " " . curl_error($ch); |
if (isDebug()) { |
if (isDebug()) { |
echo $url; |
echo $url; |
} |
} |
echo "</font><br>"; |
echo "</font><br>"; |
} |
} |
curl_close($ch); |
curl_close($ch); |
debug(print_r($page, true), "json"); |
debug(print_r($page, true), "json"); |
return $page; |
return $page; |
} |
} |
function baseURL() { |
|
$protocol = $_SERVER['HTTPS'] ? "https" : "http"; |
|
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
|
|
} |
|
function curPageURL() { |
function curPageURL() { |
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"); |
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"); |
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443"))); |
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443"))); |
$port = ($port) ? ':' . $_SERVER["SERVER_PORT"] : ''; |
$port = ($port) ? ':' . $_SERVER["SERVER_PORT"] : ''; |
$url = ($isHTTPS ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"] . $port . htmlentities(dirname($_SERVER['PHP_SELF']), ENT_QUOTES); |
$url = ($isHTTPS ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"] . $port . htmlentities(dirname($_SERVER['PHP_SELF']), ENT_QUOTES); |
return $url; |
return $url; |
} |
} |
|
|
?> |
|
|
|