From 27707593858a919e2fc1d8a528264796a3d4fc4d Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Mon, 5 May 2008 21:08:57 +0000 Subject: [PATCH] code clean up, is typing started git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@57 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/webim/button.php | 8 ++--- src/webim/client.php | 8 ++--- src/webim/install/index.php | 2 +- src/webim/leavemessage.php | 22 ++++++------ src/webim/libs/chat.php | 48 +++++++++++++------------- src/webim/libs/common.php | 24 ++++++------- src/webim/libs/config.php | 13 +++---- src/webim/libs/converter.php | 2 +- src/webim/libs/operator.php | 7 ++-- src/webim/libs/pagination.php | 2 +- src/webim/mail.php | 14 ++++---- src/webim/operator/agent.php | 10 +++--- src/webim/operator/getcode.php | 2 +- src/webim/operator/history.php | 2 +- src/webim/operator/index.php | 2 +- src/webim/operator/login.php | 2 +- src/webim/operator/logout.php | 2 +- src/webim/operator/operator.php | 22 ++++++------ src/webim/operator/operators.php | 2 +- src/webim/operator/threadprocessor.php | 2 +- src/webim/operator/update.php | 2 +- src/webim/operator/users.php | 3 +- src/webim/thread.php | 9 ++--- 23 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/webim/button.php b/src/webim/button.php index e10b434a..5d272253 100644 --- a/src/webim/button.php +++ b/src/webim/button.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,11 +21,11 @@ if( !$lang || !in_array($lang,$available_locales) ) $lang = $current_locale; $image_postfix = has_online_operators() ? "on" : "off"; -$name = "locales/${lang}/button/${image}_${image_postfix}.gif"; +$filename = "locales/${lang}/button/${image}_${image_postfix}.gif"; -$fp = fopen($name, 'rb') or die("no image"); +$fp = fopen($filename, 'rb') or die("no image"); header("Content-Type: image/gif"); -header("Content-Length: ".filesize($name)); +header("Content-Length: ".filesize($filename)); fpassthru($fp); exit; ?> \ No newline at end of file diff --git a/src/webim/client.php b/src/webim/client.php index 4cc30e88..bf994788 100644 --- a/src/webim/client.php +++ b/src/webim/client.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,9 +31,9 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { } $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""; - $remote = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR']; + $remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR']; $visitor = $remote_visitor(); - $thread = create_thread($visitor['name'], $remote, $referer,$current_locale); + $thread = create_thread($visitor['name'], $remoteHost, $referer,$current_locale); $_SESSION['threadid'] = $thread['threadid']; if( $referer ) { post_message($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referer))); @@ -72,4 +72,4 @@ if( $pparam == "mailthread" ) { require('view/chat_oldbrowser.php'); } -?> +?> \ No newline at end of file diff --git a/src/webim/install/index.php b/src/webim/install/index.php index 980d1198..9f9e1479 100644 --- a/src/webim/install/index.php +++ b/src/webim/install/index.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/leavemessage.php b/src/webim/leavemessage.php index 1048a25a..3a2c65c2 100644 --- a/src/webim/leavemessage.php +++ b/src/webim/leavemessage.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,36 +18,36 @@ require('libs/chat.php'); $errors = array(); $page = array(); -$mail = getparam('email'); -$name = getparam('name'); +$email = getparam('email'); +$visitor_name = getparam('name'); $message = getparam('message'); -if( !$mail ) { +if( !$email ) { $errors[] = no_field("form.field.email"); -} else if( !$name ) { +} else if( !$visitor_name ) { $errors[] = no_field("form.field.name"); } else if( !$message ) { $errors[] = no_field("form.field.message"); } else { - if( !is_valid_email($mail)) { + if( !is_valid_email($email)) { $errors[] = wrong_field("form.field.email"); } } if( count($errors) > 0 ) { - $page['formname'] = $name; - $page['formemail'] = $mail; + $page['formname'] = $visitor_name; + $page['formemail'] = $email; $page['formmessage'] = $message; start_html_output(); require('view/chat_leavemsg.php'); exit; } -$subject = getstring2_("leavemail.subject", array($name), $webim_messages_encoding); -$body = getstring2_("leavemail.body", array($name,$mail,$message), $webim_messages_encoding); +$subject = getstring2_("leavemail.subject", array($visitor_name), $webim_messages_encoding); +$body = getstring2_("leavemail.body", array($visitor_name,$email,$message), $webim_messages_encoding); $headers = 'From: '.$webim_from_email."\r\n" . - 'Reply-To: '.$mail."\r\n" . + 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/'.phpversion(); mail($webim_messages_mail,$subject,wordwrap($body,70),$headers); diff --git a/src/webim/libs/chat.php b/src/webim/libs/chat.php index 0cff2d02..59fe0b83 100644 --- a/src/webim/libs/chat.php +++ b/src/webim/libs/chat.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,7 @@ * Pavel Petroshenko - history search */ -$connection_timeout = 30; # sec +$connection_timeout = 30; // sec $namecookie = "WEBIM_Name"; @@ -44,7 +44,7 @@ function next_revision($link) { return $val; } -function post_message_($threadid,$kind,$message,$link,$from=null,$time=null,$opid=null) { +function post_message_($threadid,$kind,$message,$link,$from=null,$utime=null,$opid=null) { $query = sprintf( "insert into chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s, %s,'%s',%s,%s,%s)", $threadid, @@ -52,7 +52,7 @@ function post_message_($threadid,$kind,$message,$link,$from=null,$time=null,$opi quote_smart($message,$link), $from ? "'".quote_smart($from,$link)."'" : "null", $opid ? $opid : "0", - $time ? "FROM_UNIXTIME($time)" : "CURRENT_TIMESTAMP" ); + $utime ? "FROM_UNIXTIME($utime)" : "CURRENT_TIMESTAMP" ); perform_query($query,$link); return mysql_insert_id($link); @@ -84,16 +84,16 @@ function message_to_html($msg) { function message_to_text($msg) { global $kind_user, $kind_agent, $kind_info; - $time = date("H:i:s ",$msg['created']); + $message_time = date("H:i:s ",$msg['created']); if($msg['ikind'] == $kind_user || $msg['ikind'] == $kind_agent) { if( $msg['tname'] ) - return $time.$msg['tname'].": ".$msg['tmessage']."\n"; + return $message_time.$msg['tname'].": ".$msg['tmessage']."\n"; else - return $time.$msg['tmessage']."\n"; + return $message_time.$msg['tmessage']."\n"; } else if($msg['ikind'] == $kind_info ) { - return $time.$msg['tmessage']."\n"; + return $message_time.$msg['tmessage']."\n"; } else { - return $time."[".$msg['tmessage']."]\n"; + return $message_time."[".$msg['tmessage']."]\n"; } } @@ -164,9 +164,9 @@ function print_thread_messages($threadid, $token, $lastid, $isuser,$format) { } } -function get_user_name($name, $id="") { +function get_user_name($username, $id="") { global $presentable_name_pattern; - return str_replace("{id}", $id, str_replace("{name}", $name, $presentable_name_pattern)); + return str_replace("{id}", $id, str_replace("{name}", $username, $presentable_name_pattern)); } function setup_chatview_for_user($thread,$level) { @@ -211,27 +211,27 @@ function setup_chatview_for_operator($thread,$operator) { $page['namePostfix'] = ""; } -function is_ajax_browser($name,$ver,$useragent) { - if( $name == "opera" ) +function is_ajax_browser($browserid,$ver,$useragent) { + if( $browserid == "opera" ) return $ver >= 8.02; - if( $name == "safari" ) + if( $browserid == "safari" ) return $ver >= 125; - if( $name == "msie" ) + if( $browserid == "msie" ) return $ver >= 5.5 && !strstr($useragent, "powerpc"); - if( $name == "netscape" ) + if( $browserid == "netscape" ) return $ver >= 7.1; - if( $name == "mozilla") + if( $browserid == "mozilla") return $ver >= 1.4; - if( $name == "firefox") + if( $browserid == "firefox") return $ver >= 1.0; return false; } -function is_old_browser($name,$ver) { - if( $name == "opera" ) +function is_old_browser($browserid,$ver) { + if( $browserid == "opera" ) return $ver < 7.0; - if( $name == "msie" ) + if( $browserid == "msie" ) return $ver < 5.0; return false; } @@ -279,7 +279,7 @@ function get_access_time($threadid, $isuser, $link) { $threadid), $link); } -function ping_thread($thread, $isuser) { +function ping_thread($thread, $isuser,$istyping) { global $kind_for_agent, $state_chatting, $state_waiting, $kind_conn, $connection_timeout; $link = connect(); $params = array(($isuser ? "lastpinguser" : "lastpingagent") => "CURRENT_TIMESTAMP" ); @@ -343,7 +343,7 @@ function close_thread($thread,$isuser) { post_message($thread['threadid'], $kind_events, $message); } -function create_thread($username,$remote,$referer,$lang) { +function create_thread($username,$remoteHost,$referer,$lang) { $link = connect(); $query = sprintf( @@ -351,7 +351,7 @@ function create_thread($username,$remote,$referer,$lang) { "('%s',"."%s,'%s','%s',%s,'%s',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)", mysql_real_escape_string($username), next_token(), - mysql_real_escape_string($remote), + mysql_real_escape_string($remoteHost), mysql_real_escape_string($referer), next_revision($link), mysql_real_escape_string($lang) ); diff --git a/src/webim/libs/common.php b/src/webim/libs/common.php index ac1d9a53..bbbdb481 100644 --- a/src/webim/libs/common.php +++ b/src/webim/libs/common.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ session_start(); require(dirname(__FILE__).'/converter.php'); require(dirname(__FILE__).'/config.php'); -$version = 'v1.0.8'; +$version = 'v1.0.9'; function myiconv($in_enc, $out_enc, $string) { global $_utf8win1251, $_win1251utf8; @@ -44,6 +44,8 @@ function getrawparam( $name ) { function getparam( $name ) { if( isset($_POST[$name]) ) return $_POST[$name]; + if( isset($_GET[$name])) + return $_GET[$name]; die("no ".$name." parameter"); } @@ -140,9 +142,9 @@ function load_messages($locale) { $fp = fopen(dirname(__FILE__)."/../locales/$locale/properties","r"); while (!feof($fp)) { $line = fgets($fp, 4096); - $list = split("=", $line, 2 ); - if( isset($list[1]) ) { - $hash[$list[0]] = str_replace("\\n", "\n",trim($list[1])); + $keyval = split("=", $line, 2 ); + if( isset($keyval[1]) ) { + $hash[$keyval[0]] = str_replace("\\n", "\n",trim($keyval[1])); } } fclose($fp); @@ -264,11 +266,11 @@ function get_image($href,$width,$height) { return ""; } -function get_gifimage_size($file) { +function get_gifimage_size($filename) { if( function_exists('gd_info')) { $info = gd_info(); if( isset($info['GIF Read Support']) && $info['GIF Read Support'] ) { - $img = @imagecreatefromgif($file); + $img = @imagecreatefromgif($filename); if($img) { $height = imagesy($img); $width = imagesx($img); @@ -351,12 +353,10 @@ function get_form_date($day,$month) { return 0; } -function set_form_date($time,$prefix) { +function set_form_date($utime,$prefix) { global $page; - $page["form${prefix}day"] = date("d", $time); - $page["form${prefix}month"] = date("m.y", $time); + $page["form${prefix}day"] = date("d", $utime); + $page["form${prefix}month"] = date("m.y", $utime); } - - ?> \ No newline at end of file diff --git a/src/webim/libs/config.php b/src/webim/libs/config.php index 1de4d70c..e228bfdd 100644 --- a/src/webim/libs/config.php +++ b/src/webim/libs/config.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,8 @@ $mysqlpass = "123"; * Localization parameters */ -// Use CP-1251 database + +/* Use CP-1251 database */ $dbencoding = "cp1251"; $webim_encoding = "cp1251"; $request_encoding = "utf-8"; @@ -37,7 +38,7 @@ $output_charset = "Windows-1251"; $force_charset_in_connection = true; -// Use UTF-8 database +/* Use UTF-8 database */ /* $dbencoding = "utf8"; $webim_encoding = "cp1251"; @@ -49,7 +50,7 @@ $force_charset_in_connection = true; /* * From field in outgoing mail. */ -$webim_from_email = "webim@yourdomain.com"; // email from field +$webim_from_email = "webim@yourdomain.com"; /* email from field */ /* * Inbox for left messages @@ -71,8 +72,8 @@ $company_logo_link = ""; * Locales */ $available_locales = array("en", "ru"); -$home_locale = "ru"; // native name will be used in this locale -$default_locale = "en"; // if user does not provide known lang +$home_locale = "ru"; /* native name will be used in this locale */ +$default_locale = "en"; /* if user does not provide known lang */ /* * Allows users to change their names diff --git a/src/webim/libs/converter.php b/src/webim/libs/converter.php index 34145ede..c91ca9c4 100644 --- a/src/webim/libs/converter.php +++ b/src/webim/libs/converter.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/libs/operator.php b/src/webim/libs/operator.php index e56a6a64..68f07376 100644 --- a/src/webim/libs/operator.php +++ b/src/webim/libs/operator.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -108,7 +108,8 @@ function get_operator_name($operator) { function generate_button($title,$locale,$inner,$showhost,$forcesecure) { $link = get_app_location($showhost,$forcesecure)."/client.php". ($locale?"?locale=".$locale : ""); - return "".get_popup($link, $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=600,height=420,resizable=1" ).""; + $temp = get_popup($link, $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=600,height=420,resizable=1" ); + return "".$temp.""; } function check_login() { @@ -154,4 +155,4 @@ function logout_operator() { } } -?> \ No newline at end of file +?> diff --git a/src/webim/libs/pagination.php b/src/webim/libs/pagination.php index 34a57f63..bc11aab3 100644 --- a/src/webim/libs/pagination.php +++ b/src/webim/libs/pagination.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/mail.php b/src/webim/mail.php index 1ec1696c..49b7e92b 100644 --- a/src/webim/mail.php +++ b/src/webim/mail.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,17 +26,17 @@ if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) { die("wrong thread"); } -$mail = getparam('email'); -$page['email'] = $mail; +$email = getparam('email'); +$page['email'] = $email; -if( !$mail ) { +if( !$email ) { $errors[] = no_field("form.field.email"); -} else if( !is_valid_email($mail)) { +} else if( !is_valid_email($email)) { $errors[] = wrong_field("form.field.email"); } if( count($errors) > 0 ) { - $page['formemail'] = $mail; + $page['formemail'] = $email; $page['ct.chatThreadId'] = $thread['threadid']; $page['ct.token'] = $thread['ltoken']; $page['level'] = ""; @@ -59,7 +59,7 @@ $headers = 'From: '.$webim_from_email."\r\n" . 'Reply-To: '.$webim_from_email."\r\n" . 'X-Mailer: PHP/'.phpversion(); -mail($mail,$subject,wordwrap($body,70),$headers); +mail($email,$subject,wordwrap($body,70),$headers); start_html_output(); require('view/chat_mailsent.php'); diff --git a/src/webim/operator/agent.php b/src/webim/operator/agent.php index 093535c0..0f98d29c 100644 --- a/src/webim/operator/agent.php +++ b/src/webim/operator/agent.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,11 +31,11 @@ if( !isset($_GET['token']) ) { die("wrong thread"); } - take_thread($thread,$operator); + take_thread($thread,$operator); - $token = $thread['ltoken']; - header("Location: ".$_SERVER['PHP_SELF']."?thread=$threadid&token=$token"); - exit; + $token = $thread['ltoken']; + header("Location: ".$_SERVER['PHP_SELF']."?thread=$threadid&token=$token"); + exit; } $token = verifyparam( "token", "/^\d{1,8}$/"); diff --git a/src/webim/operator/getcode.php b/src/webim/operator/getcode.php index 84dca55e..516779c5 100644 --- a/src/webim/operator/getcode.php +++ b/src/webim/operator/getcode.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/history.php b/src/webim/operator/history.php index 341b727a..94a068eb 100644 --- a/src/webim/operator/history.php +++ b/src/webim/operator/history.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/index.php b/src/webim/operator/index.php index ea4ee246..4624ca3e 100644 --- a/src/webim/operator/index.php +++ b/src/webim/operator/index.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/login.php b/src/webim/operator/login.php index 68f789cc..651a31cd 100644 --- a/src/webim/operator/login.php +++ b/src/webim/operator/login.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/logout.php b/src/webim/operator/logout.php index e71918a6..339569df 100644 --- a/src/webim/operator/logout.php +++ b/src/webim/operator/logout.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/operator.php b/src/webim/operator/operator.php index 618aff09..14f4d3f7 100644 --- a/src/webim/operator/operator.php +++ b/src/webim/operator/operator.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,15 +20,17 @@ $operator = check_login(); $page = array('agentId' => ''); $errors = array(); + if( isset($_POST['login']) && isset($_POST['password']) ) { $agentId = verifyparam( "agentId", "/^(\d{1,9})?$/", ""); $login = getparam('login'); $password = getparam('password'); $passwordConfirm = getparam('passwordConfirm'); - $name = getparam('name'); + $localname = getparam('name'); $commonname = getparam('commonname'); - if( !$name ) + + if( !$localname ) $errors[] = no_field("form.field.agent_name"); if( !$commonname ) @@ -43,22 +45,22 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { if( $password != $passwordConfirm ) $errors[] = getstring("my_settings.error.password_match"); - $login_operator = operator_by_login($login); - if( (!$agentId && $login_operator) || - ( $agentId && $login_operator && $agentId != $login_operator['operatorid']) ) + $existing_operator = operator_by_login($login); + if( (!$agentId && $existing_operator) || + ( $agentId && $existing_operator && $agentId != $existing_operator['operatorid']) ) $errors[] = getstring("page_agent.error.duplicate_login"); if( count($errors) == 0 ) { - if( $agentId ) { - update_operator($agentId,$login,$password,$name,$commonname); + if (!$agentId) { + create_operator($login,$password,$localname,$commonname); } else { - create_operator($login,$password,$name,$commonname); + update_operator($agentId,$login,$password,$localname,$commonname); } header("Location: ".dirname($_SERVER['PHP_SELF'])."/operators.php"); exit; } else { $page['formlogin'] = $login; - $page['formname'] = $name; + $page['formname'] = $localname; $page['formcommonname'] = $commonname; $page['agentId'] = $agentId; } diff --git a/src/webim/operator/operators.php b/src/webim/operator/operators.php index a63bf6bf..e7528b7c 100644 --- a/src/webim/operator/operators.php +++ b/src/webim/operator/operators.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/threadprocessor.php b/src/webim/operator/threadprocessor.php index 3eb81df7..92546cf2 100644 --- a/src/webim/operator/threadprocessor.php +++ b/src/webim/operator/threadprocessor.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/update.php b/src/webim/operator/update.php index aa7a282f..5d784cda 100644 --- a/src/webim/operator/update.php +++ b/src/webim/operator/update.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/webim/operator/users.php b/src/webim/operator/users.php index 34af522a..466e3a65 100644 --- a/src/webim/operator/users.php +++ b/src/webim/operator/users.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,7 +16,6 @@ require('../libs/common.php'); require('../libs/operator.php'); - $operator = check_login(); notify_operator_alive($operator['operatorid']); diff --git a/src/webim/thread.php b/src/webim/thread.php index 082c062b..a0b2ac53 100644 --- a/src/webim/thread.php +++ b/src/webim/thread.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2007 Internet Services Ltd. + * Copyright (c) 2005-2008 Internet Services Ltd. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,15 +16,12 @@ require('libs/common.php'); require('libs/chat.php'); require('libs/operator.php'); - - $act = verifyparam( "act", "/^(refresh|post|rename|close|ping".")$/"); $token = verifyparam( "token", "/^\d{1,9}$/"); $threadid = verifyparam( "thread", "/^\d{1,9}$/"); $isuser = verifyparam( "user", "/^true$/", "false") == 'true'; $outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml"; - - +$istyping = verifyparam( "typed", "/^1$/", "") == '1'; $thread = thread_by_id($threadid); if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) { @@ -34,7 +31,7 @@ if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) { # This code helps in simulation of operator connection problems # if( !$isuser ) die("error"); -ping_thread($thread, $isuser); +ping_thread($thread, $isuser,$istyping); if( !$isuser && $act != "rename" ) { $operator = check_login();