protected function httpGet($uri, $session = null, $maxRedirects = 0) { $request = new Sabel_Request_Object(normalize_uri($uri)); if (isset($parsedUrl["query"]) && !empty($parsedUrl["query"])) { parse_str($parsedUrl["query"], $get); $request->setGetValues($get); } return $this->request($request, $session, $maxRedirects); }
protected function getRequestUri($bus) { $uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : "/"; if (!is_cli() && isset($_SERVER["SCRIPT_NAME"]) && $_SERVER["SCRIPT_NAME"] !== "/index.php") { $bus->set("NO_VIRTUAL_HOST", true); $pubdir = substr(RUN_BASE . DS . "public", strlen($_SERVER["DOCUMENT_ROOT"])); define("URI_PREFIX", $pubdir); $uri = substr(str_replace("/index.php", "", $uri), strlen($pubdir)); } return normalize_uri($uri); }
protected function getRequestUri() { if (class_exists("Sabel_Context", false)) { $bus = Sabel_Context::getContext()->getBus(); if (is_object($bus) && ($request = $bus->get("request"))) { return "/" . $request->getUri(); } } if (isset($_SERVER["REQUEST_URI"])) { return "/" . normalize_uri($_SERVER["REQUEST_URI"]); } else { return "/"; } }
protected function getRequestUri($bus) { $uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : "/"; if (isset($_SERVER["SCRIPT_NAME"]) && strpos($_SERVER["SCRIPT_NAME"], "/index.php") >= 1) { $uri = substr($uri, strlen($_SERVER["SCRIPT_NAME"])); $bus->set("NO_VIRTUAL_HOST", true); } if (defined("NO_REWRITE_PREFIX") && isset($_GET[NO_REWRITE_PREFIX])) { $uri = substr($uri, strlen(NO_REWRITE_PREFIX) + 2); $parsed = parse_url($uri); if (isset($parsed["query"])) { parse_str($parsed["query"], $_GET); } unset($_GET[NO_REWRITE_PREFIX]); $bus->set("NO_REWRITE_MODULE", true); } return normalize_uri($uri); }
function xfn2db($userid, $url) { global $db; $xfn = array(); $page = get_url($url); @($xml = simplexml_load_string($page)); if ($xml) { $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' friend ')]"); $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' contact ')]"); $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' kin ')]"); $relme = $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' me ')]"); } //end if xml if ($relme) { foreach ($relme as $tag) { if (substr($tag['href'], 0, 4) != 'http') { $domain = explode('/', $url); $domain = $domain[2]; if (substr($tag['href'], 0, 1) == '/') { $tag['href'] = 'http://' . $domain . $tag['href']; } else { $tag['href'] = dirname($url) . '/' . $tag['href']; } } //end if not http if ($tag['href'] != $url) { $apage = get_url($tag['href']); @($xml = simplexml_load_string($apage)); if ($xml) { $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' friend ')]"); $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' contact ')]"); $xfn += $xml->xpath("//*[contains(concat(' ',normalize-space(@rel),' '),' kin ')]"); } //end if xml } //end if != } //end foreach relme } //end if relme require_once dirname(__FILE__) . '/connectDB.php'; foreach ($xfn as $tag) { if (substr($tag['href'], 0, 4) != 'http') { $domain = explode('/', $url); $domain = $domain[2]; if (substr($tag['href'], 0, 1) == '/') { $tag['href'] = 'http://' . $domain . $tag['href']; } else { $tag['href'] = dirname($url) . '/' . $tag['href']; } } //end if not http $dbuser = mysql_query("SELECT user_id FROM openids WHERE openid='" . mysql_real_escape_string(normalize_uri($tag['href']), $db) . "' LIMIT 1", $db) or die(mysql_error()); $dbuser = mysql_fetch_assoc($dbuser); if ($dbuser['user_id']) { $exists = mysql_query("SELECT friend_id FROM friends WHERE user_id={$userid} AND friend_id=" . $dbuser['user_id'], $db) or die(mysql_error()); if (!mysql_fetch_assoc($exists)) { mysql_query("INSERT INTO friends (user_id,friend_id) VALUES ({$userid}," . $dbuser['user_id'] . ")", $db) or die(mysql_error()); } } //end if dbuser } //end foreach xfn }
function absolute_uri($uri, $base_absolute_uri = null) { if (is_null($base_absolute_uri)) { $base_absolute_uri = get_current_url(); } # 5.2.1. Pre-parse the base URI $base_absolute_uri = normalize_uri($base_absolute_uri); # 5.2.2 Transform References $base = parse_uri($base_absolute_uri); $r = parse_uri($uri); $target = array(); if (isset($r['scheme'])) { $target['scheme'] = $r['scheme']; $target['path'] = remove_dot_segments(remove_multiple_slashes($r['path'])); $target['query'] = @$r['query']; // conceptually, $target['authority'] = @$r['authority']; $target['host'] = @$r['host']; $target['port'] = @$r['port']; $target['user'] = @$r['user']; $target['pass'] = @$r['pass']; } else { // conceptually, if (isset($r['authority')) if (isset($r['host'])) { $target['path'] = remove_dot_segments(remove_multiple_slashes($r['path'])); $target['query'] = @$r['query']; // conceptually, $target['authority'] = @$r['authority']; $target['host'] = @$r['host']; $target['port'] = @$r['port']; $target['user'] = @$r['user']; $target['pass'] = @$r['pass']; } else { if (empty($r['path'])) { $target['path'] = $base['path']; if (isset($r['query'])) { $target['query'] = $r['query']; } else { $target['query'] = $base['query']; } } else { if (substr($r['path'], 0, 1) === '/') { $target['path'] = remove_dot_segments(remove_multiple_slashes($r['path'])); } else { // conceptually, $target['path'] = merge($base['path'], $r['path']); if (isset($base['host']) and empty($base['path'])) { $target['path'] = "/" . $r['path']; } else { $segs = explode('/', $base['path']); array_pop($segs); $target['path'] = implode('/', $segs) . "/" . $r['path']; } $target['path'] = remove_dot_segments(remove_multiple_slashes($target['path'])); } $target['query'] = @$r['query']; } // conceptually, $target['authority'] = @$r['authority']; $target['host'] = @$base['host']; $target['port'] = @$base['port']; $target['user'] = @$base['user']; $target['pass'] = @$base['pass']; } $target['scheme'] = @$base['scheme']; } $target['fragment'] = @$r['fragment']; return unparse_uri($target); }