• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Try to do an archive command

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
1 post • Page 1 of 1

Postby dhalsim » Mon Jan 22, 2007 10:46 am

Hi,

I've started to write a "/history x" command which open a tab and give all sent messages in the main room since x days.

It's work pretty well for now, i've just a little problem when I try to close the tab, i've this error
"Paramètre manquant (/leave [ch|pv [[{channel|nickname}] {reason}]])"

The /leave command works well so I don't well-understand the problem.

this is the history.class.php

Code: Select all
<?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_history extends pfcCommand
{
function run(&$xml_reponse, $p)
{
$clientid    = $p["clientid"];
$param       = $p["param"];
$sender      = $p["sender"];
$recipient   = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;

$days = $param;   
   $timestart = time() - $days * 60*60*24;   

$nickid   = $u->nickid;
$nick = $u->nick;
$pvname = "History";
$pvnickid = md5($pvname);

// generate a pvid from the two nicknames ids
$pvrecipient = "pv_history_" . $nickid; 
$pvrecipientid = md5($pvrecipient);

//    $xml_reponse->addScript("alert('privmsg: pvnickid=".$pvnickid."');");
//    $xml_reponse->addScript("alert('privmsg: pvname=".$pvname." pvrecipient=".$pvrecipient."');");

// update the private message list
// in the sessions
if (!isset($u->privmsg[$pvrecipientid]))
{
if ($c->max_privmsg <= count($u->privmsg))
{
   // the maximum number of private messages has been reached
   $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'max_privmsg', Array());");
   return;
}

$u->privmsg[$pvrecipientid]["recipient"] = $pvrecipient;
$u->privmsg[$pvrecipientid]["name"]      = $pvname;
$u->privmsg[$pvrecipientid]["pvnickid"]  = $pvnickid;
$u->saveInCache();

// reset the message id indicator
// i.e. be ready to re-get all last posted messages
/* $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$pvrecipientid;
$from_id     = $container->getLastId($pvrecipient)-$c->max_msg-1;
$_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id;*/
}

// register the user (and his metadata) in this pv
$ct =& $c->getContainerInstance();
$ct->createNick($pvrecipient, $u->nick, $u->nickid);
$this->forceWhoisReload($u->nick);

// return ok to the client
// then the client will create a new tab

$xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$pvrecipientid."','".addslashes($pvname)."'));");


   $aHistory = $ct->read($recipient,0);   
   
   
   
   if (is_array($aHistory['data'])){
      foreach ($aHistory['data'] as $idx => $value){
      
         
         $aDate = explode('/',$value['date']);
         $aTime = explode(':',$value['time']);
         
         $ts = mktime($aTime[0],$aTime[1],$aTime[2],$aDate[1],$aDate[0],$aDate[2]);
         
         if ($ts < $timestart) {
            continue;
         }
         
         $command = $value['cmd'];             
         switch ($command) {
            case "send" :
               $command = "The " .$value['date']. " at  ".$value['time']." ".$value['sender']." says : ".$value['param'];
               break;
            case "notice" :
               $command = "The " .$value['date']. " at  ".$value['time']." ".$value['param'];
               break;
            default :
               $command = "";
               break;
         }
         
         if ($command != "" )
            $msgid = $ct->write($pvrecipient, "History", "history", $command);
      }
         
   $msgid = $ct->write($pvrecipient, "History", "history", "Fin des archives");
   
} else {
   $msgid = $ct->write($pvrecipient, "History", "history", "Pas d'archives disponible");
}

}
}

?>

2. When this command will work fine, i'd like to put a button in the button list but I don't know if there is a simple way to do this.

Thanks
dhalsim
New member
 
Posts: 4
Joined: Wed Dec 20, 2006 11:50 am
Top

Post a reply
1 post • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 12 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub