Exemple #1
0
 private function delete()
 {
     if (!SMOBAuth::check()) {
         die;
     }
     $post = new SMOBPost(SMOBTools::get_post_uri($this->uri, 'post'));
     $post->delete();
     header("Location: " . SMOB_ROOT);
 }
Exemple #2
0
         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 {
         //  header( 'Location: '.SMOB_ROOT.'auth?redirect=private' ) ;
         //};
         header('Location: ' . SMOB_ROOT . 'auth');
     } else {
         error_log("authenticated");
         if ($a && $a == 'edit') {
             echo PrivateProfile::view_private_profile_form();
         } else {
             echo PrivateProfile::view_private_profile();
             exit;
         }
Exemple #3
0
 public function render()
 {
     global $sioc_nick, $count;
     $uri = $this->uri;
     $content = $this->data['content'];
     $ocontent = strip_tags($content);
     $author = $this->data['author'];
     $creator = $this->data['creator'];
     $date = $this->data['date'];
     $name = $this->data['name'];
     $reply_of = $this->data['reply_of'];
     $reply_of_of = $this->data['reply_of_of'];
     $presence = $this->data['presence'];
     $location = $this->data['location'];
     $locname = $this->data['locname'];
     $star = $this->get_star();
     $pic = SMOBTools::either($this->data['depiction'], SMOB_ROOT . 'img/avatar-blank.jpg');
     $class = strpos($uri, SMOB_ROOT) !== FALSE ? "post internal" : "post external";
     $ht .= "<div about=\"{$presence}\" rel=\"opo:customMessage\">\n";
     $ht .= "<div class=\"{$class}\" typeof=\"sioct:MicroblogPost\" about=\"{$uri}\">\n";
     $ht .= "<span style=\"display:none;\" rel=\"sioc:has_container\" href=\"" . SMOB_ROOT . "\"></span>\n";
     $ht .= "<img about=\"{$author}\" rel=\"foaf:depiction\" href=\"{$pic}\" src=\"{$pic}\" class=\"depiction\" alt=\"Depiction for {$name}\"/>";
     $ht .= "  <span class=\"content\" property=\"content:encoded\">{$content}</span>\n";
     $ht .= "  <span style=\"display:none;\" property=\"sioc:content\">{$ocontent}</span>\n";
     $ht .= '  <div class="infos">';
     $ht .= "  by <a class=\"author\" rel=\"foaf:maker\" href=\"{$author}\"><span property=\"foaf:name\">{$name}</span></a> - \n";
     if ($location) {
         $ht .= "  location: <span about=\"{$presence}\"><a rel=\"opo:currentLocation\" href=\"{$location}\"><span property=\"rdfs:label\">{$locname}</span></a></span><br/>\n";
     } else {
         $ht .= "  location: <span about=\"{$presence}\">unspecified</span><br/>\n";
     }
     $ht .= "  <div style=\"margin: 2px;\"></div> ";
     $ht .= "  <div id=\"star{$count}\" class=\"rating\">&nbsp;</div>";
     $ht .= "  <span style=\"display:none;\" rel=\"sioc:has_creator\" href=\"{$creator}\"></span>\n";
     $ht .= "  <a href=\"{$uri}\" class=\"date\" property=\"dcterms:created\">{$date}</a>\n";
     if (strpos($uri, 'http://twitter.com/') !== FALSE) {
         $ex = explode('/', $uri);
         $data = SMOB_ROOT . 'data/twitter/' . $ex[5];
     } else {
         $data = str_replace('post', 'data', $uri);
     }
     $ht .= " [<a href=\"{$data}\">RDF</a>]\n";
     if (SMOBAuth::check()) {
         if (strpos($uri, SMOB_ROOT) !== FALSE) {
             $ex = explode('/', $uri);
             error_log("DEBUG: post delete path: " . join(' ', $ex), 0);
             error_log("DEBUG: post uri: " . $uri, 0);
             $action = SMOB_ROOT . 'delete/' . $ex[5];
             // the previous line doesn't work as the post is in the position 4
             $action = str_replace('post', 'delete', $uri);
             error_log("DEBUG: is going to be run the action: " . $action, 0);
             $ht .= " [<a href=\"{$action}\" onclick=\"javascript:return confirm('Are you sure ? This cannot be undone.')\">Delete post</a>]";
         }
         $action = $this->get_publish_uri();
         $ht .= " [<a href=\"{$action}\">Post a reply</a>]\n";
     }
     if ($reply_of) {
         $action = SMOBTools::get_uri($reply_of, 'post');
         $ht .= " [<a href=\"{$action}\">Replied message</a>]\n";
     }
     if ($reply_of_of) {
         $action = SMOBTools::get_uri($reply_of_of, 'post');
         $ht .= " [<a href=\"{$action}\">Replies</a>]\n";
     }
     $ht .= '  </div>';
     $ht .= '</div>';
     $ht .= "</div>\n\n";
     $ht .= "<script type=\"text/javascript\">\n\$(document).ready(function(){\n\t\$('#star{$count}').rating('ajax/star.php?u={$uri}', {maxvalue: 1, curvalue: {$star}});\n\t});\n</script>";
     return $ht;
 }
Exemple #4
0
 function getAuth($foafuri = NULL)
 {
     if (!$_SERVER[HTTPS]) {
         return array('isAuthenticated' => 0, 'authDiagnostic' => 'No client certificate supplied on an unsecure connection');
     }
     if (!$_SERVER[SSL_CLIENT_CERT]) {
         return array('isAuthenticated' => 0, 'authDiagnostic' => 'No client certificate supplied');
     }
     error_log('certificate:', 0);
     error_log($_SERVER[SSL_CLIENT_CERT], 0);
     $certrsakey = SMOBAuth::openssl_pkey_get_public_hex();
     if (!$certrsakey) {
         return array('isAuthenticated' => 0, 'authDiagnostic' => 'No RSA Key in the supplied client certificate');
     }
     error_log('rsa key:', 0);
     error_log($certrsakey['modulus'], 0);
     $result = array('certRSAKey' => $certrsakey);
     $san = SMOBAuth::openssl_get_subjectAltName();
     $foafuri = $san[URI];
     error_log('foaf ur:', 0);
     error_log($foafuri, 0);
     $result = array_merge($result, array('subjectAltName' => $foafuri));
     $foafrsakey = SMOBAuth::get_foaf_rsakey($foafuri);
     $result = array_merge($result, array('subjectAltNameRSAKey' => $foafrsakey));
     if (SMOBAuth::equal_rsa_keys($certrsakey, $foafrsakey)) {
         $result = array_merge($result, array('isAuthenticated' => 1, 'authDiagnostic' => 'Client Certificate RSAkey matches SAN RSAkey'));
     } else {
         $result = array_merge($result, array('isAuthenticated' => 0, 'authDiagnostic' => 'Client Certificate RSAkey does not match SAN RSAkey'));
     }
     return $result;
 }
Exemple #5
0
<?php

require_once dirname(__FILE__) . '/../lib/smob/SMOBAuth.php';
require_once dirname(__FILE__) . '/../lib/smob/SMOBStore.php';
require_once dirname(__FILE__) . '/../lib/smob/SMOBTools.php';
require_once dirname(__FILE__) . '/../config/config.php';
error_log("going to authenticate");
SMOBAuth::grant();
error_log("authentication done");
if ($_SESSION['grant'] && isset($_REQUEST['referer'])) {
    error_log("has been authenticated and came from other page, going to the initial page");
    header("Location: " . $_REQUEST['referer']);
    //if ($_SESSION['grant'] && $_GET["redirect"]) {
    //  error_log("has been authenticated and came from other page, going to the initial page");
    //  header("Location: ".SMOB_ROOT.$_GET["redirect"]);
} else {
    error_log("has no been authenticated or did not come from other page, going to the main page");
    header("Location: " . SMOB_ROOT);
}
Exemple #6
0
 public function users($type, $users)
 {
     $ht = '<h2>' . ucfirst($type) . '</h2>';
     if ($users) {
         $ht .= '<ul>';
         foreach ($users as $u) {
             $user = $u['uri'];
             $ht .= "<li><a href='{$user}'>{$user}</a>";
             if (SMOBAuth::check()) {
                 $t = substr($type, 0, -1);
                 $remove = SMOB_ROOT . "remove/{$t}/{$user}";
                 $ht .= " [<a href=\"{$remove}\" onclick=\"javascript:return confirm('Are you sure ? This cannot be undone.')\">remove</a>]";
             }
             $ht .= "</li>";
         }
         $ht .= '</ul>';
     } else {
         $ht .= 'No one at the moment';
     }
     if ($type == 'followings' && SMOBAuth::check()) {
         $ht .= "<p>If you want to follow new people, use the <a href=\"javascript:window.location='" . SMOB_ROOT . "add/following/'+window.location\">Follow in my SMOB!</a> bookmarklet.</p>";
     }
     return $ht;
 }