Ejemplo n.º 1
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     //    $xml_reponse->script("trace('".implode(',',$params)."');");
     //    return;
     // get the nickid from the parameters
     // if the run command is whois2 then the parameter is a nickid
     $nickid = '';
     if ($this->name == 'whois2') {
         $nickid = $params[0];
     } else {
         $nickid = $ct->getNickId($params[0]);
     }
     if ($nickid) {
         $usermeta = $ct->getAllUserMeta($nickid);
         $usermeta['nickid'] = $nickid;
         unset($usermeta['cmdtoplay']);
         // used internaly
         // remove private usermeta from the list if the client is not admin
         $isadmin = $ct->getUserMeta($u->nickid, 'isadmin');
         if (!$isadmin) {
             foreach ($c->nickmeta_private as $nmp) {
                 unset($usermeta[$nmp]);
             }
         }
         // sort the list
         $nickmeta_sorted = array();
         $order = array_merge(array_diff(array_keys($usermeta), array_keys($c->nickmeta)), array_keys($c->nickmeta));
         foreach ($order as $o) {
             $nickmeta_sorted[$o] = $usermeta[$o];
         }
         $usermeta = $nickmeta_sorted;
         require_once dirname(__FILE__) . '/../pfcjson.class.php';
         $json = new pfcJSON();
         $js = $json->encode($usermeta);
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', " . $js . ");");
     } else {
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ko','" . $param . "');");
     }
 }
Ejemplo n.º 2
0
 function _getChanMeta($recipient, $recipientid)
 {
     $c =& pfcGlobalConfig::Instance();
     $ct =& pfcContainer::Instance();
     $chanmeta = array();
     $chanmeta['chan'] = $recipient;
     $chanmeta['chanid'] = $recipientid;
     $chanmeta['meta'] = $ct->getAllUserMeta($chanmeta['chan']);
     $users = $ct->getOnlineNick($chanmeta['chan']);
     $chanmeta['meta']['users'] = array();
     $chanmeta['meta']['users']['nick'] = $users['nick'];
     $chanmeta['meta']['users']['nickid'] = $users['nickid'];
     require_once dirname(__FILE__) . '/../pfcjson.class.php';
     $json = new pfcJSON();
     $js = $json->encode($chanmeta);
     return $js;
 }
Ejemplo n.º 3
0
    function &loadScripts($theme, &$xml_reponse)
    {
        if ($xml_reponse == null) {
            $xml_reponse =& new pfcResponse();
        }
        $c =& pfcGlobalConfig::Instance();
        $js = '';
        // load customize.js.php
        $path = $c->getFilePathFromTheme('customize.js.php');
        $t = new pfcTemplate($path);
        $t->assignObject($c, "c");
        $js .= $t->getOutput();
        // load translations
        require_once dirname(__FILE__) . '/pfcjson.class.php';
        $json = new pfcJSON();
        $labels_to_load = array("Do you really want to leave this room ?", "Are you sure you want to close this tab ?", "Hide nickname marker", "Show nickname marker", "Hide dates and hours", "Show dates and hours", "Disconnect", "Connect", "Magnify", "Cut down", "Hide smiley box", "Show smiley box", "Hide online users box", "Show online users box", "Please enter your nickname", "Private message", "Close this tab", "Enter your message here", "Enter your nickname here", "Bold", "Italics", "Underline", "Delete", "Mail", "Color", "PHP FREE CHAT [powered by phpFreeChat-%s]", "Enter the text to format", "Configuration has been rehashed", "A problem occurs during rehash", "Chosen nickname is already used", "phpfreechat current version is %s", "Maximum number of joined channels has been reached", "Maximum number of private chat has been reached", "Click here to send your message", "Send", "You are not allowed to speak to yourself", "Close", "Chosen nickname is not allowed", "Enable sound notifications", "Disable sound notifications", "Input Required", "OK", "Cancel", "You are trying to speak to a unknown (or not connected) user");
        foreach ($labels_to_load as $l) {
            $js .= "pfc.res.setLabel(" . $json->encode($l) . "," . $json->encode(_pfc2($l)) . ");\n";
        }
        // load ressources
        $fileurl_to_load = array('images/ch.gif', 'images/pv.gif', 'images/tab_remove.gif', 'images/ch-active.gif', 'images/pv-active.gif', 'images/user.gif', 'images/user-me.gif', 'images/user_female.gif', 'images/user_female-me.gif', 'images/color-on.gif', 'images/color-off.gif', 'images/clock-on.gif', 'images/clock-off.gif', 'images/logout.gif', 'images/login.gif', 'images/maximize.gif', 'images/minimize.gif', 'images/smiley-on.gif', 'images/smiley-off.gif', 'images/online-on.gif', 'images/online-off.gif', 'images/bt_strong.gif', 'images/bt_em.gif', 'images/bt_ins.gif', 'images/bt_del.gif', 'images/bt_mail.gif', 'images/bt_color.gif', 'images/color_transparent.gif', 'images/close-whoisbox.gif', 'images/openpv.gif', 'images/user-admin.gif', 'images/sound-on.gif', 'images/sound-off.gif', 'sound.swf');
        foreach ($fileurl_to_load as $f) {
            $js .= "pfc.res.setFileUrl(" . $json->encode($f) . ",\"" . $c->getFileUrlFromTheme($f) . "\");\n";
        }
        foreach ($c->smileys as $s_file => $s_str) {
            for ($j = 0; $j < count($s_str); $j++) {
                $js .= "pfc.res.setSmiley(" . $json->encode($s_str[$j]) . ",\"" . $c->getFileUrlFromTheme($s_file) . "\");\n";
            }
        }
        $js .= '
pfc.gui.loadSmileyBox();
pfc.gui.loadBBCodeColorList();
pfc.connectListener();
pfc.refreshGUI();
if (pfc_connect_at_startup) pfc.connect_disconnect();
';
        $xml_reponse->script($js);
        return $xml_reponse;
    }
 function trace(&$xml_reponse, $msg, $data = NULL)
 {
     if ($data != NULL) {
         require_once dirname(__FILE__) . '/pfcjson.class.php';
         $json = new pfcJSON();
         $js = $json->encode($data);
         $xml_reponse->script("trace('" . $msg . " -> " . $js . "');");
     } else {
         $xml_reponse->script("trace('" . $msg . "');");
     }
 }
Ejemplo n.º 5
0
?>
/js/pfcgui.js"></script>
<script type="text/javascript" src="<?php 
echo $c->data_public_url;
?>
/js/pfcresource.js"></script>
<script type="text/javascript" src="<?php 
echo $c->data_public_url;
?>
/js/pfcprompt.js"></script>

<script type="text/javascript">
  // <![CDATA[
<?php 
require_once dirname(__FILE__) . '/../../src/pfcjson.class.php';
$json = new pfcJSON();
$nick = $u->getNickname() != '' ? $json->encode($u->getNickname()) : $json->encode($c->nick);
?>

var pfc                       = null; // will contains a pfcClient instance
var pfc_nickname              = <?php 
echo $GLOBALS["output_encoding"] == "UTF-8" ? $nick : iconv("UTF-8", $GLOBALS["output_encoding"], $nick);
?>
;
var pfc_nickid                = <?php 
echo $json->encode($u->nickid);
?>
;
var pfc_version               = <?php 
echo $json->encode($version);
?>
Ejemplo n.º 6
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     // do nothing if the recipient is not defined
     if ($recipient == "") {
         return;
     }
     // check this methode is not being called
     if (isset($_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid])) {
         // kill the lock if it has been created more than 10 seconds ago
         $last_10sec = time() - 10;
         $last_lock = $_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid];
         if ($last_lock < $last_10sec) {
             $_SESSION["pfc_lock_" . $c->getId() . "_" . $clientid] = 0;
         }
         if ($_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] != 0) {
             exit;
         }
     }
     // create a new lock
     $_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] = time();
     // read the last from_id value
     $container =& pfcContainer::Instance();
     $from_id_sid = "pfc_from_id_" . $c->getId() . "_" . $clientid . "_" . $recipientid;
     $from_id = 0;
     if (isset($_SESSION[$from_id_sid])) {
         $from_id = $_SESSION[$from_id_sid];
     } else {
         $from_id = $container->getLastId($recipient) - $c->max_msg - 1;
         if ($from_id < 0) {
             $from_id = 0;
         }
     }
     // check if this is the first time you get messages
     $oldmsg_sid = "pfc_oldmsg_" . $c->getId() . "_" . $clientid . "_" . $recipientid;
     $oldmsg = false;
     if (isset($_SESSION[$oldmsg_sid])) {
         unset($_SESSION[$oldmsg_sid]);
         $oldmsg = true;
     }
     $new_msg = $container->read($recipient, $from_id);
     $new_from_id = $new_msg["new_from_id"];
     $data = $new_msg["data"];
     // transform new message in html format
     $js = array();
     $data_sent = false;
     foreach ($data as $d) {
         $m_id = $d["id"];
         $m_date = gmdate($c->date_format, $d["timestamp"] + $c->time_offset);
         $m_time = gmdate($c->time_format, $d["timestamp"] + $c->time_offset);
         $m_sender = $d["sender"];
         $m_recipientid = $recipientid;
         $m_cmd = $d["cmd"];
         $m_param = phpFreeChat::PostFilterMsg($d["param"]);
         $js[] = array($m_id, $m_date, $m_time, $m_sender, $m_recipientid, $m_cmd, $m_param, gmdate($c->date_format, time() + $c->time_offset) == $m_date ? 1 : 0, $oldmsg ? 1 : 0);
         // is it a new message in the current session or is it a part of the history
         $data_sent = true;
     }
     if (count($js) != 0) {
         require_once dirname(__FILE__) . '/../pfcjson.class.php';
         $json = new pfcJSON();
         $js = $json->encode($js);
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', (" . $js . "));");
     }
     if ($data_sent) {
         // store the new msg id
         $_SESSION[$from_id_sid] = $new_from_id;
     }
     // remove the lock
     $_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] = 0;
 }