static function resolve($agent)
 {
     static $cache = array();
     if (isset($cache[$agent])) {
         return $cache[$agent];
     } else {
         $cache[$agent] =& $trace;
     }
     $args = array();
     $BASE = p::__BASE__();
     $agent = rawurlencode($agent);
     $agent = str_replace(array('%21', '%7E', '%2A', '%28', '%29', '%2C', '%2F', '%3A', '%40', '%24', '%3B'), array('!', '~', '*', '(', ')', ',', '/', ':', '@', '$', ';'), $agent);
     $agent = p::base($agent, true);
     $agent = preg_replace("'^.*?://[^/]*'", '', $agent);
     $h = patchwork_http_socket($_SERVER['SERVER_ADDR'], $_SERVER['SERVER_PORT'], isset($_SERVER['HTTPS']));
     $keys = p::$lang;
     $keys = "GET {$agent}?p:=k:{$keys} HTTP/1.0\r\n";
     $keys .= "Host: {$_SERVER['HTTP_HOST']}\r\n";
     $keys .= "Connection: close\r\n\r\n";
     fwrite($h, $keys);
     $keys = array();
     while (false !== ($a = fgets($h))) {
         $keys[] = $a;
     }
     fclose($h);
     $h = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
     $h = "/w\\.k\\((-?[0-9]+),({$h}),({$h}),({$h}),\\[((?:{$h}(?:,{$h})*)?)\\]\\)/su";
     if (!preg_match($h, implode('', $keys), $keys)) {
         user_error('Error while getting meta info data for ' . htmlspecialchars($agent));
         p::disable(true);
     }
     $appId = (int) $keys[1];
     $base = stripcslashes(substr($keys[2], 1, -1));
     $agent = stripcslashes(substr($keys[3], 1, -1));
     $a = stripcslashes(substr($keys[4], 1, -1));
     $keys = eval('return array(' . $keys[5] . ');');
     if ('' !== $a) {
         $args['__0__'] = $a;
         $i = 0;
         foreach (explode('/', $a) as $a) {
             $args['__' . ++$i . '__'] = $a;
         }
     }
     if ($base === $BASE) {
         $appId = $base = false;
     } else {
         p::watch('foreignTrace');
     }
     return $trace = array($appId, $base, $agent, $keys, $args);
 }
Ejemplo n.º 2
0
 /**
  * Sends the request to the webserver but don't wait for the response.
  */
 static function touch($url)
 {
     $url = Patchwork::base($url, true);
     if (!preg_match("'^http(s?)://([^:/]*)((?::[0-9]+)?)(/.*)\$'", $url, $h)) {
         throw new Exception('Illegal URL');
     }
     $url = "GET {$h[4]} HTTP/1.0\r\n";
     $url .= "Host: {$h[2]}\r\n";
     $url .= "Connection: close\r\n\r\n";
     try {
         $h = patchwork_http_socket($h[2], substr($h[3], 1), $h[1], 5);
         socket_set_blocking($h, 0);
         do {
             $len = fwrite($h, $url);
             $url = substr($url, $len);
         } while (false !== $len && false !== $url);
         fclose($h);
     } catch (Exception $h) {
         user_error($h->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**/
 case isset($_SERVER['ORIG_PATH_INFO']):
     /**/
 /**/
 case isset($_SERVER['PATH_INFO']):
     break;
     /**/
     /**/
 /**/
 /**/
 default:
     /**/
     // Check if the webserver supports PATH_INFO
     /**/
     /**/
     $h = patchwork_http_socket($_SERVER['SERVER_ADDR'], $_SERVER['SERVER_PORT'], isset($_SERVER['HTTPS']), 5, $_SERVER['HTTP_HOST']);
     /**/
     /**/
     $a = strpos($_SERVER['REQUEST_URI'], '?');
     /**/
     $a = false === $a ? $_SERVER['REQUEST_URI'] : substr($_SERVER['REQUEST_URI'], 0, $a);
     /**/
     '/' === substr($a, -1) && ($a .= basename(isset($_SERVER['ORIG_SCRIPT_NAME']) ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']));
     /**/
     /**/
     $a = "GET {$a}/:?p:=exit HTTP/1.0\r\n";
     /**/
     $a .= "Host: {$_SERVER['HTTP_HOST']}\r\n";
     /**/
     $a .= "Connection: close\r\n\r\n";
     /**/