getScriptURI() static public method

static public getScriptURI ( )
Example #1
0
 function parse($q, $src = '')
 {
     $this->setDefaultPrefixes();
     $this->base = $src ? $this->calcBase($src) : ARC2::getScriptURI();
     $this->r = array('base' => '', 'vars' => array(), 'prefixes' => array());
     $this->unparsed_code = $q;
     list($r, $v) = $this->xQuery($q);
     if ($r) {
         $this->r['query'] = $r;
         $this->unparsed_code = trim($v);
     } elseif (!$this->getErrors() && !$this->unparsed_code) {
         $this->addError('Query not properly closed');
     }
     $this->r['prefixes'] = $this->prefixes;
     $this->r['base'] = $this->base;
     /* remove trailing comments */
     while (preg_match('/^\\s*(\\#[^\\xd\\xa]*)(.*)$/si', $this->unparsed_code, $m)) {
         $this->unparsed_code = $m[2];
     }
     if ($this->unparsed_code && !$this->getErrors()) {
         $rest = preg_replace('/[\\x0a|\\x0d]/i', ' ', substr($this->unparsed_code, 0, 30));
         $msg = trim($rest) ? 'Could not properly handle "' . $rest . '"' : 'Syntax error, probably an incomplete pattern';
         $this->addError($msg);
     }
 }
Example #2
0
 function getRequestURI()
 {
     if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) {
         return preg_replace('/^([a-z]+)\\/.*$/', '\\1', strtolower($_SERVER['SERVER_PROTOCOL'])) . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['REQUEST_URI'];
     }
     return ARC2::getScriptURI();
 }
Example #3
0
 function __init()
 {
     /* base, time_limit */
     $this->inc_path = ARC2::getIncPath();
     $this->base = $this->v('base', ARC2::getScriptURI(), $this->a);
     $this->errors = array();
     $this->warnings = array();
 }
 public function testGetRequestURI()
 {
     $tmp = $_SERVER;
     unset($_SERVER);
     $actual = ARC2::getRequestURI();
     $this->assertEquals(ARC2::getScriptURI(), $actual);
     $_SERVER = $tmp;
     $_SERVER = array('SERVER_PROTOCOL' => 'http', 'SERVER_PORT' => 1234, 'HTTP_HOST' => 'example.com', 'REQUEST_URI' => '/foo');
     $actual = ARC2::getRequestURI();
     $this->assertEquals('http://example.com:1234/foo', $actual);
     $_SERVER = $tmp;
 }
 function parse($v, $src = '', $iso_fallback = 'ignore')
 {
     $this->setDefaultPrefixes();
     $this->base = $src ? $this->calcBase($src) : ARC2::getScriptURI();
     $this->blocks = array();
     $this->r = array('base' => '', 'vars' => array(), 'prefixes' => $this->prefixes);
     do {
         $proceed = 0;
         if ((list($r, $v) = $this->xScriptBlock($v)) && $r) {
             $this->blocks[] = $r;
             $proceed = 1;
         }
         $this->unparsed_code = trim($v);
     } while ($proceed);
     if (trim($this->unparsed_code) && !$this->getErrors()) {
         $rest = preg_replace('/[\\x0a|\\x0d]/i', ' ', substr($this->unparsed_code, 0, 30));
         $msg = trim($rest) ? 'Could not properly handle "' . $rest . '"' : 'Syntax Error';
         $this->addError($msg);
     }
 }
Example #6
0
 function parseData($data)
 {
     return $this->parse(ARC2::getScriptURI(), $data);
 }
 function processQueryBlock($block)
 {
     $ep_uri = $this->env['endpoint'];
     /* q */
     $q = 'BASE <' . $block['base'] . '>';
     foreach ($block['prefixes'] as $k => $v) {
         $q .= "\n" . 'PREFIX ' . $k . ' <' . $v . '>';
     }
     $q .= "\n" . $block['query'];
     /* placeholders */
     $q = $this->replacePlaceholders($q);
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         $store = ARC2::getStore($this->a);
         /* @@todo error checking */
         return $store->query($q);
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri));
         $store =& new ARC2_RemoteStore($conf, $this);
         return $store->query($q, '', $ep_uri);
     } else {
         return $this->addError("no store");
     }
 }
 function getStore($ep_uri)
 {
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         if (!isset($this->local_store)) {
             $this->local_store = ARC2::getStore($this->a);
         }
         /* @@todo error checking */
         return $this->local_store;
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri, 'reader_timeout' => 10));
         return new ARC2_RemoteStore($conf, $this);
     }
     return 0;
 }
 function getAbsBase()
 {
     return preg_replace('/index\\.php$/', '', ARC2::getScriptURI());
 }
 function processQueryBlock($block)
 {
     if ($this->max_queries && $this->env['query_count'] >= $this->max_queries) {
         return $this->addError('Number of ' . $this->max_queries . ' allowed queries exceeded.');
     }
     $this->env['query_count']++;
     $ep_uri = $this->env['endpoint'];
     /* q */
     $q = 'BASE <' . $block['base'] . '>';
     $ns = isset($this->a['ns']) ? array_merge($this->a['ns'], $block['prefixes']) : $block['prefixes'];
     foreach ($ns as $k => $v) {
         $k = rtrim($k, ':');
         $q .= strpos($block['query'], $k . ':') !== false ? "\n" . 'PREFIX ' . $k . ': <' . $v . '>' : '';
     }
     $q .= "\n" . $block['query'];
     /* placeholders */
     $q = $this->replacePlaceholders($q, 'query');
     $this->env['query_log'][] = '(' . $ep_uri . ') ' . $q;
     /* local store */
     if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && $this->v('sparqlscript_default_endpoint', '', $this->a) == 'local') {
         if (!isset($this->local_store)) {
             $this->local_store = ARC2::getStore($this->a);
         }
         /* @@todo error checking */
         return $this->local_store->query($q);
     } elseif ($ep_uri) {
         ARC2::inc('RemoteStore');
         $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri));
         $store =& new ARC2_RemoteStore($conf, $this);
         return $store->query($q, '', $ep_uri);
     } else {
         return $this->addError("no store");
     }
 }