$pwd = 'moustache';
$digest = makeDigest($pwd, $nonce, $time);
include_once 'Blogmarks/Marker.php';
$marker =& Blogmarks_Marker::singleton();
$auth = $marker->authenticate($user, $digest, $nonce, $time, false);
// AUTH OK :)
if (!Blogmarks::isError($auth)) {
    $params = array('user_login' => 'znarf', 'order_by' => array('created', 'DESC'), 'select_priv' => true);
    $e = $marker->createMark(array('title' => 'StandBlog', 'tags' => array('standards', 'blog', 'fr'), 'href' => 'http://www.standblog.com', 'via' => 'http://dev.upian.com/hotlinks', 'source' => 'http://upian.net/znarf/carnet'));
    if (Blogmarks::isError($e)) {
        echo $e->getMessage() . "\n\n";
    } else {
        echo "Mark [{$e->id}] ajouté avec succès :)\n";
    }
    $list =& $marker->getMarksList($params);
    if (Blogmarks::isError($list)) {
        echo $list->getMessage() . "\n\n";
    }
    echo "Récupération des Marks de znarf : \n";
    while ($list->fetch()) {
        echo "\n ** {$list->title} \n";
        foreach ($list->getTags() as $tag) {
            echo " [{$tag}] ";
        }
        echo "\n";
    }
} else {
    echo "*** Erreur : " . $auth->getMessage() . "\n";
}
# -------------------------------------------------------------------------------
/***/
Example #2
0
<?php 
include 'includes/header.inc.php';
?>

<div id="content">

<h3>Insert a bookmark</h3>

<?php 
if ($marker->userIsAuthenticated()) {
    $array_tags = explode(" ", trim($_POST['tags']));
    $params = array('related' => trim($_POST['url']), 'title' => trim($_POST['title']), 'summary' => $_POST['description'], 'via' => trim($_POST['via']), 'tags' => $array_tags, 'public' => true);
    print_r($params);
    $result =& $marker->createMark($params);
    if (Blogmarks::isError($result)) {
        die($result->getMessage());
    }
    if (DB::isError($result)) {
        die($result->getMessage());
    }
    echo '<p>Mark Sucessfully inserted !</p>' . "\n";
    echo '<p>URI:<br />' . print_r($result) . '</p>' . "\n";
} else {
    ?>

	<p>You are not logged !</p>

	<!-- 
	<form method="POST" action="add.php?connect=1">
Example #3
0
 /** Renvoie la liste des Marks d'un utilisateur.
  * Si l'utilisateur requeteur n'est pas l'utilisateur possesseur, 
  * seule la liste de ses Marks publics de l'utilisateur possesseur est renvoyée.
  *
  * @param      string      $login_user      
  * @param      array       $include_tags    Ids de Tags, seuls les Marks correspondants aux Tags listés ici seront sélectionnés
  * @param      array       $exclude_tags    Ids de Tags, les Marks correspondants à ces Tags ne seront pas sélectionnés
  *
  */
 function getMarksListOfUser($login_user, $include_tags = null, $exclude_tags = null)
 {
     // permissions
     $cur_user =& $this->_slots['auth']->getConnectedUser();
     if (Blogmarks::isError($cur_user)) {
         return $cur_user;
     }
     $include_priv = $cur_user->login === $login_user ? true : false;
     // On vérifie que l'utilisateur existe
     $user =& Element_Factory::makeElement('Bm_Users');
     if (!$user->get('login', $login_user)) {
         return Blogmarks::raiseError("L'utilisateur [{$login_user}] n'existe pas", 404);
     }
     // Récupération de la liste des Marks
     $res = $user->getMarksList($include_tags, $exclude_tags, $include_priv);
     return $res;
 }
Example #4
0
 function execute($arg)
 {
     // Récupère la ligne X-WSSE du header
     $headers = apache_request_headers();
     $auth_line = '';
     foreach ($headers as $header => $value) {
         if ($header == "X-WSSE") {
             $auth_line = $value;
         }
     }
     if ($auth_line != '') {
         // on récupère les informations du header
         $pattern = 'Username="******", PasswordDigest="(.+)",';
         $pattern .= ' Nonce="(.+)", Created="(.+)"';
         if (ereg($pattern, $auth_line, $regs)) {
             $marker = new BlogMarks_Marker();
             echo "authentifie ...\n";
             $auth_str = $marker->authenticate($regs[1], $regs[2], $regs[3], $regs[4]);
             if (Blogmarks::isError($auth_str)) {
                 echo "Error :" . $auth_str->getMessage() . "\n";
             }
             $arg['auth_str'] = $auth_str;
         } else {
             return BlogMarks::raiseError("Erreur à la ligne X-WSSE : {$pattern} ne vérfifie pas {$auth_line}", 400);
         }
     }
     // passe au filtre suivant
     if ($this->_hasChild) {
         $tmp =& $this->_childFilter;
         return $tmp->execute($arg);
     }
 }
Example #5
0
 if ($_GET['section'] == 'PublicMarks') {
     echo $owner . " - ";
 }
 $link = $list->getLink('related');
 echo '<a href="' . $link->href . '">' . $list->title . '</a>';
 if (strlen($list->summary)) {
     echo ' : ' . $list->summary;
 }
 //	echo ' (' . dcdate2php( $list->created ) . ')';
 if (isset($login) and $owner == $login) {
     $private = true;
 } else {
     $private = false;
 }
 $tags_id = $marker->getTags($list->id);
 if (Blogmarks::isError($tags_id)) {
     echo $tags_id->getMessage();
 } else {
     foreach ($marker->getTags($list->id) as $tag_id) {
         $tag = $marker->getTag($tag_id);
         if ($tag->author != NULL) {
             // tag privé
             $link = ' <a class="private_tag" href="?include_tags=private:' . $tag->title . '"';
         } else {
             // tag public
             $link = ' <a class="public_tag" href="?include_tags=' . $tag->title . '"';
         }
         if (isset($tag->summary) && $tag->summary != '') {
             $link .= ' title="' . $tag->summary . '"';
         }
         $link .= '>[' . $tag->title . ']</a> ';
Example #6
0
 function execute($arg)
 {
     // Récupère la ligne X-WSSE du header
     $headers = apache_request_headers();
     $auth_line = '';
     foreach ($headers as $header => $value) {
         if ($header == "X-WSSE") {
             $auth_line = $value;
         }
     }
     if ($auth_line != '') {
         // on récupère les informations du header
         $pattern = 'Username="******", PasswordDigest="(.+)",';
         $pattern .= ' Nonce="(.+)", Created="(.+)", Expires="(.+)"';
         if (ereg($pattern, $auth_line, $regs)) {
             $auth = $arg['marker']->authenticate($regs[1], $regs[2], $regs[3], $regs[4], false);
             if (Blogmarks::isError($auth)) {
                 return $auth;
             }
         } else {
             return BlogMarks::raiseError("Erreur à la ligne X-WSSE : {$pattern} ne vérfifie pas {$auth_line}", 400);
         }
     }
     // passe au filtre suivant
     if ($this->_hasChild) {
         $tmp =& $this->_childFilter;
         return $tmp->execute($arg);
     }
 }
Example #7
0
 /** Renvoie des informations à propos de l'utilisateur connecté.
  * Renvoie un tableau associatif si la méthode est appelée sans paramètre, ou la valeur 
  * du champs ($field) passé en paramètre.
  *
  * @param      string      $field      (optionnal) 
  * @return     mixed       array ou string
  */
 function getUserInfo($field = null)
 {
     $user =& $this->_slots['auth']->getConnectedUser();
     if (Blogmarks::isError($user)) {
         return $user;
     }
     // Champs dont on a le droit de récupérer la valeurs
     $info_fields = $user->getInfoFields();
     $ret = null;
     // Un seul champs est demandé
     if ($field) {
         $ret = $user->{$field};
     } else {
         foreach ($info_fields as $field) {
             $ret[$field] = $user->{$field};
         }
     }
     return $ret;
 }
Example #8
0
}
$time_start = getmicrotime();
/* ------------------------------- */
session_start();
//error_reporting( E_ALL ^ E_NOTICE );
error_reporting(E_ALL);
require_once 'PEAR.php';
include_once 'Blogmarks/Marker.php';
$marker =& Blogmarks_Marker::singleton();
//echo "<p>Exec. time : " . round( ( getmicrotime() - $time_start ) , 3 ) . " s</p>";
if (isset($_GET['connect']) and $_GET['connect'] == 1) {
    $nonce = microtime() / rand();
    $time = date("YMDHMS");
    $digest = makeDigest(trim($_POST['pwd']), $nonce, $time);
    $auth = $marker->authenticate(trim($_POST['login']), $digest, $nonce, $time, TRUE);
    if (Blogmarks::isError($auth)) {
        $auth_error = $auth->getMessage();
    } elseif (DB::isError($auth)) {
        $auth_error = $auth->getMessage();
    }
    //header("Location: index.php");
    header("Location: " . str_replace("connect=1", "", $_SERVER["REQUEST_URI"]));
}
if (isset($_GET['disconnect']) and $_GET['disconnect'] == 1) {
    $marker->disconnectUser();
    header("Location: index.php");
    //header("Location: " . $_SERVER["REQUEST_URI"] );
}
if (!isset($_GET['section'])) {
    $_GET['section'] = 'PublicMarks';
}
Example #9
0
?>

<div id="content">

<h3>Edit a bookmark</h3>

<form method="POST" action="update.php<?php 
if (isset($_GET['mini'])) {
    echo '?mini=1';
}
?>
">

<?php 
$mark =& $marker->getMark($_GET['id']);
if (Blogmarks::isError($mark)) {
    die($mark->getMessage());
}
if (DB::isError($mark)) {
    die($mark->getMessage());
}
//print_r( $mark );
$link = $mark->getLink('related');
$via = $mark->getLink('via');
//$href = $mark->getHref();
//print_r( $mark );
?>
	<input name="id" type="hidden" value="<?php 
echo $_GET['id'];
?>
" />