2008-10-12 19:03:13 +04:00
|
|
|
<?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.
|
2008-10-12 19:03:13 +04:00
|
|
|
*/
|
|
|
|
|
2011-02-26 17:04:12 +03:00
|
|
|
function demo_print_message($msg, $format)
|
|
|
|
{
|
2008-10-12 19:03:13 +04:00
|
|
|
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";
|
2008-10-13 03:05:47 +04:00
|
|
|
} else {
|
|
|
|
print topage(message_to_html($msg));
|
|
|
|
}
|
2008-10-12 19:03:13 +04:00
|
|
|
}
|
|
|
|
|
2011-02-26 17:04:12 +03:00
|
|
|
function demo_process_thread($act, $outformat, $lastid, $isuser, $canpost, $istyping, $postmessage)
|
|
|
|
{
|
2009-06-09 03:19:21 +04:00
|
|
|
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") {
|
2008-10-12 19:03:13 +04:00
|
|
|
$lastid++;
|
2011-02-26 17:04:12 +03:00
|
|
|
if ($outformat == "xml") {
|
2008-10-13 03:05:47 +04:00
|
|
|
start_xml_output();
|
2011-02-26 17:04:12 +03:00
|
|
|
print("<thread lastid=\"$lastid\" typing=\"" . ($istyping ? 1 : 0) . "\" canpost=\"" . ($canpost ? 1 : 0) . "\">");
|
2008-10-13 03:05:47 +04:00
|
|
|
} else {
|
|
|
|
start_html_output();
|
2011-02-26 17:04:12 +03:00
|
|
|
$url = "$webimroot/thread.php?act=refresh&thread=0&token=123&html=on&user=" . ($isuser ? "true" : "false");
|
|
|
|
|
2009-06-05 19:49:51 +04:00
|
|
|
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&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'>");
|
|
|
|
|
2008-10-13 03:05:47 +04:00
|
|
|
}
|
2011-02-26 17:04:12 +03:00
|
|
|
if ($lastid == 1) {
|
2008-10-12 19:03:13 +04:00
|
|
|
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);
|
2008-10-12 19:03:13 +04:00
|
|
|
demo_print_message(
|
2011-02-26 17:04:12 +03:00
|
|
|
array('ikind' => $kind_info, 'created' => time() - 15, 'tname' => '',
|
|
|
|
'tmessage' => getstring('chat.wait')), $outformat);
|
2008-10-12 19:03:13 +04:00
|
|
|
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);
|
2008-10-12 19:03:13 +04:00
|
|
|
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);
|
2008-10-12 19:03:13 +04:00
|
|
|
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') {
|
2008-10-13 00:35:42 +04:00
|
|
|
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);
|
2008-10-13 00:35:42 +04:00
|
|
|
}
|
|
|
|
}
|
2011-02-26 17:04:12 +03:00
|
|
|
if ($act == 'post') {
|
2008-10-13 00:35:42 +04:00
|
|
|
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);
|
2008-10-13 03:05:47 +04:00
|
|
|
}
|
2011-02-26 17:04:12 +03:00
|
|
|
if ($outformat == "xml") {
|
2008-10-13 03:05:47 +04:00
|
|
|
print("</thread>");
|
|
|
|
} else {
|
|
|
|
print(
|
2011-02-26 17:04:12 +03:00
|
|
|
"</td></tr></table><a name='aend'></a>" .
|
|
|
|
"</body></html>");
|
2008-10-12 19:03:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|