-
Notifications
You must be signed in to change notification settings - Fork 4
/
tabdata.php
97 lines (74 loc) · 3.26 KB
/
tabdata.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
89
90
91
92
93
94
95
96
97
<?php
/**
* index.php - general application framework that powers foaf.me
*
* Copyright 2008-2009 foaf.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* "Everything should be made as simple as possible, but no simpler."
* -- Albert Einstein
*
*/
// includes
require_once('head.php');
require_once('header.php');
require_once('lib/Authentication.php');
if ($auth->isAuthenticated()) {
$authAgent = $auth->getAgent();
$webid = $authAgent['webid'];
$name = !empty($authAgent['name'])?$authAgent['name']:$webid;
}
// set up db connection
$db = new db_class();
$db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']);
$searchstring1 = '<?xml version="1.0"?>' . "\n";
$searchstring2 = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$searchstring3 = '<?xml version="1.0" encoding="UTF-8"?>';
$searchstring4 = '<?xml version="1.0" encoding="ISO-8859-1"?>';
// get webid from db
$res = $db->select(" select * from foaf where CONCAT(URI, '#me') = '$webid' or URI = '$webid' ");
if ($res && ($row = $db->get_row($res))) {
if (!empty($row) && !empty($row['rdf'])) {
$rdf = $row['rdf'];
}
if (!empty ($_REQUEST['rdf'])) {
$rdf = stripslashes($_REQUEST['rdf']);
$res2 = $db->update_sql(" update foaf set rdf = '$rdf' where CONCAT(URI, '#me') = '$webid' or URI = '$webid' ");
}
}
if (!empty($webid) && empty($rdf)) {
$rdf = file_get_contents($webid);
}
$rdf = str_replace($searchstring1, '', $rdf);
$rdf = str_replace($searchstring2, '', $rdf);
$rdf = str_replace($searchstring3, '', $rdf);
$rdf = str_replace($searchstring4, '', $rdf);
?>
<form name="results" action="" method="post" >
<div>
<h3>Enter FOAF as Raw Data (Beta) </h3>
<textarea style='height:400px' name="rdf" cols="80" rows="80"><?php echo $rdf; ?></textarea>
<br/><input id="webid" value="<?php echo $_REQUEST['webid'] ?>" type="hidden" name="webid" />
<?php if ($loggedIn) { echo '<input value="Update" type="submit" name="button"/>'; } ?>
<br/>
</div>
</form>
<div>webid : <a rel="webid" href="<?php echo $webid ?>"><?php echo $webid ?></a></div>
<div>validate + graph : <a rel="webid" href="<?php echo "http://www.w3.org/RDF/Validator/ARPServlet?URI=" . urlencode($webid) . "&PARSE=Parse+URI%3A+&TRIPLES_AND_GRAPH=PRINT_BOTH&FORMAT=PNG_EMBED" ?>">Go</a></div>
<?php
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {
require_once("footer.php");
}
?>