本文整理汇总了PHP中checktoken函数的典型用法代码示例。如果您正苦于以下问题:PHP checktoken函数的具体用法?PHP checktoken怎么用?PHP checktoken使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checktoken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: data
function data()
{
checktoken();
global $db;
$usertable = TABLE_PREFIX . DB_USERTABLE;
$usertable_username = DB_USERTABLE_NAME;
$usertable_userid = DB_USERTABLE_USERID;
$response = array();
$messages = array();
$criteria = "cometchat.id > '" . mysql_real_escape_string($_POST['timestamp']) . "' and ";
$criteria2 = 'desc';
if (empty($_POST['timestamp'])) {
$criteria = '';
$criteria2 = 'desc limit 20';
}
$sql = "select cometchat.id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat, {$usertable} f, {$usertable} t where {$criteria} f.{$usertable_userid} = cometchat.from and t.{$usertable_userid} = cometchat.to order by cometchat.id {$criteria2}";
$query = mysql_query($sql);
$timestamp = $_POST['timestamp'];
while ($chat = mysql_fetch_array($query)) {
if (function_exists('processName')) {
$chat['fromu'] = processName($chat['fromu']);
$chat['tou'] = processName($chat['tou']);
}
$time = date('g:iA M dS', $chat['sent']);
array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $chat['message'], 'time' => $time));
if ($chat['id'] > $timestamp) {
$timestamp = $chat['id'];
}
}
$response['timestamp'] = $timestamp;
if (!empty($messages)) {
$response['messages'] = $messages;
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
exit;
}
示例2: searchlogs
function searchlogs()
{
checktoken();
global $usertable_userid;
global $usertable_username;
global $usertable;
global $navigation;
global $body;
$username = $_POST['susername'];
if (empty($username)) {
// Base 64 Encoded
$username = 'Q293YXJkaWNlIGFza3MgdGhlIHF1ZXN0aW9uIC0gaXMgaXQgc2FmZT8NCkV4cGVkaWVuY3kgYXNrcyB0aGUgcXVlc3Rpb24gLSBpcyBpdCBwb2xpdGljPw0KVmFuaXR5IGFza3MgdGhlIHF1ZXN0aW9uIC0gaXMgaXQgcG9wdWxhcj8NCkJ1dCBjb25zY2llbmNlIGFza3MgdGhlIHF1ZXN0aW9uIC0gaXMgaXQgcmlnaHQ/DQpBbmQgdGhlcmUgY29tZXMgYSB0aW1lIHdoZW4gb25lIG11c3QgdGFrZSBhIHBvc2l0aW9uDQp0aGF0IGlzIG5laXRoZXIgc2FmZSwgbm9yIHBvbGl0aWMsIG5vciBwb3B1bGFyOw0KYnV0IG9uZSBtdXN0IHRha2UgaXQgYmVjYXVzZSBpdCBpcyByaWdodC4=';
}
$sql = "select {$usertable_userid} id, {$usertable_username} username from {$usertable} where {$usertable_username} LIKE '%" . mysql_real_escape_string(sanitize_core($username)) . "%'";
$query = mysql_query($sql);
$userslist = '';
while ($user = mysql_fetch_array($query)) {
if (function_exists('processName')) {
$user['username'] = processName($user['username']);
}
$userslist .= '<li class="ui-state-default"><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;">' . $user['username'] . ' - ' . $user['id'] . '</span><div style="clear:both"></div></li>';
}
$body = <<<EOD
\t{$navigation}
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Search results</h2>
\t\t<h3>Please find the user id next to each username. <a href="?module=chatrooms&action=finduser">Click here to search again</a></h3>
\t\t<div>
\t\t\t<ul id="modules_logs">
\t\t\t\t{$userslist}
\t\t\t</ul>
\t\t</div>
\t\t<div style="clear:both;padding:7.5px;"></div>
\t</div>
\t<div style="clear:both"></div>
EOD;
template();
}
示例3: checkfile
function checkfile($p_path, $p_file, $p_quiet = false)
{
if (!$p_quiet) {
echo "Testing language file '{$p_file}' (phase 1)...<br />";
flush();
}
$file = $p_path . $p_file;
set_error_handler('lang_error_handler');
$result = checktoken($file, $p_file == STRINGS_ENGLISH);
restore_error_handler();
if (!$result) {
print_error("Language file '{$p_file}' failed at phase 1.", 'FAILED');
if ($p_quiet) {
return false;
}
}
if (!$p_quiet) {
echo "Testing language file '{$p_file}' (phase 2)...<br />";
flush();
} else {
return true;
}
set_error_handler('lang_error_handler');
ob_start();
$result = eval("require_once( '{$file}' );");
$data = ob_get_contents();
ob_end_clean();
restore_error_handler();
if ($result === false) {
print_error("Language file '{$p_file}' failed at eval", 'FAILED');
if ($p_quiet) {
return false;
}
}
if (!empty($data)) {
print_error("Language file '{$p_file}' failed at require_once (data output: " . var_export($data, true) . ")", 'FAILED');
if ($p_quiet) {
return false;
}
}
return true;
}
示例4: uploadthemeprocess
function uploadthemeprocess()
{
checktoken();
global $db;
global $body;
global $trayicon;
global $navigation;
global $themes;
$extension = '';
$error = '';
if (!empty($_FILES["file"]["size"])) {
if ($_FILES["file"]["error"] > 0) {
$error = "Theme corrupted. Please try again.";
} else {
if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $_FILES["file"]["name"])) {
unlink(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $_FILES["file"]["name"]);
}
if (!move_uploaded_file($_FILES["file"]["tmp_name"], dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $_FILES["file"]["name"])) {
$error = "Unable to copy to temp folder. Please CHMOD temp folder to 777.";
}
}
} else {
$error = "Theme not found. Please try again.";
}
if (!empty($error)) {
$_SESSION['cometchat']['error'] = $error;
header("Location: ?module=themes&action=uploadtheme");
exit;
}
require_once 'pclzip.lib.php';
$filename = $_FILES['file']['name'];
$archive = new PclZip(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $_FILES["file"]["name"]);
if ($archive->extract(PCLZIP_OPT_PATH, dirname(dirname(__FILE__))) == 0) {
$error = "Unable to unzip archive. Please upload the contents of the zip file to themes folder.";
}
if (!empty($error)) {
$_SESSION['cometchat']['error'] = $error;
header("Location: ?module=themes&action=uploadtheme");
exit;
}
unlink(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $_FILES["file"]["name"]);
header("Location: ?module=themes");
exit;
}
示例5: newannouncementprocess
function newannouncementprocess()
{
checktoken();
$announcement = $_POST['announcement'];
$zero = '0';
if ($_POST['sli'] == 0) {
$zero = '-1';
}
$sql = "insert into cometchat_announcements (announcement,time,`to`) values ('" . mysql_real_escape_string($announcement) . "', '" . getTimeStamp() . "','" . $zero . "')";
$query = mysql_query($sql);
header("Location: ?module=announcements");
}
示例6: setmsg
setmsg(t("No such package defined."), 'warning', 'package.php');
}
$op = $_REQUEST['op'];
if (checktoken() && 'remove' == $op) {
if (ZPackage::removePackage($id)) {
setmsg(t('Package Removed.'), 'notice');
}
}
if (checktoken() && 'suspend' == $_REQUEST['op']) {
if (ZPackage::suspendPackage($id, !intval($_REQUEST['suspend']))) {
setmsg('', 'notice');
} else {
setmsg(t('Error'));
}
}
if (checktoken() && 'edit' == $op) {
$package = array();
$package['name'] = strip_tags($_REQUEST['name']);
$package['desc'] = strip_tags($_REQUEST['desc']);
$package['space'] = $_REQUEST['space'];
$package['bandwidth'] = $_REQUEST['bandwidth'];
$package['site'] = intval($_REQUEST['site']);
$package['ftp'] = intval($_REQUEST['ftp']);
$package['sql'] = intval($_REQUEST['sql']);
$package['state'] = intval($_REQUEST['state']);
$package['updated'] = date('Y-m-d H:i:s');
if (ZPackage::updatePackage($id, $package)) {
setmsg(t("Package Updated."), 'notice', 'package.php');
}
}
break;
示例7: createmoduleprocess
function createmoduleprocess()
{
checktoken();
$extension = '';
$error = '';
$modulename = createslug($_POST['title'], true);
if ($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg" || $_FILES["file"]["type"] == "image/png") {
if ($_FILES["file"]["error"] > 0) {
$error = "Module icon incorrect. Please try again.";
} else {
if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $modulename)) {
unlink(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $modulename);
}
$extension = extension($_FILES["file"]["name"]);
if (!move_uploaded_file($_FILES["file"]["tmp_name"], dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $modulename)) {
$error = "Unable to copy to temp folder. Please CHMOD temp folder to 777.";
}
}
} else {
$error = "Module icon not found. Please try again.";
}
if (empty($_POST['title'])) {
$error = "Module title is empty. Please try again.";
}
if (empty($_POST['link'])) {
$error = "Module link is empty. Please try again.";
}
if (!empty($error)) {
$_SESSION['cometchat']['error'] = $error;
header("Location: ?module=modules&action=createmodule");
exit;
}
mkdir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $modulename);
copy(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $modulename, dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $modulename . DIRECTORY_SEPARATOR . 'icon.png');
unlink(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "temp" . DIRECTORY_SEPARATOR . $modulename);
$code = "\$trayicon[] = array('" . $modulename . "','" . addslashes(addslashes(addslashes(str_replace('"', '', $_POST['title'])))) . "','" . $_POST['link'] . "','" . $_POST['type'] . "','" . $_POST['width'] . "','" . $_POST['height'] . "','','');";
configeditor('ICONS', $code, 1);
header("Location:?module=modules");
}
示例8: date_create
$nowTimestamp = $date->getTimestamp();
$date->modify('first day of next month');
$et = $date->getTimestamp() - 300;
//cuối tháng chọn in timespan format
//$et = strtotime('first day of next month'))-300;
$datestring = $tmp . ' first day of last month';
$dt = date_create($datestring);
$lastmon = $dt->format('Y-m-d');
$lastmonthstr = explode('-', $lastmon);
//echo '<pre>'; print_r($lastmonthstr);
$lmstr = (int) $lastmonthstr[0] . '-' . (int) $lastmonthstr[1];
//tháng trước in Y-m format
//echo $st.' == '.$et.' == '.$lmstr; exit();
CONNECT_DB();
mysql_query("SET NAMES utf8");
$checktoken = checktoken($userid, $token);
if (!$checktoken) {
die('404');
}
$data['dauky'] = null;
$data['cuoiky'] = null;
/*
* Khởi tạo giá trị confirm ban đầu, nếu tồn tại thì rewrite lại confirm
*/
$confirminfo = array('month' => '', 'sub_confirm' => 0, 'pc_confirm' => 0, 'fullname_sub_confirm' => '', 'fullname_pc_confirm' => '', 'date_pc_confirm' => '', 'date_confirm' => '', 'edit_date_confirm' => '', 'edit_count' => 0);
//tạm ẩn đi để xem nguồn h1 lấy ở đâu
$data['confirminfo'] = $confirminfo;
/*
* Lây các thông số unit, số sau dấu phẩy, hệ số nhân, hệ số tổn thất ĐZ của meter
*/
$unitmeter = 0;
示例9: addchatroomplugin
function addchatroomplugin()
{
checktoken();
global $crplugins;
if (!empty($_GET['data'])) {
$plugindata = '$crplugins = array(';
foreach ($crplugins as $plugin) {
$plugindata .= "'{$plugin}',";
}
$plugindata .= "'{$_GET['data']}',";
$plugindata = substr($plugindata, 0, -1) . ');';
configeditor('CHATROOMPLUGINS', $plugindata);
}
header("Location:?module=plugins&action=chatroomplugins");
}
示例10: getlanguage
function getlanguage($lang)
{
checktoken();
global $db;
global $body;
global $trayicon;
global $navigation;
$filestoedit = array("" => "", "i" => "i", "m" => "m", "desktop" => "desktop");
if ($handle = opendir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_dir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $file) && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'code.php') && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'en.php')) {
$filestoedit["modules" . DIRECTORY_SEPARATOR . $file] = $file;
}
}
closedir($handle);
}
if ($handle = opendir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'plugins')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_dir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $file) && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'code.php') && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'en.php')) {
$filestoedit["plugins" . DIRECTORY_SEPARATOR . $file] = $file;
}
}
closedir($handle);
}
if ($handle = opendir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'extensions')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_dir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $file) && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'code.php') && file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'en.php')) {
$filestoedit["extensions" . DIRECTORY_SEPARATOR . $file] = $file;
}
}
closedir($handle);
}
$data = '<?php ' . "\r\n" . '// CometChat Language File - ' . $lang . "\r\n" . "\r\n";
foreach ($filestoedit as $name => $file) {
if (empty($name)) {
$namews = $name;
} else {
$namews = $name . '/';
}
if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $namews . 'lang' . DIRECTORY_SEPARATOR . 'en.php')) {
if (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $namews . 'lang' . DIRECTORY_SEPARATOR . $lang . '.php')) {
if (!empty($file)) {
$file .= '_';
}
$array = $file . 'language';
$file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $namews . 'lang' . DIRECTORY_SEPARATOR . $lang . '.php';
$fh = fopen($file, 'r');
$readdata = @fread($fh, filesize($file));
fclose($fh);
$data .= '$file["' . $name . '"]=\'' . base64_encode($readdata) . '\';' . "\r\n\r\n";
}
}
}
$data .= ' ?>';
return $data;
}
示例11: viewuserconversation
function viewuserconversation()
{
checktoken();
global $db;
global $body;
global $trayicon;
global $navigation;
global $usertable_userid;
global $usertable_username;
global $usertable;
$userid = $_GET['data'];
$userid2 = $_GET['data2'];
$sql = "select {$usertable_username} username from {$usertable} where {$usertable_userid} = '" . mysql_real_escape_string($userid) . "'";
$query = mysql_query($sql);
$usern = mysql_fetch_array($query);
$sql = "select {$usertable_username} username from {$usertable} where {$usertable_userid} = '" . mysql_real_escape_string($userid2) . "'";
$query = mysql_query($sql);
$usern2 = mysql_fetch_array($query);
$sql = "(select m.* from cometchat m where (m.from = '" . mysql_real_escape_string($userid) . "' and m.to = '" . mysql_real_escape_string($userid2) . "') or (m.to = '" . mysql_real_escape_string($userid) . "' and m.from = '" . mysql_real_escape_string($userid2) . "'))\n\torder by id desc";
$query = mysql_query($sql);
$userslist = '';
while ($chat = mysql_fetch_array($query)) {
$time = date('g:iA M dS', $chat['sent']);
if ($userid == $chat['from']) {
$dir = '>';
} else {
$dir = '<';
}
$userslist .= '<li class="ui-state-default"><span style="font-size:11px;float:left;margin-top:2px;margin-left:0px;width:10px;margin-right:10px;color:#fff;background-color:#333;padding:0px;-moz-border-radius:5px;-webkit-border-radius:5px;"><b>' . $dir . '</b></span><span style="font-size:11px;float:left;margin-top:2px;margin-left:5px;width:560px;"> ' . $chat['message'] . '</span><span style="font-size:11px;float:right;width:100px;overflow:hidden;margin-top:2px;margin-left:10px;">' . $time . '</span><div style="clear:both"></div></li>';
}
if (function_exists('processName')) {
$usern['username'] = processName($usern['username']);
$usern2['username'] = processName($usern2['username']);
}
$body = <<<EOD
\t{$navigation}
\t<form action="?module=logs&action=newlogprocess" method="post" enctype="multipart/form-data">
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Log between {$usern['username']} and {$usern2['username']}</h2>
\t\t<h3>To see other conversations of {$usern['username']}, <a href="?module=logs&action=viewuser&data={$userid}">click here</a></h3>
\t\t<div>
\t\t\t<ul id="modules_logslong">
\t\t\t\t{$userslist}
\t\t\t</ul>
\t\t</div>
\t</div>
\t<div style="clear:both"></div>
EOD;
template();
}
示例12: action_checktokens
function action_checktokens()
{
# -- CHECKTOKENS --
# validate callsigns and tokens (clears tokens)
global $link, $checktokens, $groups;
debug(" ::::: ", 2);
if ($checktokens != '') {
function remove_empty($value)
{
return empty($value) ? false : true;
}
$garray = array_filter(explode("\r\n", $groups), 'remove_empty');
foreach (array_filter(explode("\r\n", $checktokens), 'remove_empty') as $checktoken) {
list($callsign, $rest) = explode('@', $checktoken);
if ($rest) {
list($ip, $token) = explode('=', $rest);
} else {
$ip = '';
list($callsign, $token) = explode('=', $checktoken);
}
if ($token) {
checktoken($callsign, $ip, $token, $garray);
}
}
}
}
示例13: mysql_query
$dbhost = $host;
// overwrites the global $dbhost
// create user
if (ZDatabase::addmysqluser($user)) {
$sql = "DROP USER '{$user}'@'{$old_host}'";
$res = mysql_query($sql);
if (!$res) {
setmsg(mysql_error());
break;
}
setmsg(t('Updated.'), 'notice');
} else {
setmsg(t('Database Error. ') . mysql_error(), 'error');
}
}
if (checktoken() && ('deluser' == $op || 'remove' == $op)) {
$deldb = isset($_REQUEST['deldb']);
$host = $_REQUEST['host'];
$host || ($host = 'localhost');
$user = $name;
// delete user
$sql = "DROP USER '{$user}'@'{$host}'";
$res = mysql_query($sql);
if (!$res) {
setmsg(mysql_error());
break;
}
if ($deldb) {
foreach ($databases as $dbname) {
$sql = "DROP DATABASE `{$dbname}`;";
$res = mysql_query($sql);
示例14: newchatroomprocess
function newchatroomprocess()
{
checktoken();
$chatroom = $_POST['chatroom'];
$type = $_POST['type'];
$password = $_POST['ppassword'];
if (!empty($password) && ($type == 1 || $type == 2)) {
$password = md5($password);
} else {
$password = '';
}
$sql = "insert into cometchat_chatrooms (name,createdby,lastactivity,password,type) values ('" . mysql_real_escape_string(sanitize_core($chatroom)) . "', '0','" . getTimeStamp() . "','" . mysql_real_escape_string($password) . "','" . mysql_real_escape_string($type) . "')";
$query = mysql_query($sql);
header("Location: ?module=chatrooms");
}
示例15: data
function data()
{
if (USE_COMET == 1 && SAVE_LOGS == 0) {
echo 0;
} else {
checktoken();
global $db;
global $guestsMode;
global $guestnamePrefix;
$usertable = TABLE_PREFIX . DB_USERTABLE;
$usertable_username = DB_USERTABLE_NAME;
$usertable_userid = DB_USERTABLE_USERID;
$guestpart = "";
$criteria = "cometchat.id > '" . mysql_real_escape_string($_POST['timestamp']) . "' and ";
$criteria2 = 'desc';
if ($guestsMode) {
$guestpart = "UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read,CONCAT('{$guestnamePrefix}',' ',f.name) fromu, CONCAT('{$guestnamePrefix}',' ',t.name) tou from cometchat, cometchat_guests f, cometchat_guests t where {$criteria} f.id = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f." . $usertable_username . " fromu, CONCAT('{$guestnamePrefix}',' ',t.name) tou from cometchat, " . $usertable . " f, cometchat_guests t where {$criteria} f." . $usertable_userid . " = cometchat.from and t.id = cometchat.to) UNION (select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, CONCAT('{$guestnamePrefix}',' ',f.name) fromu, t." . $usertable_username . " tou from cometchat, cometchat_guests f, " . $usertable . " t where {$criteria} f.id = cometchat.from and t." . $usertable_userid . " = cometchat.to) ";
}
$response = array();
$messages = array();
if (empty($_POST['timestamp'])) {
$criteria = '';
$criteria2 = 'desc limit 20';
}
$sql = "(select cometchat.id id, cometchat.from, cometchat.to, cometchat.message, cometchat.sent, cometchat.read, f.{$usertable_username} fromu, t.{$usertable_username} tou from cometchat, {$usertable} f, {$usertable} t where {$criteria} f.{$usertable_userid} = cometchat.from and t.{$usertable_userid} = cometchat.to ) " . $guestpart . " order by id {$criteria2}";
$query = mysql_query($sql);
$timestamp = $_POST['timestamp'];
while ($chat = mysql_fetch_array($query)) {
if (function_exists('processName')) {
$chat['fromu'] = processName($chat['fromu']);
$chat['tou'] = processName($chat['tou']);
}
$time = date('g:iA M dS', $chat['sent']);
array_unshift($messages, array('id' => $chat['id'], 'from' => $chat['from'], 'to' => $chat['to'], 'fromu' => $chat['fromu'], 'tou' => $chat['tou'], 'message' => $chat['message'], 'time' => $time));
if ($chat['id'] > $timestamp) {
$timestamp = $chat['id'];
}
}
$response['timestamp'] = $timestamp;
$response['online'] = onlineusers();
if (!empty($messages)) {
$response['messages'] = $messages;
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
}
exit;
}