示例#1
0
 public function rss_header()
 {
     $version = SMOBTools::version();
     $owner = SMOBTools::ownername();
     $title = "SMOB Hub of {$owner}";
     $ts = date('c');
     return "<?xml version='1.0' encoding='utf-8'?>\n\n<rdf:RDF\n\txmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n\txmlns:dc='http://purl.org/dc/elements/1.1/'\n\txmlns='http://purl.org/rss/1.0/'\n\txmlns:dcterms='http://purl.org/dc/terms/'\n\txmlns:cc='http://web.resource.org/cc/'\n\txmlns:content='http://purl.org/rss/1.0/modules/content/'\n\txmlns:admin='http://webns.net/mvcb/'\n\txmlns:atom='http://www.w3.org/2005/Atom'\n> \n\n<channel rdf:about='" . SMOB_ROOT . "'>\n\t<title>{$title}</title>\n\t<link>" . SMOB_ROOT . "</link>\n\t<atom:link rel='hub' href='" . HUB_URL_SUBSCRIBE . "'/>\n\t<description>{$title}</description>\n\t<dc:creator>{$owner}</dc:creator>\n\t<dc:date>{$ts}</dc:date>\n\t<admin:generatorAgent rdf:resource='http://smob.me/#smob?v={$version}' />\n\t<items>\n\t\t<rdf:Seq>\n";
 }
示例#2
0
 function get_uris()
 {
     $uri = "http://api.sindice.com/v2/search?page=1&q=" . urlencode($this->item) . "&qt=term&format=json";
     $res = SMOBTools::do_curl($uri);
     $json = json_decode($res[1], true);
     foreach ($json['entries'] as $j) {
         $r[$j['title'][0]] = $j['link'];
     }
     return $r;
 }
示例#3
0
 private function get_location()
 {
     $loc = SMOBTools::location();
     if ($loc) {
         $uri = $loc[0];
         $loc = SMOBStore::query("SELECT ?lat ?long WHERE { <{$uri}> geo:lat ?lat ; geo:long ?long .}");
         return array($loc[0]['lat'], $loc[0]['long']);
     } else {
         return array(0, 0);
     }
 }
示例#4
0
 function get_uris()
 {
     $uri = "http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryString=" . urlencode($this->item) . "&QueryClass=&MaxHits=10";
     $res = SMOBTools::do_curl($uri, null, null, 'GET');
     $xml = simplexml_load_string($res[0]);
     foreach ($xml->Result as $x) {
         // That shall work with an XML method
         $vars = get_object_vars($x);
         $r[$vars['Label']] = $vars['URI'];
     }
     return $r;
 }
示例#5
0
 function get_uris()
 {
     $uri = "http://ws.geonames.org/searchJSON?q=" . urlencode($this->item) . "&maxRows=10";
     $res = SMOBTools::do_curl($uri);
     $json = json_decode($res[1], true);
     foreach ($json['geonames'] as $j) {
         $uri = "http://sws.geonames.org/" . $j['geonameId'] . "/";
         $name = $j['name'] . '(' . $j['countryName'] . ')';
         $r[$name] = $uri;
     }
     return $r;
 }
示例#6
0
 private function load_tweet($tweet)
 {
     $id = $tweet->id;
     $username = $tweet->user->screen_name;
     $local = $this->user;
     $uri = "http://twitter.com/{$username}/status/{$id}";
     $content = $tweet->text;
     $userid = $tweet->user->id;
     $name = $tweet->user->name;
     $ts = date('c', time($tweet->created_at));
     $user_uri = "http://twitter.com/{$username}";
     $user_foaf_uri = "http://twitter.com/{$username}#me";
     $depiction = $tweet->user->profile_image_url;
     $triples = array();
     $triples[] = array(SMOBTools::uri($uri), "a", "sioct:MicroblogPost");
     $triples[] = array("sioc:has_container", SMOBTools::uri('http://twitter.com/'));
     $triples[] = array("sioc:has_creator", SMOBTools::uri($user_uri));
     $triples[] = array("foaf:maker", SMOBTools::uri($user_foaf_uri));
     $triples[] = array("dct:created", SMOBTools::date($ts));
     $triples[] = array("dct:title", SMOBTools::literal("Update - " . $ts));
     $triples[] = array("sioc:content", SMOBTools::literal($content));
     if (strpos($content, '@' . $this->user) !== false) {
         $triples[] = array("sioc:addressed_to", SMOBTools::uri(FOAF_URI));
         $triples[] = array("sioc:addressed_to", SMOBTools::uri('http://twitter.com/' . $this->user . '#me'));
         $triples[] = array(SMOBTools::uri(FOAF_URI), 'sioc:name', SMOBTools::literal($this->user));
         $triples[] = array(SMOBTools::uri('http://twitter.com/' . $this->user . '#me'), 'sioc:name', SMOBTools::literal($this->user));
     }
     $triples[] = array(SMOBTools::uri($user_foaf_uri), "foaf:name", SMOBTools::literal($name));
     $triples[] = array("foaf:depiction", SMOBTools::uri($depiction));
     $opo_uri = $uri . '#presence';
     $triples[] = array(SMOBTools::uri($opo_uri), "a", "opo:OnlinePresence");
     $triples[] = array("opo:declaredOn", SMOBTools::uri($user_uri));
     $triples[] = array("opo:declaredBy", SMOBTools::uri($user_foaf_uri));
     $triples[] = array("opo:StartTime", SMOBTools::date($ts));
     $triples[] = array("opo:customMessage", SMOBTools::uri($uri));
     $graph = SMOB_ROOT . "data/twitter/{$id}";
     $rdf = SMOBTools::render_sparql_triples($triples);
     $query = "INSERT INTO <{$graph}> { {$rdf} }";
     $res = SMOBStore::query($query);
 }
示例#7
0
 function query($query, $ask = false)
 {
     global $arc_config;
     if (!$arc_config) {
         include_once dirname(__FILE__) . '/../arc/ARC2.php';
         include_once dirname(__FILE__) . '/../../config/config.php';
     }
     $store = ARC2::getStore(SMOBTools::arc_config());
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     $query = "\n\tPREFIX sioc: <http://rdfs.org/sioc/ns#>\n\tPREFIX sioct: <http://rdfs.org/sioc/types#>\n\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\tPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\tPREFIX dct: <http://purl.org/dc/terms/>\n\tPREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>\n\tPREFIX moat: <http://moat-project.org/ns#>\n\tPREFIX opo: <http://online-presence.net/opo/ns#>\n\tPREFIX opo-actions: <http://online-presence.net/opo-actions/ns#>\n\tPREFIX ctag: <http://commontag.org/ns#>\n\tPREFIX smob: <http://smob.me/ns#>\n\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\tPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\tPREFIX rev: <http://purl.org/stuff/rev#>\n\tPREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>\n\tPREFIX rel: <http://purl.org/vocab/relationship/>\n\n\t\t{$query}";
     $rs = $store->query($query);
     if ($errors = $store->getErrors()) {
         error_log("SMOB SPARQL Error:\n" . join("\n", $errors));
         return array();
     }
     if ($ask) {
         return $rs['result'];
     } else {
         return $rs['result']['rows'];
     }
 }
示例#8
0
文件: index.php 项目: anukat2015/smob
     if (array_key_exists('REMOTE_HOST', $_SERVER)) {
         //&& ($_SERVER['REMOTE_HOST'] == HUB_URL_SUBSCRIBE)) {
         error_log("DEBUG: request from host: " . $_SERVER['REMOTE_HOST']);
     }
     if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
         error_log("DEBUG: request from user_agent: " . $_SERVER['REMOTE_HOST']);
     }
     // Getting hub_challenge from hub after sending it post subscription
     if (isset($_GET["hub_challenge"])) {
         // send confirmation to the hub
         echo $_GET["hub_challenge"];
         error_log("DEBUG: received and sent back hub challenge:" . $_GET["hub_challenge"], 0);
     } elseif (isset($_POST)) {
         $post_data = file_get_contents("php://input");
         error_log("DEBUG: received POST with content: {$post_data}", 0);
         SMOBTools::get_rdf_from_rss($post_data);
     } elseif (isset($_DELETE)) {
         $post_data = file_get_contents("php://input");
         error_log("DEBUG: received DELETE with content: {$post_data}", 0);
     } elseif (isset($_PUT)) {
         $post_data = file_get_contents("php://input");
         error_log("DEBUG: received PUT with content: {$post_data}", 0);
     }
 } elseif ($t == 'private') {
     // TODO: The private profile graph is the same as the profile graph, privacy preferences will decide what is visible
     // TODO: Authorize depending on the WebID URI
     if (!SMOBAuth::check()) {
         error_log("not authenticated");
         //if($a && $a == 'edit'){
         //  header( 'Location: '.SMOB_ROOT.'auth?redirect=private/edit' ) ;
         //} else {
示例#9
0
 public function tweet()
 {
     $dest = 'http://twitter.com/statuses/update.xml';
     $postfields = 'status=' . urlencode($this->content) . '&source=smob';
     $userpwd = TWITTER_USER . ':' . TWITTER_PASS;
     SMOBTools::do_curl($dest, $postfields, $userpwd);
     print '<li>Notified on Twitter !</li>';
 }
示例#10
0
文件: SMOB.php 项目: anukat2015/smob
 private function followers()
 {
     return SMOBTemplate::users($this->type, SMOBTools::followers());
 }
示例#11
0
function setupUser()
{
    include_once dirname(__FILE__) . '/../config/config.php';
    $foaf_uri = $_GET['foaf_uri'];
    $twitter_read = $_GET['twitter_read'] == 'on' ? 1 : 0;
    $twitter_post = $_GET['twitter_post'] == 'on' ? 1 : 0;
    $twitter_login = $_GET['twitter_login'];
    $twitter_pass = $_GET['twitter_pass'];
    $auth = $_GET['auth'];
    if ($foaf_uri) {
        if (!SMOBTools::checkFoaf($foaf_uri)) {
            print "<p>An error occurred with your FOAF URI. <b>Please ensure that it dereferences to an RDF file and that this file contains information about your URI.<b><br/>You will have to <a href='{$smob_root}'>restart the install process<a/></p>";
            unlink(dirname(__FILE__) . '/../config/config.php');
            die;
        }
    } else {
        if (!$foaf_uri) {
            $foaf_uri = SMOB_ROOT . 'me#id';
            $username = $_GET['username'];
            $depiction = $_GET['depiction'];
            $profile = "\nINSERT INTO <" . SMOB_ROOT . "/profile> {\t\t\t\n<{$foaf_uri}> a foaf:Person ; \n\tfoaf:name \"{$username}\" ;\n\tfoaf:depiction <{$depiction}> .\n}";
            SMOBStore::query($profile);
        }
    }
    $config = "\ndefine('FOAF_URI', '{$foaf_uri}');\n\ndefine('TWITTER_READ', '{$twitter_read}');\ndefine('TWITTER_POST', '{$twitter_post}');\n\ndefine('TWITTER_USER', '{$twitter_login}');\ndefine('TWITTER_PASS', '{$twitter_pass}');\n\ndefine('AUTH', '{$auth}');\n\t\t\n?>";
    $f = fopen(dirname(__FILE__) . '/../config/config.php', 'a');
    fwrite($f, $config);
    fclose($f);
    print "<p>Enjoy, you can now access your <a href='.'>SMOB Hub</a> !<br/>\n\tLog-in using the 'Authenticate' link and start writing microblog po.<br/>\n\tAlso, be sure to restrict access to the <code>config/</code> directory.</p>";
}
示例#12
0
<?php

require_once dirname(__FILE__) . '/../lib/smob/SMOBTools.php';
$query = $_GET['query'];
$uri = "http://ws.geonames.org/searchJSON?q=" . urlencode($query) . "&maxRows=10";
$res = SMOBTools::do_curl($uri);
$json = json_decode($res[1], true);
foreach ($json['geonames'] as $j) {
    $uri = "http://sws.geonames.org/" . $j['geonameId'] . "/";
    $name = $j['name'] . ', ' . $j['countryName'] . ' (' . $j['fcodeName'] . ')';
    $suggestions .= "'{$name}',";
    $data .= "'{$uri}',";
}
$s = substr($suggestions, 0, -1);
$d = substr($data, 0, -1);
print "{ query:'{$query}',suggestions:[{$s}],data:[{$d}] }";
示例#13
0
文件: cron.php 项目: anukat2015/smob
<?php

require_once dirname(__FILE__) . '/lib/smob/SMOB.php';
require_once dirname(__FILE__) . "/config/config.php";
// Get tweets
if (TWITTER_READ) {
    echo 'on lit twitter';
    $tweet = new SMOBTweet();
    $tweet->getposts();
}
// Purge messages
if (PURGE > 0) {
    SMOBTools::purge(PURGE);
}
示例#14
0
 public function person($person, $uri)
 {
     $names = SMOBTools::either($person['names'], array("Anonymous"));
     $imgs = SMOBTools::either($person['images'], array(SMOB_ROOT . '../img/avatar-blank.jpg'));
     $homepage = $person['homepage'];
     $weblog = $person['weblog'];
     $knows = $person['knows'];
     $name = $names[0];
     $pic = $imgs[0];
     $ht = "<div class=\"person\">\n";
     $ht .= "<img src=\"{$pic}\" class=\"depiction\" alt=\"Depiction\" />";
     $ht .= "{$name}\n";
     foreach ($homepage as $h) {
         $ht .= " [<a href=\"{$h}\">Website</a>]\n";
     }
     foreach ($weblog as $w) {
         $ht .= " [<a href=\"{$w}\">Blog</a>]\n";
     }
     foreach ($knows as $k) {
         $enc = get_uri($k, 'user');
         $ht .= " [<a href=\"{$enc}\">Friend</a>]\n";
     }
     $ht .= "</div>\n\n";
     return $ht;
 }
示例#15
0
 function rss2rdf($post_data)
 {
     // Function to convert RSS to RDF, some elements as tags will be missing
     //@FIXME: this solution is a bit hackish
     $post_data = str_replace('dc:date', 'dc_date', $post_data);
     // Parsing the new feeds to load in the triple store
     $xml = simplexml_load_string($post_data);
     if (count($xml) == 0) {
         return;
     }
     error_log("DEBUG: xml received from publisher: " . print_r($xml, 1), 0);
     foreach ($xml->item as $item) {
         $link = (string) $item->link;
         $date = (string) $item->dc_date;
         $description = (string) $item->description;
         $site = SMOBTools::host($link);
         $author = $site . "/me";
         $query = "INSERT INTO <{$link}> {\n            <{$site}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://smob.me/ns#Hub> .\n            <{$link}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/types#MicroblogPost> .\n            <{$link}> <http://rdfs.org/sioc/ns#has_container> <{$site}> .\n            <{$link}> <http://rdfs.org/sioc/ns#has_creator> <{$author}> .\n            <{$link}> <http://xmlns.com/foaf/0.1/maker> <{$author}#id> .\n            <{$link}> <http://purl.org/dc/terms/created> \"{$date}\"^^<http://www.w3.org/2001/XMLSchema#dateTime> .\n            <{$link}> <http://purl.org/dc/terms/title> \"Update - {$date}\"^^<http://www.w3.org/2001/XMLSchema#string> .\n            <{$link}> <http://rdfs.org/sioc/ns#content> \"{$description}\"^^<http://www.w3.org/2001/XMLSchema#string> .\n            <{$link}#presence> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://online-presence.net/opo/ns#OnlinePresence> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#declaredOn> <{$author}> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#declaredBy> <{$author}#id> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#StartTime> \"{$date}\"^^<http://www.w3.org/2001/XMLSchema#dateTime> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#customMessage> <{$link}> . }";
         SMOBStore::query($query);
         error_log("DEBUG: Added the triples: {$query}", 0);
     }
 }
示例#16
0
 function get_uris()
 {
     return array($this->item => SMOBTools::get_uri_if_found("http://twitter.com/" . $this->item));
 }
示例#17
0
 function view_private_profile()
 {
     $turtle = SMOBTools::triples_from_graph(SMOB_ROOT . "me");
     header('Content-Type: text/turtle; charset=utf-8');
     return $turtle;
 }