-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdf_module_dbpedia.php
53 lines (38 loc) · 1.2 KB
/
rdf_module_dbpedia.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
<?php
$inchi = substr($_SERVER['REQUEST_URI'],2);
print "<!-- $inchi -->\n";
$pos = strpos($inchi, 'info:inchi/');
if ($pos === 0) {
$inchi = substr($inchi, 11);
}
print "<!-- $inchi -->\n";
if (strlen($inchi) === 0) {
$inchi = "InChI=1/CH4/h1H4";
}
if (strlen($inchi) < 8 ||
(substr($inchi, 0,8) != "InChI=1/" &&
substr($inchi, 0,9) != "InChI=1S/")) {
$inchi = "InChI=1/CH4/h1H4";
}
?>
<rdf:Description
xmlns:owl="http://www.w3.org/2002/07/owl#"
rdf:about="http://rdf.openmolecules.net/?<?php echo $inchi;?>">
<dc:source>DBPedia</dc:source>
<?
$paper_id = false;
$safe_inchi = mysql_escape_string($inchi);
if ($safe_inchi) {
echo "<!-- DEBUG: inchi=".$safe_inchi." -->\n";
$query = "SELECT SQL_CALC_FOUND_ROWS * FROM dbpedia ";
$where_clause = "WHERE inchi = '$safe_inchi'";
$query = $query.$where_clause;
print "<!-- DEBUG: query = $query -->\n";
$results = mysql_query($query);
$rows = mysql_num_rows($results);
while ($row = mysql_fetch_assoc($results)) {
print "<owl:sameAs rdf:resource=\"".$row['dbresource']."\"/>\n";
}
}
?>
</rdf:Description>