Пример #1
0
function viewShortInfo($webid, $me, $base_uri, $endpoint)
{
    // fetch info for webid
    $ret = '';
    $person = new MyProfile($webid, $base_uri, $endpoint);
    $person->load();
    $profile = $person->get_profile();
    // find if he has me in his list of foaf:knows!
    $has_me = false;
    if (in_array($me, $profile->all('foaf:knows'))) {
        $has_me = true;
    }
    // check if the user has subscribed to local messages
    $is_subscribed = strlen($person->get_hash()) > 0 ? true : false;
    // start populating array
    $friend = array('webid' => (string) $webid, 'img' => (string) $person->get_picture(), 'name' => (string) $profile->get("foaf:name"), 'nick' => (string) $profile->get("foaf:nick"), 'email' => (string) $profile->get("foaf:mbox"), 'blog' => (string) $profile->get("foaf:weblog"), 'pingback' => (string) $profile->get("http://purl.org/net/pingback/to"), 'hash' => $person->get_hash(), 'hasme' => $has_me);
    if (isset($new)) {
        $friend['new'] = $new;
    }
    $ret .= "<table>\n";
    $ret .= "<tr bgcolor=\"\"><td>\n";
    $ret .= "<table><tr>\n";
    $ret .= "<td width=\"70\" style=\"vertical-align: top; padding: 10px;\">\n";
    $ret .= "<div align=\"left\"><a href=\"view.php?webid=" . urlencode($friend['webid']) . "\" target=\"_blank\">";
    $ret .= "<img title=\"" . $friend['name'] . "\" alt=\"" . $friend['name'] . ".\" width=\"64\" src=\"" . $friend['img'] . "\" />";
    $ret .= "</a></div>\n";
    $ret .= "</td>\n";
    $ret .= "<td><table>\n";
    if ($friend['name'] != null) {
        $ret .= "<tr><td><strong>" . $friend['name'] . "</strong>\n";
    } else {
        $ret .= "<tr><td><strong>Anonymous</strong>\n";
    }
    if ($friend['nick'] != null) {
        $ret .= "''" . $friend['nick'] . "''";
    }
    $ret .= "</td></tr>\n";
    if ($friend['hasme'] == true) {
        $ret .= "<tr><td><div style=\"color:#60be60;\">Has you as friend.</div></td></tr>\n";
    }
    //$ret .= "<tr><td>&nbsp;</td></tr>\n";
    if ($friend['email'] != null) {
        $ret .= "<tr><td>Email: <a href=\"" . $friend['email'] . "\">" . clean_mail($friend['email']) . "</a></td></tr>\n";
    }
    if ($friend['blog'] != null) {
        $ret .= "<tr><td>Blog:<a href=\"" . $friend['blog'] . "\">" . $friend['blog'] . "</a></td></tr>\n";
    }
    $ret .= "<tr><td>WebID: <a href=\"view.php?webid=" . urlencode($friend['webid']) . "\">" . $friend['webid'] . "</a></td></tr>\n";
    $ret .= "</table>\n";
    $ret .= "<br/><table>\n";
    $ret .= "<tr>\n";
    // add or remove friends if we have them in our list
    if (isset($_SESSION['webid']) && webid_is_local($_SESSION['webid'])) {
        if ($_SESSION['myprofile']->is_friend($webid)) {
            // remove friend
            $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
            $ret .= "<input type=\"hidden\" name=\"action\" value=\"delfriend\">\n";
            $ret .= "<input type=\"hidden\" name=\"uri\" value=\"" . $friend['webid'] . "\">\n";
            $ret .= "<input src=\"img/actions/remove.png\" type=\"image\" title=\"Remove friend\" name=\"submit\" value=\" Remove \">\n";
            $ret .= "</form></td>\n";
        } else {
            // add friend
            $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
            $ret .= "<input type=\"hidden\" name=\"action\" value=\"addfriend\">\n";
            $ret .= "<input type=\"hidden\" name=\"uri\" value=\"" . $friend['webid'] . "\">\n";
            $ret .= "<input src=\"img/actions/add.png\" type=\"image\" title=\"Add friend\" name=\"submit\" value=\" Add \">\n";
            $ret .= "</form></td>\n";
        }
    }
    // send messages using the pingback protocol
    if ($friend['pingback'] != null) {
        $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"messages.php\" method=\"POST\">\n";
        $ret .= "<input type=\"hidden\" name=\"new\" value=\"true\">\n";
        $ret .= "<input type=\"hidden\" name=\"to\" value=\"" . $friend['webid'] . "\">\n";
        $ret .= "<input src=\"img/actions/message.png\" type=\"image\" title=\"Send a message\" name=\"submit\" value=\" Message \" onclick=\"this.form.target='_blank';return true;\">\n";
        $ret .= "</form></td>\n";
    }
    // more functions if the user has previously subscribed to the local services
    if ($is_subscribed) {
        // Post on the user's wall
        $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"wall.php\" method=\"POST\">\n";
        $ret .= "<input type=\"hidden\" name=\"user\" value=\"" . $friend['hash'] . "\">\n";
        $ret .= "<input src=\"img/actions/wall.png\" type=\"image\" title=\"View posts\" name=\"submit\" value=\" Wall \" onclick=\"this.form.target='_blank';return true;\">\n";
        $ret .= "</form></td>\n";
    }
    $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"GET\">\n";
    $ret .= "<input type=\"hidden\" name=\"webid\" value=\"" . $friend['webid'] . "\">\n";
    $ret .= "<input type=\"hidden\" name=\"me\" value=\"" . $me . "\">\n";
    $ret .= "<input src=\"img/actions/friends.png\" type=\"image\" title=\"View friends\" name=\"submit\" value=\" Friends \">\n";
    $ret .= "</form></td>\n";
    $ret .= "</tr></table></p>\n";
    $ret .= "</td>\n";
    $ret .= "</tr></table>\n";
    $ret .= "</td></tr>\n";
    $ret .= "</table>\n";
    return $ret;
}
Пример #2
0
}
if (isset($_REQUEST['webid'])) {
    $ret .= '<div>';
    $ret .= "<h3 class=\"demoHeaders\">Details for WebID: <a href=\"" . urldecode($_REQUEST['webid']) . "\">";
    if (strlen($_REQUEST['webid']) > 50) {
        $ret .= substr(urldecode($_REQUEST['webid']), 0, 47) . '...';
    } else {
        $ret .= urldecode($_REQUEST['webid']);
    }
    $ret .= "</a></h3><p>(view  <a href=\"view.php?html=0&webid=" . urlencode($_REQUEST['webid']) . "\">RDF</a> or \n";
    $ret .= "</a></h3><a href=\"view.php?html=1&webid=" . urlencode($_REQUEST['webid']) . "\">normal</a>?)</p><br/>\n";
    // graph
    $person = new MyProfile(urldecode($_REQUEST['webid']), BASE_URI, SPARQL_ENDPOINT);
    $person->load(true);
    $graph = $person->get_graph();
    $profile = $person->get_profile();
    // sameAs is disabled until further notice
    //$profile->loadSameAs();
    // check if the user has subscribed to local messages
    $is_subscribed = strlen($person->get_hash()) > 0 ? true : false;
    $ret .= "<table><tr>\n";
    // add or remove friends if we have them in our list
    if (isset($_SESSION['webid']) && webid_is_local($_SESSION['webid'])) {
        if ($_SESSION['myprofile']->is_friend($_REQUEST['webid'])) {
            // remove friend
            $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
            $ret .= "<input type=\"hidden\" name=\"action\" value=\"delfriend\">\n";
            $ret .= "<input type=\"hidden\" name=\"webid\" value=\"" . $_REQUEST['webid'] . "\">\n";
            $ret .= "<input src=\"img/actions/remove.png\" type=\"image\" title=\"Remove friend\" name=\"submit\" value=\" Remove \">\n";
            $ret .= "</form></td>\n";
        } else {
Пример #3
0
function sendPing($to, $message, $base_uri, $verbose = false)
{
    $ret = "<br/>\n";
    $to = trim($to);
    // fetch the user's profile
    $person = new MyProfile($to, $base_uri, SPARQL_ENDPOINT);
    $person->load();
    $profile = $person->get_profile();
    $to_name = $person->get_name();
    $to_email = $person->get_email();
    $pingback_service = $profile->get("pingback:to");
    // set form data
    $source = $_SESSION['webid'];
    // parse the pingback form
    $config = array('auto_extract' => 0);
    $parser = ARC2::getSemHTMLParser($config);
    $parser->parse($pingback_service);
    $parser->extractRDF('rdfa');
    // load triples
    $triples = $parser->getTriples();
    // proceed only if the user has defined a pingback:to relation
    if ($pingback_service != null) {
        if (sizeof($triples) > 0) {
            //echo "<pre>" . print_r($triples, true) . "</pre>\n";
            foreach ($triples as $triple) {
                // proceed only if we have a valid pingback resource
                if ($triple['o'] == 'http://purl.org/net/pingback/Container') {
                    $fields = array('source' => $source, 'target' => $to, 'comment' => $message);
                    // Should really replace curl with an ajax call
                    //open connection to pingback service
                    $ch = curl_init();
                    //set the url, number of POST vars, POST data
                    curl_setopt($ch, CURLOPT_URL, $pingback_service);
                    curl_setopt($ch, CURLOPT_POST, count($fields));
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    //execute post
                    $return = curl_exec($ch);
                    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                    //close connection
                    curl_close($ch);
                    if ($httpCode == '201' || $httpCode == '202') {
                        $ret .= success('Message delivered!');
                    } else {
                        $ret .= error('Something happened and I couldn\'t deliver the message!');
                        $ret .= "<p>Details:</p>\n";
                        $ret .= "</p>" . $return . "</p>\n";
                    }
                    break;
                }
            }
        } else {
            $ret .= "   <p>{$pingback_service} does not comply with semantic pingback standards! Showing the pingback service page instead.</p>\n";
            // show frame
            $ret .= "   <iframe src=\"{$pingback_service}\" width=\"100%\" height=\"300\">\n";
            $ret .= "   <p>Your browser does not support iframes.</p>\n";
            $ret .= "   </iframe>\n";
        }
    } else {
        // no valid pingback service found, fallback to AKSW
        $ret .= "   <p>Could not find a pingback service for the given WebID. Here is a generic pingback service provided by http://pingback.aksw.org/.</p>\n";
        $ret .= "   <iframe src=\"http://pingback.aksw.org/\" width=\"100%\" height=\"300\">\n";
        $ret .= "   <p>Your browser does not support iframes.</p>\n";
        $ret .= "   </iframe>\n";
    }
    if ($verbose) {
        return $ret;
    }
}