Avatar jabber
dans Archives
Bonjour,
je tente de faire des modifications du CMS dans le but d'ajouter les avatars jabber de ceux qui postent.
Malheureusement, rien ne marche.
Pourriez-vous m'aidez ?
PS: J'ai aussi ajouter un espace membre a mon blog, et l'adresse jabber est stocké dans $_SESSION
PS2 : J'utilise le site http://presence.jabberfr.org pour afficher cet avatar
template.php
je tente de faire des modifications du CMS dans le but d'ajouter les avatars jabber de ceux qui postent.
Malheureusement, rien ne marche.
Pourriez-vous m'aidez ?
PS: J'ai aussi ajouter un espace membre a mon blog, et l'adresse jabber est stocké dans $_SESSION
PS2 : J'utilise le site http://presence.jabberfr.org pour afficher cet avatar
template.php
<?php if($pluxml->coms):?>
<div id="comments">
<h2>Commentaires</h2>
<?php while($pluxml->coms->loop()):?>
<div class="comment <?php echo 'ligne'.$pluxml->coms->i%2 ?>">
<p>Par <?php __('com_author', 'link'); ?> le <?php __('com_date'); ?></p>
<div class='avatar_jabber'><img src='http://presence.jabberfr.org/<?php __('com_jabber'); ?>/avatar-96' /></div><blockquote><p><?php __('com_content'); ?></p></blockquote>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php if($pluxml->config['allow_com'] == 1 && $pluxml->result->f('allow_com') == 1) : ?>
<div id="form">
<h2>Ecrire un commentaire</h2>
<form action="index.php?<?php echo $pluxml->get; ?>" method="post">
<fieldset>
<label>Nom :</label>
<?php if(isset($_SESSION['login']) && $_SESSION['login'] == 1) { ?>
<i><?php echo $_SESSION['pseudo']; ?></i><input name="jabber" type="hidden" size="30" value="<?php echo md5($_SESSION['jabber']); ?>" /><input name="name" type="hidden" size="30" value="<?php echo $_SESSION['pseudo']; ?>" />
<?php } else { ?>
<input name="name" type="text" size="30" value="" /><?php } ?><br />
<label>Site (facultatif) :</label>
<?php if(isset($_SESSION['login']) && $_SESSION['login'] == 1 && strlen($_SESSION['site']) != 0) { ?>
<i><?php echo $_SESSION['site']; ?></i><input name="site" type="hidden" size="30" value="<?php echo $_SESSION['site']; ?>" />
<?php } else { ?>
<input name="site" type="text" size="30" value="http://" /><?php } ?>
<br />
<label>E-mail (facultatif) :</label>
<?php if(isset($_SESSION['login']) && $_SESSION['login'] == 1 && strlen($_SESSION['courriel']) != 0) { ?>
<i><?php echo $_SESSION['courriel']; ?></i><input name="mail" type="hidden" size="30" value="<?php echo $_SESSION['courriel']; ?>" />
<?php } else { ?>
<input name="mail" type="text" size="30" value="" /><?php } ?>
<br />
<label>Commentaire :</label>
<textarea name="message" cols="35" rows="8"></textarea>
<?php # affichage du capcha anti-spam
if($pluxml->config['capcha'] == 1){
echo '<label><strong>Vérification anti-spam</strong> :</label>';
echo '<p>'.$capcha->q().'<input name="rep" type="text" size="10" /></p>';
echo '<input name="rep2" type="hidden" value="'.$capcha->r().'" />';
} ?>
<p><input type="hidden" name="login" value="<?php if(isset($_SESSION['login']) && $_SESSION['login'] == 1) { echo '1'; } else { echo '0'; } ?>" /><input type="submit" value="Envoyer" /></p>
</fieldset>
</form>
</div>
<?php endif; ?>
style.css
.avatar_jabber {
float: left;
}
class.pluxml.php
function parseComments($filename){
$data = implode("",file($filename));
$parser = xml_parser_create('ISO-8859-1');
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
xml_parse_into_struct($parser,$data,$valeurs,$index_tags);
xml_parser_free($parser);
for($i=0;$i < count($index_tags['author']);$i++) {
$array[$i]['author'] = $valeurs[$index_tags['author'][$i]]['value'];
$array[$i]['date'] = $valeurs[$index_tags['date'][$i]]['value'];
$array[$i]['ip'] = $valeurs[$index_tags['ip'][$i]]['value'];
if(isset($valeurs[$index_tags['mail'][$i]]['value'])){
$array[$i]['mail'] = $valeurs[$index_tags['mail'][$i]]['value'];
}else{
$array[$i]['mail'] = '';
}
$array[$i]['site'] = 'http://'.str_replace('http://', '', $valeurs[$index_tags['site'][$i]]['value']);
$array[$i]['jabber'] = $valeurs[$index_tags['jabber'][$i]]['value'];
$array[$i]['content'] = $valeurs[$index_tags['content'][$i]]['value'];
}
return $array;
}
function newComment($article){
global $capcha;
if($this->config['capcha'] == 0 || $_POST['rep2'] == md5($capcha->grain_de_sel.$_POST['rep'])){
if(!empty($_POST['name']) && !empty($_POST['message'])){
$author = htmlentities(unslash(trim($_POST['name'])));
$message = nl2br(htmlentities(unslash(trim($_POST['message']))));
$date = date::isodate();
$site = htmlentities(unslash(trim($_POST['site'])));
$mail = htmlentities(unslash(trim($_POST['mail'])));
$jabber = $_POST['jabber'];
$ip = $_SERVER['REMOTE_ADDR'];
$filename = PLX_DOC.$this->config['racine_xmlcom'].'com.'.$article.'.xml';
if(!file_exists($filename)){
$this->createCommentFile($filename);
}
$this->addComment($filename, $author, $date, $ip, $mail, $site, $jabber, $message);
}
}
}
function addComment($file, $author, $date, $ip, $mail, $site, $jabber, $message){
$data = implode("",file($file));
$end = '</comments>';
$add = "\t<comment>\n".
"\t\t<author><![CDATA[$author]]></author>\n".
"\t\t<date>$date</date>\n".
"\t\t<ip>$ip</ip>\n".
"\t\t<mail><![CDATA[$mail]]></mail>\n".
"\t\t<site><![CDATA[$site]]></site>\n".
"\t\t<jabber><![CDATA[$jabber]]></jabber>\n".
"\t\t<content><![CDATA[$message]]></content>\n".
"\t</comment>\n";
$xml = str_replace($end, $add.$end, $data);
write($xml, $file);
//envoie d'un mail lors de l'ajout d'un commentaire par Fightsoul
$email='xxxxxxxxxxxx';
$sujet='Nouveau commentaire posté';
$numero_article = explode('.', $file);
$message='Un nouveau commentaire a été posté sur votre site :
-------------------------------------------
IP : '.$ip.'
Nom ou pseudo : '.$author.'
E-mail : '.$mail.'
URL de votre site web :'.$site.'
Lien : http://jonathanmm.free.fr/blog/?'.$numero_article[1].'-l
Message :'."\n".
html_entity_decode($message).'
-------------------------------------------';
$headers="From: $author \r\nReply-To: $mail";
mail($email,$sujet,$message,$headers);
}
function deleteComment($article, $comment){
$filename = PLX_DOC.$this->config['racine_xmlcom'].'com.'.$article.'.xml';
$this->getComments();
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>".
"<comments>\n";
while($this->coms->loop()){
if(count($this->coms->result) < 2){
unlink($filename);
return;
}
if($this->coms->i != $comment){
$xml .= "\t<comment>\n".
"\t\t<author>".$this->coms->f('author')."</author>\n".
"\t\t<date>".$this->coms->f('date')."</date>\n".
"\t\t<ip>".$this->coms->f('ip')."</ip>\n".
"\t\t<mail>".$this->coms->f('mail')."</mail>\n".
"\t\t<site>".$this->coms->f('site')."</site>\n".
"\t\t<jabber>".$this->coms->f('jabber')."</jabber>\n".
"\t\t<content><![CDATA[".$this->coms->f('content')."]]></content>\n".
"\t</comment>\n";
}
}
$xml .= "</comments>";
write($xml, $filename);
}
function editComment($article, $comment, $post){
if(!empty($_POST['message'])){
$message = unslash(trim($_POST['message']));
$this->getComments();
$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>".
"<comments>\n";
while($this->coms->loop()){
if($this->coms->i == $comment){
$xml .= "\t<comment>\n".
"\t\t<author>".$this->coms->f('author')."</author>\n".
"\t\t<date>".$this->coms->f('date')."</date>\n".
"\t\t<ip>".$this->coms->f('ip')."</ip>\n".
"\t\t<mail>".$this->coms->f('mail')."</mail>\n".
"\t\t<site>".$this->coms->f('site')."</site>\n".
"\t\t<jabber>".$this->coms->f('jabber')."</jabber>\n".
"\t\t<content><![CDATA[".$message."]]></content>\n".
"\t</comment>\n";
}else{
$xml .= "\t<comment>\n".
"\t\t<author>".$this->coms->f('author')."</author>\n".
"\t\t<date>".$this->coms->f('date')."</date>\n".
"\t\t<ip>".$this->coms->f('ip')."</ip>\n".
"\t\t<mail>".$this->coms->f('mail')."</mail>\n".
"\t\t<site>".$this->coms->f('site')."</site>\n".
"\t\t<jabber>".$this->coms->f('jabber')."</jabber>\n".
"\t\t<content><![CDATA[".$this->coms->f('content')."]]></content>\n".
"\t</comment>\n";
}
}
$xml .= "</comments>";
$filename = PLX_DOC.$this->config['racine_xmlcom'].'com.'.$article.'.xml';
write($xml, $filename);
}
}
functions.php
case 'com_jabber':
echo $pluxml->coms->f('jabber');
break;
Merci d'avance Connectez-vous ou Inscrivez-vous pour répondre.
Réponses
C'est une très bonne idée, cette intégration de Présence.
Qu'est-ce qui ne marche pas ?
Le problème est que le md5 de l'adresse jabber ne se met pas