-
Notifications
You must be signed in to change notification settings - Fork 2
/
lda.inc.php
88 lines (77 loc) · 3.05 KB
/
lda.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
$appRoot = dirname(__FILE__);
set_include_path(get_include_path() . PATH_SEPARATOR . $appRoot);
define('PUELIA_VERSION', '0.1');
//define('PUELIA_SERVE_FROM_CACHE', true);
define('PUELIA_RDF_ACCEPT_MIMES', 'application/json;q=1,text/turtle;q=0.9,application/rdf+xml;q=0.8,*/*;q=0.1');
define('PUELIA_SPARQL_ACCEPT_MIMES', 'application/sparql-results+json;q=1,application/sparql-results+xml;q=0.8,*/*;q=0.1');
// define('MORIARTY_HTTP_CACHE_USE_STALE_ON_FAILURE', true);
define('MORIARTY_ALWAYS_CACHE_EVERYTHING', true);
define('MORIARTY_ARC_DIR', 'lib/arc/');
define('MORIARTY_HTTP_CACHE_DIR', dirname(__FILE__). '/cache/');
require 'lib/moriarty/simplegraph.class.php';
define('API', 'http://purl.org/linked-data/api/vocab#');
define('RDFS', 'http://www.w3.org/2000/01/rdf-schema#');
define("XSD", "http://www.w3.org/2001/XMLSchema#");
define("FOAF", 'http://xmlns.com/foaf/0.1/');
define("FOAF_KNOWS", 'http://xmlns.com/foaf/0.1/knows');
define("FOAF_HOMEPAGE", 'http://xmlns.com/foaf/0.1/homepage');
define("REL", 'http://vocab.org/relationship/');
define("RDF", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
define("XHV", "http://www.w3.org/1999/xhtml/vocab#");
define("DCT", "http://purl.org/dc/terms/");
define("PUELIA", "http://kwijibo.talis.com/vocabs/puelia#");
define("OPENSEARCH", "http://a9.com/-/spec/opensearch/1.1/");
define("OPMV", "http://purl.org/net/opmv#");
define("COPMV", "http://purl.org/net/opmv/types/common#");
define("SPARQL", "http://purl.org/net/opmv/types/sparql#");
define("DOAP", "http://usefulinc.com/ns/doap#");
define("SD", "http://www.w3.org/ns/sparql-service-description#");
define("VOID", "http://rdfs.org/ns/void#");
define('GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
define("LOG_SELECT_QUERIES", 0);
define("LOG_VIEW_QUERIES", 0);
define('PUELIA_CACHE_AGE', 1);
//define('PUELIA_CACHE_AGE', (60*60*24*1));
define('PUELIA_LOG_DIR', dirname(__FILE__).'/logs/');
require_once('lib/log4php/src/main/php/Logger.php');
function getApiConfigAsTurtle(){
$files = glob('api-config-files/*.ttl');
$graph = new SimpleGraph();
foreach($files as $file){
$graph->add_rdf(file_get_contents($file));
}
return $graph->to_turtle();
}
function queryStringToParams($query){
$query = ltrim($query, '?');
$pairs = explode('&', $query);
$params = array();
foreach($pairs as $pair){
if($tuple = explode('=', $pair) AND isset($tuple[1])){
$params[urldecode($tuple[0])]=urldecode($tuple[1]);
}
}
return $params;
}
function logError($message){
$logger = Logger::getLogger('Puelia');
$logger->error($message);
}
function logSelectQuery($request, $query){
$uri = $request->getUri();
$message = "{$uri}\t<<<{$query}>>>";
$logger = Logger::getLogger('Puelia');
$logger->info($message);
}
function logViewQuery($request, $query){
$uri = $request->getUri();
$message = "{$uri}\t<<<{$query}>>>";
$logger = Logger::getLogger('Puelia');
$logger->info($message);
}
function logDebug($message){
$logger = Logger::getLogger('Puelia');
$logger->debug($message);
}
?>