<?php require_once "config.php"; require_once "db.class.php"; $db = new db_class(); $db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']); $r = $db->insert_sql('CREATE TABLE IF NOT EXISTS `foaf` ( `id` int(11) NOT NULL auto_increment, `username` varchar(255) NOT NULL, `rdf` blob NOT NULL, `rdf2` blob NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1000 ;'); echo "foaf table created in db {$config['db_name']}";
$certrsakey = openssl_pkey_get_public_hex(); $rdf = $_POST['rdf']; if (empty($rdf) || $rdf == '0') { $rdf = '<rdf:RDF'; printrdf(' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'); printrdf(' xmlns:cert="http://www.w3.org/ns/auth/cert#"'); printrdf(' xmlns:rsa="http://www.w3.org/ns/auth/rsa#">'); printrdf('<rsa:RSAPublicKey>'); $foaffile = $subjectAltName['URI'] ? $subjectAltName['URI'] : 'TYPE YOUR WEBID HERE'; printrdf(' <cert:identity rdf:resource="' . $foaffile . '"/>'); printrdf(' <rsa:public_exponent cert:decimal="'); $exponent = $certrsakey['exponent'] ? hexdec($certrsakey['exponent']) : 'TYPE THE EXPONENT OF YOUR PUBLIC KEY HERE'; printrdf($exponent . '"/>'); printrdf(' <rsa:modulus cert:hex="'); $modulus = $certrsakey['modulus'] ? $certrsakey['modulus'] : 'TYPE THE MODULUS OF YOUR PUBLIC RSA KEY HERE'; printrdf($modulus . '"/>'); printrdf('</rsa:RSAPublicKey>'); printrdf('</rdf:RDF>'); } $res = $db->select(" select * from foaf where username like '{$_POST['uri']}' "); if ($db->row_count == 0) { $db->insert_sql(" insert into foaf (id, username, rdf) VALUES (NULL, '{$_POST['uri']}', '{$rdf}') "); } else { $db->update_sql(" update foaf set rdf = '{$_POST['rdf']}' , rdf2 = '{$rdf}' where username like '{$_POST['uri']}' "); } print "Congratulations, you have successfully created a foaf file, which can be permanently accessed here: <br/><br/><a href='http://{$_SERVER['HTTP_HOST']}/{$_POST['uri']}'>http://{$_SERVER['HTTP_HOST']}/{$_POST['uri']}</a>"; ?> </div> </body> </html>
xmlns:rsa="http://www.w3.org/ns/auth/rsa#" xmlns:cert="http://www.w3.org/ns/auth/cert#" xmlns:admin="http://webns.net/mvcb/"> <foaf:PersonalProfileDocument rdf:about=""> <foaf:maker rdf:resource="#me"/> <foaf:primaryTopic rdf:resource="#me"/> </foaf:PersonalProfileDocument> <foaf:Person rdf:ID="me"> <foaf:mbox_sha1sum>' . substr($username, 5) . '</foaf:mbox_sha1sum> </foaf:Person> </rdf:RDF>'; //rdfLog('insert', $username, $webid, NULL, $rdf); $db->insert_sql(" insert into foaf (id, username, rdf) VALUES (NULL, '{$username}', '{$rdf}') "); xmlheader($xsl); print $rdf; } else { // logger('/home/foaf/www/datawiki/insert.log', $webid, $username); $rdf = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rsa="http://www.w3.org/ns/auth/rsa#" xmlns:cert="http://www.w3.org/ns/auth/cert#" xmlns:admin="http://webns.net/mvcb/"> <foaf:PersonalProfileDocument rdf:about=""> <foaf:maker rdf:resource="#me"/> <foaf:primaryTopic rdf:resource="#me"/>