public function match($uri) { global $conf; global $localUri; global $lodspk; $method = ucwords($_SERVER['REQUEST_METHOD']); $uriSegment = str_replace($conf['basedir'], '', $localUri); //Check if looking for session validation if ($uriSegment === $this->sessionUri) { //GET will return the form if ($method == "GET") { $this->showSessionForm(); return true; } //POST will take the data and validate it if ($method == "POST") { if ($this->validateAuthentication($_POST)) { session_start(); $_SESSION['lodspk'] = 1; HTTPStatus::send303($conf['basedir'], ''); return false; } else { HTTPStatus::send401("Authentication not valid."); return true; } } } else { session_start(); if (isset($_SESSION['lodspk'])) { return false; } else { HTTPStatus::send303($conf['basedir'] . $this->sessionUri, ''); return true; } } }
public function execute($pair) { global $conf; global $localUri; global $uri; global $acceptContentType; global $endpoints; global $lodspk; global $results; global $firstResults; list($res, $page, $format) = $pair; //If resource is not the page, send a 303 to the document if ($res == $localUri) { HTTPStatus::send303($page, $acceptContentType); } $uri = $res; if ($conf['mirror_external_uris'] != false) { $localUri = preg_replace("|^" . $conf['ns']['local'] . "|", $conf['basedir'], $res); } $extension = Utils::getExtension($format); /*Redefine Content type based on the * dcterms:format for this page */ $acceptContentType = $format; //Check if files for model and view exist $t = Queries::getClass($uri, $endpoints['local']); $obj = $this->getModelandView($t, $extension); $modelFile = $obj['modelFile']; $lodspk['model'] = $conf['model']['directory']; $viewFile = $obj['viewFile']; $lodspk['view'] = $obj['view']['directory']; if ($viewFile == null) { $lodspk['transform_select_query'] = true; } $lodspk['type'] = $modelFile; $lodspk['home'] = $conf['basedir']; $lodspk['baseUrl'] = $conf['basedir']; $lodspk['module'] = 'type'; $lodspk['root'] = $conf['root']; $lodspk['contentType'] = $acceptContentType; $lodspk['ns'] = $conf['ns']; $lodspk['endpoint'] = $conf['endpoint']; $lodspk['view'] = $conf['view']['directory']; $lodspk['add_mirrored_uris'] = true; $lodspk['this']['value'] = $uri; $lodspk['this']['curie'] = Utils::uri2curie($uri); $lodspk['local']['value'] = $localUri; $lodspk['local']['curie'] = Utils::uri2curie($localUri); $lodspk['this']['extension'] = $extension; //chdir($conf['home'].$conf['model']['directory']); Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults); if (!$lodspk['resultRdf']) { $results = Utils::internalize($results); $firstAux = Utils::getfirstResults($results); //chdir($conf['home']); if (is_array($results)) { $resultsObj = Convert::array_to_object($results); $results = $resultsObj; } else { $resultsObj = $results; } $lodspk['firstResults'] = Convert::array_to_object($firstAux); } else { $resultsObj = $results; } //chdir($conf['home'].$conf['model']['directory']); Utils::processDocument($viewFile, $lodspk, $resultsObj); }
public function execute($p) { global $conf; global $localUri; global $uri; global $acceptContentType; global $endpoints; global $lodspk; global $results; global $firstResults; $res = $p['res']; $page = $p['page']; $format = $p['format']; $modelFile = $p['modelFile']; $viewFile = $p['viewFile']; $uri = $res; $curie = Utils::uri2curie($res); //If resource is not the page, send a 303 to the document if ($res == $localUri) { HTTPStatus::send303($page, $acceptContentType); } $uri = $res; if ($conf['mirror_external_uris'] != false) { $localUri = preg_replace("|^" . $conf['ns']['local'] . "|", $conf['basedir'], $res); } $extension = Utils::getExtension($format); /*Redefine Content type based on the * dcterms:format for this page */ $acceptContentType = $format; $curie = Utils::uri2curie($uri); if ($modelFile == NULL) { return; } //$lodspk = $conf['view']['standard']; $lodspk['type'] = $modelFile; $lodspk['home'] = $conf['basedir']; $lodspk['module'] = 'uri'; $lodspk['add_mirrored_uris'] = true; $lodspk['this']['value'] = $uri; $lodspk['this']['curie'] = Utils::uri2curie($uri); $lodspk['local']['value'] = $localUri; $lodspk['local']['curie'] = Utils::uri2curie($localUri); $lodspk['contentType'] = $acceptContentType; $lodspk['model'] = $conf['model']['directory']; $lodspk['view'] = $conf['view']['directory']; $lodspk['ns'] = $conf['ns']; //chdir($conf['home'].$conf['model']['directory']); Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults); if (!$lodspk['resultRdf']) { $results = Utils::internalize($results); $firstAux = Utils::getfirstResults($results); chdir($conf['home']); if (is_array($results)) { $resultsObj = Convert::array_to_object($results); $results = $resultsObj; } else { $resultsObj = $results; } $lodspk['firstResults'] = Convert::array_to_object($firstAux); } else { $resultsObj = $results; } //chdir($conf['home']); if ($conf['debug']) { Logging::log("Using template " . $viewFile); } Utils::processDocument($viewFile, $lodspk, $resultsObj); }