Exemplo n.º 1
0
function demo_print_message($msg, $format)
{
    global $webim_encoding;
    if ($format == "xml") {
        print "<message>" . myiconv($webim_encoding, "utf-8", escape_with_cdata(message_to_html($msg))) . "</message>\n";
    } else {
        print topage(message_to_html($msg));
    }
}
Exemplo n.º 2
0
function get_messages($threadid, $meth, $isuser, &$lastid)
{
    global $kind_for_agent, $kind_avatar, $webim_encoding, $mysqlprefix;
    $link = connect();
    $query = sprintf("select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from {$mysqlprefix}chatmessage " . "where threadid = %s and messageid > %s %s order by messageid", $threadid, $lastid, $isuser ? "and ikind <> {$kind_for_agent}" : "");
    $messages = array();
    $msgs = select_multi_assoc($query, $link);
    foreach ($msgs as $msg) {
        $message = "";
        if ($meth == 'xml') {
            switch ($msg['ikind']) {
                case $kind_avatar:
                    $message = "<avatar>" . myiconv($webim_encoding, "utf-8", escape_with_cdata($msg['tmessage'])) . "</avatar>";
                    break;
                default:
                    $message = "<message>" . myiconv($webim_encoding, "utf-8", escape_with_cdata(message_to_html($msg))) . "</message>\n";
            }
        } else {
            if ($msg['ikind'] != $kind_avatar) {
                $message = $meth == 'text' ? message_to_text($msg) : topage(message_to_html($msg));
            }
        }
        $messages[] = $message;
        if ($msg['messageid'] > $lastid) {
            $lastid = $msg['messageid'];
        }
    }
    mysql_close($link);
    return $messages;
}