java/src/messenger/webim/libs/demothread.php

90 lines
3.7 KiB
PHP
Raw Normal View History

<?php
/*
2013-03-07 01:22:53 +04:00
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2011-02-26 17:04:12 +03:00
function demo_print_message($msg, $format)
{
global $webim_encoding;
2011-02-26 17:04:12 +03:00
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));
}
}
2011-02-26 17:04:12 +03:00
function demo_process_thread($act, $outformat, $lastid, $isuser, $canpost, $istyping, $postmessage)
{
global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent, $webimroot, $settings;
loadsettings();
2011-02-26 17:04:12 +03:00
if ($act == "refresh" || $act == "post") {
$lastid++;
2011-02-26 17:04:12 +03:00
if ($outformat == "xml") {
start_xml_output();
2011-02-26 17:04:12 +03:00
print("<thread lastid=\"$lastid\" typing=\"" . ($istyping ? 1 : 0) . "\" canpost=\"" . ($canpost ? 1 : 0) . "\">");
} else {
start_html_output();
2011-02-26 17:04:12 +03:00
$url = "$webimroot/thread.php?act=refresh&amp;thread=0&amp;token=123&amp;html=on&amp;user=" . ($isuser ? "true" : "false");
print(
2011-02-26 17:04:12 +03:00
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" .
"<html>\n<head>\n" .
"<link href=\"$webimroot/styles/default/chat.css\" rel=\"stylesheet\" type=\"text/css\">\n" .
"<meta http-equiv=\"Refresh\" content=\"" . $settings['updatefrequency_oldchat'] . "; URL=$url&amp;sn=11\">\n" .
"<meta http-equiv=\"Pragma\" content=\"no-cache\">\n" .
"<title>chat</title>\n" .
"</head>\n" .
"<body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>" .
"<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>");
}
2011-02-26 17:04:12 +03:00
if ($lastid == 1) {
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_for_agent, 'created' => time() - 15, 'tname' => '',
'tmessage' => getstring2('chat.came.from', array("http://google.com"))), $outformat);
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_info, 'created' => time() - 15, 'tname' => '',
'tmessage' => getstring('chat.wait')), $outformat);
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_events, 'created' => time() - 10, 'tname' => '',
'tmessage' => getstring2("chat.status.operator.joined", array("Administrator"))), $outformat);
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_agent, 'created' => time() - 9, 'tname' => 'Administrator',
'tmessage' => getstring("demo.chat.welcome")), $outformat);
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_user, 'created' => time() - 5, 'tname' => getstring("chat.default.username"),
'tmessage' => getstring("demo.chat.question")), $outformat);
if ($canpost && $outformat == 'xml') {
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $kind_info, 'created' => time() - 5, 'tname' => '',
'tmessage' => 'Hint: type something in message field to see typing notification'), $outformat);
}
}
2011-02-26 17:04:12 +03:00
if ($act == 'post') {
demo_print_message(
2011-02-26 17:04:12 +03:00
array('ikind' => $isuser ? $kind_user : $kind_agent, 'created' => time(), 'tmessage' => $postmessage,
'tname' => $isuser ? getstring("chat.default.username") : "Administrator"), $outformat);
}
2011-02-26 17:04:12 +03:00
if ($outformat == "xml") {
print("</thread>");
} else {
print(
2011-02-26 17:04:12 +03:00
"</td></tr></table><a name='aend'></a>" .
"</body></html>");
}
}
}
?>