/examples/jsonrpc/public/services/phpolait/rpcproxy_constructor.php
PHP | 30 lines | 23 code | 1 blank | 6 comment | 8 complexity | bf2a14df4f1a235bb448242ab1351fba MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
1<?php
2 /**
3 * Internal code for the JSONRpcProxy::JSONRpcProxy() function
4 * This _extremely_ annoying approach is necessitated to have PHP 4 and PHP 5 compatibility with the same code-base.
5 * I SINCERELY hope it works!
6 */
7 // Converts from relative to absolute URL's. Permits relative URL's and prevents local filesystem access.
8 if (! ((substr($url, 0, 7) == "http://") || (substr($url, 0, 8) == "https://")) ){
9 if (substr($_SERVER["SERVER_PROTOCOL"],0,5)=="HTTPS") {
10 $newUrl = "https";
11 } else {
12 $newUrl = "http";
13 }
14 $newUrl .= "://";
15 $newUrl .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
16 $newUrl .= dirname($_SERVER['PHP_SELF']);
17 if (substr($newUrl, -1)!="/") $newUrl .= "/";
18 $url = $newUrl . $url;
19 }
20 $this->url = $url;
21
22 if (!(is_object($httpWrapper))) {
23 $this->httpWrap = HttpWrapper::GetWrapper();
24 } else {
25 $this->httpWrap = $httpWrapper;
26 }
27 $this->jsonlib = JSON_PHP_FILE;
28 if ($jsonlib!=null)
29 $this->jsonlib = $jsonlib;
30?>