2012-04-23 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_html.php, include/javascript/jquery.pandora.js,
	include/functions_db.php: cleaned source code style.
	
	* include/functions_users.php, index.php, operation/menu.php,
	operation/users/webchat.php, include/javascript/webchat.js,
	general/header.php: added first version of webchat.
	
	* include/functions.php: into the function "check_login" added the
	parameter $output for some cases don't want see the error page like
	as the ajax querys.
	
	MERGED FROM 4.0.2




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6088 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-04-23 11:20:28 +00:00
parent 9294f23fd0
commit c6a2e14e04
11 changed files with 867 additions and 127 deletions

View File

@ -1,3 +1,18 @@
2012-04-23 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php, include/javascript/jquery.pandora.js,
include/functions_db.php: cleaned source code style.
* include/functions_users.php, index.php, operation/menu.php,
operation/users/webchat.php, include/javascript/webchat.js,
general/header.php: added first version of webchat.
* include/functions.php: into the function "check_login" added the
parameter $output for some cases don't want see the error page like
as the ajax querys.
MERGED FROM 4.0.2
2012-04-23 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/search_reports.php,

View File

@ -32,13 +32,11 @@ config_check();
<table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; margin-top: 5px;" border="0">
<tr>
<td rowspan="2">
<a href="index.php?sec=main">
<?php
if (!defined ('PANDORA_ENTERPRISE')){
echo html_print_image('images/pandora_header_logo.png', true, array("alt" => 'Pandora FMS Opensource', "border" => '0'));
}
else {
} else {
echo html_print_image('images/pandora_header_logo_enterprise.png', true, array("alt" => 'Pandora FMS Enterprise', "border" => '0'));
}
?>
@ -57,7 +55,6 @@ config_check();
if ($config["metaconsole"] == 0){
$msg_cnt = messages_get_count ($config["id_user"]);
if ($msg_cnt > 0) {
echo '<div id="dialog_messages" style="display: none"></div>';
ui_require_css_file ('dialog');
@ -70,6 +67,12 @@ config_check();
}
}
echo "<span id='icon_new_messages_chat' style='display: none;'>";
echo "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>";
html_print_image('images/comments.png');
echo "</a>";
echo "</span>";
if ($config["alert_cnt"] > 0) {
echo '<div id="alert_messages" style="display: none"></div>';
ui_require_css_file ('dialog');
@ -111,7 +114,6 @@ config_check();
else {
// TODO: Put here to remark this is a metaconsole
echo "";
}
?>
</td>
@ -200,10 +202,14 @@ if ($config["metaconsole"] == 0){
<script type="text/javascript" src="include/javascript/jquery.ui.droppable.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.resizable.js "></script>
-->
<script type="text/javascript" src="include/javascript/webchat.js "></script>
<script type="text/javascript">
/* <![CDATA[ */
var new_chat = <?php echo (int)$_SESSION['new_chat'];?>;
$(document).ready (function () {
check_new_chats_icon('icon_new_messages_chat');
/* Temporal fix to hide graphics when ui_dialog are displayed */
$("#yougotalert").click(function () {
$("#agent_access").css("display", "none");

View File

@ -1293,13 +1293,19 @@ function check_sql ($sql) {
*
* It will stop the execution if those variables were not set
*
* @param boolean $output Set return instead the output. By default true.
*
* @return bool 0 on success exit() on no success
*/
function check_login () {
function check_login ($output = true) {
global $config;
if (!isset ($config["homedir"])) {
if (!$output) {
return false;
}
// No exists $config. Exit inmediatly
include("general/noaccess.php");
exit;
@ -1308,7 +1314,8 @@ function check_login () {
if ((isset($_SESSION["id_usuario"])) AND ($_SESSION["id_usuario"] != "")) {
if (is_user ($_SESSION["id_usuario"])) {
$config['id_user'] = $_SESSION["id_usuario"];
return 0;
return true;
}
}
else {
@ -1319,11 +1326,15 @@ function check_login () {
$user = $_SESSION['user'];
$id_user = $user->getIdUser();
if (is_user ($id_user)) {
return 0;
return true;
}
}
}
if (!$output) {
return false;
}
db_pandora_audit("No session", "Trying to access without a valid session", "N/A");
include ($config["homedir"]."/general/noaccess.php");
exit;

View File

@ -1013,6 +1013,9 @@ function html_print_table (&$table, $return = false) {
continue;
}
if (!is_array($row))
$row = (array)$row;
/* It's a normal row */
foreach ($row as $key => $item) {
if (!isset ($size[$key])) {

View File

@ -222,4 +222,344 @@ function users_get_user_by_id ($id_user){
return $result_user;
}
////////////////////////////////////////////////////////////////////////
//////////////////////WEBCHAT FUNCTIONS/////////////////////////////////
////////////////////////////////////////////////////////////////////////
function users_get_last_messages($last_time = false) {
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
//First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
if ($fp_global_counter === false) {
echo json_encode($return);
return;
}
//Try to look $max_times times
$tries = 0;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries >= $max_times) {
echo json_encode($return);
return;
}
sleep(1);
}
fscanf($fp_global_counter, "%d", $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
$timestamp = time();
if ($last_time === false)
$last_time = 24 * 60 * 60;
$from = $timestamp - $last_time;
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
$return = array('correct' => false, 'log' => array());
if (!file_exists($log_chat_file)) {
touch($log_chat_file);
}
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
if ($log !== false) {
if ($log === null)
$log = array();
$log_last_time = array();
foreach ($log as $message) {
if ($message['timestamp'] >= $from) {
$log_last_time[] = $message;
}
}
$return['correct'] = true;
$return['log'] = $log_last_time;
$return['global_counter'] = $global_counter_file;
}
echo json_encode($return);
fclose($fp_global_counter);
return;
}
function users_save_login() {
global $config;
$user = db_get_row_filter('tusuario',
array('id_user' => $config['id_user']));
$message = sprintf(__('User %s login at %s'), $user['fullname'],
date($config['date_format']));
users_save_text_message($message, 'notification');
}
function users_save_logout() {
global $config;
$user = db_get_row_filter('tusuario',
array('id_user' => $config['id_user']));
$message = sprintf(__('User %s logout at %s'), $user['fullname'],
date($config['date_format']));
users_save_text_message($message, 'notification');
}
function users_save_text_message($message = false, $type = 'message') {
global $config;
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
$max_times = 10;
$return = array('correct' => false);
$id_user = $config['id_user'];
$user = db_get_row_filter('tusuario',
array('id_user' => $id_user));
$message_data = array();
$message_data['type'] = $type;
$message_data['id_user'] = $id_user;
$message_data['user_name'] = $user['fullname'];
$message_data['text'] = io_safe_input_html($message);
//The $message_data['timestamp'] set when adquire the files to save.
//First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
if ($fp_global_counter === false) {
echo json_encode($return);
return;
}
//Try to look $max_times times
$tries = 0;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries >= $max_times) {
echo json_encode($return);
return;
}
sleep(1);
}
@fscanf($fp_global_counter, "%d", $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
//Clean the file
ftruncate($fp_global_counter, 0);
$message_data['timestamp'] = time();
$message_data['human_time'] = date($config['date_format'], $message_data['timestamp']);
$global_counter = $global_counter_file + 1;
$status = fwrite($fp_global_counter, $global_counter);
if ($status === false) {
fclose($fp_global_counter);
echo json_encode($return);
return;
}
else {
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
$log[$global_counter] = $message_data;
$status = file_put_contents($log_chat_file, json_encode($log));
fclose($fp_global_counter);
$return['correct'] = true;
echo json_encode($return);
}
return;
}
function users_long_polling_check_messages($global_counter) {
global $config;
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
$changes = false;
$max_times = 10;
while (!$changes) {
//First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
if ($fp_global_counter) {
//Try to look $max_times times
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries >= $max_times) {
$lock = false;
break;
}
sleep(1);
}
if ($lock) {
@fscanf($fp_global_counter, "%d", $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
if ($global_counter_file > $global_counter) {
//TODO Optimize slice the array.
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
$return_log = array();
foreach ($log as $key => $message) {
if ($key <= $global_counter) continue;
$return_log[] = $message;
}
$return = array(
'correct' => true,
'global_counter' => $global_counter_file,
'log' => $return_log);
echo json_encode($return);
fclose($fp_global_counter);
return;
}
}
fclose($fp_global_counter);
}
sleep(3);
}
echo json_encode(array('correct' => false));
return;
}
/**
* Get the last global counter for chat.
*
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
*/
function users_get_last_global_counter($mode = 'json') {
global $config;
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
$global_counter_file = 0;
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
if ($fp_global_counter) {
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries >= $max_times) {
$lock = false;
break;
}
sleep(1);
}
if ($lock) {
@fscanf($fp_global_counter, "%d", $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
fclose($fp_global_counter);
}
}
switch ($mode) {
case 'json':
echo json_encode(array('correct' => true, 'global_counter' => $global_counter_file));
break;
case 'return':
return $global_counter_file;
break;
case 'session':
$_SESSION['global_counter_chat'] = $global_counter_file;
break;
}
}
/**
* Get the last global counter for chat.
*
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
*/
function users_get_last_type_message() {
global $config;
$return = 'false';
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
$global_counter_file = 0;
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
if ($fp_global_counter) {
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries >= $max_times) {
$lock = false;
break;
}
sleep(1);
}
if ($lock) {
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
$last = end($log);
$return = $last['type'];
fclose($fp_global_counter);
}
}
return $return;
}
function users_is_last_system_message() {
$type = users_get_last_type_message();
if ($type != 'message')
return true;
else
return false;
}
?>

View File

@ -0,0 +1,49 @@
function check_new_chats_icon(id_icon) {
if (new_chat) {
$("#" + id_icon).pulsate ();
}
}
function check_new_chats_icon_ajax(id_icon) {
var exit = false;
url_chunks = location.href.split('&');
$.each(url_chunks, function(key, chunk) {
if (chunk == 'sec2=operation/users/webchat')
exit = true;
return;
});
if (exit) {
return;
}
old = global_counter_chat;
get_last_global_counter();
if (old < global_counter_chat) {
$("#" + id_icon).pulsate ();
}
setTimeout("check_new_chats_icon(\"" + id_icon + "\")", 5000);
}
function get_last_global_counter() {
var parameters = {};
parameters['page'] = "operation/users/webchat";
parameters['get_last_global_counter'] = 1;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
async: false,
success: function(data) {
if (data['correct'] == 1) {
console.log(global_counter_chat+" < "+data['global_counter']);
global_counter_chat = data['global_counter'];
}
}
});
}

View File

@ -99,7 +99,6 @@ $config["pure"] = (bool) get_parameter ("pure");
// Auto Refresh page (can now be disabled anywhere in the script)
$config["refr"] = (int) get_parameter ("refr");
ob_start ();
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
@ -272,6 +271,46 @@ extensions_load_extensions ($config['extensions']);
if ($process_login) {
/* Call all extensions login function */
extensions_call_login_function ();
//Set the initial global counter for chat.
users_get_last_global_counter('session');
}
//Get old parameters before navigation.
$old_sec = '';
$old_sec2 = '';
$old_page = $_SERVER['HTTP_REFERER'];
$chunks = explode('?', $old_page);
if (count($chunks) == 2) {
$chunks = explode('&', $chunks[1]);
foreach ($chunks as $chunk) {
if (strstr($chunk, 'sec=') !== false) {
$old_sec = str_replace('sec=', '', $chunk);
}
if (strstr($chunk, 'sec2=') !== false) {
$old_sec = str_replace('sec2=', '', $chunk);
}
}
}
$_SESSION['new_chat'] = false;
if ($old_sec2 == 'operation/users/webchat') {
users_get_last_global_counter('session');
}
if ($page == 'operation/users/webchat') {
//Reload the global counter.
users_get_last_global_counter('session');
}
$old_global_counter_chat = $_SESSION['global_counter_chat'];
$now_global_counter_chat = users_get_last_global_counter('return');
if ($old_global_counter_chat != $now_global_counter_chat) {
if (!users_is_last_system_message())
$_SESSION['new_chat'] = true;
}
// Header
@ -286,6 +325,7 @@ else {
echo '<div id="main_pure">';
}
// http://es2.php.net/manual/en/ref.session.php#64525
// Session locking concurrency speedup!
session_write_close ();

View File

@ -45,7 +45,8 @@ if (check_acl ($config['id_user'], 0, "AR")) {
$sub["operation/agentes/estado_agente"]["text"] = __('Agent detail');
$sub["operation/agentes/estado_agente"]["refr"] = 0;
$sub["operation/agentes/estado_agente"]["subsecs"] = array("godmode/agentes/agent_conf_gis",
$sub["operation/agentes/estado_agente"]["subsecs"] = array(
"godmode/agentes/agent_conf_gis",
"godmode/agentes/agent_disk_conf_editor",
"godmode/agentes/agent_template",
"godmode/agentes/configurar_agente",
@ -80,7 +81,8 @@ if (check_acl ($config['id_user'], 0, "AR")) {
//SNMP Console
$sub["operation/snmpconsole/snmp_view"]["text"] = __('SNMP console');
$sub["operation/snmpconsole/snmp_view"]["refr"] = 0;
$sub["operation/snmpconsole/snmp_view"]["subsecs"] = array("enterprise/godmode/snmpconsole",
$sub["operation/snmpconsole/snmp_view"]["subsecs"] = array(
"enterprise/godmode/snmpconsole",
"godmode/snmpconsole/snmp_trap_editor",
"godmode/snmpconsole/snmp_alert",
"godmode/snmpconsole/snmp_filters");
@ -127,7 +129,8 @@ if (check_acl ($config['id_user'], 0, "AR")) {
//Visual console
$sub["godmode/reporting/map_builder"]["text"] = __('Visual console');
//Set godomode path
$sub["godmode/reporting/map_builder"]["subsecs"] = array("godmode/reporting/map_builder",
$sub["godmode/reporting/map_builder"]["subsecs"] = array(
"godmode/reporting/map_builder",
"godmode/reporting/visual_console_builder");
if (!empty($config['vc_refr'])){
@ -188,7 +191,8 @@ if (check_acl ($config['id_user'], 0, "AR")) {
$sub["godmode/reporting/graphs"]["text"] = __('Custom graphs');
//Set godomode path
$sub["godmode/reporting/graphs"]["subsecs"] = array("operation/reporting/graph_viewer",
$sub["godmode/reporting/graphs"]["subsecs"] = array(
"operation/reporting/graph_viewer",
"godmode/reporting/graph_builder");
enterprise_hook ('dashboard_menu');
@ -296,6 +300,12 @@ $sub = array();
$sub["operation/users/user_edit"]["text"] = __('Edit my user');
$sub["operation/users/user_edit"]["refr"] = 0;
// ANY user can chat with other user and dogs.
// Users
$sub = array();
$sub["operation/users/webchat"]["text"] = __('WebChat');
$sub["operation/users/webchat"]["refr"] = 0;
//Incidents
if (check_acl ($config['id_user'], 0, "IR") == 1) {
$temp_sec2 = $sec2;
@ -308,7 +318,8 @@ if (check_acl ($config['id_user'], 0, "IR") == 1) {
$sub[$sec2]["text"] = __('Incidents');
$sub[$sec2]["refr"] = 0;
$sub[$sec2]["subsecs"] = array("operation/incidents/incident_detail",
$sub[$sec2]["subsecs"] = array(
"operation/incidents/incident_detail",
"operation/integria_incidents");
$sub2 = array ();
@ -370,10 +381,10 @@ if (check_acl ($config['id_user'], 0, "AR")) {
//Check if was displayed inside other menu
if ($extension["operation_menu"]["fatherId"] == '') {
$sub[$extension_menu["sec2"]]["text"] = $extension_menu["name"];
$sub[$extension_menu["sec2"]]["refr"] = 0;
} else {
}
else {
if (array_key_exists('fatherId',$extension_menu)) {
if (strlen($extension_menu['fatherId']) > 0) {
$menu[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]["text"] = __($extension_menu['name']);

View File

@ -0,0 +1,265 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
if (is_ajax ()) {
global $config;
require_once("include/functions_users.php");
$status = check_login(false);
if ($status) {
$get_last_messages = (bool)get_parameter('get_last_messages', 0);
$send_message = (bool)get_parameter('send_message', 0);
$send_login = (bool)get_parameter('send_login', 0);
$send_logout = (bool)get_parameter('send_logout', 0);
$long_polling_check_messages = (bool)get_parameter('long_polling_check_messages', 0);
$get_last_global_counter = (bool)get_parameter('get_last_global_counter', 0);
if ($get_last_messages) {
$time = (int)get_parameter('time', 24 * 60 * 60);
users_get_last_messages($time);
}
if ($send_message) {
$message = get_parameter('message', false);
users_save_text_message($message);
}
if ($send_login) {
users_save_login();
}
if ($send_logout) {
users_save_logout();
}
if ($long_polling_check_messages) {
$global_counter = (int)get_parameter('global_counter', 0);
users_long_polling_check_messages($global_counter);
}
if ($get_last_global_counter) {
users_get_last_global_counter();
}
}
else {
echo json_encode(array('correct' => false));
}
return;
}
global $config;
check_login ();
ui_print_page_header (__('Webchat'), "images/group.png", false, "", false, "");
$table = null;
$table->width = '95%';
$table->colspan[0][0] = 2;
$table->data[0][0] = '<div id="chat_box" style="width: 100%;
height: 300px; background: #ffffff; border: 1px inset black;
overflow: auto; padding: 10px;"></div>';
$table->data[1][0] = html_print_input_text('message_box', '', '',
100, 150, true);
$table->data[1][1] = html_print_button('send', 'send', false, 'send_message()',
'class="sub next" style="width: 100%"', true);
html_print_table($table);
?>
<script type="text/javascript">
var global_counter_chat = 0;
var chat_log = '';
var user_move_scroll = false;
var first_time = true;
$(document).ready(function() {
$("input[name=\"message_box\"]").keydown(function(e){
//Enter key.
if (e.keyCode == 13) {
send_message();
}
});
init_webchat();
});
$(window).unload(function () {
exit_webchat();
});
function init_webchat() {
send_login_message();
long_polling_check_messages();
}
function long_polling_check_messages() {
var parameters = {};
parameters['page'] = "operation/users/webchat";
parameters['long_polling_check_messages'] = 1;
parameters['global_counter'] = global_counter_chat;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
if (first_time) {
print_messages({
0: {'type' : 'notification',
'text': '<?php echo __('Connection established...get last 24h messages...');?>'}
}, true);
first_time = false;
}
global_counter_chat = data['global_counter'];
print_messages(data['log']);
}
else {
print_messages({
0: {'type' : 'error',
'text': '<?php echo __('Error in connection.');?>'}
}, false);
}
long_polling_check_messages();
},
error: function(request, status, err) {
long_polling_check_messages();
}
});
}
function print_messages(messages, clear_chat_box) {
//event_add_text = true;
if (typeof(clear_chat_box) == 'undefined') {
clear_chat_box = false;
}
var html = '';
$.each(messages, function(key, message) {
html = html + '<div ';
if (message['type'] == 'error') {
html = html + "style='color: red; font-style: italic;'";
}
else if (message['type'] == 'notification') {
html = html + "style='color: grey; font-style: italic;'";
}
else if (message['type'] == 'message') {
html = html + "style='color: black; font-style: normal;'";
}
html = html + '>';
if (message['type'] != 'message') {
html = html + message['text'];
}
else {
html = html +
'<span style="color: grey; font-style: italic;">' +
message['human_time'] + '</span>';
html = html + ' ' +
'<span style="color: black; font-weight: bolder;">' +
message['user_name'] + ':&gt; </span>';
html = html + ' ' + message['text'];
}
html = html + '</div>';
});
if (clear_chat_box) {
$("#chat_box").html(html);
}
else {
$("#chat_box").append(html);
}
$("#chat_box").scrollTop($("#chat_box").attr('scrollHeight'));
}
function send_message() {
var parameters = {};
parameters['page'] = "operation/users/webchat";
parameters['send_message'] = 1;
parameters['message'] = $("input[name=\"message_box\"]").val();
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
$("input[name=\"message_box\"]").val('');
}
else {
print_messages({
0: {'type' : 'error',
'text': '<?php echo __('Error sendding message.');?>'}
}, false);
}
}
});
}
function exit_webchat() {
send_logout_message();
get_last_global_counter();
}
function send_login_message() {
var parameters = {};
parameters['page'] = "operation/users/webchat";
parameters['send_login'] = 1;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
}
else {
print_messages({
0: {'type' : 'error',
'text': '<?php echo __('Error login.');?>'}
}, false);
}
}
});
}
function send_logout_message() {
var parameters = {};
parameters['page'] = "operation/users/webchat";
parameters['send_logout'] = 1;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
}
});
}
</script>