<?php require_once dirname(__FILE__) . '/common.php'; if (isset($_GET['logout'])) { $_SESSION = array(); } checkOpenID(); #$rdf->reset(); $rdf->query('BASE <.> LOAD </../brondsema.n3>') or throw new Exception (print_r($rdf->getErrors(),true)); if ($_SESSION['openid'] and !$_SESSION['id']) { # TODO: check ?p URI to match the URIs we use, or have a foaf:Group for the family, just in case other foaf:Persons get LOADed in $q = $prefixes . "\n SELECT ?p ?name\n WHERE { ?p foaf:openid <{$_SESSION['openid']}>\n OPTIONAL { ?p foaf:name ?name . }\n }"; $me = $rdf->query($q, 'row'); # set up a new account if ($_SESSION['openid'] == $admin_openid and !isset($me['p'])) { $r = $rdf->query($prefixes . "INSERT INTO <{$rdf_uri_prefix}/graph> {\n <" . get_next_uri($rdf, 'person') . "> a foaf:Person;\n foaf:openid <{$admin_openid}>;\n foaf:name 'New Admin User - Please change to your name' .\n }"); if (!$r) { throw new Exception(print_r($rdf->getErrors(), true)); } # requery $me = $rdf->query($q, 'row'); } if ($me['p']) { $_SESSION['id'] = $me['p']; } if ($me['name']) { $_SESSION['name'] = $me['name']; } else { $_SESSION['name'] = $_SESSION['openid']; } } ?>
# this deletes all previous occurrences of $s $p _ function replace($rdf, $s, $p, $o, $old_o) { global $prefixes; $q = $prefixes . "DELETE { <{$s}> {$p} ?o . }"; #echo $q; $rmod = $rdf->query($q); #print_r($rmod); if ($rdf->getErrors()) { throw new Exception(print_r($rdf->getErrors(), true)); } insert($rdf, $s, $p, $o); } if ($id == null) { # new $id = get_next_uri($rdf, 'person'); # TODO: maybe a way to send 'foaf:Person' without it being inserted as a string insert($rdf, $id, 'a', '<http://xmlns.com/foaf/0.1/Person>'); if ($_POST['name']) { insert($rdf, $id, 'foaf:name', $_POST['name']); } if ($_POST['email']) { insert($rdf, $id, 'foaf:mbox', '<mailto:' . $_POST['email'] . '>'); } if ($_POST['web']) { insert($rdf, $id, 'foaf:homepage', '<' . $_POST['web'] . '>'); } if ($_POST['bday']) { insert($rdf, $id, 'foaf:bday', $_POST['bday'] . '^^xs:date'); } if ($_POST['gender']) {