mirror of
https://github.com/Mibew/i18n.git
synced 2025-01-22 21:40:28 +03:00
format code
This commit is contained in:
parent
2bcffd5f4a
commit
03dec2afb2
80
src/messenger/.idea/projectCodeStyle.xml
Normal file
80
src/messenger/.idea/projectCodeStyle.xml
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="js">
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="jsp">
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="php">
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="sass">
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="sql">
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="xml">
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
<ADDITIONAL_INDENT_OPTIONS fileType="yml">
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</ADDITIONAL_INDENT_OPTIONS>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
@ -99,7 +99,7 @@ $dbtables = array(
|
||||
"blockedCount" => "int DEFAULT 0"
|
||||
),
|
||||
|
||||
"${mysqlprefix}chatconfig" => array (
|
||||
"${mysqlprefix}chatconfig" => array(
|
||||
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||
"vckey" => "varchar(255)",
|
||||
"vcvalue" => "varchar(255)",
|
||||
@ -111,7 +111,7 @@ $dbtables = array(
|
||||
"groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
|
||||
"vcvalue" => "varchar(1024) NOT NULL",
|
||||
),
|
||||
|
||||
|
||||
"${mysqlprefix}chatnotification" => array(
|
||||
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||
"locale" => "varchar(8)",
|
||||
@ -137,7 +137,8 @@ $dbtables_can_update = array(
|
||||
"${mysqlprefix}chatnotification" => array(),
|
||||
);
|
||||
|
||||
function show_install_err($text) {
|
||||
function show_install_err($text)
|
||||
{
|
||||
global $page, $version, $errors, $webimroot;
|
||||
$page = array(
|
||||
'version' => $version,
|
||||
@ -149,17 +150,18 @@ function show_install_err($text) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function create_table($id,$link) {
|
||||
function create_table($id, $link)
|
||||
{
|
||||
global $dbtables, $memtables, $dbencoding, $mysqlprefix;
|
||||
|
||||
if(!isset($dbtables[$id])) {
|
||||
show_install_err("Unknown table: $id, ".mysql_error());
|
||||
if (!isset($dbtables[$id])) {
|
||||
show_install_err("Unknown table: $id, " . mysql_error());
|
||||
}
|
||||
|
||||
$query =
|
||||
"CREATE TABLE $id\n".
|
||||
"(\n";
|
||||
foreach( $dbtables[$id] as $k => $v ) {
|
||||
"CREATE TABLE $id\n" .
|
||||
"(\n";
|
||||
foreach ($dbtables[$id] as $k => $v) {
|
||||
$query .= " $k $v,\n";
|
||||
}
|
||||
|
||||
@ -171,19 +173,20 @@ function create_table($id,$link) {
|
||||
$query .= " TYPE=InnoDb";
|
||||
}
|
||||
|
||||
mysql_query($query,$link) or show_install_err(' Query failed: '.mysql_error());
|
||||
mysql_query($query, $link) or show_install_err(' Query failed: ' . mysql_error());
|
||||
|
||||
if( $id == "${mysqlprefix}chatoperator" ) {
|
||||
if ($id == "${mysqlprefix}chatoperator") {
|
||||
create_operator_("admin", "", "", "", "Administrator", "Administrator", 0, $link);
|
||||
} else if( $id == "${mysqlprefix}chatrevision" ) {
|
||||
perform_query("INSERT INTO ${mysqlprefix}chatrevision VALUES (1)",$link);
|
||||
} else if ($id == "${mysqlprefix}chatrevision") {
|
||||
perform_query("INSERT INTO ${mysqlprefix}chatrevision VALUES (1)", $link);
|
||||
}
|
||||
}
|
||||
|
||||
function get_tables($link) {
|
||||
function get_tables($link)
|
||||
{
|
||||
global $mysqldb, $errors;
|
||||
$result = mysql_query("SHOW TABLES FROM `$mysqldb`");
|
||||
if( $result ) {
|
||||
if ($result) {
|
||||
$arr = array();
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
|
||||
$arr[] = $row[0];
|
||||
@ -192,15 +195,16 @@ function get_tables($link) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
$errors[] = "Cannot get tables from database. Error: ".mysql_error();
|
||||
$errors[] = "Cannot get tables from database. Error: " . mysql_error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function get_columns($tablename,$link) {
|
||||
function get_columns($tablename, $link)
|
||||
{
|
||||
global $errors;
|
||||
$result = mysql_query("SHOW COLUMNS FROM $tablename");
|
||||
if( $result ) {
|
||||
if ($result) {
|
||||
$arr = array();
|
||||
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
|
||||
$arr[] = $row[0];
|
||||
@ -209,7 +213,7 @@ function get_columns($tablename,$link) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
$errors[] = "Cannot get columns from table \"$tablename\". Error: ".mysql_error();
|
||||
$errors[] = "Cannot get columns from table \"$tablename\". Error: " . mysql_error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -23,143 +23,144 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('dbinfo.php');
|
||||
|
||||
function runsql($query,$link) {
|
||||
$res = mysql_query($query,$link)
|
||||
or show_install_err(' Query failed: '.mysql_error());
|
||||
function runsql($query, $link)
|
||||
{
|
||||
$res = mysql_query($query, $link)
|
||||
or show_install_err(' Query failed: ' . mysql_error());
|
||||
return $res;
|
||||
}
|
||||
|
||||
$act = verifyparam( "act", "/^(silentcreateall|createdb|ct|dt|addcolumns)$/");
|
||||
$act = verifyparam("act", "/^(silentcreateall|createdb|ct|dt|addcolumns)$/");
|
||||
|
||||
$link = @mysql_connect($mysqlhost,$mysqllogin ,$mysqlpass )
|
||||
or show_install_err('Could not connect: ' . mysql_error());
|
||||
$link = @mysql_connect($mysqlhost, $mysqllogin, $mysqlpass)
|
||||
or show_install_err('Could not connect: ' . mysql_error());
|
||||
|
||||
if ($act == "silentcreateall") {
|
||||
mysql_query("CREATE DATABASE $mysqldb",$link)
|
||||
or show_install_err(' Query failed: '.mysql_error());
|
||||
foreach($dbtables as $id) {
|
||||
mysql_query("CREATE DATABASE $mysqldb", $link)
|
||||
or show_install_err(' Query failed: ' . mysql_error());
|
||||
foreach ($dbtables as $id) {
|
||||
create_table($id, $link);
|
||||
}
|
||||
} else if($act == "createdb") {
|
||||
mysql_query("CREATE DATABASE $mysqldb",$link)
|
||||
or show_install_err(' Query failed: '.mysql_error());
|
||||
}
|
||||
} else if ($act == "createdb") {
|
||||
mysql_query("CREATE DATABASE $mysqldb", $link)
|
||||
or show_install_err(' Query failed: ' . mysql_error());
|
||||
} else {
|
||||
mysql_select_db($mysqldb,$link)
|
||||
or show_install_err('Could not select database');
|
||||
if( $force_charset_in_connection ) {
|
||||
mysql_select_db($mysqldb, $link)
|
||||
or show_install_err('Could not select database');
|
||||
if ($force_charset_in_connection) {
|
||||
mysql_query("SET character set $dbencoding", $link);
|
||||
}
|
||||
|
||||
if( $act == "ct") {
|
||||
if ($act == "ct") {
|
||||
$curr_tables = get_tables($link);
|
||||
if( $curr_tables === false) {
|
||||
if ($curr_tables === false) {
|
||||
show_install_err($errors[0]);
|
||||
}
|
||||
$tocreate = array_diff(array_keys($dbtables), $curr_tables);
|
||||
foreach( $tocreate as $id) {
|
||||
foreach ($tocreate as $id) {
|
||||
create_table($id, $link);
|
||||
}
|
||||
} else if( $act == "dt") {
|
||||
foreach( array_keys($dbtables) as $id) {
|
||||
mysql_query("DROP TABLE IF EXISTS $id",$link)
|
||||
or show_install_err(' Query failed: '.mysql_error());
|
||||
} else if ($act == "dt") {
|
||||
foreach (array_keys($dbtables) as $id) {
|
||||
mysql_query("DROP TABLE IF EXISTS $id", $link)
|
||||
or show_install_err(' Query failed: ' . mysql_error());
|
||||
}
|
||||
} else if( $act == "addcolumns") {
|
||||
} else if ($act == "addcolumns") {
|
||||
$absent = array();
|
||||
foreach( $dbtables as $id => $columns) {
|
||||
foreach ($dbtables as $id => $columns) {
|
||||
$curr_columns = get_columns($id, $link);
|
||||
if( $curr_columns === false ) {
|
||||
if ($curr_columns === false) {
|
||||
show_install_err($errors[0]);
|
||||
}
|
||||
$tocreate = array_diff(array_keys($columns), $curr_columns);
|
||||
foreach($tocreate as $v) {
|
||||
foreach ($tocreate as $v) {
|
||||
$absent[] = "$id.$v";
|
||||
}
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatmessage.agentId", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatmessage.agentId", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind", $link);
|
||||
runsql("update ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.agentId", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.agentId", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName", $link);
|
||||
runsql("update ${mysqlprefix}chatthread, ${mysqlprefix}chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.agentTyping", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.agentTyping", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD agentTyping int DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.userTyping", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.userTyping", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userTyping int DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.messageCount", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.messageCount", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD messageCount varchar(16)", $link);
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_threadid_ikind (threadid, ikind)", $link);
|
||||
runsql("UPDATE ${mysqlprefix}chatthread t SET t.messageCount = (SELECT COUNT(*) FROM ${mysqlprefix}chatmessage WHERE ${mysqlprefix}chatmessage.threadid = t.threadid AND ikind = 1)", $link);
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatmessage DROP INDEX idx_threadid_ikind", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.nextagent", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.nextagent", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD nextagent int NOT NULL DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.shownmessageid", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.shownmessageid", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD shownmessageid int NOT NULL DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.userid", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.userid", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userid varchar(255) DEFAULT \"\"", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.iperm", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.iperm", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD iperm int DEFAULT 65535", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.istatus", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.istatus", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD istatus int DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.inotify", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.inotify", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD inotify int DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.vcavatar", $absent) ) {
|
||||
|
||||
if (in_array("${mysqlprefix}chatoperator.vcavatar", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcavatar varchar(255)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.vcjabbername", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.vcjabbername", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcjabbername varchar(255)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.vcemail", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.vcemail", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcemail varchar(64)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.dtmrestore", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.dtmrestore", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD dtmrestore datetime DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatoperator.vcrestoretoken", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatoperator.vcrestoretoken", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcrestoretoken varchar(64)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.groupid", $absent) ) {
|
||||
|
||||
if (in_array("${mysqlprefix}chatthread.groupid", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD groupid int references ${mysqlprefix}chatgroup(groupid)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatthread.userAgent", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatthread.userAgent", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userAgent varchar(255)", $link);
|
||||
}
|
||||
|
||||
if( in_array("${mysqlprefix}chatgroup.vcemail", $absent) ) {
|
||||
if (in_array("${mysqlprefix}chatgroup.vcemail", $absent)) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatgroup ADD vcemail varchar(64)", $link);
|
||||
}
|
||||
|
||||
|
||||
$res = mysql_query("select null from information_schema.statistics where table_name = '${mysqlprefix}chatmessage' and index_name = 'idx_agentid'", $link);
|
||||
if($res && mysql_num_rows($res) == 0) {
|
||||
if ($res && mysql_num_rows($res) == 0) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link);
|
||||
}
|
||||
}
|
||||
|
@ -33,35 +33,37 @@ $page['nextstep'] = false;
|
||||
$page['nextnotice'] = false;
|
||||
$errors = array();
|
||||
|
||||
function check_webimroot() {
|
||||
function check_webimroot()
|
||||
{
|
||||
global $page, $errors, $webimroot;
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
if(!preg_match('/^(.*)\\/install(\\/[^\\/\\\\]*)?$/', $requestUri, $matches)) {
|
||||
if (!preg_match('/^(.*)\\/install(\\/[^\\/\\\\]*)?$/', $requestUri, $matches)) {
|
||||
$errors[] = "Cannot detect application location: $requestUri";
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
$applocation = $matches[1];
|
||||
|
||||
if($applocation != $webimroot) {
|
||||
|
||||
if ($applocation != $webimroot) {
|
||||
$errors[] = "Please, check file ${applocation}/libs/config.php<br/>Wrong value of \$webimroot variable, should be \"$applocation\"";
|
||||
$webimroot = $applocation;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
$page['done'][] = getlocal2("install.0.app", array($applocation));
|
||||
return true;
|
||||
}
|
||||
|
||||
function check_connection() {
|
||||
global $mysqlhost,$mysqllogin,$mysqlpass, $page, $errors, $webimroot;
|
||||
$link = @mysql_connect($mysqlhost,$mysqllogin,$mysqlpass);
|
||||
function check_connection()
|
||||
{
|
||||
global $mysqlhost, $mysqllogin, $mysqlpass, $page, $errors, $webimroot;
|
||||
$link = @mysql_connect($mysqlhost, $mysqllogin, $mysqlpass);
|
||||
if ($link) {
|
||||
$result = mysql_query("SELECT VERSION() as c", $link);
|
||||
if( $result && $ver = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
if ($result && $ver = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$page['done'][] = getlocal2("install.1.connected", array($ver['c']));
|
||||
mysql_free_result($result);
|
||||
} else {
|
||||
$errors[] = "Version of your SQL server is unknown. Please check. Error: ".mysql_error();
|
||||
$errors[] = "Version of your SQL server is unknown. Please check. Error: " . mysql_error();
|
||||
mysql_close($link);
|
||||
return null;
|
||||
}
|
||||
@ -72,11 +74,12 @@ function check_connection() {
|
||||
}
|
||||
}
|
||||
|
||||
function check_database($link) {
|
||||
function check_database($link)
|
||||
{
|
||||
global $mysqldb, $force_charset_in_connection, $dbencoding, $page, $webimroot;
|
||||
if(mysql_select_db($mysqldb,$link)) {
|
||||
if (mysql_select_db($mysqldb, $link)) {
|
||||
$page['done'][] = getlocal2("install.2.db_exists", array($mysqldb));
|
||||
if( $force_charset_in_connection ) {
|
||||
if ($force_charset_in_connection) {
|
||||
mysql_query("SET character set $dbencoding", $link);
|
||||
}
|
||||
return true;
|
||||
@ -88,12 +91,13 @@ function check_database($link) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_tables($link) {
|
||||
function check_tables($link)
|
||||
{
|
||||
global $dbtables, $page, $webimroot;
|
||||
$curr_tables = get_tables($link);
|
||||
if( $curr_tables !== false) {
|
||||
if ($curr_tables !== false) {
|
||||
$tocreate = array_diff(array_keys($dbtables), $curr_tables);
|
||||
if( count($tocreate) == 0 ) {
|
||||
if (count($tocreate) == 0) {
|
||||
$page['done'][] = getlocal("install.3.tables_exist");
|
||||
return true;
|
||||
} else {
|
||||
@ -104,19 +108,20 @@ function check_tables($link) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_columns($link) {
|
||||
function check_columns($link)
|
||||
{
|
||||
global $dbtables, $dbtables_can_update, $errors, $page, $webimroot;
|
||||
|
||||
$need_to_create_columns = false;
|
||||
foreach( $dbtables as $id => $columns) {
|
||||
foreach ($dbtables as $id => $columns) {
|
||||
$curr_columns = get_columns($id, $link);
|
||||
if( $curr_columns === false ) {
|
||||
if ($curr_columns === false) {
|
||||
return false;
|
||||
}
|
||||
$tocreate = array_diff(array_keys($columns), $curr_columns);
|
||||
if( count($tocreate) != 0 ) {
|
||||
if (count($tocreate) != 0) {
|
||||
$cannot_update = array_diff($tocreate, $dbtables_can_update[$id]);
|
||||
if( count($cannot_update) != 0) {
|
||||
if (count($cannot_update) != 0) {
|
||||
$errors[] = "Key columns are absent in table `$id'. Unable to continue installation.";
|
||||
$page['nextstep'] = getlocal("install.kill_tables");
|
||||
$page['nextstepurl'] = "$webimroot/install/dbperform.php?act=dt";
|
||||
@ -127,7 +132,7 @@ function check_columns($link) {
|
||||
}
|
||||
}
|
||||
|
||||
if( $need_to_create_columns ) {
|
||||
if ($need_to_create_columns) {
|
||||
$page['nextstep'] = getlocal("install.4.create");
|
||||
$page['nextstepurl'] = "$webimroot/install/dbperform.php?act=addcolumns";
|
||||
$page['nextnotice'] = getlocal("install.4.notice");
|
||||
@ -138,29 +143,30 @@ function check_columns($link) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function check_status() {
|
||||
function check_status()
|
||||
{
|
||||
global $page, $webimroot, $settings, $dbversion;
|
||||
|
||||
if(!check_webimroot()) {
|
||||
|
||||
if (!check_webimroot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$link = check_connection();
|
||||
if(!$link) {
|
||||
if (!$link) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !check_database($link)) {
|
||||
if (!check_database($link)) {
|
||||
mysql_close($link);
|
||||
return;
|
||||
}
|
||||
|
||||
if( !check_tables($link)) {
|
||||
if (!check_tables($link)) {
|
||||
mysql_close($link);
|
||||
return;
|
||||
}
|
||||
|
||||
if( !check_columns($link)) {
|
||||
if (!check_columns($link)) {
|
||||
mysql_close($link);
|
||||
return;
|
||||
}
|
||||
@ -168,9 +174,9 @@ function check_status() {
|
||||
$page['done'][] = getlocal("installed.message");
|
||||
|
||||
$page['nextstep'] = getlocal("installed.login_link");
|
||||
$page['nextnotice'] = getlocal2("installed.notice", array($webimroot."/install/"));
|
||||
$page['nextnotice'] = getlocal2("installed.notice", array($webimroot . "/install/"));
|
||||
$page['nextstepurl'] = "$webimroot/";
|
||||
|
||||
|
||||
$page['show_small_login'] = true;
|
||||
|
||||
mysql_close($link);
|
||||
|
@ -15,54 +15,57 @@
|
||||
Copyright 2006 WebCheatSheet.com
|
||||
*/
|
||||
|
||||
function can_show_captcha() {
|
||||
function can_show_captcha()
|
||||
{
|
||||
return extension_loaded("gd");
|
||||
}
|
||||
|
||||
function gen_captcha() {
|
||||
$md5_hash = md5(rand(0,9999));
|
||||
return substr($md5_hash, 15, 5);
|
||||
function gen_captcha()
|
||||
{
|
||||
$md5_hash = md5(rand(0, 9999));
|
||||
return substr($md5_hash, 15, 5);
|
||||
}
|
||||
|
||||
function draw_captcha($security_code) {
|
||||
function draw_captcha($security_code)
|
||||
{
|
||||
|
||||
//Set the image width and height
|
||||
$width = 100;
|
||||
$height = 25;
|
||||
//Set the image width and height
|
||||
$width = 100;
|
||||
$height = 25;
|
||||
|
||||
//Create the image resource
|
||||
$image = ImageCreate($width, $height);
|
||||
if(function_exists('imageantialias')) {
|
||||
//Create the image resource
|
||||
$image = ImageCreate($width, $height);
|
||||
if (function_exists('imageantialias')) {
|
||||
imageantialias($image, true);
|
||||
}
|
||||
|
||||
//We are making three colors, white, black and gray
|
||||
$white = ImageColorAllocate($image, 255, 255, 255);
|
||||
$black = ImageColorAllocate($image, 15, 50, 15);
|
||||
$grey = ImageColorAllocate($image, 204, 204, 204);
|
||||
$ellipsec = ImageColorAllocate($image, 0, 100, 60);
|
||||
|
||||
//Make the background black
|
||||
ImageFill($image, 0, 0, $black);
|
||||
imagefilledellipse($image, 56,15,30,17, $ellipsec);
|
||||
|
||||
//Add randomly generated string in white to the image
|
||||
ImageString($image, 5, 30, 4, $security_code, $white);
|
||||
|
||||
//Throw in some lines to make it a little bit harder for any bots to break
|
||||
ImageRectangle($image,0,0,$width-1,$height-1,$grey);
|
||||
imageline($image, 0, $height/2+3, $width, $height/2+5, $grey);
|
||||
imageline($image, $width/2-14, 0, $width/2+7, $height, $grey);
|
||||
}
|
||||
|
||||
|
||||
//Tell the browser what kind of file is come in
|
||||
header("Content-Type: image/jpeg");
|
||||
//We are making three colors, white, black and gray
|
||||
$white = ImageColorAllocate($image, 255, 255, 255);
|
||||
$black = ImageColorAllocate($image, 15, 50, 15);
|
||||
$grey = ImageColorAllocate($image, 204, 204, 204);
|
||||
$ellipsec = ImageColorAllocate($image, 0, 100, 60);
|
||||
|
||||
//Output the newly created image in jpeg format
|
||||
ImageJpeg($image);
|
||||
|
||||
//Free up resources
|
||||
ImageDestroy($image);
|
||||
//Make the background black
|
||||
ImageFill($image, 0, 0, $black);
|
||||
imagefilledellipse($image, 56, 15, 30, 17, $ellipsec);
|
||||
|
||||
//Add randomly generated string in white to the image
|
||||
ImageString($image, 5, 30, 4, $security_code, $white);
|
||||
|
||||
//Throw in some lines to make it a little bit harder for any bots to break
|
||||
ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
|
||||
imageline($image, 0, $height / 2 + 3, $width, $height / 2 + 5, $grey);
|
||||
imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey);
|
||||
|
||||
|
||||
//Tell the browser what kind of file is come in
|
||||
header("Content-Type: image/jpeg");
|
||||
|
||||
//Output the newly created image in jpeg format
|
||||
ImageJpeg($image);
|
||||
|
||||
//Free up resources
|
||||
ImageDestroy($image);
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -40,88 +40,97 @@ $kind_conn = 5;
|
||||
$kind_events = 6;
|
||||
$kind_avatar = 7;
|
||||
|
||||
$kind_to_string = array( $kind_user => "user", $kind_agent => "agent", $kind_for_agent => "hidden",
|
||||
$kind_info => "inf", $kind_conn => "conn", $kind_events => "event", $kind_avatar => "avatar" );
|
||||
$kind_to_string = array($kind_user => "user", $kind_agent => "agent", $kind_for_agent => "hidden",
|
||||
$kind_info => "inf", $kind_conn => "conn", $kind_events => "event", $kind_avatar => "avatar");
|
||||
|
||||
function get_user_id() {
|
||||
return (time() + microtime()).rand(0,99999999);
|
||||
function get_user_id()
|
||||
{
|
||||
return (time() + microtime()) . rand(0, 99999999);
|
||||
}
|
||||
|
||||
function next_token() {
|
||||
return rand(99999,99999999);
|
||||
function next_token()
|
||||
{
|
||||
return rand(99999, 99999999);
|
||||
}
|
||||
|
||||
function next_revision($link) {
|
||||
function next_revision($link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
perform_query("update ${mysqlprefix}chatrevision set id=LAST_INSERT_ID(id+1)",$link);
|
||||
perform_query("update ${mysqlprefix}chatrevision set id=LAST_INSERT_ID(id+1)", $link);
|
||||
$val = mysql_insert_id($link);
|
||||
return $val;
|
||||
}
|
||||
|
||||
function post_message_($threadid,$kind,$message,$link,$from=null,$utime=null,$opid=null) {
|
||||
function post_message_($threadid, $kind, $message, $link, $from = null, $utime = null, $opid = null)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s, %s,'%s',%s,%s,%s)",
|
||||
$threadid,
|
||||
$kind,
|
||||
mysql_real_escape_string($message,$link),
|
||||
$from ? "'".mysql_real_escape_string($from,$link)."'" : "null",
|
||||
$opid ? $opid : "0",
|
||||
$utime ? "FROM_UNIXTIME($utime)" : "CURRENT_TIMESTAMP" );
|
||||
$threadid,
|
||||
$kind,
|
||||
mysql_real_escape_string($message, $link),
|
||||
$from ? "'" . mysql_real_escape_string($from, $link) . "'" : "null",
|
||||
$opid ? $opid : "0",
|
||||
$utime ? "FROM_UNIXTIME($utime)" : "CURRENT_TIMESTAMP");
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
return mysql_insert_id($link);
|
||||
}
|
||||
|
||||
function post_message($threadid,$kind,$message,$from=null,$agentid=null) {
|
||||
function post_message($threadid, $kind, $message, $from = null, $agentid = null)
|
||||
{
|
||||
$link = connect();
|
||||
$id = post_message_($threadid,$kind,$message,$link,$from,null,$agentid);
|
||||
$id = post_message_($threadid, $kind, $message, $link, $from, null, $agentid);
|
||||
mysql_close($link);
|
||||
return $id;
|
||||
}
|
||||
|
||||
function prepare_html_message($text) {
|
||||
function prepare_html_message($text)
|
||||
{
|
||||
$escaped_text = htmlspecialchars($text);
|
||||
$text_w_links = preg_replace('/(http|ftp):\/\/\S*/','<a href="$0" target="_blank">$0</a>',$escaped_text);
|
||||
$multiline = str_replace("\n","<br/>",$text_w_links);
|
||||
$text_w_links = preg_replace('/(http|ftp):\/\/\S*/', '<a href="$0" target="_blank">$0</a>', $escaped_text);
|
||||
$multiline = str_replace("\n", "<br/>", $text_w_links);
|
||||
return $multiline;
|
||||
}
|
||||
|
||||
function message_to_html($msg) {
|
||||
function message_to_html($msg)
|
||||
{
|
||||
global $kind_to_string, $kind_avatar;
|
||||
if( $msg['ikind'] == $kind_avatar ) return "";
|
||||
$message = "<span>".date("H:i:s",$msg['created'])."</span> ";
|
||||
if ($msg['ikind'] == $kind_avatar) return "";
|
||||
$message = "<span>" . date("H:i:s", $msg['created']) . "</span> ";
|
||||
$kind = $kind_to_string{$msg['ikind']};
|
||||
if( $msg['tname'] )
|
||||
$message.= "<span class='n$kind'>".htmlspecialchars($msg['tname'])."</span>: ";
|
||||
$message.= "<span class='m$kind'>".prepare_html_message($msg['tmessage'])."</span><br/>";
|
||||
if ($msg['tname'])
|
||||
$message .= "<span class='n$kind'>" . htmlspecialchars($msg['tname']) . "</span>: ";
|
||||
$message .= "<span class='m$kind'>" . prepare_html_message($msg['tmessage']) . "</span><br/>";
|
||||
return $message;
|
||||
}
|
||||
|
||||
function message_to_text($msg) {
|
||||
function message_to_text($msg)
|
||||
{
|
||||
global $kind_user, $kind_agent, $kind_info, $kind_avatar;
|
||||
if( $msg['ikind'] == $kind_avatar ) return "";
|
||||
$message_time = date("H:i:s ",$msg['created']);
|
||||
if($msg['ikind'] == $kind_user || $msg['ikind'] == $kind_agent) {
|
||||
if( $msg['tname'] )
|
||||
return $message_time.$msg['tname'].": ".$msg['tmessage']."\n";
|
||||
if ($msg['ikind'] == $kind_avatar) return "";
|
||||
$message_time = date("H:i:s ", $msg['created']);
|
||||
if ($msg['ikind'] == $kind_user || $msg['ikind'] == $kind_agent) {
|
||||
if ($msg['tname'])
|
||||
return $message_time . $msg['tname'] . ": " . $msg['tmessage'] . "\n";
|
||||
else
|
||||
return $message_time.$msg['tmessage']."\n";
|
||||
} else if($msg['ikind'] == $kind_info ) {
|
||||
return $message_time.$msg['tmessage']."\n";
|
||||
return $message_time . $msg['tmessage'] . "\n";
|
||||
} else if ($msg['ikind'] == $kind_info) {
|
||||
return $message_time . $msg['tmessage'] . "\n";
|
||||
} else {
|
||||
return $message_time."[".$msg['tmessage']."]\n";
|
||||
return $message_time . "[" . $msg['tmessage'] . "]\n";
|
||||
}
|
||||
}
|
||||
|
||||
function get_messages($threadid,$meth,$isuser,&$lastid) {
|
||||
function get_messages($threadid, $meth, $isuser, &$lastid)
|
||||
{
|
||||
global $kind_for_agent, $kind_avatar, $webim_encoding, $mysqlprefix;
|
||||
$link = connect();
|
||||
|
||||
$query = sprintf(
|
||||
"select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from ${mysqlprefix}chatmessage ".
|
||||
"select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from ${mysqlprefix}chatmessage " .
|
||||
"where threadid = %s and messageid > %s %s order by messageid",
|
||||
$threadid, $lastid, $isuser ? "and ikind <> $kind_for_agent" : "" );
|
||||
$threadid, $lastid, $isuser ? "and ikind <> $kind_for_agent" : "");
|
||||
|
||||
$messages = array();
|
||||
$msgs = select_multi_assoc($query, $link);
|
||||
@ -130,10 +139,10 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
|
||||
if ($meth == 'xml') {
|
||||
switch ($msg['ikind']) {
|
||||
case $kind_avatar:
|
||||
$message = "<avatar>".myiconv($webim_encoding,"utf-8",escape_with_cdata($msg['tmessage']))."</avatar>";
|
||||
$message = "<avatar>" . myiconv($webim_encoding, "utf-8", escape_with_cdata($msg['tmessage'])) . "</avatar>";
|
||||
break;
|
||||
default:
|
||||
$message = "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."</message>\n";
|
||||
$message = "<message>" . myiconv($webim_encoding, "utf-8", escape_with_cdata(message_to_html($msg))) . "</message>\n";
|
||||
}
|
||||
} else {
|
||||
if ($msg['ikind'] != $kind_avatar) {
|
||||
@ -142,7 +151,7 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
|
||||
}
|
||||
|
||||
$messages[] = $message;
|
||||
if( $msg['messageid'] > $lastid ) {
|
||||
if ($msg['messageid'] > $lastid) {
|
||||
$lastid = $msg['messageid'];
|
||||
}
|
||||
}
|
||||
@ -151,97 +160,102 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agentid=null) {
|
||||
function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agentid = null)
|
||||
{
|
||||
global $webim_encoding, $webimroot, $connection_timeout, $settings;
|
||||
$threadid = $thread['threadid'];
|
||||
$istyping = abs($thread['current']-$thread[$isuser ? "lpagent" : "lpuser"]) < $connection_timeout
|
||||
&& $thread[$isuser?"agentTyping":"userTyping"] == "1" ? "1" : "0";
|
||||
$istyping = abs($thread['current'] - $thread[$isuser ? "lpagent" : "lpuser"]) < $connection_timeout
|
||||
&& $thread[$isuser ? "agentTyping" : "userTyping"] == "1" ? "1" : "0";
|
||||
|
||||
if( $format == "xml" ) {
|
||||
$output = get_messages($threadid,"xml",$isuser,$lastid);
|
||||
if ($format == "xml") {
|
||||
$output = get_messages($threadid, "xml", $isuser, $lastid);
|
||||
|
||||
start_xml_output();
|
||||
print("<thread lastid=\"$lastid\" typing=\"".$istyping."\" canpost=\"".(($isuser || $agentid != null && $agentid == $thread['agentId']) ? 1 : 0)."\">");
|
||||
foreach( $output as $msg ) {
|
||||
print("<thread lastid=\"$lastid\" typing=\"" . $istyping . "\" canpost=\"" . (($isuser || $agentid != null && $agentid == $thread['agentId']) ? 1 : 0) . "\">");
|
||||
foreach ($output as $msg) {
|
||||
print $msg;
|
||||
}
|
||||
print("</thread>");
|
||||
} else if( $format == "html" ) {
|
||||
} else if ($format == "html") {
|
||||
loadsettings();
|
||||
$output = get_messages($threadid,"html",$isuser,$lastid);
|
||||
$output = get_messages($threadid, "html", $isuser, $lastid);
|
||||
|
||||
start_html_output();
|
||||
$url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=".($isuser?"true":"false");
|
||||
$url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=" . ($isuser ? "true" : "false");
|
||||
|
||||
print(
|
||||
"<!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' onload=\"if( location.hash != '#aend' ){location.hash='#aend';}\">".
|
||||
"<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>" );
|
||||
|
||||
foreach( $output as $msg ) {
|
||||
"<!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' onload=\"if( location.hash != '#aend' ){location.hash='#aend';}\">" .
|
||||
"<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>");
|
||||
|
||||
foreach ($output as $msg) {
|
||||
print $msg;
|
||||
}
|
||||
|
||||
print(
|
||||
"</td></tr></table><a name='aend'></a>".
|
||||
"</body></html>" );
|
||||
"</td></tr></table><a name='aend'></a>" .
|
||||
"</body></html>");
|
||||
}
|
||||
}
|
||||
|
||||
function get_user_name($username, $addr, $id) {
|
||||
function get_user_name($username, $addr, $id)
|
||||
{
|
||||
global $settings;
|
||||
loadsettings();
|
||||
return str_replace("{addr}", $addr,
|
||||
str_replace("{id}", $id,
|
||||
str_replace("{name}", $username, $settings['usernamepattern'])));
|
||||
str_replace("{id}", $id,
|
||||
str_replace("{name}", $username, $settings['usernamepattern'])));
|
||||
}
|
||||
|
||||
function is_ajax_browser($browserid,$ver,$useragent) {
|
||||
if( $browserid == "opera" )
|
||||
function is_ajax_browser($browserid, $ver, $useragent)
|
||||
{
|
||||
if ($browserid == "opera")
|
||||
return $ver >= 8.02;
|
||||
if( $browserid == "safari" )
|
||||
if ($browserid == "safari")
|
||||
return $ver >= 125;
|
||||
if( $browserid == "msie" )
|
||||
if ($browserid == "msie")
|
||||
return $ver >= 5.5 && !strstr($useragent, "powerpc");
|
||||
if( $browserid == "netscape" )
|
||||
if ($browserid == "netscape")
|
||||
return $ver >= 7.1;
|
||||
if( $browserid == "mozilla")
|
||||
if ($browserid == "mozilla")
|
||||
return $ver >= 1.4;
|
||||
if( $browserid == "firefox")
|
||||
if ($browserid == "firefox")
|
||||
return $ver >= 1.0;
|
||||
if( $browserid == "chrome")
|
||||
if ($browserid == "chrome")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_old_browser($browserid,$ver) {
|
||||
if( $browserid == "opera" )
|
||||
function is_old_browser($browserid, $ver)
|
||||
{
|
||||
if ($browserid == "opera")
|
||||
return $ver < 7.0;
|
||||
if( $browserid == "msie" )
|
||||
if ($browserid == "msie")
|
||||
return $ver < 5.0;
|
||||
return false;
|
||||
}
|
||||
|
||||
$knownAgents = array("opera","msie","chrome","safari","firefox","netscape","mozilla");
|
||||
$knownAgents = array("opera", "msie", "chrome", "safari", "firefox", "netscape", "mozilla");
|
||||
|
||||
function get_remote_level($useragent) {
|
||||
function get_remote_level($useragent)
|
||||
{
|
||||
global $knownAgents;
|
||||
$useragent = strtolower($useragent);
|
||||
foreach( $knownAgents as $agent ) {
|
||||
if( strstr($useragent,$agent) ) {
|
||||
if( preg_match( "/".$agent."[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches ) ) {
|
||||
foreach ($knownAgents as $agent) {
|
||||
if (strstr($useragent, $agent)) {
|
||||
if (preg_match("/" . $agent . "[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches)) {
|
||||
$ver = $matches[1];
|
||||
|
||||
if( is_ajax_browser($agent,$ver,$useragent) )
|
||||
if (is_ajax_browser($agent, $ver, $useragent))
|
||||
return "ajaxed";
|
||||
else if( is_old_browser($agent,$ver) )
|
||||
else if (is_old_browser($agent, $ver))
|
||||
return "old";
|
||||
|
||||
return "simple";
|
||||
@ -251,10 +265,11 @@ function get_remote_level($useragent) {
|
||||
return "simple";
|
||||
}
|
||||
|
||||
function is_agent_opera95() {
|
||||
function is_agent_opera95()
|
||||
{
|
||||
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
if( strstr($useragent,"opera") ) {
|
||||
if( preg_match( "/opera[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches ) ) {
|
||||
if (strstr($useragent, "opera")) {
|
||||
if (preg_match("/opera[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches)) {
|
||||
$ver = $matches[1];
|
||||
|
||||
if ($ver >= "9.5")
|
||||
@ -264,17 +279,20 @@ function is_agent_opera95() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_mac_opera() {
|
||||
function is_mac_opera()
|
||||
{
|
||||
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
return strstr($useragent,"opera") && strstr($useragent, "mac");
|
||||
return strstr($useragent, "opera") && strstr($useragent, "mac");
|
||||
}
|
||||
|
||||
function needsFramesrc() {
|
||||
function needsFramesrc()
|
||||
{
|
||||
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
return strstr($useragent,"safari/");
|
||||
return strstr($useragent, "safari/");
|
||||
}
|
||||
|
||||
function setup_logo() {
|
||||
function setup_logo()
|
||||
{
|
||||
global $page, $settings;
|
||||
loadsettings();
|
||||
$page['ct.company.name'] = topage($settings['title']);
|
||||
@ -282,7 +300,8 @@ function setup_logo() {
|
||||
$page['webimHost'] = topage($settings['hosturl']);
|
||||
}
|
||||
|
||||
function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info, $referrer,$canshowcaptcha) {
|
||||
function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info, $referrer, $canshowcaptcha)
|
||||
{
|
||||
global $settings, $page;
|
||||
$page['formname'] = topage($name);
|
||||
$page['formemail'] = topage($email);
|
||||
@ -294,44 +313,46 @@ function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info
|
||||
$page['referrer'] = urlencode(topage($referrer));
|
||||
}
|
||||
|
||||
function setup_survey($name, $email, $groupid, $info, $referrer) {
|
||||
function setup_survey($name, $email, $groupid, $info, $referrer)
|
||||
{
|
||||
global $settings, $page;
|
||||
|
||||
|
||||
$page['formname'] = topage($name);
|
||||
$page['formemail'] = topage($email);
|
||||
$page['formgroupid'] = $groupid;
|
||||
$page['forminfo'] = topage($info);
|
||||
$page['referrer'] = urlencode(topage($referrer));
|
||||
|
||||
if($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") {
|
||||
if ($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") {
|
||||
$link = connect();
|
||||
$allgroups = get_groups($link,false);
|
||||
$allgroups = get_groups($link, false);
|
||||
mysql_close($link);
|
||||
$val = "";
|
||||
foreach($allgroups as $k) {
|
||||
foreach ($allgroups as $k) {
|
||||
$groupname = $k['vclocalname'];
|
||||
if($k['inumofagents'] == 0) {
|
||||
if ($k['inumofagents'] == 0) {
|
||||
continue;
|
||||
}
|
||||
if($k['ilastseen'] !== NULL && $k['ilastseen'] < $settings['online_timeout']) {
|
||||
if(!$groupid) {
|
||||
$groupid = $k['groupid']; // select first online group
|
||||
if ($k['ilastseen'] !== NULL && $k['ilastseen'] < $settings['online_timeout']) {
|
||||
if (!$groupid) {
|
||||
$groupid = $k['groupid']; // select first online group
|
||||
}
|
||||
} else {
|
||||
$groupname .= " (offline)";
|
||||
}
|
||||
$isselected = $k['groupid'] == $groupid;
|
||||
$val .= "<option value=\"".$k['groupid']."\"".($isselected ? " selected=\"selected\"" : "").">$groupname</option>";
|
||||
$val .= "<option value=\"" . $k['groupid'] . "\"" . ($isselected ? " selected=\"selected\"" : "") . ">$groupname</option>";
|
||||
}
|
||||
$page['groups'] = $val;
|
||||
}
|
||||
|
||||
|
||||
$page['showemail'] = $settings["surveyaskmail"] == "1" ? "1" : "";
|
||||
$page['showmessage'] = $settings["surveyaskmessage"] == "1" ? "1" : "";
|
||||
$page['showname'] = $settings['usercanchangename'] == "1" ? "1" : "";
|
||||
}
|
||||
|
||||
function setup_chatview_for_user($thread,$level) {
|
||||
function setup_chatview_for_user($thread, $level)
|
||||
{
|
||||
global $page, $webimroot, $settings;
|
||||
loadsettings();
|
||||
$page = array();
|
||||
@ -349,19 +370,19 @@ function setup_chatview_for_user($thread,$level) {
|
||||
$page['chat.title'] = topage($settings['chattitle']);
|
||||
|
||||
setup_logo();
|
||||
if($settings['sendmessagekey'] == 'enter') {
|
||||
if ($settings['sendmessagekey'] == 'enter') {
|
||||
$page['send_shortcut'] = "Enter";
|
||||
$page['ignorectrl'] = 1;
|
||||
$page['ignorectrl'] = 1;
|
||||
} else {
|
||||
$page['send_shortcut'] = is_mac_opera() ? "⌘-Enter" : "Ctrl-Enter";
|
||||
$page['ignorectrl'] = 0;
|
||||
$page['ignorectrl'] = 0;
|
||||
}
|
||||
|
||||
$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
|
||||
$page['mailLink'] = "$webimroot/client.php?".$params."&level=$level&act=mailthread";
|
||||
$params = "thread=" . $thread['threadid'] . "&token=" . $thread['ltoken'];
|
||||
$page['mailLink'] = "$webimroot/client.php?" . $params . "&level=$level&act=mailthread";
|
||||
|
||||
if($settings['enablessl'] == "1" && !is_secure_request()) {
|
||||
$page['sslLink'] = get_app_location(true, true)."/client.php?".$params."&level=$level";
|
||||
if ($settings['enablessl'] == "1" && !is_secure_request()) {
|
||||
$page['sslLink'] = get_app_location(true, true) . "/client.php?" . $params . "&level=$level";
|
||||
}
|
||||
|
||||
$page['isOpera95'] = is_agent_opera95();
|
||||
@ -370,22 +391,23 @@ function setup_chatview_for_user($thread,$level) {
|
||||
$page['frequency'] = $settings['updatefrequency_chat'];
|
||||
}
|
||||
|
||||
function load_canned_messages($locale, $groupid) {
|
||||
function load_canned_messages($locale, $groupid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$result = select_multi_assoc(
|
||||
"select vcvalue from ${mysqlprefix}chatresponses where locale = '".$locale."' ".
|
||||
"AND (groupid is NULL OR groupid = 0) order by vcvalue", $link);
|
||||
if(count($result) == 0) {
|
||||
foreach(explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
"select vcvalue from ${mysqlprefix}chatresponses where locale = '" . $locale . "' " .
|
||||
"AND (groupid is NULL OR groupid = 0) order by vcvalue", $link);
|
||||
if (count($result) == 0) {
|
||||
foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
$result[] = array('vcvalue' => $answer);
|
||||
}
|
||||
}
|
||||
if($groupid) {
|
||||
if ($groupid) {
|
||||
$result2 = select_multi_assoc(
|
||||
"select vcvalue from ${mysqlprefix}chatresponses where locale = '".$locale."' ".
|
||||
"AND groupid = $groupid order by vcvalue", $link);
|
||||
foreach($result as $r) {
|
||||
"select vcvalue from ${mysqlprefix}chatresponses where locale = '" . $locale . "' " .
|
||||
"AND groupid = $groupid order by vcvalue", $link);
|
||||
foreach ($result as $r) {
|
||||
$result2[] = $r;
|
||||
}
|
||||
$result = $result2;
|
||||
@ -394,7 +416,8 @@ function load_canned_messages($locale, $groupid) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function setup_chatview_for_operator($thread,$operator) {
|
||||
function setup_chatview_for_operator($thread, $operator)
|
||||
{
|
||||
global $page, $webimroot, $company_logo_link, $company_name, $settings;
|
||||
loadsettings();
|
||||
$page = array();
|
||||
@ -403,76 +426,78 @@ function setup_chatview_for_operator($thread,$operator) {
|
||||
$page['canpost'] = $thread['agentId'] == $operator['operatorid'];
|
||||
$page['ct.chatThreadId'] = $thread['threadid'];
|
||||
$page['ct.token'] = $thread['ltoken'];
|
||||
$page['ct.user.name'] = htmlspecialchars(topage(get_user_name($thread['userName'],$thread['remote'],$thread['userid'])));
|
||||
$page['ct.user.name'] = htmlspecialchars(topage(get_user_name($thread['userName'], $thread['remote'], $thread['userid'])));
|
||||
$page['chat.title'] = topage($settings['chattitle']);
|
||||
|
||||
setup_logo();
|
||||
if($settings['sendmessagekey'] == 'enter') {
|
||||
if ($settings['sendmessagekey'] == 'enter') {
|
||||
$page['send_shortcut'] = "Enter";
|
||||
$page['ignorectrl'] = 1;
|
||||
$page['ignorectrl'] = 1;
|
||||
} else {
|
||||
$page['send_shortcut'] = is_mac_opera() ? "⌘-Enter" : "Ctrl-Enter";
|
||||
$page['ignorectrl'] = 0;
|
||||
$page['ignorectrl'] = 0;
|
||||
}
|
||||
|
||||
if($settings['enablessl'] == "1" && !is_secure_request()) {
|
||||
$page['sslLink'] = get_app_location(true, true)."/operator/agent.php?thread=".$thread['threadid']."&token=".$thread['ltoken'];
|
||||
if ($settings['enablessl'] == "1" && !is_secure_request()) {
|
||||
$page['sslLink'] = get_app_location(true, true) . "/operator/agent.php?thread=" . $thread['threadid'] . "&token=" . $thread['ltoken'];
|
||||
}
|
||||
$page['isOpera95'] = is_agent_opera95();
|
||||
$page['neediframesrc'] = needsFramesrc();
|
||||
$page['historyParams'] = array("userid" => "".$thread['userid']);
|
||||
$page['historyParamsLink'] = add_params($webimroot."/operator/userhistory.php",$page['historyParams']);
|
||||
$page['historyParams'] = array("userid" => "" . $thread['userid']);
|
||||
$page['historyParamsLink'] = add_params($webimroot . "/operator/userhistory.php", $page['historyParams']);
|
||||
$predefinedres = "";
|
||||
$canned_messages = load_canned_messages($thread['locale'], $thread['groupid']);
|
||||
foreach($canned_messages as $answer) {
|
||||
$predefinedres .= "<option>".htmlspecialchars(topage($answer['vcvalue']))."</option>";
|
||||
foreach ($canned_messages as $answer) {
|
||||
$predefinedres .= "<option>" . htmlspecialchars(topage($answer['vcvalue'])) . "</option>";
|
||||
}
|
||||
$page['predefinedAnswers'] = $predefinedres;
|
||||
$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
|
||||
$page['redirectLink'] = "$webimroot/operator/agent.php?".$params."&act=redirect";
|
||||
$params = "thread=" . $thread['threadid'] . "&token=" . $thread['ltoken'];
|
||||
$page['redirectLink'] = "$webimroot/operator/agent.php?" . $params . "&act=redirect";
|
||||
|
||||
$page['namePostfix'] = "";
|
||||
$page['frequency'] = $settings['updatefrequency_chat'];
|
||||
}
|
||||
|
||||
function update_thread_access($threadid, $params, $link) {
|
||||
function update_thread_access($threadid, $params, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$clause = "";
|
||||
foreach( $params as $k => $v ) {
|
||||
if( strlen($clause) > 0 )
|
||||
foreach ($params as $k => $v) {
|
||||
if (strlen($clause) > 0)
|
||||
$clause .= ", ";
|
||||
$clause .= $k."=".$v;
|
||||
$clause .= $k . "=" . $v;
|
||||
}
|
||||
perform_query(
|
||||
"update ${mysqlprefix}chatthread set $clause ".
|
||||
"where threadid = ".$threadid,$link);
|
||||
"update ${mysqlprefix}chatthread set $clause " .
|
||||
"where threadid = " . $threadid, $link);
|
||||
}
|
||||
|
||||
function ping_thread($thread, $isuser,$istyping) {
|
||||
function ping_thread($thread, $isuser, $istyping)
|
||||
{
|
||||
global $kind_for_agent, $state_queue, $state_loading, $state_chatting, $state_waiting, $kind_conn, $connection_timeout;
|
||||
$link = connect();
|
||||
$params = array(($isuser ? "lastpinguser" : "lastpingagent") => "CURRENT_TIMESTAMP",
|
||||
($isuser ? "userTyping" : "agentTyping") => ($istyping? "1" : "0") );
|
||||
($isuser ? "userTyping" : "agentTyping") => ($istyping ? "1" : "0"));
|
||||
|
||||
$lastping = $thread[$isuser ? "lpagent" : "lpuser"];
|
||||
$current = $thread['current'];
|
||||
|
||||
if( $thread['istate'] == $state_loading && $isuser) {
|
||||
if ($thread['istate'] == $state_loading && $isuser) {
|
||||
$params['istate'] = $state_queue;
|
||||
commit_thread($thread['threadid'], $params, $link);
|
||||
mysql_close($link);
|
||||
return;
|
||||
}
|
||||
|
||||
if( $lastping > 0 && abs($current-$lastping) > $connection_timeout ) {
|
||||
if ($lastping > 0 && abs($current - $lastping) > $connection_timeout) {
|
||||
$params[$isuser ? "lastpingagent" : "lastpinguser"] = "0";
|
||||
if( !$isuser ) {
|
||||
if (!$isuser) {
|
||||
$message_to_post = getstring_("chat.status.user.dead", $thread['locale']);
|
||||
post_message_($thread['threadid'],$kind_for_agent,$message_to_post,$link,null,$lastping+$connection_timeout);
|
||||
} else if( $thread['istate'] == $state_chatting ) {
|
||||
post_message_($thread['threadid'], $kind_for_agent, $message_to_post, $link, null, $lastping + $connection_timeout);
|
||||
} else if ($thread['istate'] == $state_chatting) {
|
||||
|
||||
$message_to_post = getstring_("chat.status.operator.dead", $thread['locale']);
|
||||
post_message_($thread['threadid'],$kind_conn,$message_to_post,$link,null,$lastping+$connection_timeout);
|
||||
post_message_($thread['threadid'], $kind_conn, $message_to_post, $link, null, $lastping + $connection_timeout);
|
||||
$params['istate'] = $state_waiting;
|
||||
$params['nextagent'] = 0;
|
||||
commit_thread($thread['threadid'], $params, $link);
|
||||
@ -485,111 +510,120 @@ function ping_thread($thread, $isuser,$istyping) {
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function commit_thread($threadid,$params,$link) {
|
||||
function commit_thread($threadid, $params, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = "update ${mysqlprefix}chatthread t set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
|
||||
foreach( $params as $k => $v ) {
|
||||
$query .= ", ".$k."=".$v;
|
||||
$query = "update ${mysqlprefix}chatthread t set lrevision = " . next_revision($link) . ", dtmmodified = CURRENT_TIMESTAMP";
|
||||
foreach ($params as $k => $v) {
|
||||
$query .= ", " . $k . "=" . $v;
|
||||
}
|
||||
$query .= " where threadid = ".$threadid;
|
||||
$query .= " where threadid = " . $threadid;
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
}
|
||||
|
||||
function rename_user($thread, $newname) {
|
||||
function rename_user($thread, $newname)
|
||||
{
|
||||
global $kind_events;
|
||||
|
||||
$link = connect();
|
||||
commit_thread( $thread['threadid'], array('userName' => "'".mysql_real_escape_string($newname,$link)."'"), $link);
|
||||
commit_thread($thread['threadid'], array('userName' => "'" . mysql_real_escape_string($newname, $link) . "'"), $link);
|
||||
|
||||
if( $thread['userName'] != $newname ) {
|
||||
post_message_($thread['threadid'],$kind_events,
|
||||
getstring2_("chat.status.user.changedname",array($thread['userName'], $newname), $thread['locale']), $link);
|
||||
if ($thread['userName'] != $newname) {
|
||||
post_message_($thread['threadid'], $kind_events,
|
||||
getstring2_("chat.status.user.changedname", array($thread['userName'], $newname), $thread['locale']), $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function close_thread($thread,$isuser) {
|
||||
function close_thread($thread, $isuser)
|
||||
{
|
||||
global $state_closed, $kind_events, $mysqlprefix;
|
||||
|
||||
$link = connect();
|
||||
if( $thread['istate'] != $state_closed ) {
|
||||
commit_thread( $thread['threadid'], array('istate' => $state_closed,
|
||||
'messageCount' => "(SELECT COUNT(*) FROM ${mysqlprefix}chatmessage WHERE ${mysqlprefix}chatmessage.threadid = t.threadid AND ikind = 1)"), $link);
|
||||
if ($thread['istate'] != $state_closed) {
|
||||
commit_thread($thread['threadid'], array('istate' => $state_closed,
|
||||
'messageCount' => "(SELECT COUNT(*) FROM ${mysqlprefix}chatmessage WHERE ${mysqlprefix}chatmessage.threadid = t.threadid AND ikind = 1)"), $link);
|
||||
}
|
||||
|
||||
$message = $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
|
||||
: getstring2_("chat.status.operator.left", array($thread['agentName']), $thread['locale']);
|
||||
$message = $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
|
||||
: getstring2_("chat.status.operator.left", array($thread['agentName']), $thread['locale']);
|
||||
post_message_($thread['threadid'], $kind_events, $message, $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function thread_by_id_($id,$link) {
|
||||
function thread_by_id_($id, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
return select_one_row("select threadid,userName,agentName,agentId,lrevision,istate,ltoken,userTyping,agentTyping".
|
||||
",unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created".
|
||||
",remote,referer,locale,unix_timestamp(lastpinguser) as lpuser,unix_timestamp(lastpingagent) as lpagent, unix_timestamp(CURRENT_TIMESTAMP) as current,nextagent,shownmessageid,userid,userAgent,groupid".
|
||||
" from ${mysqlprefix}chatthread where threadid = ". $id, $link );
|
||||
return select_one_row("select threadid,userName,agentName,agentId,lrevision,istate,ltoken,userTyping,agentTyping" .
|
||||
",unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created" .
|
||||
",remote,referer,locale,unix_timestamp(lastpinguser) as lpuser,unix_timestamp(lastpingagent) as lpagent, unix_timestamp(CURRENT_TIMESTAMP) as current,nextagent,shownmessageid,userid,userAgent,groupid" .
|
||||
" from ${mysqlprefix}chatthread where threadid = " . $id, $link);
|
||||
}
|
||||
|
||||
function ban_for_addr_($addr,$link) {
|
||||
function ban_for_addr_($addr, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
return select_one_row("select banid,comment from ${mysqlprefix}chatban where unix_timestamp(dtmtill) > unix_timestamp(CURRENT_TIMESTAMP) AND address = '".mysql_real_escape_string($addr,$link)."'", $link );
|
||||
return select_one_row("select banid,comment from ${mysqlprefix}chatban where unix_timestamp(dtmtill) > unix_timestamp(CURRENT_TIMESTAMP) AND address = '" . mysql_real_escape_string($addr, $link) . "'", $link);
|
||||
}
|
||||
|
||||
function thread_by_id($id) {
|
||||
function thread_by_id($id)
|
||||
{
|
||||
$link = connect();
|
||||
$thread = thread_by_id_($id,$link);
|
||||
$thread = thread_by_id_($id, $link);
|
||||
mysql_close($link);
|
||||
return $thread;
|
||||
}
|
||||
|
||||
function create_thread($groupid,$username,$remoteHost,$referer,$lang,$userid,$userbrowser,$initialState,$link) {
|
||||
function create_thread($groupid, $username, $remoteHost, $referer, $lang, $userid, $userbrowser, $initialState, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatthread (userName,userid,ltoken,remote,referer,lrevision,locale,userAgent,dtmcreated,dtmmodified,istate".($groupid?",groupid":"").") values ".
|
||||
"('%s','%s',%s,'%s','%s',%s,'%s','%s',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,$initialState".($groupid?",$groupid":"").")",
|
||||
mysql_real_escape_string($username, $link),
|
||||
mysql_real_escape_string($userid, $link),
|
||||
next_token(),
|
||||
mysql_real_escape_string($remoteHost, $link),
|
||||
mysql_real_escape_string($referer, $link),
|
||||
next_revision($link),
|
||||
mysql_real_escape_string($lang, $link),
|
||||
mysql_real_escape_string($userbrowser, $link));
|
||||
"insert into ${mysqlprefix}chatthread (userName,userid,ltoken,remote,referer,lrevision,locale,userAgent,dtmcreated,dtmmodified,istate" . ($groupid ? ",groupid" : "") . ") values " .
|
||||
"('%s','%s',%s,'%s','%s',%s,'%s','%s',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,$initialState" . ($groupid ? ",$groupid" : "") . ")",
|
||||
mysql_real_escape_string($username, $link),
|
||||
mysql_real_escape_string($userid, $link),
|
||||
next_token(),
|
||||
mysql_real_escape_string($remoteHost, $link),
|
||||
mysql_real_escape_string($referer, $link),
|
||||
next_revision($link),
|
||||
mysql_real_escape_string($lang, $link),
|
||||
mysql_real_escape_string($userbrowser, $link));
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
$id = mysql_insert_id($link);
|
||||
|
||||
$newthread = thread_by_id_($id,$link);
|
||||
$newthread = thread_by_id_($id, $link);
|
||||
return $newthread;
|
||||
}
|
||||
|
||||
function do_take_thread($threadid,$operatorId,$operatorName) {
|
||||
function do_take_thread($threadid, $operatorId, $operatorName)
|
||||
{
|
||||
global $state_chatting;
|
||||
$link = connect();
|
||||
commit_thread( $threadid,
|
||||
array("istate" => $state_chatting,
|
||||
"nextagent" => 0,
|
||||
"agentId" => $operatorId,
|
||||
"agentName" => "'".mysql_real_escape_string($operatorName, $link)."'"), $link);
|
||||
commit_thread($threadid,
|
||||
array("istate" => $state_chatting,
|
||||
"nextagent" => 0,
|
||||
"agentId" => $operatorId,
|
||||
"agentName" => "'" . mysql_real_escape_string($operatorName, $link) . "'"), $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function reopen_thread($threadid) {
|
||||
global $state_queue,$state_loading,$state_waiting,$state_chatting,$state_closed,$state_left,$kind_events;
|
||||
function reopen_thread($threadid)
|
||||
{
|
||||
global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events;
|
||||
$link = connect();
|
||||
$thread = thread_by_id_($threadid, $link);
|
||||
|
||||
if( !$thread )
|
||||
if (!$thread)
|
||||
return FALSE;
|
||||
|
||||
if( $thread['istate'] == $state_closed || $thread['istate'] == $state_left )
|
||||
if ($thread['istate'] == $state_closed || $thread['istate'] == $state_left)
|
||||
return FALSE;
|
||||
|
||||
if( $thread['istate'] != $state_chatting && $thread['istate'] != $state_queue && $thread['istate'] != $state_loading ) {
|
||||
commit_thread( $threadid,
|
||||
array("istate" => $state_waiting, "nextagent" => 0), $link);
|
||||
if ($thread['istate'] != $state_chatting && $thread['istate'] != $state_queue && $thread['istate'] != $state_loading) {
|
||||
commit_thread($threadid,
|
||||
array("istate" => $state_waiting, "nextagent" => 0), $link);
|
||||
}
|
||||
|
||||
post_message_($thread['threadid'], $kind_events, getstring_("chat.status.user.reopenedthread", $thread['locale']), $link);
|
||||
@ -597,7 +631,8 @@ function reopen_thread($threadid) {
|
||||
return $thread;
|
||||
}
|
||||
|
||||
function take_thread($thread,$operator) {
|
||||
function take_thread($thread, $operator)
|
||||
{
|
||||
global $state_queue, $state_loading, $state_waiting, $state_chatting, $kind_events, $kind_avatar, $home_locale;
|
||||
|
||||
$state = $thread['istate'];
|
||||
@ -606,11 +641,11 @@ function take_thread($thread,$operator) {
|
||||
|
||||
$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
|
||||
if( $state == $state_queue || $state == $state_waiting || $state == $state_loading) {
|
||||
if ($state == $state_queue || $state == $state_waiting || $state == $state_loading) {
|
||||
do_take_thread($threadid, $operator['operatorid'], $operatorName);
|
||||
|
||||
if( $state == $state_waiting ) {
|
||||
if( $operatorName != $thread['agentName'] ) {
|
||||
if ($state == $state_waiting) {
|
||||
if ($operatorName != $thread['agentName']) {
|
||||
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
|
||||
} else {
|
||||
$message_to_post = getstring2_("chat.status.operator.returned", array($operatorName), $thread['locale']);
|
||||
@ -618,8 +653,8 @@ function take_thread($thread,$operator) {
|
||||
} else {
|
||||
$message_to_post = getstring2_("chat.status.operator.joined", array($operatorName), $thread['locale']);
|
||||
}
|
||||
} else if( $state == $state_chatting ) {
|
||||
if( $operator['operatorid'] != $thread['agentId'] ) {
|
||||
} else if ($state == $state_chatting) {
|
||||
if ($operator['operatorid'] != $thread['agentId']) {
|
||||
do_take_thread($threadid, $operator['operatorid'], $operatorName);
|
||||
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
|
||||
}
|
||||
@ -627,36 +662,38 @@ function take_thread($thread,$operator) {
|
||||
die("cannot take thread");
|
||||
}
|
||||
|
||||
if( $message_to_post ) {
|
||||
post_message($threadid,$kind_events,$message_to_post);
|
||||
post_message($threadid,$kind_avatar,$operator['vcavatar'] ? $operator['vcavatar'] : "");
|
||||
if ($message_to_post) {
|
||||
post_message($threadid, $kind_events, $message_to_post);
|
||||
post_message($threadid, $kind_avatar, $operator['vcavatar'] ? $operator['vcavatar'] : "");
|
||||
}
|
||||
}
|
||||
|
||||
function check_for_reassign($thread,$operator) {
|
||||
function check_for_reassign($thread, $operator)
|
||||
{
|
||||
global $state_waiting, $home_locale, $kind_events, $kind_avatar;
|
||||
$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
if( $thread['istate'] == $state_waiting &&
|
||||
( $thread['nextagent'] == $operator['operatorid']
|
||||
|| $thread['agentId'] == $operator['operatorid'] )) {
|
||||
if ($thread['istate'] == $state_waiting &&
|
||||
($thread['nextagent'] == $operator['operatorid']
|
||||
|| $thread['agentId'] == $operator['operatorid'])) {
|
||||
do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName);
|
||||
if( $operatorName != $thread['agentName'] ) {
|
||||
if ($operatorName != $thread['agentName']) {
|
||||
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
|
||||
} else {
|
||||
$message_to_post = getstring2_("chat.status.operator.returned", array($operatorName), $thread['locale']);
|
||||
}
|
||||
|
||||
post_message($thread['threadid'],$kind_events,$message_to_post);
|
||||
post_message($thread['threadid'],$kind_avatar,$operator['vcavatar'] ? $operator['vcavatar'] : "");
|
||||
post_message($thread['threadid'], $kind_events, $message_to_post);
|
||||
post_message($thread['threadid'], $kind_avatar, $operator['vcavatar'] ? $operator['vcavatar'] : "");
|
||||
}
|
||||
}
|
||||
|
||||
function notify_operators($thread,$firstmessage,$link) {
|
||||
function notify_operators($thread, $firstmessage, $link)
|
||||
{
|
||||
global $settings, $mysqlprefix;
|
||||
if($settings['enablejabber'] == 1) {
|
||||
if ($settings['enablejabber'] == 1) {
|
||||
$groupid = $thread['groupid'];
|
||||
$query = "select ${mysqlprefix}chatoperator.operatorid as opid, inotify, vcjabbername, vcemail, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
|
||||
if($groupid) {
|
||||
if ($groupid) {
|
||||
$query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = ${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
|
||||
} else {
|
||||
$query .= " where istatus = 0";
|
||||
@ -664,46 +701,48 @@ function notify_operators($thread,$firstmessage,$link) {
|
||||
$query .= " and inotify = 1";
|
||||
$result = select_multi_assoc($query, $link);
|
||||
$text = getstring2_("notify.new.text", array(
|
||||
get_app_location(true, $settings['enablessl'] == '1' && $settings['forcessl'] == '1')."/operator/agent.php?thread=".$thread['threadid'],
|
||||
$thread['userName']
|
||||
), $thread['locale']);
|
||||
if($firstmessage) {
|
||||
get_app_location(true, $settings['enablessl'] == '1' && $settings['forcessl'] == '1') . "/operator/agent.php?thread=" . $thread['threadid'],
|
||||
$thread['userName']
|
||||
), $thread['locale']);
|
||||
if ($firstmessage) {
|
||||
$text .= "\n$firstmessage";
|
||||
}
|
||||
foreach($result as $op) {
|
||||
if($op['time'] < $settings['online_timeout'] && is_valid_email($op['vcjabbername'])) {
|
||||
foreach ($result as $op) {
|
||||
if ($op['time'] < $settings['online_timeout'] && is_valid_email($op['vcjabbername'])) {
|
||||
webim_xmpp($op['vcjabbername'], getstring2("notify.new.subject", array($thread['userName'])), $text, $link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_connections_from_remote($remote,$link) {
|
||||
function check_connections_from_remote($remote, $link)
|
||||
{
|
||||
global $settings, $state_closed, $state_left, $mysqlprefix;
|
||||
if($settings['max_connections_from_one_host'] == 0) {
|
||||
if ($settings['max_connections_from_one_host'] == 0) {
|
||||
return true;
|
||||
}
|
||||
$result = select_one_row(
|
||||
"select count(*) as opened from ${mysqlprefix}chatthread ".
|
||||
"where remote = '". mysql_real_escape_string($remote, $link)."' AND istate <> $state_closed AND istate <> $state_left", $link );
|
||||
if($result && isset($result['opened'])) {
|
||||
"select count(*) as opened from ${mysqlprefix}chatthread " .
|
||||
"where remote = '" . mysql_real_escape_string($remote, $link) . "' AND istate <> $state_closed AND istate <> $state_left", $link);
|
||||
if ($result && isset($result['opened'])) {
|
||||
return $result['opened'] < $settings['max_connections_from_one_host'];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function visitor_from_request() {
|
||||
function visitor_from_request()
|
||||
{
|
||||
global $namecookie, $webim_encoding, $usercookie;
|
||||
$defaultName = getstring("chat.default.username");
|
||||
$userName = $defaultName;
|
||||
if( isset($_COOKIE[$namecookie]) ) {
|
||||
$data = base64_decode(strtr($_COOKIE[$namecookie],'-_,', '+/='));
|
||||
if( strlen($data) > 0 ) {
|
||||
$userName = myiconv("utf-8",$webim_encoding,$data);
|
||||
if (isset($_COOKIE[$namecookie])) {
|
||||
$data = base64_decode(strtr($_COOKIE[$namecookie], '-_,', '+/='));
|
||||
if (strlen($data) > 0) {
|
||||
$userName = myiconv("utf-8", $webim_encoding, $data);
|
||||
}
|
||||
}
|
||||
|
||||
if($userName == $defaultName) {
|
||||
if ($userName == $defaultName) {
|
||||
$userName = getgetparam('name', $userName);
|
||||
}
|
||||
|
||||
@ -711,16 +750,17 @@ function visitor_from_request() {
|
||||
$userId = $_COOKIE[$usercookie];
|
||||
} else {
|
||||
$userId = get_user_id();
|
||||
setcookie($usercookie, $userId, time()+60*60*24*365);
|
||||
setcookie($usercookie, $userId, time() + 60 * 60 * 24 * 365);
|
||||
}
|
||||
return array( 'id' => $userId, 'name' => $userName );
|
||||
return array('id' => $userId, 'name' => $userName);
|
||||
}
|
||||
|
||||
function get_remote_host() {
|
||||
function get_remote_host()
|
||||
{
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'];
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) &&
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) {
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'].' ('.$_SERVER['HTTP_X_FORWARDED_FOR'].')';
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) {
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')';
|
||||
}
|
||||
return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr;
|
||||
}
|
||||
|
@ -21,68 +21,73 @@
|
||||
|
||||
session_start();
|
||||
|
||||
require_once(dirname(__FILE__).'/converter.php');
|
||||
require_once(dirname(__FILE__).'/config.php');
|
||||
require_once(dirname(__FILE__) . '/converter.php');
|
||||
require_once(dirname(__FILE__) . '/config.php');
|
||||
|
||||
$version = '1.6.4';
|
||||
$jsver = "164";
|
||||
|
||||
function myiconv($in_enc, $out_enc, $string) {
|
||||
function myiconv($in_enc, $out_enc, $string)
|
||||
{
|
||||
global $_utf8win1251, $_win1251utf8;
|
||||
if($in_enc == $out_enc ) {
|
||||
if ($in_enc == $out_enc) {
|
||||
return $string;
|
||||
}
|
||||
if( function_exists('iconv') ) {
|
||||
if (function_exists('iconv')) {
|
||||
$converted = @iconv($in_enc, $out_enc, $string);
|
||||
if( $converted !== FALSE ) {
|
||||
if ($converted !== FALSE) {
|
||||
return $converted;
|
||||
}
|
||||
}
|
||||
if( $in_enc == "cp1251" && $out_enc == "utf-8" )
|
||||
if ($in_enc == "cp1251" && $out_enc == "utf-8")
|
||||
return strtr($string, $_win1251utf8);
|
||||
if( $in_enc == "utf-8" && $out_enc == "cp1251" )
|
||||
if ($in_enc == "utf-8" && $out_enc == "cp1251")
|
||||
return strtr($string, $_utf8win1251);
|
||||
|
||||
return $string; // do not know how to convert
|
||||
}
|
||||
|
||||
function verifyparam( $name, $regexp, $default = null ) {
|
||||
if( isset( $_GET[$name] ) ) {
|
||||
function verifyparam($name, $regexp, $default = null)
|
||||
{
|
||||
if (isset($_GET[$name])) {
|
||||
$val = $_GET[$name];
|
||||
if( preg_match( $regexp, $val ) )
|
||||
if (preg_match($regexp, $val))
|
||||
return $val;
|
||||
|
||||
} else if( isset( $_POST[$name] ) ) {
|
||||
} else if (isset($_POST[$name])) {
|
||||
$val = $_POST[$name];
|
||||
if( preg_match( $regexp, $val ) )
|
||||
if (preg_match($regexp, $val))
|
||||
return $val;
|
||||
|
||||
} else {
|
||||
if( isset( $default ) )
|
||||
if (isset($default))
|
||||
return $default;
|
||||
}
|
||||
echo "<html><head></head><body>Wrong parameter used or absent: ".$name."</body></html>";
|
||||
echo "<html><head></head><body>Wrong parameter used or absent: " . $name . "</body></html>";
|
||||
exit;
|
||||
}
|
||||
|
||||
function debugexit_print( $var ) {
|
||||
function debugexit_print($var)
|
||||
{
|
||||
echo "<html><body><pre>";
|
||||
print_r( $var );
|
||||
print_r($var);
|
||||
echo "</pre></body></html>";
|
||||
exit;
|
||||
}
|
||||
|
||||
$locale_pattern = "/^[\w-]{2,5}$/";
|
||||
|
||||
function locale_exists($locale) {
|
||||
return file_exists(dirname(__FILE__)."/../locales/$locale/properties");
|
||||
function locale_exists($locale)
|
||||
{
|
||||
return file_exists(dirname(__FILE__) . "/../locales/$locale/properties");
|
||||
}
|
||||
|
||||
function get_available_locales() {
|
||||
function get_available_locales()
|
||||
{
|
||||
global $locale_pattern;
|
||||
$list = array();
|
||||
$folder = dirname(__FILE__)."/../locales";
|
||||
if($handle = opendir($folder)) {
|
||||
$folder = dirname(__FILE__) . "/../locales";
|
||||
if ($handle = opendir($folder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match($locale_pattern, $file) && $file != 'names' && is_dir("$folder/$file")) {
|
||||
$list[] = $file;
|
||||
@ -94,45 +99,47 @@ function get_available_locales() {
|
||||
return $list;
|
||||
}
|
||||
|
||||
function get_user_locale() {
|
||||
function get_user_locale()
|
||||
{
|
||||
global $default_locale;
|
||||
|
||||
if( isset($_COOKIE['webim_locale']) ) {
|
||||
if (isset($_COOKIE['webim_locale'])) {
|
||||
$requested_lang = $_COOKIE['webim_locale'];
|
||||
if( locale_exists($requested_lang) )
|
||||
if (locale_exists($requested_lang))
|
||||
return $requested_lang;
|
||||
}
|
||||
|
||||
if( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {
|
||||
$requested_langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
foreach( $requested_langs as $requested_lang) {
|
||||
if( strlen($requested_lang) > 2 )
|
||||
$requested_lang = substr($requested_lang,0,2);
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
$requested_langs = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
foreach ($requested_langs as $requested_lang) {
|
||||
if (strlen($requested_lang) > 2)
|
||||
$requested_lang = substr($requested_lang, 0, 2);
|
||||
|
||||
if( locale_exists($requested_lang) )
|
||||
if (locale_exists($requested_lang))
|
||||
return $requested_lang;
|
||||
}
|
||||
}
|
||||
|
||||
if( locale_exists($default_locale) )
|
||||
if (locale_exists($default_locale))
|
||||
return $default_locale;
|
||||
|
||||
return 'en';
|
||||
}
|
||||
|
||||
function get_locale() {
|
||||
function get_locale()
|
||||
{
|
||||
global $webimroot, $locale_pattern;
|
||||
|
||||
$locale = verifyparam("locale", $locale_pattern, "");
|
||||
|
||||
if( $locale && locale_exists($locale) ) {
|
||||
if ($locale && locale_exists($locale)) {
|
||||
$_SESSION['locale'] = $locale;
|
||||
setcookie('webim_locale', $locale, time()+60*60*24*1000, "$webimroot/");
|
||||
} else if( isset($_SESSION['locale']) ){
|
||||
setcookie('webim_locale', $locale, time() + 60 * 60 * 24 * 1000, "$webimroot/");
|
||||
} else if (isset($_SESSION['locale'])) {
|
||||
$locale = $_SESSION['locale'];
|
||||
}
|
||||
|
||||
if( !$locale || !locale_exists($locale) )
|
||||
if (!$locale || !locale_exists($locale))
|
||||
$locale = get_user_locale();
|
||||
return $locale;
|
||||
}
|
||||
@ -141,42 +148,44 @@ $current_locale = get_locale();
|
||||
$messages = array();
|
||||
$output_encoding = array();
|
||||
|
||||
if(function_exists("date_default_timezone_set")) {
|
||||
if (function_exists("date_default_timezone_set")) {
|
||||
// TODO try to get timezone from config.php/session etc.
|
||||
// autodetect timezone
|
||||
@date_default_timezone_set(function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT");
|
||||
}
|
||||
|
||||
function get_locale_links($href) {
|
||||
function get_locale_links($href)
|
||||
{
|
||||
global $current_locale;
|
||||
$localeLinks = array();
|
||||
$allLocales = get_available_locales();
|
||||
if(count($allLocales) < 2) {
|
||||
if (count($allLocales) < 2) {
|
||||
return null;
|
||||
}
|
||||
foreach($allLocales as $k) {
|
||||
foreach ($allLocales as $k) {
|
||||
$localeLinks[$k] = getlocal_($k, "names");
|
||||
}
|
||||
return $localeLinks;
|
||||
}
|
||||
|
||||
function load_messages($locale) {
|
||||
function load_messages($locale)
|
||||
{
|
||||
global $messages, $webim_encoding, $output_encoding;
|
||||
$hash = array();
|
||||
$current_encoding = $webim_encoding;
|
||||
$fp = fopen(dirname(__FILE__)."/../locales/$locale/properties", "r");
|
||||
$fp = fopen(dirname(__FILE__) . "/../locales/$locale/properties", "r");
|
||||
while (!feof($fp)) {
|
||||
$line = fgets($fp, 4096);
|
||||
$keyval = preg_split("/=/", $line, 2 );
|
||||
if( isset($keyval[1]) ) {
|
||||
if($keyval[0] == 'encoding') {
|
||||
$keyval = preg_split("/=/", $line, 2);
|
||||
if (isset($keyval[1])) {
|
||||
if ($keyval[0] == 'encoding') {
|
||||
$current_encoding = trim($keyval[1]);
|
||||
} else if($keyval[0] == 'output_encoding') {
|
||||
} else if ($keyval[0] == 'output_encoding') {
|
||||
$output_encoding[$locale] = trim($keyval[1]);
|
||||
} else if( $current_encoding == $webim_encoding ) {
|
||||
$hash[$keyval[0]] = str_replace("\\n", "\n",trim($keyval[1]));
|
||||
} else if ($current_encoding == $webim_encoding) {
|
||||
$hash[$keyval[0]] = str_replace("\\n", "\n", trim($keyval[1]));
|
||||
} else {
|
||||
$hash[$keyval[0]] = myiconv($current_encoding, $webim_encoding, str_replace("\\n", "\n",trim($keyval[1])));
|
||||
$hash[$keyval[0]] = myiconv($current_encoding, $webim_encoding, str_replace("\\n", "\n", trim($keyval[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,132 +193,146 @@ function load_messages($locale) {
|
||||
$messages[$locale] = $hash;
|
||||
}
|
||||
|
||||
function getoutputenc() {
|
||||
function getoutputenc()
|
||||
{
|
||||
global $current_locale, $output_encoding, $webim_encoding, $messages;
|
||||
if(!isset($messages[$current_locale]))
|
||||
if (!isset($messages[$current_locale]))
|
||||
load_messages($current_locale);
|
||||
return isset($output_encoding[$current_locale]) ? $output_encoding[$current_locale] : $webim_encoding;
|
||||
}
|
||||
|
||||
function getstring_($text,$locale) {
|
||||
function getstring_($text, $locale)
|
||||
{
|
||||
global $messages;
|
||||
if(!isset($messages[$locale]))
|
||||
if (!isset($messages[$locale]))
|
||||
load_messages($locale);
|
||||
|
||||
$localized = $messages[$locale];
|
||||
if( isset($localized[$text]) )
|
||||
if (isset($localized[$text]))
|
||||
return $localized[$text];
|
||||
if( $locale != 'en' ) {
|
||||
return getstring_($text,'en');
|
||||
if ($locale != 'en') {
|
||||
return getstring_($text, 'en');
|
||||
}
|
||||
|
||||
return "!".$text;
|
||||
return "!" . $text;
|
||||
}
|
||||
|
||||
function getstring($text) {
|
||||
function getstring($text)
|
||||
{
|
||||
global $current_locale;
|
||||
return getstring_($text,$current_locale);
|
||||
return getstring_($text, $current_locale);
|
||||
}
|
||||
|
||||
function getlocal($text) {
|
||||
function getlocal($text)
|
||||
{
|
||||
global $current_locale, $webim_encoding;
|
||||
return myiconv($webim_encoding,getoutputenc(), getstring_($text,$current_locale));
|
||||
return myiconv($webim_encoding, getoutputenc(), getstring_($text, $current_locale));
|
||||
}
|
||||
|
||||
function getlocal_($text,$locale) {
|
||||
function getlocal_($text, $locale)
|
||||
{
|
||||
global $webim_encoding;
|
||||
return myiconv($webim_encoding,getoutputenc(), getstring_($text,$locale));
|
||||
return myiconv($webim_encoding, getoutputenc(), getstring_($text, $locale));
|
||||
}
|
||||
|
||||
function topage($text) {
|
||||
function topage($text)
|
||||
{
|
||||
global $webim_encoding;
|
||||
return myiconv($webim_encoding,getoutputenc(), $text);
|
||||
return myiconv($webim_encoding, getoutputenc(), $text);
|
||||
}
|
||||
|
||||
function getstring2_($text,$params,$locale) {
|
||||
$string = getstring_($text,$locale);
|
||||
for( $i = 0; $i < count($params); $i++ ) {
|
||||
$string = str_replace("{".$i."}", $params[$i], $string);
|
||||
function getstring2_($text, $params, $locale)
|
||||
{
|
||||
$string = getstring_($text, $locale);
|
||||
for ($i = 0; $i < count($params); $i++) {
|
||||
$string = str_replace("{" . $i . "}", $params[$i], $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function getstring2($text,$params) {
|
||||
function getstring2($text, $params)
|
||||
{
|
||||
global $current_locale;
|
||||
return getstring2_($text,$params,$current_locale);
|
||||
return getstring2_($text, $params, $current_locale);
|
||||
}
|
||||
|
||||
function getlocal2($text,$params) {
|
||||
function getlocal2($text, $params)
|
||||
{
|
||||
global $current_locale, $webim_encoding;
|
||||
$string = myiconv($webim_encoding,getoutputenc(), getstring_($text,$current_locale));
|
||||
for( $i = 0; $i < count($params); $i++ ) {
|
||||
$string = str_replace("{".$i."}", $params[$i], $string);
|
||||
$string = myiconv($webim_encoding, getoutputenc(), getstring_($text, $current_locale));
|
||||
for ($i = 0; $i < count($params); $i++) {
|
||||
$string = str_replace("{" . $i . "}", $params[$i], $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/* prepares for Javascript string */
|
||||
function getlocalforJS($text,$params) {
|
||||
function getlocalforJS($text, $params)
|
||||
{
|
||||
global $current_locale, $webim_encoding;
|
||||
$string = myiconv($webim_encoding,getoutputenc(), getstring_($text,$current_locale));
|
||||
$string = str_replace("\"", "\\\"", str_replace("\n", "\\n", $string));
|
||||
for( $i = 0; $i < count($params); $i++ ) {
|
||||
$string = str_replace("{".$i."}", $params[$i], $string);
|
||||
$string = myiconv($webim_encoding, getoutputenc(), getstring_($text, $current_locale));
|
||||
$string = str_replace("\"", "\\\"", str_replace("\n", "\\n", $string));
|
||||
for ($i = 0; $i < count($params); $i++) {
|
||||
$string = str_replace("{" . $i . "}", $params[$i], $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/* ajax server actions use utf-8 */
|
||||
function getrawparam( $name ) {
|
||||
function getrawparam($name)
|
||||
{
|
||||
global $webim_encoding;
|
||||
if( isset($_POST[$name]) ) {
|
||||
$value = myiconv("utf-8",$webim_encoding,$_POST[$name]);
|
||||
if (isset($_POST[$name])) {
|
||||
$value = myiconv("utf-8", $webim_encoding, $_POST[$name]);
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$value = stripslashes($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
die("no ".$name." parameter");
|
||||
die("no " . $name . " parameter");
|
||||
}
|
||||
|
||||
/* form processors use current Output encoding */
|
||||
function getparam( $name ) {
|
||||
function getparam($name)
|
||||
{
|
||||
global $webim_encoding;
|
||||
if( isset($_POST[$name]) ) {
|
||||
if (isset($_POST[$name])) {
|
||||
$value = myiconv(getoutputenc(), $webim_encoding, $_POST[$name]);
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$value = stripslashes($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
die("no ".$name." parameter");
|
||||
die("no " . $name . " parameter");
|
||||
}
|
||||
|
||||
function unicode_urldecode($url) {
|
||||
preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);
|
||||
function unicode_urldecode($url)
|
||||
{
|
||||
preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);
|
||||
|
||||
foreach ($a[1] as $uniord) {
|
||||
$dec = hexdec($uniord);
|
||||
$utf = '';
|
||||
foreach ($a[1] as $uniord) {
|
||||
$dec = hexdec($uniord);
|
||||
$utf = '';
|
||||
|
||||
if ($dec < 128) {
|
||||
$utf = chr($dec);
|
||||
} else if ($dec < 2048) {
|
||||
$utf = chr(192 + (($dec - ($dec % 64)) / 64));
|
||||
$utf .= chr(128 + ($dec % 64));
|
||||
} else {
|
||||
$utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
|
||||
$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
|
||||
$utf .= chr(128 + ($dec % 64));
|
||||
}
|
||||
$url = str_replace('%u'.$uniord, $utf, $url);
|
||||
}
|
||||
return urldecode($url);
|
||||
if ($dec < 128) {
|
||||
$utf = chr($dec);
|
||||
} else if ($dec < 2048) {
|
||||
$utf = chr(192 + (($dec - ($dec % 64)) / 64));
|
||||
$utf .= chr(128 + ($dec % 64));
|
||||
} else {
|
||||
$utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
|
||||
$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
|
||||
$utf .= chr(128 + ($dec % 64));
|
||||
}
|
||||
$url = str_replace('%u' . $uniord, $utf, $url);
|
||||
}
|
||||
return urldecode($url);
|
||||
}
|
||||
|
||||
function getgetparam($name,$default='') {
|
||||
function getgetparam($name, $default = '')
|
||||
{
|
||||
global $webim_encoding;
|
||||
if( !isset($_GET[$name]) || !$_GET[$name] ) {
|
||||
if (!isset($_GET[$name]) || !$_GET[$name]) {
|
||||
return $default;
|
||||
}
|
||||
$value = myiconv("utf-8", $webim_encoding, unicode_urldecode($_GET[$name]));
|
||||
@ -319,36 +342,40 @@ function getgetparam($name,$default='') {
|
||||
return $value;
|
||||
}
|
||||
|
||||
function connect() {
|
||||
function connect()
|
||||
{
|
||||
global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection;
|
||||
if(!extension_loaded("mysql")) {
|
||||
if (!extension_loaded("mysql")) {
|
||||
die('Mysql extension is not loaded');
|
||||
}
|
||||
$link = @mysql_connect($mysqlhost,$mysqllogin ,$mysqlpass )
|
||||
or die('Could not connect: ' . mysql_error());
|
||||
mysql_select_db($mysqldb,$link) or die('Could not select database');
|
||||
if( $force_charset_in_connection ) {
|
||||
$link = @mysql_connect($mysqlhost, $mysqllogin, $mysqlpass)
|
||||
or die('Could not connect: ' . mysql_error());
|
||||
mysql_select_db($mysqldb, $link) or die('Could not select database');
|
||||
if ($force_charset_in_connection) {
|
||||
mysql_query("SET NAMES '$dbencoding'", $link);
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
function perform_query($query,$link) {
|
||||
mysql_query($query,$link)
|
||||
or die(' Query failed: '.mysql_error()/*.": ".$query*/);
|
||||
function perform_query($query, $link)
|
||||
{
|
||||
mysql_query($query, $link)
|
||||
or die(' Query failed: ' . mysql_error() /*.": ".$query*/);
|
||||
}
|
||||
|
||||
function select_one_row($query,$link) {
|
||||
$result = mysql_query($query,$link) or die(' Query failed: ' .
|
||||
mysql_error().": ".$query);
|
||||
function select_one_row($query, $link)
|
||||
{
|
||||
$result = mysql_query($query, $link) or die(' Query failed: ' .
|
||||
mysql_error() . ": " . $query);
|
||||
$line = mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
mysql_free_result($result);
|
||||
return $line;
|
||||
}
|
||||
|
||||
function select_multi_assoc($query, $link) {
|
||||
$sqlresult = mysql_query($query,$link) or die(' Query failed: ' .
|
||||
mysql_error().": ".$query);
|
||||
function select_multi_assoc($query, $link)
|
||||
{
|
||||
$sqlresult = mysql_query($query, $link) or die(' Query failed: ' .
|
||||
mysql_error() . ": " . $query);
|
||||
|
||||
$result = array();
|
||||
while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
|
||||
@ -358,21 +385,24 @@ function select_multi_assoc($query, $link) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function db_build_select($fields, $table, $conditions, $orderandgroup) {
|
||||
$condition = count($conditions) > 0 ? " where ".implode(" and ", $conditions) : "";
|
||||
if($orderandgroup) $orderandgroup = " ".$orderandgroup;
|
||||
function db_build_select($fields, $table, $conditions, $orderandgroup)
|
||||
{
|
||||
$condition = count($conditions) > 0 ? " where " . implode(" and ", $conditions) : "";
|
||||
if ($orderandgroup) $orderandgroup = " " . $orderandgroup;
|
||||
return "select $fields from $table$condition$orderandgroup";
|
||||
}
|
||||
}
|
||||
|
||||
function db_rows_count($table,$conditions,$countfields, $link) {
|
||||
$result = mysql_query(db_build_select("count(".($countfields ? $countfields : "*").")", $table, $conditions, ""),$link)
|
||||
or die(' Count query failed: '.mysql_error());
|
||||
function db_rows_count($table, $conditions, $countfields, $link)
|
||||
{
|
||||
$result = mysql_query(db_build_select("count(" . ($countfields ? $countfields : "*") . ")", $table, $conditions, ""), $link)
|
||||
or die(' Count query failed: ' . mysql_error());
|
||||
$line = mysql_fetch_array($result, MYSQL_NUM);
|
||||
mysql_free_result($result);
|
||||
return $line[0];
|
||||
}
|
||||
|
||||
function start_xml_output() {
|
||||
function start_xml_output()
|
||||
{
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
@ -380,173 +410,196 @@ function start_xml_output() {
|
||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
}
|
||||
|
||||
function start_html_output() {
|
||||
function start_html_output()
|
||||
{
|
||||
$charset = getstring("output_charset");
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-type: text/html".(isset($charset)?"; charset=".$charset:""));
|
||||
header("Content-type: text/html" . (isset($charset) ? "; charset=" . $charset : ""));
|
||||
}
|
||||
|
||||
function escape_with_cdata($text) {
|
||||
return "<![CDATA[" . str_replace("]]>", "]]>]]><![CDATA[",$text) . "]]>";
|
||||
function escape_with_cdata($text)
|
||||
{
|
||||
return "<![CDATA[" . str_replace("]]>", "]]>]]><![CDATA[", $text) . "]]>";
|
||||
}
|
||||
|
||||
function form_value($key) {
|
||||
function form_value($key)
|
||||
{
|
||||
global $page;
|
||||
if( isset($page) && isset($page["form$key"]) )
|
||||
if (isset($page) && isset($page["form$key"]))
|
||||
return htmlspecialchars($page["form$key"]);
|
||||
return "";
|
||||
}
|
||||
|
||||
function form_value_cb($key) {
|
||||
function form_value_cb($key)
|
||||
{
|
||||
global $page;
|
||||
if( isset($page) && isset($page["form$key"]) )
|
||||
if (isset($page) && isset($page["form$key"]))
|
||||
return $page["form$key"] === true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function form_value_mb($key,$id) {
|
||||
function form_value_mb($key, $id)
|
||||
{
|
||||
global $page;
|
||||
if( isset($page) && isset($page["form$key"]) && is_array($page["form$key"]) ) {
|
||||
if (isset($page) && isset($page["form$key"]) && is_array($page["form$key"])) {
|
||||
return in_array($id, $page["form$key"]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function no_field($key) {
|
||||
return getlocal2("errors.required",array(getlocal($key)));
|
||||
function no_field($key)
|
||||
{
|
||||
return getlocal2("errors.required", array(getlocal($key)));
|
||||
}
|
||||
|
||||
function failed_uploading_file($filename, $key) {
|
||||
function failed_uploading_file($filename, $key)
|
||||
{
|
||||
return getlocal2("errors.failed.uploading.file",
|
||||
array($filename, getlocal($key)));
|
||||
array($filename, getlocal($key)));
|
||||
}
|
||||
|
||||
function wrong_field($key) {
|
||||
return getlocal2("errors.wrong_field",array(getlocal($key)));
|
||||
function wrong_field($key)
|
||||
{
|
||||
return getlocal2("errors.wrong_field", array(getlocal($key)));
|
||||
}
|
||||
|
||||
function get_popup($href,$jshref,$message,$title,$wndName,$options) {
|
||||
if(!$jshref) { $jshref = "'$href'"; }
|
||||
return "<a href=\"$href\" target=\"_blank\" ".($title?"title=\"$title\" ":"")."onclick=\"if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 && window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open($jshref, '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
|
||||
function get_popup($href, $jshref, $message, $title, $wndName, $options)
|
||||
{
|
||||
if (!$jshref) {
|
||||
$jshref = "'$href'";
|
||||
}
|
||||
return "<a href=\"$href\" target=\"_blank\" " . ($title ? "title=\"$title\" " : "") . "onclick=\"if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 && window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open($jshref, '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
|
||||
}
|
||||
|
||||
function get_image($href,$width,$height) {
|
||||
if( $width != 0 && $height != 0 )
|
||||
function get_image($href, $width, $height)
|
||||
{
|
||||
if ($width != 0 && $height != 0)
|
||||
return "<img src=\"$href\" border=\"0\" width=\"$width\" height=\"$height\" alt=\"\"/>";
|
||||
return "<img src=\"$href\" border=\"0\" alt=\"\"/>";
|
||||
}
|
||||
|
||||
function get_gifimage_size($filename) {
|
||||
if( function_exists('gd_info')) {
|
||||
function get_gifimage_size($filename)
|
||||
{
|
||||
if (function_exists('gd_info')) {
|
||||
$info = gd_info();
|
||||
if( isset($info['GIF Read Support']) && $info['GIF Read Support'] ) {
|
||||
if (isset($info['GIF Read Support']) && $info['GIF Read Support']) {
|
||||
$img = @imagecreatefromgif($filename);
|
||||
if($img) {
|
||||
if ($img) {
|
||||
$height = imagesy($img);
|
||||
$width = imagesx($img);
|
||||
imagedestroy($img);
|
||||
return array($width,$height);
|
||||
return array($width, $height);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(0,0);
|
||||
return array(0, 0);
|
||||
}
|
||||
|
||||
function add_params($servlet, $params) {
|
||||
function add_params($servlet, $params)
|
||||
{
|
||||
$infix = '?';
|
||||
if( strstr($servlet,$infix) !== FALSE )
|
||||
if (strstr($servlet, $infix) !== FALSE)
|
||||
$infix = '&';
|
||||
foreach($params as $k => $v) {
|
||||
$servlet .= $infix.$k."=".$v;
|
||||
foreach ($params as $k => $v) {
|
||||
$servlet .= $infix . $k . "=" . $v;
|
||||
$infix = '&';
|
||||
}
|
||||
return $servlet;
|
||||
}
|
||||
|
||||
function div($a,$b) {
|
||||
return ($a-($a % $b)) / $b;
|
||||
function div($a, $b)
|
||||
{
|
||||
return ($a - ($a % $b)) / $b;
|
||||
}
|
||||
|
||||
function date_diff_to_text($seconds) {
|
||||
$minutes = div($seconds,60);
|
||||
function date_diff_to_text($seconds)
|
||||
{
|
||||
$minutes = div($seconds, 60);
|
||||
$seconds = $seconds % 60;
|
||||
if( $minutes < 60 ) {
|
||||
return sprintf("%02d:%02d",$minutes, $seconds);
|
||||
if ($minutes < 60) {
|
||||
return sprintf("%02d:%02d", $minutes, $seconds);
|
||||
} else {
|
||||
$hours = div($minutes,60);
|
||||
$hours = div($minutes, 60);
|
||||
$minutes = $minutes % 60;
|
||||
return sprintf("%02d:%02d:%02d",$hours, $minutes, $seconds);
|
||||
return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
|
||||
}
|
||||
}
|
||||
|
||||
function is_valid_email($email) {
|
||||
function is_valid_email($email)
|
||||
{
|
||||
return preg_match("/^[^@]+@[^\.]+(\.[^\.]+)*$/", $email);
|
||||
}
|
||||
|
||||
function get_app_location($showhost,$issecure) {
|
||||
function get_app_location($showhost, $issecure)
|
||||
{
|
||||
global $webimroot;
|
||||
if( $showhost ) {
|
||||
return ($issecure?"https://":"http://").$_SERVER['HTTP_HOST'].$webimroot;
|
||||
if ($showhost) {
|
||||
return ($issecure ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $webimroot;
|
||||
} else {
|
||||
return $webimroot;
|
||||
}
|
||||
}
|
||||
|
||||
function is_secure_request() {
|
||||
function is_secure_request()
|
||||
{
|
||||
return
|
||||
isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443'
|
||||
|| isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"
|
||||
|| isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on";
|
||||
isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443'
|
||||
|| isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"
|
||||
|| isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on";
|
||||
}
|
||||
|
||||
function get_month_selection($fromtime,$totime) {
|
||||
function get_month_selection($fromtime, $totime)
|
||||
{
|
||||
$start = getdate($fromtime);
|
||||
$month = $start['mon'];
|
||||
$year = $start['year'];
|
||||
$result = array();
|
||||
do {
|
||||
$current = mktime(0,0,0,$month,1,$year);
|
||||
$result[date("m.y",$current)] = strftime("%B, %Y",$current);
|
||||
$current = mktime(0, 0, 0, $month, 1, $year);
|
||||
$result[date("m.y", $current)] = strftime("%B, %Y", $current);
|
||||
$month++;
|
||||
if( $month > 12 ) {
|
||||
if ($month > 12) {
|
||||
$month = 1;
|
||||
$year++;
|
||||
}
|
||||
} while( $current < $totime );
|
||||
} while ($current < $totime);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_form_date($day,$month) {
|
||||
if( preg_match('/^(\d{2}).(\d{2})$/', $month, $matches)) {
|
||||
return mktime(0,0,0,$matches[1],$day,$matches[2]);
|
||||
function get_form_date($day, $month)
|
||||
{
|
||||
if (preg_match('/^(\d{2}).(\d{2})$/', $month, $matches)) {
|
||||
return mktime(0, 0, 0, $matches[1], $day, $matches[2]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function set_form_date($utime,$prefix) {
|
||||
function set_form_date($utime, $prefix)
|
||||
{
|
||||
global $page;
|
||||
$page["form${prefix}day"] = date("d", $utime);
|
||||
$page["form${prefix}month"] = date("m.y", $utime);
|
||||
}
|
||||
|
||||
function date_to_text($unixtime) {
|
||||
if ($unixtime < 60*60*24*30)
|
||||
function date_to_text($unixtime)
|
||||
{
|
||||
if ($unixtime < 60 * 60 * 24 * 30)
|
||||
return getlocal("time.never");
|
||||
|
||||
|
||||
$then = getdate($unixtime);
|
||||
$now = getdate();
|
||||
|
||||
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
|
||||
$date_format = getlocal("time.today.at");
|
||||
} else if (($then['yday']+1) == $now['yday'] && $then['year'] == $now['year']) {
|
||||
} else if (($then['yday'] + 1) == $now['yday'] && $then['year'] == $now['year']) {
|
||||
$date_format = getlocal("time.yesterday.at");
|
||||
} else {
|
||||
$date_format = getlocal("time.dateformat");
|
||||
}
|
||||
|
||||
return strftime($date_format." ".getlocal("time.timeformat"), $unixtime);
|
||||
|
||||
return strftime($date_format . " " . getlocal("time.timeformat"), $unixtime);
|
||||
}
|
||||
|
||||
$dbversion = '1.6.3';
|
||||
@ -566,26 +619,26 @@ $settings = array(
|
||||
'max_uploaded_file_size' => 100000,
|
||||
'max_connections_from_one_host' => 10,
|
||||
|
||||
'email' => '', /* inbox for left messages */
|
||||
'email' => '', /* inbox for left messages */
|
||||
'left_messages_locale' => $home_locale,
|
||||
'sendmessagekey' => 'center',
|
||||
|
||||
'enableban' => '0',
|
||||
'enablessl' => '0',
|
||||
'forcessl' => '0',
|
||||
'forcessl' => '0',
|
||||
'usercanchangename' => '1',
|
||||
'enablegroups' => '0',
|
||||
'enablestatistics' => '1',
|
||||
'enablejabber' => '0',
|
||||
'enablepresurvey' => '1',
|
||||
'surveyaskmail' => '0',
|
||||
'surveyaskgroup' => '1',
|
||||
'surveyaskmessage' => '0',
|
||||
'surveyaskmail' => '0',
|
||||
'surveyaskgroup' => '1',
|
||||
'surveyaskmessage' => '0',
|
||||
'enablepopupnotification' => '0',
|
||||
'showonlineoperators' => '0',
|
||||
'enablecaptcha' => '0',
|
||||
|
||||
'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */
|
||||
'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */
|
||||
'updatefrequency_operator' => 2,
|
||||
'updatefrequency_chat' => 2,
|
||||
'updatefrequency_oldchat' => 7,
|
||||
@ -593,14 +646,15 @@ $settings = array(
|
||||
$settingsloaded = false;
|
||||
$settings_in_db = array();
|
||||
|
||||
function loadsettings_($link) {
|
||||
function loadsettings_($link)
|
||||
{
|
||||
global $settingsloaded, $settings_in_db, $settings, $mysqlprefix;
|
||||
if($settingsloaded) {
|
||||
if ($settingsloaded) {
|
||||
return;
|
||||
}
|
||||
$settingsloaded = true;
|
||||
|
||||
$sqlresult = mysql_query("select vckey,vcvalue from ${mysqlprefix}chatconfig", $link) or die(' Query failed: '.mysql_error($link));
|
||||
$sqlresult = mysql_query("select vckey,vcvalue from ${mysqlprefix}chatconfig", $link) or die(' Query failed: ' . mysql_error($link));
|
||||
|
||||
while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
|
||||
$name = $row['vckey'];
|
||||
@ -610,28 +664,31 @@ function loadsettings_($link) {
|
||||
mysql_free_result($sqlresult);
|
||||
}
|
||||
|
||||
function loadsettings() {
|
||||
function loadsettings()
|
||||
{
|
||||
global $settingsloaded;
|
||||
if(!$settingsloaded) {
|
||||
if (!$settingsloaded) {
|
||||
$link = connect();
|
||||
loadsettings_($link);
|
||||
mysql_close($link);
|
||||
}
|
||||
}
|
||||
|
||||
function getchatstyle() {
|
||||
|
||||
function getchatstyle()
|
||||
{
|
||||
global $settings;
|
||||
$chatstyle = verifyparam( "style", "/^\w+$/", "");
|
||||
if($chatstyle) {
|
||||
$chatstyle = verifyparam("style", "/^\w+$/", "");
|
||||
if ($chatstyle) {
|
||||
return $chatstyle;
|
||||
}
|
||||
loadsettings();
|
||||
return $settings['chatstyle'];
|
||||
}
|
||||
|
||||
function jspath() {
|
||||
function jspath()
|
||||
{
|
||||
global $jsver;
|
||||
return "js/$jsver";
|
||||
return "js/$jsver";
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -50,7 +50,7 @@ $mail_encoding = "utf-8";
|
||||
/*
|
||||
* Locales
|
||||
*/
|
||||
$home_locale = "en"; /* native name will be used in this locale */
|
||||
$default_locale = "en"; /* if user does not provide known lang */
|
||||
$home_locale = "en"; /* native name will be used in this locale */
|
||||
$default_locale = "en"; /* if user does not provide known lang */
|
||||
|
||||
?>
|
||||
|
@ -20,36 +20,36 @@
|
||||
*/
|
||||
|
||||
$_utf8win1251 = array(
|
||||
"\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4",
|
||||
"\xD0\x95"=>"\xC5","\xD0\x81"=>"\xA8","\xD0\x96"=>"\xC6","\xD0\x97"=>"\xC7","\xD0\x98"=>"\xC8",
|
||||
"\xD0\x99"=>"\xC9","\xD0\x9A"=>"\xCA","\xD0\x9B"=>"\xCB","\xD0\x9C"=>"\xCC","\xD0\x9D"=>"\xCD",
|
||||
"\xD0\x9E"=>"\xCE","\xD0\x9F"=>"\xCF","\xD0\xA0"=>"\xD0","\xD0\xA1"=>"\xD1","\xD0\xA2"=>"\xD2",
|
||||
"\xD0\xA3"=>"\xD3","\xD0\xA4"=>"\xD4","\xD0\xA5"=>"\xD5","\xD0\xA6"=>"\xD6","\xD0\xA7"=>"\xD7",
|
||||
"\xD0\xA8"=>"\xD8","\xD0\xA9"=>"\xD9","\xD0\xAA"=>"\xDA","\xD0\xAB"=>"\xDB","\xD0\xAC"=>"\xDC",
|
||||
"\xD0\xAD"=>"\xDD","\xD0\xAE"=>"\xDE","\xD0\xAF"=>"\xDF","\xD0\x87"=>"\xAF","\xD0\x86"=>"\xB2",
|
||||
"\xD0\x84"=>"\xAA","\xD0\x8E"=>"\xA1","\xD0\xB0"=>"\xE0","\xD0\xB1"=>"\xE1","\xD0\xB2"=>"\xE2",
|
||||
"\xD0\xB3"=>"\xE3","\xD0\xB4"=>"\xE4","\xD0\xB5"=>"\xE5","\xD1\x91"=>"\xB8","\xD0\xB6"=>"\xE6",
|
||||
"\xD0\xB7"=>"\xE7","\xD0\xB8"=>"\xE8","\xD0\xB9"=>"\xE9","\xD0\xBA"=>"\xEA","\xD0\xBB"=>"\xEB",
|
||||
"\xD0\xBC"=>"\xEC","\xD0\xBD"=>"\xED","\xD0\xBE"=>"\xEE","\xD0\xBF"=>"\xEF","\xD1\x80"=>"\xF0",
|
||||
"\xD1\x81"=>"\xF1","\xD1\x82"=>"\xF2","\xD1\x83"=>"\xF3","\xD1\x84"=>"\xF4","\xD1\x85"=>"\xF5",
|
||||
"\xD1\x86"=>"\xF6","\xD1\x87"=>"\xF7","\xD1\x88"=>"\xF8","\xD1\x89"=>"\xF9","\xD1\x8A"=>"\xFA",
|
||||
"\xD1\x8B"=>"\xFB","\xD1\x8C"=>"\xFC","\xD1\x8D"=>"\xFD","\xD1\x8E"=>"\xFE","\xD1\x8F"=>"\xFF",
|
||||
"\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2");
|
||||
"\xD0\x90" => "\xC0", "\xD0\x91" => "\xC1", "\xD0\x92" => "\xC2", "\xD0\x93" => "\xC3", "\xD0\x94" => "\xC4",
|
||||
"\xD0\x95" => "\xC5", "\xD0\x81" => "\xA8", "\xD0\x96" => "\xC6", "\xD0\x97" => "\xC7", "\xD0\x98" => "\xC8",
|
||||
"\xD0\x99" => "\xC9", "\xD0\x9A" => "\xCA", "\xD0\x9B" => "\xCB", "\xD0\x9C" => "\xCC", "\xD0\x9D" => "\xCD",
|
||||
"\xD0\x9E" => "\xCE", "\xD0\x9F" => "\xCF", "\xD0\xA0" => "\xD0", "\xD0\xA1" => "\xD1", "\xD0\xA2" => "\xD2",
|
||||
"\xD0\xA3" => "\xD3", "\xD0\xA4" => "\xD4", "\xD0\xA5" => "\xD5", "\xD0\xA6" => "\xD6", "\xD0\xA7" => "\xD7",
|
||||
"\xD0\xA8" => "\xD8", "\xD0\xA9" => "\xD9", "\xD0\xAA" => "\xDA", "\xD0\xAB" => "\xDB", "\xD0\xAC" => "\xDC",
|
||||
"\xD0\xAD" => "\xDD", "\xD0\xAE" => "\xDE", "\xD0\xAF" => "\xDF", "\xD0\x87" => "\xAF", "\xD0\x86" => "\xB2",
|
||||
"\xD0\x84" => "\xAA", "\xD0\x8E" => "\xA1", "\xD0\xB0" => "\xE0", "\xD0\xB1" => "\xE1", "\xD0\xB2" => "\xE2",
|
||||
"\xD0\xB3" => "\xE3", "\xD0\xB4" => "\xE4", "\xD0\xB5" => "\xE5", "\xD1\x91" => "\xB8", "\xD0\xB6" => "\xE6",
|
||||
"\xD0\xB7" => "\xE7", "\xD0\xB8" => "\xE8", "\xD0\xB9" => "\xE9", "\xD0\xBA" => "\xEA", "\xD0\xBB" => "\xEB",
|
||||
"\xD0\xBC" => "\xEC", "\xD0\xBD" => "\xED", "\xD0\xBE" => "\xEE", "\xD0\xBF" => "\xEF", "\xD1\x80" => "\xF0",
|
||||
"\xD1\x81" => "\xF1", "\xD1\x82" => "\xF2", "\xD1\x83" => "\xF3", "\xD1\x84" => "\xF4", "\xD1\x85" => "\xF5",
|
||||
"\xD1\x86" => "\xF6", "\xD1\x87" => "\xF7", "\xD1\x88" => "\xF8", "\xD1\x89" => "\xF9", "\xD1\x8A" => "\xFA",
|
||||
"\xD1\x8B" => "\xFB", "\xD1\x8C" => "\xFC", "\xD1\x8D" => "\xFD", "\xD1\x8E" => "\xFE", "\xD1\x8F" => "\xFF",
|
||||
"\xD1\x96" => "\xB3", "\xD1\x97" => "\xBF", "\xD1\x94" => "\xBA", "\xD1\x9E" => "\xA2");
|
||||
$_win1251utf8 = array(
|
||||
"\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94",
|
||||
"\xC5"=>"\xD0\x95","\xA8"=>"\xD0\x81","\xC6"=>"\xD0\x96","\xC7"=>"\xD0\x97","\xC8"=>"\xD0\x98",
|
||||
"\xC9"=>"\xD0\x99","\xCA"=>"\xD0\x9A","\xCB"=>"\xD0\x9B","\xCC"=>"\xD0\x9C","\xCD"=>"\xD0\x9D",
|
||||
"\xCE"=>"\xD0\x9E","\xCF"=>"\xD0\x9F","\xD0"=>"\xD0\xA0","\xD1"=>"\xD0\xA1","\xD2"=>"\xD0\xA2",
|
||||
"\xD3"=>"\xD0\xA3","\xD4"=>"\xD0\xA4","\xD5"=>"\xD0\xA5","\xD6"=>"\xD0\xA6","\xD7"=>"\xD0\xA7",
|
||||
"\xD8"=>"\xD0\xA8","\xD9"=>"\xD0\xA9","\xDA"=>"\xD0\xAA","\xDB"=>"\xD0\xAB","\xDC"=>"\xD0\xAC",
|
||||
"\xDD"=>"\xD0\xAD","\xDE"=>"\xD0\xAE","\xDF"=>"\xD0\xAF","\xAF"=>"\xD0\x87","\xB2"=>"\xD0\x86",
|
||||
"\xAA"=>"\xD0\x84","\xA1"=>"\xD0\x8E","\xE0"=>"\xD0\xB0","\xE1"=>"\xD0\xB1","\xE2"=>"\xD0\xB2",
|
||||
"\xE3"=>"\xD0\xB3","\xE4"=>"\xD0\xB4","\xE5"=>"\xD0\xB5","\xB8"=>"\xD1\x91","\xE6"=>"\xD0\xB6",
|
||||
"\xE7"=>"\xD0\xB7","\xE8"=>"\xD0\xB8","\xE9"=>"\xD0\xB9","\xEA"=>"\xD0\xBA","\xEB"=>"\xD0\xBB",
|
||||
"\xEC"=>"\xD0\xBC","\xED"=>"\xD0\xBD","\xEE"=>"\xD0\xBE","\xEF"=>"\xD0\xBF","\xF0"=>"\xD1\x80",
|
||||
"\xF1"=>"\xD1\x81","\xF2"=>"\xD1\x82","\xF3"=>"\xD1\x83","\xF4"=>"\xD1\x84","\xF5"=>"\xD1\x85",
|
||||
"\xF6"=>"\xD1\x86","\xF7"=>"\xD1\x87","\xF8"=>"\xD1\x88","\xF9"=>"\xD1\x89","\xFA"=>"\xD1\x8A",
|
||||
"\xFB"=>"\xD1\x8B","\xFC"=>"\xD1\x8C","\xFD"=>"\xD1\x8D","\xFE"=>"\xD1\x8E","\xFF"=>"\xD1\x8F",
|
||||
"\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E");
|
||||
"\xC0" => "\xD0\x90", "\xC1" => "\xD0\x91", "\xC2" => "\xD0\x92", "\xC3" => "\xD0\x93", "\xC4" => "\xD0\x94",
|
||||
"\xC5" => "\xD0\x95", "\xA8" => "\xD0\x81", "\xC6" => "\xD0\x96", "\xC7" => "\xD0\x97", "\xC8" => "\xD0\x98",
|
||||
"\xC9" => "\xD0\x99", "\xCA" => "\xD0\x9A", "\xCB" => "\xD0\x9B", "\xCC" => "\xD0\x9C", "\xCD" => "\xD0\x9D",
|
||||
"\xCE" => "\xD0\x9E", "\xCF" => "\xD0\x9F", "\xD0" => "\xD0\xA0", "\xD1" => "\xD0\xA1", "\xD2" => "\xD0\xA2",
|
||||
"\xD3" => "\xD0\xA3", "\xD4" => "\xD0\xA4", "\xD5" => "\xD0\xA5", "\xD6" => "\xD0\xA6", "\xD7" => "\xD0\xA7",
|
||||
"\xD8" => "\xD0\xA8", "\xD9" => "\xD0\xA9", "\xDA" => "\xD0\xAA", "\xDB" => "\xD0\xAB", "\xDC" => "\xD0\xAC",
|
||||
"\xDD" => "\xD0\xAD", "\xDE" => "\xD0\xAE", "\xDF" => "\xD0\xAF", "\xAF" => "\xD0\x87", "\xB2" => "\xD0\x86",
|
||||
"\xAA" => "\xD0\x84", "\xA1" => "\xD0\x8E", "\xE0" => "\xD0\xB0", "\xE1" => "\xD0\xB1", "\xE2" => "\xD0\xB2",
|
||||
"\xE3" => "\xD0\xB3", "\xE4" => "\xD0\xB4", "\xE5" => "\xD0\xB5", "\xB8" => "\xD1\x91", "\xE6" => "\xD0\xB6",
|
||||
"\xE7" => "\xD0\xB7", "\xE8" => "\xD0\xB8", "\xE9" => "\xD0\xB9", "\xEA" => "\xD0\xBA", "\xEB" => "\xD0\xBB",
|
||||
"\xEC" => "\xD0\xBC", "\xED" => "\xD0\xBD", "\xEE" => "\xD0\xBE", "\xEF" => "\xD0\xBF", "\xF0" => "\xD1\x80",
|
||||
"\xF1" => "\xD1\x81", "\xF2" => "\xD1\x82", "\xF3" => "\xD1\x83", "\xF4" => "\xD1\x84", "\xF5" => "\xD1\x85",
|
||||
"\xF6" => "\xD1\x86", "\xF7" => "\xD1\x87", "\xF8" => "\xD1\x88", "\xF9" => "\xD1\x89", "\xFA" => "\xD1\x8A",
|
||||
"\xFB" => "\xD1\x8B", "\xFC" => "\xD1\x8C", "\xFD" => "\xD1\x8D", "\xFE" => "\xD1\x8E", "\xFF" => "\xD1\x8F",
|
||||
"\xB3" => "\xD1\x96", "\xBF" => "\xD1\x97", "\xBA" => "\xD1\x94", "\xA2" => "\xD1\x9E");
|
||||
|
||||
?>
|
@ -19,72 +19,74 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function demo_print_message($msg,$format) {
|
||||
function demo_print_message($msg, $format)
|
||||
{
|
||||
global $webim_encoding;
|
||||
if($format == "xml") {
|
||||
print "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."</message>\n";
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
function demo_process_thread($act,$outformat,$lastid,$isuser,$canpost,$istyping,$postmessage) {
|
||||
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();
|
||||
if( $act == "refresh" || $act == "post" ) {
|
||||
if ($act == "refresh" || $act == "post") {
|
||||
$lastid++;
|
||||
if($outformat == "xml") {
|
||||
if ($outformat == "xml") {
|
||||
start_xml_output();
|
||||
print("<thread lastid=\"$lastid\" typing=\"".($istyping ? 1 : 0)."\" canpost=\"".($canpost ? 1 : 0)."\">");
|
||||
print("<thread lastid=\"$lastid\" typing=\"" . ($istyping ? 1 : 0) . "\" canpost=\"" . ($canpost ? 1 : 0) . "\">");
|
||||
} else {
|
||||
start_html_output();
|
||||
$url = "$webimroot/thread.php?act=refresh&thread=0&token=123&html=on&user=".($isuser?"true":"false");
|
||||
|
||||
$url = "$webimroot/thread.php?act=refresh&thread=0&token=123&html=on&user=" . ($isuser ? "true" : "false");
|
||||
|
||||
print(
|
||||
"<!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'>" );
|
||||
|
||||
"<!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'>");
|
||||
|
||||
}
|
||||
if($lastid == 1) {
|
||||
if ($lastid == 1) {
|
||||
demo_print_message(
|
||||
array('ikind'=>$kind_for_agent,'created'=>time()-15,'tname'=>'',
|
||||
'tmessage'=>getstring2('chat.came.from',array("http://google.com"))), $outformat);
|
||||
array('ikind' => $kind_for_agent, 'created' => time() - 15, 'tname' => '',
|
||||
'tmessage' => getstring2('chat.came.from', array("http://google.com"))), $outformat);
|
||||
demo_print_message(
|
||||
array('ikind'=>$kind_info,'created'=>time()-15,'tname'=>'',
|
||||
'tmessage'=>getstring('chat.wait')), $outformat);
|
||||
array('ikind' => $kind_info, 'created' => time() - 15, 'tname' => '',
|
||||
'tmessage' => getstring('chat.wait')), $outformat);
|
||||
demo_print_message(
|
||||
array('ikind'=>$kind_events,'created'=>time()-10,'tname'=>'',
|
||||
'tmessage'=>getstring2("chat.status.operator.joined", array("Administrator"))), $outformat);
|
||||
array('ikind' => $kind_events, 'created' => time() - 10, 'tname' => '',
|
||||
'tmessage' => getstring2("chat.status.operator.joined", array("Administrator"))), $outformat);
|
||||
demo_print_message(
|
||||
array('ikind'=>$kind_agent,'created'=>time()-9,'tname'=>'Administrator',
|
||||
'tmessage'=>getstring("demo.chat.welcome")), $outformat);
|
||||
array('ikind' => $kind_agent, 'created' => time() - 9, 'tname' => 'Administrator',
|
||||
'tmessage' => getstring("demo.chat.welcome")), $outformat);
|
||||
demo_print_message(
|
||||
array('ikind'=>$kind_user,'created'=>time()-5,'tname'=>getstring("chat.default.username"),
|
||||
'tmessage'=>getstring("demo.chat.question")), $outformat);
|
||||
if($canpost && $outformat == 'xml') {
|
||||
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(
|
||||
array('ikind'=>$kind_info,'created'=>time()-5,'tname'=>'',
|
||||
'tmessage'=>'Hint: type something in message field to see typing notification'), $outformat);
|
||||
array('ikind' => $kind_info, 'created' => time() - 5, 'tname' => '',
|
||||
'tmessage' => 'Hint: type something in message field to see typing notification'), $outformat);
|
||||
}
|
||||
}
|
||||
if($act == 'post') {
|
||||
if ($act == 'post') {
|
||||
demo_print_message(
|
||||
array('ikind'=>$isuser?$kind_user:$kind_agent,'created'=>time(),'tmessage'=>$postmessage,
|
||||
'tname'=>$isuser?getstring("chat.default.username"):"Administrator"), $outformat);
|
||||
array('ikind' => $isuser ? $kind_user : $kind_agent, 'created' => time(), 'tmessage' => $postmessage,
|
||||
'tname' => $isuser ? getstring("chat.default.username") : "Administrator"), $outformat);
|
||||
}
|
||||
if($outformat == "xml") {
|
||||
if ($outformat == "xml") {
|
||||
print("</thread>");
|
||||
} else {
|
||||
print(
|
||||
"</td></tr></table><a name='aend'></a>".
|
||||
"</body></html>" );
|
||||
"</td></tr></table><a name='aend'></a>" .
|
||||
"</body></html>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,97 +23,103 @@ $ifregexp = "/\\\${(if|ifnot):([\w\.]+)}(.*?)(\\\${else:\\2}.*?)?\\\${endif:\\2}
|
||||
$expand_include_path = "";
|
||||
$current_style = "";
|
||||
|
||||
function check_condition($condition) {
|
||||
function check_condition($condition)
|
||||
{
|
||||
global $errors, $page;
|
||||
if($condition == 'errors') {
|
||||
if ($condition == 'errors') {
|
||||
return isset($errors) && count($errors) > 0;
|
||||
}
|
||||
return isset($page[$condition]) && $page[$condition];
|
||||
}
|
||||
|
||||
function expand_condition($matches) {
|
||||
function expand_condition($matches)
|
||||
{
|
||||
global $page, $ifregexp;
|
||||
$value = check_condition($matches[2]) ^ ($matches[1] != 'if');
|
||||
if($value) {
|
||||
if ($value) {
|
||||
return preg_replace_callback($ifregexp, "expand_condition", $matches[3]);
|
||||
} else if(isset($matches[4])) {
|
||||
return preg_replace_callback($ifregexp, "expand_condition", substr($matches[4],strpos($matches[4],"}")+1));
|
||||
} else if (isset($matches[4])) {
|
||||
return preg_replace_callback($ifregexp, "expand_condition", substr($matches[4], strpos($matches[4], "}") + 1));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function expand_var($matches) {
|
||||
function expand_var($matches)
|
||||
{
|
||||
global $page, $webimroot, $jsver, $errors, $current_style;
|
||||
$prefix = $matches[1];
|
||||
$var = $matches[2];
|
||||
if(!$prefix) {
|
||||
if($var == 'webimroot') {
|
||||
if (!$prefix) {
|
||||
if ($var == 'webimroot') {
|
||||
return $webimroot;
|
||||
} else if($var == 'jsver') {
|
||||
} else if ($var == 'jsver') {
|
||||
return $jsver;
|
||||
} else if($var == 'tplroot') {
|
||||
} else if ($var == 'tplroot') {
|
||||
return "$webimroot/styles/$current_style";
|
||||
} else if($var == 'styleid') {
|
||||
} else if ($var == 'styleid') {
|
||||
return $current_style;
|
||||
} else if($var == 'pagination') {
|
||||
} else if ($var == 'pagination') {
|
||||
return generate_pagination($page['pagination']);
|
||||
} else if($var == 'errors' || $var == 'harderrors') {
|
||||
if( isset($errors) && count($errors) > 0 ) {
|
||||
} else if ($var == 'errors' || $var == 'harderrors') {
|
||||
if (isset($errors) && count($errors) > 0) {
|
||||
$result = getlocal("$var.header");
|
||||
foreach( $errors as $e ) {
|
||||
$result .= getlocal("errors.prefix").$e.getlocal("errors.suffix");
|
||||
foreach ($errors as $e) {
|
||||
$result .= getlocal("errors.prefix") . $e . getlocal("errors.suffix");
|
||||
}
|
||||
$result .= getlocal("errors.footer");
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
} else if($prefix == 'msg:' || $prefix == 'url:') {
|
||||
if(strpos($var,",")!==false) {
|
||||
$pos = strpos($var,",");
|
||||
$param = substr($var, $pos+1);
|
||||
} else if ($prefix == 'msg:' || $prefix == 'url:') {
|
||||
if (strpos($var, ",") !== false) {
|
||||
$pos = strpos($var, ",");
|
||||
$param = substr($var, $pos + 1);
|
||||
$var = substr($var, 0, $pos);
|
||||
return getlocal2($var, array($page[$param]));
|
||||
}
|
||||
return getlocal($var);
|
||||
} else if($prefix == 'form:') {
|
||||
} else if ($prefix == 'form:') {
|
||||
return form_value($var);
|
||||
} else if($prefix == 'page:') {
|
||||
} else if ($prefix == 'page:') {
|
||||
return isset($page[$var]) ? $page[$var] : "";
|
||||
} else if($prefix == 'if:' || $prefix == 'else:' || $prefix == 'endif:' || $prefix == 'ifnot:') {
|
||||
} else if ($prefix == 'if:' || $prefix == 'else:' || $prefix == 'endif:' || $prefix == 'ifnot:') {
|
||||
return "<!-- wrong $prefix:$var -->";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function expand_include($matches) {
|
||||
function expand_include($matches)
|
||||
{
|
||||
global $expand_include_path;
|
||||
$name = $matches[1];
|
||||
$contents = @file_get_contents($expand_include_path.$name) or die("cannot load template");
|
||||
$contents = @file_get_contents($expand_include_path . $name) or die("cannot load template");
|
||||
return $contents;
|
||||
}
|
||||
|
||||
function expandtext($text) {
|
||||
function expandtext($text)
|
||||
{
|
||||
global $ifregexp;
|
||||
$text = preg_replace_callback("/\\\${include:([\w\.]+)}/", "expand_include", $text);
|
||||
$text = preg_replace_callback($ifregexp, "expand_condition", $text);
|
||||
return preg_replace_callback("/\\\${(\w+:)?([\w\.,]+)}/", "expand_var", $text);
|
||||
}
|
||||
|
||||
function expand($basedir,$style,$filename) {
|
||||
function expand($basedir, $style, $filename)
|
||||
{
|
||||
global $expand_include_path, $current_style;
|
||||
start_html_output();
|
||||
if(!is_dir("$basedir/$style")) {
|
||||
if (!is_dir("$basedir/$style")) {
|
||||
$style = "default";
|
||||
}
|
||||
$expand_include_path = "$basedir/$style/templates/";
|
||||
$current_style = $style;
|
||||
$contents = @file_get_contents($expand_include_path.$filename);
|
||||
if($contents === false) {
|
||||
$contents = @file_get_contents($expand_include_path . $filename);
|
||||
if ($contents === false) {
|
||||
$expand_include_path = "$basedir/default/templates/";
|
||||
$current_style = "default";
|
||||
$contents = @file_get_contents($expand_include_path.$filename) or die("cannot load template");
|
||||
$contents = @file_get_contents($expand_include_path . $filename) or die("cannot load template");
|
||||
}
|
||||
echo expandtext($contents);
|
||||
}
|
||||
|
@ -19,34 +19,37 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function setup_getcode_tabs($active) {
|
||||
function setup_getcode_tabs($active)
|
||||
{
|
||||
global $page, $webimroot;
|
||||
$page['tabselected'] = $active;
|
||||
$page['tabs'] = array(
|
||||
array('title'=> getlocal("page_getcode.tab.image"), 'link' => "$webimroot/operator/getcode.php"),
|
||||
array('title'=> getlocal("page_getcode.tab.text"), 'link' => "$webimroot/operator/gettextcode.php"),
|
||||
array('title' => getlocal("page_getcode.tab.image"), 'link' => "$webimroot/operator/getcode.php"),
|
||||
array('title' => getlocal("page_getcode.tab.text"), 'link' => "$webimroot/operator/gettextcode.php"),
|
||||
);
|
||||
}
|
||||
|
||||
function generate_button($title,$locale,$style,$group,$inner,$showhost,$forcesecure,$modsecurity) {
|
||||
$link = get_app_location($showhost,$forcesecure)."/client.php";
|
||||
if($locale)
|
||||
function generate_button($title, $locale, $style, $group, $inner, $showhost, $forcesecure, $modsecurity)
|
||||
{
|
||||
$link = get_app_location($showhost, $forcesecure) . "/client.php";
|
||||
if ($locale)
|
||||
$link = append_query($link, "locale=$locale");
|
||||
if($style)
|
||||
if ($style)
|
||||
$link = append_query($link, "style=$style");
|
||||
if($group)
|
||||
if ($group)
|
||||
$link = append_query($link, "group=$group");
|
||||
|
||||
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
|
||||
$jslink = append_query("'".$link,"url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
||||
$jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
||||
$temp = get_popup($link, "$jslink",
|
||||
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1" );
|
||||
return "<!-- mibew button -->".$temp."<!-- / mibew button -->";
|
||||
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1");
|
||||
return "<!-- mibew button -->" . $temp . "<!-- / mibew button -->";
|
||||
}
|
||||
|
||||
function get_style_list($stylesfolder) {
|
||||
function get_style_list($stylesfolder)
|
||||
{
|
||||
$stylelist = array("" => getlocal("page.preview.style_default"));
|
||||
if($handle = opendir($stylesfolder)) {
|
||||
if ($handle = opendir($stylesfolder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
||||
$stylelist[$file] = $file;
|
||||
@ -57,14 +60,15 @@ function get_style_list($stylesfolder) {
|
||||
return $stylelist;
|
||||
}
|
||||
|
||||
function verifyparam_groupid($paramid) {
|
||||
function verifyparam_groupid($paramid)
|
||||
{
|
||||
global $settings, $errors;
|
||||
$groupid = "";
|
||||
if($settings['enablegroups'] == '1') {
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$groupid = verifyparam($paramid, "/^\d{0,8}$/", "");
|
||||
if($groupid) {
|
||||
if ($groupid) {
|
||||
$group = group_by_id($groupid);
|
||||
if(!$group) {
|
||||
if (!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
$groupid = "";
|
||||
}
|
||||
@ -73,32 +77,34 @@ function verifyparam_groupid($paramid) {
|
||||
return $groupid;
|
||||
}
|
||||
|
||||
function get_groups_list() {
|
||||
function get_groups_list()
|
||||
{
|
||||
global $settings;
|
||||
$result = array();
|
||||
if($settings['enablegroups'] == '1') {
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$link = connect();
|
||||
$allgroups = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
foreach($allgroups as $g) {
|
||||
foreach ($allgroups as $g) {
|
||||
$result[] = $g;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_image_locales_map($localesdir) {
|
||||
function get_image_locales_map($localesdir)
|
||||
{
|
||||
$imageLocales = array();
|
||||
$allLocales = get_available_locales();
|
||||
foreach($allLocales as $curr) {
|
||||
foreach ($allLocales as $curr) {
|
||||
$imagesDir = "$localesdir/$curr/button";
|
||||
if($handle = @opendir($imagesDir)) {
|
||||
if ($handle = @opendir($imagesDir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
||||
&& is_file("$imagesDir/".$matches[1]."_off.gif")) {
|
||||
&& is_file("$imagesDir/" . $matches[1] . "_off.gif")) {
|
||||
$image = $matches[1];
|
||||
if( !isset($imageLocales[$image]) ) {
|
||||
if (!isset($imageLocales[$image])) {
|
||||
$imageLocales[$image] = array();
|
||||
}
|
||||
$imageLocales[$image][] = $curr;
|
||||
|
@ -19,26 +19,29 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function group_by_id($id) {
|
||||
function group_by_id($id)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$group = select_one_row(
|
||||
"select * from ${mysqlprefix}chatgroup where groupid = $id", $link );
|
||||
"select * from ${mysqlprefix}chatgroup where groupid = $id", $link);
|
||||
mysql_close($link);
|
||||
return $group;
|
||||
}
|
||||
|
||||
function get_group_name($group) {
|
||||
function get_group_name($group)
|
||||
{
|
||||
global $home_locale, $current_locale;
|
||||
if( $home_locale == $current_locale || !isset($group['vccommonname']) || !$group['vccommonname'])
|
||||
if ($home_locale == $current_locale || !isset($group['vccommonname']) || !$group['vccommonname'])
|
||||
return $group['vclocalname'];
|
||||
else
|
||||
return $group['vccommonname'];
|
||||
}
|
||||
|
||||
function setup_group_settings_tabs($gid, $active) {
|
||||
function setup_group_settings_tabs($gid, $active)
|
||||
{
|
||||
global $page, $webimroot, $settings;
|
||||
if($gid) {
|
||||
if ($gid) {
|
||||
$page['tabs'] = array(
|
||||
getlocal("page_group.tab.main") => $active != 0 ? "$webimroot/operator/group.php?gid=$gid" : "",
|
||||
getlocal("page_group.tab.members") => $active != 1 ? "$webimroot/operator/groupmembers.php?gid=$gid" : "",
|
||||
@ -48,17 +51,18 @@ function setup_group_settings_tabs($gid, $active) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_operator_groupslist($operatorid, $link) {
|
||||
function get_operator_groupslist($operatorid, $link)
|
||||
{
|
||||
global $settings, $mysqlprefix;
|
||||
if($settings['enablegroups'] == '1') {
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$groupids = array(0);
|
||||
$allgroups = select_multi_assoc("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid order by groupid",$link);
|
||||
foreach($allgroups as $g) {
|
||||
$groupids[] = $g['groupid'];
|
||||
$allgroups = select_multi_assoc("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid order by groupid", $link);
|
||||
foreach ($allgroups as $g) {
|
||||
$groupids[] = $g['groupid'];
|
||||
}
|
||||
return implode(",", $groupids);
|
||||
return implode(",", $groupids);
|
||||
} else {
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,38 +19,41 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function log_notification($locale,$kind,$to,$subj,$text,$refop,$link) {
|
||||
function log_notification($locale, $kind, $to, $subj, $text, $refop, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatnotification (locale,vckind,vcto,vcsubject,tmessage,refoperator,dtmcreated) values ('%s','%s','%s','%s','%s',%s,%s)",
|
||||
$locale,
|
||||
$kind,
|
||||
mysql_real_escape_string($to,$link),
|
||||
mysql_real_escape_string($subj,$link),
|
||||
mysql_real_escape_string($text,$link),
|
||||
$refop ? $refop : "0",
|
||||
"CURRENT_TIMESTAMP" );
|
||||
$locale,
|
||||
$kind,
|
||||
mysql_real_escape_string($to, $link),
|
||||
mysql_real_escape_string($subj, $link),
|
||||
mysql_real_escape_string($text, $link),
|
||||
$refop ? $refop : "0",
|
||||
"CURRENT_TIMESTAMP");
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
}
|
||||
|
||||
function webim_mail($toaddr, $reply_to, $subject, $body, $link) {
|
||||
function webim_mail($toaddr, $reply_to, $subject, $body, $link)
|
||||
{
|
||||
global $webim_encoding, $webim_mailbox, $mail_encoding, $current_locale;
|
||||
|
||||
$headers = "From: $webim_mailbox\r\n"
|
||||
."Reply-To: ".myiconv($webim_encoding, $mail_encoding, $reply_to)."\r\n"
|
||||
."Content-Type: text/plain; charset=$mail_encoding\r\n"
|
||||
.'X-Mailer: PHP/'.phpversion();
|
||||
. "Reply-To: " . myiconv($webim_encoding, $mail_encoding, $reply_to) . "\r\n"
|
||||
. "Content-Type: text/plain; charset=$mail_encoding\r\n"
|
||||
. 'X-Mailer: PHP/' . phpversion();
|
||||
|
||||
$real_subject = "=?".$mail_encoding."?B?".base64_encode(myiconv($webim_encoding,$mail_encoding,$subject))."?=";
|
||||
$real_subject = "=?" . $mail_encoding . "?B?" . base64_encode(myiconv($webim_encoding, $mail_encoding, $subject)) . "?=";
|
||||
|
||||
$body = preg_replace("/\n/", "\r\n", $body);
|
||||
|
||||
$body = preg_replace("/\n/","\r\n", $body);
|
||||
|
||||
log_notification($current_locale, "mail", $toaddr, $subject, $body, null, $link);
|
||||
@mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers);
|
||||
@mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body), 70), $headers);
|
||||
}
|
||||
|
||||
function webim_xmpp($toaddr, $subject, $text, $link) {
|
||||
function webim_xmpp($toaddr, $subject, $text, $link)
|
||||
{
|
||||
global $current_locale;
|
||||
log_notification($current_locale, "xmpp", $toaddr, $subject, $text, null, $link);
|
||||
}
|
||||
|
@ -33,183 +33,201 @@ $permission_ids = array(
|
||||
$can_modifyprofile => "modifyprofile"
|
||||
);
|
||||
|
||||
function operator_by_login($login) {
|
||||
function operator_by_login($login)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$operator = select_one_row(
|
||||
"select * from ${mysqlprefix}chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
|
||||
"select * from ${mysqlprefix}chatoperator where vclogin = '" . mysql_real_escape_string($login) . "'", $link);
|
||||
mysql_close($link);
|
||||
return $operator;
|
||||
}
|
||||
|
||||
function operator_by_email($mail) {
|
||||
function operator_by_email($mail)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$operator = select_one_row(
|
||||
"select * from ${mysqlprefix}chatoperator where vcemail = '".mysql_real_escape_string($mail)."'", $link );
|
||||
"select * from ${mysqlprefix}chatoperator where vcemail = '" . mysql_real_escape_string($mail) . "'", $link);
|
||||
mysql_close($link);
|
||||
return $operator;
|
||||
}
|
||||
|
||||
function operator_by_id_($id,$link) {
|
||||
function operator_by_id_($id, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
return select_one_row(
|
||||
"select * from ${mysqlprefix}chatoperator where operatorid = $id", $link );
|
||||
"select * from ${mysqlprefix}chatoperator where operatorid = $id", $link);
|
||||
}
|
||||
|
||||
function operator_by_id($id) {
|
||||
function operator_by_id($id)
|
||||
{
|
||||
$link = connect();
|
||||
$operator = operator_by_id_($id,$link);
|
||||
$operator = operator_by_id_($id, $link);
|
||||
mysql_close($link);
|
||||
return $operator;
|
||||
}
|
||||
|
||||
function operator_get_all() {
|
||||
function operator_get_all()
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
|
||||
"from ${mysqlprefix}chatoperator order by vclogin";
|
||||
$operators = select_multi_assoc($query, $link);
|
||||
mysql_close($link);
|
||||
return $operators;
|
||||
}
|
||||
|
||||
function operator_is_online($operator) {
|
||||
function operator_is_online($operator)
|
||||
{
|
||||
global $settings;
|
||||
return $operator['time'] < $settings['online_timeout'];
|
||||
}
|
||||
|
||||
function operator_is_available($operator) {
|
||||
function operator_is_available($operator)
|
||||
{
|
||||
global $settings;
|
||||
return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function operator_is_away($operator) {
|
||||
function operator_is_away($operator)
|
||||
{
|
||||
global $settings;
|
||||
return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function update_operator($operatorid,$login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
||||
function update_operator($operatorid, $login, $email, $jabber, $password, $localename, $commonname, $notify)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = sprintf(
|
||||
"update ${mysqlprefix}chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
|
||||
", vcemail = '%s', vcjabbername= '%s', inotify = %s".
|
||||
"update ${mysqlprefix}chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'" .
|
||||
", vcemail = '%s', vcjabbername= '%s', inotify = %s" .
|
||||
" where operatorid = %s",
|
||||
mysql_real_escape_string($login),
|
||||
($password ? " vcpassword='".md5($password)."'," : ""),
|
||||
($password ? " vcpassword='" . md5($password) . "'," : ""),
|
||||
mysql_real_escape_string($localename),
|
||||
mysql_real_escape_string($commonname),
|
||||
mysql_real_escape_string($email),
|
||||
mysql_real_escape_string($jabber),
|
||||
$notify,
|
||||
$operatorid );
|
||||
$operatorid);
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function update_operator_avatar($operatorid,$avatar) {
|
||||
function update_operator_avatar($operatorid, $avatar)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = sprintf(
|
||||
"update ${mysqlprefix}chatoperator set vcavatar = '%s' where operatorid = %s",
|
||||
mysql_real_escape_string($avatar), $operatorid );
|
||||
mysql_real_escape_string($avatar), $operatorid);
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link) {
|
||||
function create_operator_($login, $email, $jabber, $password, $localename, $commonname, $notify, $link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername,inotify) values ('%s','%s','%s','%s','%s','%s','%s',%s)",
|
||||
mysql_real_escape_string($login),
|
||||
md5($password),
|
||||
mysql_real_escape_string($localename),
|
||||
mysql_real_escape_string($commonname),
|
||||
'' /* no avatar */,
|
||||
mysql_real_escape_string($email),
|
||||
mysql_real_escape_string($jabber),
|
||||
$notify);
|
||||
mysql_real_escape_string($login),
|
||||
md5($password),
|
||||
mysql_real_escape_string($localename),
|
||||
mysql_real_escape_string($commonname),
|
||||
'' /* no avatar */,
|
||||
mysql_real_escape_string($email),
|
||||
mysql_real_escape_string($jabber),
|
||||
$notify);
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
$id = mysql_insert_id($link);
|
||||
|
||||
return select_one_row("select * from ${mysqlprefix}chatoperator where operatorid = $id", $link );
|
||||
return select_one_row("select * from ${mysqlprefix}chatoperator where operatorid = $id", $link);
|
||||
}
|
||||
|
||||
function create_operator($login,$email,$jabber,$password,$localename,$commonname,$notify) {
|
||||
function create_operator($login, $email, $jabber, $password, $localename, $commonname, $notify)
|
||||
{
|
||||
$link = connect();
|
||||
$newop = create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link);
|
||||
$newop = create_operator_($login, $email, $jabber, $password, $localename, $commonname, $notify, $link);
|
||||
mysql_close($link);
|
||||
return $newop;
|
||||
}
|
||||
|
||||
function notify_operator_alive($operatorid, $istatus) {
|
||||
function notify_operator_alive($operatorid, $istatus)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("update ${mysqlprefix}chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
|
||||
perform_query("update ${mysqlprefix}chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid", $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function has_online_operators($groupid="") {
|
||||
function has_online_operators($groupid = "")
|
||||
{
|
||||
global $settings, $mysqlprefix;
|
||||
loadsettings();
|
||||
$link = connect();
|
||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
|
||||
if($groupid) {
|
||||
if ($groupid) {
|
||||
$query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = " .
|
||||
"${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
|
||||
"${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
|
||||
} else {
|
||||
$query .= " where istatus = 0";
|
||||
}
|
||||
$row = select_one_row($query,$link);
|
||||
$row = select_one_row($query, $link);
|
||||
mysql_close($link);
|
||||
return $row['time'] < $settings['online_timeout'] && $row['total'] > 0;
|
||||
}
|
||||
|
||||
function is_operator_online($operatorid, $link) {
|
||||
function is_operator_online($operatorid, $link)
|
||||
{
|
||||
global $settings, $mysqlprefix;
|
||||
loadsettings_($link);
|
||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
|
||||
"from ${mysqlprefix}chatoperator where operatorid = $operatorid";
|
||||
$row = select_one_row($query,$link);
|
||||
$row = select_one_row($query, $link);
|
||||
return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
|
||||
}
|
||||
|
||||
function get_operator_name($operator) {
|
||||
function get_operator_name($operator)
|
||||
{
|
||||
global $home_locale, $current_locale;
|
||||
if( $home_locale == $current_locale )
|
||||
if ($home_locale == $current_locale)
|
||||
return $operator['vclocalename'];
|
||||
else
|
||||
return $operator['vccommonname'];
|
||||
}
|
||||
|
||||
function append_query($link,$pv) {
|
||||
function append_query($link, $pv)
|
||||
{
|
||||
$infix = '?';
|
||||
if( strstr($link,$infix) !== FALSE )
|
||||
if (strstr($link, $infix) !== FALSE)
|
||||
$infix = '&';
|
||||
return "$link$infix$pv";
|
||||
}
|
||||
|
||||
function check_login($redirect=true) {
|
||||
function check_login($redirect = true)
|
||||
{
|
||||
global $webimroot, $mysqlprefix;
|
||||
if( !isset( $_SESSION["${mysqlprefix}operator"] ) ) {
|
||||
if( isset($_COOKIE['webim_lite']) ) {
|
||||
list($login,$pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
|
||||
if (!isset($_SESSION["${mysqlprefix}operator"])) {
|
||||
if (isset($_COOKIE['webim_lite'])) {
|
||||
list($login, $pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
|
||||
$op = operator_by_login($login);
|
||||
if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
|
||||
if ($op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd) {
|
||||
$_SESSION["${mysqlprefix}operator"] = $op;
|
||||
return $op;
|
||||
}
|
||||
}
|
||||
$requested = $_SERVER['PHP_SELF'];
|
||||
if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
||||
$requested .= "?".$_SERVER['QUERY_STRING'];
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
||||
$requested .= "?" . $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
if($redirect) {
|
||||
if ($redirect) {
|
||||
$_SESSION['backpath'] = $requested;
|
||||
header("Location: $webimroot/operator/login.php");
|
||||
exit;
|
||||
@ -220,33 +238,37 @@ function check_login($redirect=true) {
|
||||
return $_SESSION["${mysqlprefix}operator"];
|
||||
}
|
||||
|
||||
function get_logged_in() {
|
||||
function get_logged_in()
|
||||
{
|
||||
global $mysqlprefix;
|
||||
return isset( $_SESSION["${mysqlprefix}operator"] ) ? $_SESSION["${mysqlprefix}operator"] : FALSE;
|
||||
return isset($_SESSION["${mysqlprefix}operator"]) ? $_SESSION["${mysqlprefix}operator"] : FALSE;
|
||||
}
|
||||
|
||||
function login_operator($operator,$remember) {
|
||||
function login_operator($operator, $remember)
|
||||
{
|
||||
global $webimroot, $mysqlprefix;
|
||||
$_SESSION["${mysqlprefix}operator"] = $operator;
|
||||
if( $remember ) {
|
||||
$value = $operator['vclogin'].",".md5($operator['vcpassword']);
|
||||
setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/");
|
||||
if ($remember) {
|
||||
$value = $operator['vclogin'] . "," . md5($operator['vcpassword']);
|
||||
setcookie('webim_lite', $value, time() + 60 * 60 * 24 * 1000, "$webimroot/");
|
||||
|
||||
} else if( isset($_COOKIE['webim_lite']) ) {
|
||||
} else if (isset($_COOKIE['webim_lite'])) {
|
||||
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
||||
}
|
||||
}
|
||||
|
||||
function logout_operator() {
|
||||
function logout_operator()
|
||||
{
|
||||
global $webimroot, $mysqlprefix;
|
||||
unset($_SESSION["${mysqlprefix}operator"]);
|
||||
unset($_SESSION['backpath']);
|
||||
if( isset($_COOKIE['webim_lite']) ) {
|
||||
if (isset($_COOKIE['webim_lite'])) {
|
||||
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
|
||||
}
|
||||
}
|
||||
|
||||
function setup_redirect_links($threadid,$token) {
|
||||
function setup_redirect_links($threadid, $token)
|
||||
{
|
||||
global $page, $webimroot, $settings, $mysqlprefix;
|
||||
loadsettings();
|
||||
$link = connect();
|
||||
@ -254,59 +276,59 @@ function setup_redirect_links($threadid,$token) {
|
||||
$operatorscount = db_rows_count("${mysqlprefix}chatoperator", array(), "", $link);
|
||||
|
||||
$groupscount = 0;
|
||||
$groups = array();
|
||||
if($settings['enablegroups'] == "1") {
|
||||
foreach(get_groups($link, true) as $group) {
|
||||
if($group['inumofagents'] == 0) {
|
||||
$groups = array();
|
||||
if ($settings['enablegroups'] == "1") {
|
||||
foreach (get_groups($link, true) as $group) {
|
||||
if ($group['inumofagents'] == 0) {
|
||||
continue;
|
||||
}
|
||||
$groups[] = $group;
|
||||
}
|
||||
$groupscount = count($groups);
|
||||
}
|
||||
|
||||
prepare_pagination(max($operatorscount,$groupscount),8);
|
||||
|
||||
prepare_pagination(max($operatorscount, $groupscount), 8);
|
||||
$p = $page['pagination'];
|
||||
$limit = $p['limit'];
|
||||
|
||||
$operators = select_multi_assoc(db_build_select(
|
||||
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
||||
"${mysqlprefix}chatoperator", array(), "order by vclogin $limit"), $link);
|
||||
|
||||
$groups = array_slice($groups, $p['start'], $p['end']-$p['start']);
|
||||
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
||||
"${mysqlprefix}chatoperator", array(), "order by vclogin $limit"), $link);
|
||||
|
||||
$groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);
|
||||
mysql_close($link);
|
||||
|
||||
$agent_list = "";
|
||||
$params = array('thread' => $threadid, 'token' => $token);
|
||||
foreach($operators as $agent) {
|
||||
foreach ($operators as $agent) {
|
||||
$params['nextAgent'] = $agent['operatorid'];
|
||||
$status = $agent['time'] < $settings['online_timeout']
|
||||
? ($agent['istatus'] == 0
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
: getlocal("char.redirect.operator.away_suff")
|
||||
)
|
||||
: "";
|
||||
$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||
"\" title=\"".topage(get_operator_name($agent))."\">".
|
||||
topage(get_operator_name($agent)).
|
||||
"</a> $status</li>";
|
||||
? ($agent['istatus'] == 0
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
: getlocal("char.redirect.operator.away_suff")
|
||||
)
|
||||
: "";
|
||||
$agent_list .= "<li><a href=\"" . add_params($webimroot . "/operator/redirect.php", $params) .
|
||||
"\" title=\"" . topage(get_operator_name($agent)) . "\">" .
|
||||
topage(get_operator_name($agent)) .
|
||||
"</a> $status</li>";
|
||||
}
|
||||
$page['redirectToAgent'] = $agent_list;
|
||||
|
||||
$group_list = "";
|
||||
if($settings['enablegroups'] == "1") {
|
||||
if ($settings['enablegroups'] == "1") {
|
||||
$params = array('thread' => $threadid, 'token' => $token);
|
||||
foreach($groups as $group) {
|
||||
foreach ($groups as $group) {
|
||||
$params['nextGroup'] = $group['groupid'];
|
||||
$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout']
|
||||
? getlocal("char.redirect.operator.away_suff")
|
||||
: "");
|
||||
$group_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||
"\" title=\"".topage(get_group_name($group))."\">".
|
||||
topage(get_group_name($group)).
|
||||
"</a> $status</li>";
|
||||
? getlocal("char.redirect.operator.away_suff")
|
||||
: "");
|
||||
$group_list .= "<li><a href=\"" . add_params($webimroot . "/operator/redirect.php", $params) .
|
||||
"\" title=\"" . topage(get_group_name($group)) . "\">" .
|
||||
topage(get_group_name($group)) .
|
||||
"</a> $status</li>";
|
||||
}
|
||||
}
|
||||
$page['redirectToGroup'] = $group_list;
|
||||
@ -314,10 +336,11 @@ function setup_redirect_links($threadid,$token) {
|
||||
|
||||
$permission_list = array();
|
||||
|
||||
function get_permission_list() {
|
||||
function get_permission_list()
|
||||
{
|
||||
global $permission_list, $permission_ids;
|
||||
if(count($permission_list) == 0) {
|
||||
foreach($permission_ids as $permid) {
|
||||
if (count($permission_list) == 0) {
|
||||
foreach ($permission_ids as $permid) {
|
||||
$permission_list[] = array(
|
||||
'id' => $permid,
|
||||
'descr' => getlocal("permission.$permid")
|
||||
@ -327,15 +350,17 @@ function get_permission_list() {
|
||||
return $permission_list;
|
||||
}
|
||||
|
||||
function is_capable($perm,$operator) {
|
||||
function is_capable($perm, $operator)
|
||||
{
|
||||
$permissions = $operator && isset($operator['iperm']) ? $operator['iperm'] : 0;
|
||||
return $perm >= 0 && $perm < 32 && ($permissions & (1 << $perm)) != 0;
|
||||
}
|
||||
|
||||
function prepare_menu($operator,$hasright=true) {
|
||||
function prepare_menu($operator, $hasright = true)
|
||||
{
|
||||
global $page, $settings, $can_administrate;
|
||||
$page['operator'] = topage(get_operator_name($operator));
|
||||
if($hasright) {
|
||||
if ($hasright) {
|
||||
loadsettings();
|
||||
$page['showban'] = $settings['enableban'] == "1";
|
||||
$page['showgroups'] = $settings['enablegroups'] == "1";
|
||||
@ -345,33 +370,36 @@ function prepare_menu($operator,$hasright=true) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_all_groups($link) {
|
||||
function get_all_groups($link)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription from ${mysqlprefix}chatgroup order by vclocalname";
|
||||
return select_multi_assoc($query, $link);
|
||||
}
|
||||
|
||||
function get_groups($link,$checkaway) {
|
||||
function get_groups($link, $checkaway)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription".
|
||||
", (SELECT count(*) from ${mysqlprefix}chatgroupoperator where ${mysqlprefix}chatgroup.groupid = " .
|
||||
"${mysqlprefix}chatgroupoperator.groupid) as inumofagents".
|
||||
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus = 0 and " .
|
||||
"${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid ".
|
||||
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseen".
|
||||
($checkaway
|
||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus <> 0 and " .
|
||||
"${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid ".
|
||||
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseenaway"
|
||||
: ""
|
||||
).
|
||||
$query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription" .
|
||||
", (SELECT count(*) from ${mysqlprefix}chatgroupoperator where ${mysqlprefix}chatgroup.groupid = " .
|
||||
"${mysqlprefix}chatgroupoperator.groupid) as inumofagents" .
|
||||
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
|
||||
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus = 0 and " .
|
||||
"${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid " .
|
||||
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseen" .
|
||||
($checkaway
|
||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time " .
|
||||
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus <> 0 and " .
|
||||
"${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid " .
|
||||
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseenaway"
|
||||
: ""
|
||||
) .
|
||||
" from ${mysqlprefix}chatgroup order by vclocalname";
|
||||
return select_multi_assoc($query, $link);
|
||||
}
|
||||
|
||||
function get_operator_groupids($operatorid) {
|
||||
function get_operator_groupids($operatorid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = "select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid";
|
||||
|
@ -19,26 +19,27 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function setup_operator_settings_tabs($opId, $active) {
|
||||
function setup_operator_settings_tabs($opId, $active)
|
||||
{
|
||||
global $page, $webimroot, $settings;
|
||||
loadsettings();
|
||||
|
||||
if($opId) {
|
||||
|
||||
if ($opId) {
|
||||
$page['tabselected'] = $active;
|
||||
if($settings['enablegroups'] == '1') {
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$page['tabs'] = array(
|
||||
array('title'=> getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"),
|
||||
array('title'=> getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"),
|
||||
array('title'=> getlocal("page_agent.tab.groups"), 'link' => "$webimroot/operator/opgroups.php?op=$opId"),
|
||||
array('title'=> getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.groups"), 'link' => "$webimroot/operator/opgroups.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"),
|
||||
);
|
||||
} else {
|
||||
$page['tabs'] = array(
|
||||
array('title'=> getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"),
|
||||
array('title'=> getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"),
|
||||
array('title'=> getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"),
|
||||
array('title' => getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"),
|
||||
);
|
||||
if($active == 3) $active--;
|
||||
if ($active == 3) $active--;
|
||||
}
|
||||
} else {
|
||||
$page['tabs'] = array();
|
||||
|
@ -22,110 +22,117 @@
|
||||
$pagination_spacing = " ";
|
||||
$links_on_page = 5;
|
||||
|
||||
function generate_pagination_link($page,$title) {
|
||||
function generate_pagination_link($page, $title)
|
||||
{
|
||||
$lnk = $_SERVER['REQUEST_URI'];
|
||||
$href = preg_replace("/\?page=\d+\&/", "?", preg_replace("/\&page=\d+/", "", $lnk));
|
||||
$href .= strstr($href,"?") ? "&page=$page" : "?page=$page";
|
||||
return "<a href=\"".htmlspecialchars($href)."\" class=\"pagelink\">$title</a>";
|
||||
$href .= strstr($href, "?") ? "&page=$page" : "?page=$page";
|
||||
return "<a href=\"" . htmlspecialchars($href) . "\" class=\"pagelink\">$title</a>";
|
||||
}
|
||||
|
||||
function generate_pagination_image($id,$alt) {
|
||||
function generate_pagination_image($id, $alt)
|
||||
{
|
||||
global $webimroot;
|
||||
return "<img src=\"$webimroot/images/$id.gif\" border=\"0\" alt=\"".htmlspecialchars($alt)."\"/>";
|
||||
return "<img src=\"$webimroot/images/$id.gif\" border=\"0\" alt=\"" . htmlspecialchars($alt) . "\"/>";
|
||||
}
|
||||
|
||||
function prepare_pagination($items_count,$default_items_per_page=15) {
|
||||
function prepare_pagination($items_count, $default_items_per_page = 15)
|
||||
{
|
||||
global $page;
|
||||
|
||||
if( $items_count ) {
|
||||
if ($items_count) {
|
||||
$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page);
|
||||
if( $items_per_page < 2 )
|
||||
if ($items_per_page < 2)
|
||||
$items_per_page = 2;
|
||||
|
||||
$total_pages = div($items_count + $items_per_page - 1, $items_per_page);
|
||||
$curr_page = verifyparam("page", "/^\d{1,6}$/", 1);
|
||||
|
||||
if( $curr_page < 1 )
|
||||
if ($curr_page < 1)
|
||||
$curr_page = 1;
|
||||
if( $curr_page > $total_pages )
|
||||
if ($curr_page > $total_pages)
|
||||
$curr_page = $total_pages;
|
||||
|
||||
$start_index = ($curr_page-1)*$items_per_page;
|
||||
$end_index = min($start_index+$items_per_page, $items_count);
|
||||
$start_index = ($curr_page - 1) * $items_per_page;
|
||||
$end_index = min($start_index + $items_per_page, $items_count);
|
||||
$page['pagination'] =
|
||||
array( "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages,
|
||||
"count" => $items_count, "start" => $start_index, "end" => $end_index,
|
||||
"limit" => "LIMIT $start_index,".($end_index - $start_index) );
|
||||
array("page" => $curr_page, "items" => $items_per_page, "total" => $total_pages,
|
||||
"count" => $items_count, "start" => $start_index, "end" => $end_index,
|
||||
"limit" => "LIMIT $start_index," . ($end_index - $start_index));
|
||||
} else {
|
||||
$page['pagination'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function setup_pagination($items,$default_items_per_page=15) {
|
||||
function setup_pagination($items, $default_items_per_page = 15)
|
||||
{
|
||||
global $page;
|
||||
prepare_pagination($items ? count($items) : 0, $default_items_per_page);
|
||||
if($items && count($items) > 0) {
|
||||
if ($items && count($items) > 0) {
|
||||
$p = $page['pagination'];
|
||||
$page['pagination.items'] = array_slice($items, $p['start'], $p['end']-$p['start']);
|
||||
$page['pagination.items'] = array_slice($items, $p['start'], $p['end'] - $p['start']);
|
||||
} else {
|
||||
$page['pagination.items'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
function select_with_pagintation($fields, $table, $conditions, $order, $countfields, $link) {
|
||||
function select_with_pagintation($fields, $table, $conditions, $order, $countfields, $link)
|
||||
{
|
||||
global $page;
|
||||
$count = db_rows_count($table, $conditions, $countfields, $link);
|
||||
prepare_pagination($count);
|
||||
if($count) {
|
||||
if ($count) {
|
||||
$p = $page['pagination'];
|
||||
$limit = $p['limit'];
|
||||
$page['pagination.items'] = select_multi_assoc(db_build_select($fields, $table, $conditions, $order)." ".$limit, $link);
|
||||
$page['pagination.items'] = select_multi_assoc(db_build_select($fields, $table, $conditions, $order) . " " . $limit, $link);
|
||||
} else {
|
||||
$page['pagination.items'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
function setup_empty_pagination() {
|
||||
function setup_empty_pagination()
|
||||
{
|
||||
global $page;
|
||||
$page['pagination.items'] = false;
|
||||
$page['pagination'] = false;
|
||||
}
|
||||
|
||||
function generate_pagination($pagination,$bottom=true) {
|
||||
function generate_pagination($pagination, $bottom = true)
|
||||
{
|
||||
global $pagination_spacing, $links_on_page;
|
||||
$result = getlocal2("tag.pagination.info",
|
||||
array($pagination['page'],$pagination['total'],$pagination['start']+1,$pagination['end'],$pagination['count']))."<br/>";
|
||||
array($pagination['page'], $pagination['total'], $pagination['start'] + 1, $pagination['end'], $pagination['count'])) . "<br/>";
|
||||
|
||||
if( $pagination['total'] > 1 ) {
|
||||
if(!$bottom) {
|
||||
if ($pagination['total'] > 1) {
|
||||
if (!$bottom) {
|
||||
$result = "";
|
||||
} else {
|
||||
$result .= "<br/>";
|
||||
}
|
||||
$result.="<div class='pagination'>";
|
||||
$result .= "<div class='pagination'>";
|
||||
$curr_page = $pagination['page'];
|
||||
|
||||
$minPage = max( $curr_page - $links_on_page, 1 );
|
||||
$maxPage = min( $curr_page + $links_on_page, $pagination['total'] );
|
||||
$minPage = max($curr_page - $links_on_page, 1);
|
||||
$maxPage = min($curr_page + $links_on_page, $pagination['total']);
|
||||
|
||||
if( $curr_page > 1 ) {
|
||||
$result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage", getlocal("tag.pagination.previous"))).$pagination_spacing;
|
||||
if ($curr_page > 1) {
|
||||
$result .= generate_pagination_link($curr_page - 1, generate_pagination_image("prevpage", getlocal("tag.pagination.previous"))) . $pagination_spacing;
|
||||
}
|
||||
|
||||
for($i = $minPage; $i <= $maxPage; $i++ ) {
|
||||
$title = abs($curr_page-$i) >= $links_on_page && $i != 1 ? "..." : $i;
|
||||
if( $i != $curr_page)
|
||||
for ($i = $minPage; $i <= $maxPage; $i++) {
|
||||
$title = abs($curr_page - $i) >= $links_on_page && $i != 1 ? "..." : $i;
|
||||
if ($i != $curr_page)
|
||||
$result .= generate_pagination_link($i, $title);
|
||||
else
|
||||
$result .= "<span class=\"pagecurrent\">$title</span>";
|
||||
if( $i < $maxPage )
|
||||
if ($i < $maxPage)
|
||||
$result .= $pagination_spacing;
|
||||
}
|
||||
|
||||
if( $curr_page < $pagination['total'] ) {
|
||||
$result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage", getlocal("tag.pagination.next")));
|
||||
if ($curr_page < $pagination['total']) {
|
||||
$result .= $pagination_spacing . generate_pagination_link($curr_page + 1, generate_pagination_image("nextpage", getlocal("tag.pagination.next")));
|
||||
}
|
||||
$result.="</div>";
|
||||
$result .= "</div>";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -19,28 +19,30 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function update_settings() {
|
||||
function update_settings()
|
||||
{
|
||||
global $settings, $settings_in_db, $mysqlprefix;
|
||||
$link = connect();
|
||||
foreach ($settings as $key => $value) {
|
||||
if(!isset($settings_in_db[$key])) {
|
||||
perform_query("insert into ${mysqlprefix}chatconfig (vckey) values ('$key')",$link);
|
||||
if (!isset($settings_in_db[$key])) {
|
||||
perform_query("insert into ${mysqlprefix}chatconfig (vckey) values ('$key')", $link);
|
||||
}
|
||||
$query = sprintf("update ${mysqlprefix}chatconfig set vcvalue='%s' where vckey='$key'", mysql_real_escape_string($value));
|
||||
perform_query($query,$link);
|
||||
$query = sprintf("update ${mysqlprefix}chatconfig set vcvalue='%s' where vckey='$key'", mysql_real_escape_string($value));
|
||||
perform_query($query, $link);
|
||||
}
|
||||
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function setup_settings_tabs($active) {
|
||||
function setup_settings_tabs($active)
|
||||
{
|
||||
global $page, $webimroot;
|
||||
$page['tabselected'] = $active;
|
||||
$page['tabs'] = array(
|
||||
array('title'=> getlocal("page_settings.tab.main"), 'link' => "$webimroot/operator/settings.php"),
|
||||
array('title'=> getlocal("page_settings.tab.features"), 'link' => "$webimroot/operator/features.php"),
|
||||
array('title'=> getlocal("page_settings.tab.performance"), 'link' => "$webimroot/operator/performance.php"),
|
||||
array('title'=> getlocal("page_settings.tab.themes"), 'link' => "$webimroot/operator/themes.php"),
|
||||
array('title' => getlocal("page_settings.tab.main"), 'link' => "$webimroot/operator/settings.php"),
|
||||
array('title' => getlocal("page_settings.tab.features"), 'link' => "$webimroot/operator/features.php"),
|
||||
array('title' => getlocal("page_settings.tab.performance"), 'link' => "$webimroot/operator/performance.php"),
|
||||
array('title' => getlocal("page_settings.tab.themes"), 'link' => "$webimroot/operator/themes.php"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -19,38 +19,40 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function get_useragent_version($userAgent) {
|
||||
global $knownAgents;
|
||||
if (is_array($knownAgents)) {
|
||||
$userAgent = strtolower($userAgent);
|
||||
foreach( $knownAgents as $agent ) {
|
||||
if( strstr($userAgent,$agent) ) {
|
||||
if( preg_match( "/".$agent."[\\s\/]?(\\d+(\\.\\d+(\\.\\d+(\\.\\d+)?)?)?)/", $userAgent, $matches ) ) {
|
||||
$ver = $matches[1];
|
||||
if($agent=='safari') {
|
||||
if(preg_match( "/version\/(\\d+(\\.\\d+(\\.\\d+)?)?)/", $userAgent, $matches)) {
|
||||
$ver = $matches[1];
|
||||
} else {
|
||||
$ver = "1 or 2 (build ".$ver.")";
|
||||
function get_useragent_version($userAgent)
|
||||
{
|
||||
global $knownAgents;
|
||||
if (is_array($knownAgents)) {
|
||||
$userAgent = strtolower($userAgent);
|
||||
foreach ($knownAgents as $agent) {
|
||||
if (strstr($userAgent, $agent)) {
|
||||
if (preg_match("/" . $agent . "[\\s\/]?(\\d+(\\.\\d+(\\.\\d+(\\.\\d+)?)?)?)/", $userAgent, $matches)) {
|
||||
$ver = $matches[1];
|
||||
if ($agent == 'safari') {
|
||||
if (preg_match("/version\/(\\d+(\\.\\d+(\\.\\d+)?)?)/", $userAgent, $matches)) {
|
||||
$ver = $matches[1];
|
||||
} else {
|
||||
$ver = "1 or 2 (build " . $ver . ")";
|
||||
}
|
||||
if (preg_match("/mobile\/(\\d+(\\.\\d+(\\.\\d+)?)?)/", $userAgent, $matches)) {
|
||||
$userAgent = "iPhone " . $matches[1] . " ($agent $ver)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(preg_match( "/mobile\/(\\d+(\\.\\d+(\\.\\d+)?)?)/", $userAgent, $matches)) {
|
||||
$userAgent = "iPhone ".$matches[1]." ($agent $ver)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$userAgent = ucfirst($agent)." ".$ver;
|
||||
break;
|
||||
$userAgent = ucfirst($agent) . " " . $ver;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $userAgent;
|
||||
return $userAgent;
|
||||
}
|
||||
|
||||
function get_user_addr($addr) {
|
||||
function get_user_addr($addr)
|
||||
{
|
||||
global $settings;
|
||||
if($settings['geolink'] && preg_match( "/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches )) {
|
||||
if ($settings['geolink'] && preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches)) {
|
||||
$userip = $matches[1];
|
||||
return get_popup(str_replace("{ip}", $userip, $settings['geolink']), '', htmlspecialchars($addr), "GeoLocation", "ip$userip", $settings['geolinkparams']);
|
||||
}
|
||||
|
@ -29,47 +29,47 @@ require_once('../libs/expand.php');
|
||||
$operator = check_login();
|
||||
|
||||
loadsettings();
|
||||
if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") {
|
||||
if(!is_secure_request()) {
|
||||
if ($settings['enablessl'] == "1" && $settings['forcessl'] == "1") {
|
||||
if (!is_secure_request()) {
|
||||
$requested = $_SERVER['PHP_SELF'];
|
||||
if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
||||
header("Location: ".get_app_location(true,true)."/operator/agent.php?".$_SERVER['QUERY_STRING']);
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
|
||||
header("Location: " . get_app_location(true, true) . "/operator/agent.php?" . $_SERVER['QUERY_STRING']);
|
||||
} else {
|
||||
die("only https connections are handled");
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$threadid = verifyparam( "thread", "/^\d{1,8}$/");
|
||||
$threadid = verifyparam("thread", "/^\d{1,8}$/");
|
||||
|
||||
if( !isset($_GET['token']) ) {
|
||||
if (!isset($_GET['token'])) {
|
||||
|
||||
$remote_level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
|
||||
if( $remote_level != "ajaxed" ) {
|
||||
if ($remote_level != "ajaxed") {
|
||||
die("old browser is used, please update it");
|
||||
}
|
||||
|
||||
$thread = thread_by_id($threadid);
|
||||
if( !$thread || !isset($thread['ltoken']) ) {
|
||||
if (!$thread || !isset($thread['ltoken'])) {
|
||||
die("wrong thread");
|
||||
}
|
||||
|
||||
$viewonly = verifyparam( "viewonly", "/^true$/", false);
|
||||
$viewonly = verifyparam("viewonly", "/^true$/", false);
|
||||
|
||||
$forcetake = verifyparam("force", "/^true$/", false);
|
||||
if( !$viewonly && $thread['istate'] == $state_chatting && $operator['operatorid'] != $thread['agentId'] ) {
|
||||
if (!$viewonly && $thread['istate'] == $state_chatting && $operator['operatorid'] != $thread['agentId']) {
|
||||
|
||||
if(!is_capable($can_takeover, $operator)) {
|
||||
if (!is_capable($can_takeover, $operator)) {
|
||||
$errors = array("Cannot take over");
|
||||
start_html_output();
|
||||
expand("../styles", getchatstyle(), "error.tpl");
|
||||
exit;
|
||||
}
|
||||
|
||||
if( $forcetake == false ) {
|
||||
if ($forcetake == false) {
|
||||
$page = array(
|
||||
'user' => topage($thread['userName']), 'agent' => topage($thread['agentName']), 'link' => $_SERVER['PHP_SELF']."?thread=$threadid&force=true"
|
||||
'user' => topage($thread['userName']), 'agent' => topage($thread['agentName']), 'link' => $_SERVER['PHP_SELF'] . "?thread=$threadid&force=true"
|
||||
);
|
||||
start_html_output();
|
||||
require('../view/confirm.php');
|
||||
@ -78,8 +78,8 @@ if( !isset($_GET['token']) ) {
|
||||
}
|
||||
|
||||
if (!$viewonly) {
|
||||
take_thread($thread,$operator);
|
||||
} else if(!is_capable($can_viewthreads, $operator)) {
|
||||
take_thread($thread, $operator);
|
||||
} else if (!is_capable($can_viewthreads, $operator)) {
|
||||
$errors = array("Cannot view threads");
|
||||
start_html_output();
|
||||
expand("../styles", getchatstyle(), "error.tpl");
|
||||
@ -91,14 +91,14 @@ if( !isset($_GET['token']) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$token = verifyparam( "token", "/^\d{1,8}$/");
|
||||
$token = verifyparam("token", "/^\d{1,8}$/");
|
||||
|
||||
$thread = thread_by_id($threadid);
|
||||
if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
|
||||
if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken']) {
|
||||
die("wrong thread");
|
||||
}
|
||||
|
||||
if($thread['agentId'] != $operator['operatorid'] && !is_capable($can_viewthreads, $operator)) {
|
||||
if ($thread['agentId'] != $operator['operatorid'] && !is_capable($can_viewthreads, $operator)) {
|
||||
$errors = array("Cannot view threads");
|
||||
start_html_output();
|
||||
expand("../styles", getchatstyle(), "error.tpl");
|
||||
@ -109,9 +109,9 @@ setup_chatview_for_operator($thread, $operator);
|
||||
|
||||
start_html_output();
|
||||
|
||||
$pparam = verifyparam( "act", "/^(redirect)$/", "default");
|
||||
if( $pparam == "redirect" ) {
|
||||
setup_redirect_links($threadid,$token);
|
||||
$pparam = verifyparam("act", "/^(redirect)$/", "default");
|
||||
if ($pparam == "redirect") {
|
||||
setup_redirect_links($threadid, $token);
|
||||
expand("../styles", getchatstyle(), "redirect.tpl");
|
||||
} else {
|
||||
expand("../styles", getchatstyle(), "chat.tpl");
|
||||
|
@ -25,7 +25,7 @@ require_once('../libs/operator.php');
|
||||
$operator = check_login(false);
|
||||
|
||||
start_xml_output();
|
||||
if($operator) {
|
||||
if ($operator) {
|
||||
echo "<login><status>OK</status></login>";
|
||||
} else {
|
||||
echo "<login><status>FAILED</status></login>";
|
||||
|
@ -25,57 +25,57 @@ require_once('../libs/operator_settings.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||
$opId = verifyparam("op", "/^\d{1,9}$/");
|
||||
$page = array('opid' => $opId, 'avatar' => '');
|
||||
$errors = array();
|
||||
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
|
||||
$op = operator_by_id($opId);
|
||||
|
||||
if( !$op ) {
|
||||
if (!$op) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
|
||||
} else if( isset($_POST['op']) ) {
|
||||
} else if (isset($_POST['op'])) {
|
||||
$avatar = $op['vcavatar'];
|
||||
|
||||
if(!$canmodify) {
|
||||
if (!$canmodify) {
|
||||
$errors[] = getlocal('page_agent.cannot_modify');
|
||||
|
||||
} else if( isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
|
||||
$valid_types = array("gif","jpg", "png", "tif");
|
||||
} else if (isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
|
||||
$valid_types = array("gif", "jpg", "png", "tif");
|
||||
|
||||
$orig_filename = $_FILES['avatarFile']['name'];
|
||||
$tmp_file_name = $_FILES['avatarFile']['tmp_name'];
|
||||
$orig_filename = $_FILES['avatarFile']['name'];
|
||||
$tmp_file_name = $_FILES['avatarFile']['tmp_name'];
|
||||
|
||||
$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, ".")));
|
||||
$new_file_name = "$opId.$ext";
|
||||
loadsettings();
|
||||
$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, ".")));
|
||||
$new_file_name = "$opId.$ext";
|
||||
loadsettings();
|
||||
|
||||
$file_size = $_FILES['avatarFile']['size'];
|
||||
if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
|
||||
} elseif(!in_array($ext, $valid_types)) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
|
||||
} else {
|
||||
$avatar_local_dir = "../images/avatar/";
|
||||
$full_file_path = $avatar_local_dir.$new_file_name;
|
||||
if (file_exists($full_file_path)) {
|
||||
unlink($full_file_path);
|
||||
}
|
||||
if (!move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
|
||||
} else {
|
||||
$avatar = "$webimroot/images/avatar/$new_file_name";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$errors[] = "No file selected";
|
||||
}
|
||||
$file_size = $_FILES['avatarFile']['size'];
|
||||
if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
|
||||
} elseif (!in_array($ext, $valid_types)) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
|
||||
} else {
|
||||
$avatar_local_dir = "../images/avatar/";
|
||||
$full_file_path = $avatar_local_dir . $new_file_name;
|
||||
if (file_exists($full_file_path)) {
|
||||
unlink($full_file_path);
|
||||
}
|
||||
if (!move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
|
||||
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
|
||||
} else {
|
||||
$avatar = "$webimroot/images/avatar/$new_file_name";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$errors[] = "No file selected";
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
update_operator_avatar($op['operatorid'],$avatar);
|
||||
if (count($errors) == 0) {
|
||||
update_operator_avatar($op['operatorid'], $avatar);
|
||||
|
||||
if ($opId && $avatar && $_SESSION[$mysqlprefix . 'operator'] && $operator['operatorid'] == $opId) {
|
||||
$_SESSION[$mysqlprefix . 'operator']['vcavatar'] = $avatar;
|
||||
@ -88,18 +88,18 @@ if( !$op ) {
|
||||
|
||||
} else {
|
||||
if (isset($_GET['delete']) && $_GET['delete'] == "true" && $canmodify) {
|
||||
update_operator_avatar($op['operatorid'],'');
|
||||
update_operator_avatar($op['operatorid'], '');
|
||||
header("Location: $webimroot/operator/avatar.php?op=$opId");
|
||||
exit;
|
||||
}
|
||||
$page['avatar'] = topage($op['vcavatar']);
|
||||
}
|
||||
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : "-not found-";
|
||||
$page['canmodify'] = $canmodify ? "1" : "";
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_operator_settings_tabs($opId,1);
|
||||
setup_operator_settings_tabs($opId, 1);
|
||||
start_html_output();
|
||||
require('../view/avatar.php');
|
||||
?>
|
@ -31,55 +31,55 @@ $page['thread'] = '';
|
||||
$page['threadid'] = '';
|
||||
$errors = array();
|
||||
|
||||
if( isset($_POST['address']) ) {
|
||||
$banId = verifyparam( "banId", "/^(\d{1,9})?$/", "");
|
||||
if (isset($_POST['address'])) {
|
||||
$banId = verifyparam("banId", "/^(\d{1,9})?$/", "");
|
||||
$address = getparam("address");
|
||||
$days = getparam("days");
|
||||
$comment = getparam('comment');
|
||||
$threadid = isset($_POST['threadid']) ? getparam('threadid') : "";
|
||||
|
||||
if( !$address ) {
|
||||
if (!$address) {
|
||||
$errors[] = no_field("form.field.address");
|
||||
}
|
||||
|
||||
if( !preg_match( "/^\d+$/", $days )) {
|
||||
if (!preg_match("/^\d+$/", $days)) {
|
||||
$errors[] = wrong_field("form.field.ban_days");
|
||||
}
|
||||
|
||||
if( !$comment ) {
|
||||
if (!$comment) {
|
||||
$errors[] = no_field("form.field.ban_comment");
|
||||
}
|
||||
|
||||
$link = connect();
|
||||
$existing_ban = ban_for_addr_($address,$link);
|
||||
$existing_ban = ban_for_addr_($address, $link);
|
||||
mysql_close($link);
|
||||
|
||||
if( (!$banId && $existing_ban) ||
|
||||
( $banId && $existing_ban && $banId != $existing_ban['banid']) ) {
|
||||
$errors[] = getlocal2("ban.error.duplicate",array($address,$existing_ban['banid']));
|
||||
if ((!$banId && $existing_ban) ||
|
||||
($banId && $existing_ban && $banId != $existing_ban['banid'])) {
|
||||
$errors[] = getlocal2("ban.error.duplicate", array($address, $existing_ban['banid']));
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
if (count($errors) == 0) {
|
||||
$link = connect();
|
||||
$utime = time() + $days * 24*60*60;
|
||||
$utime = time() + $days * 24 * 60 * 60;
|
||||
if (!$banId) {
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatban (dtmcreated,dtmtill,address,comment) values (CURRENT_TIMESTAMP,%s,'%s','%s')",
|
||||
"FROM_UNIXTIME($utime)",
|
||||
mysql_real_escape_string($address,$link),
|
||||
mysql_real_escape_string($comment,$link));
|
||||
perform_query($query,$link);
|
||||
mysql_real_escape_string($address, $link),
|
||||
mysql_real_escape_string($comment, $link));
|
||||
perform_query($query, $link);
|
||||
} else {
|
||||
$query = sprintf(
|
||||
"update ${mysqlprefix}chatban set dtmtill = %s,address = '%s',comment = '%s' where banid = $banId",
|
||||
"FROM_UNIXTIME($utime)",
|
||||
mysql_real_escape_string($address,$link),
|
||||
mysql_real_escape_string($comment,$link));
|
||||
perform_query($query,$link);
|
||||
}
|
||||
mysql_real_escape_string($address, $link),
|
||||
mysql_real_escape_string($comment, $link));
|
||||
perform_query($query, $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
|
||||
if(!$threadid) {
|
||||
if (!$threadid) {
|
||||
header("Location: $webimroot/operator/blocked.php");
|
||||
exit;
|
||||
} else {
|
||||
@ -93,24 +93,24 @@ if( isset($_POST['address']) ) {
|
||||
$page['formcomment'] = topage($comment);
|
||||
$page['threadid'] = $threadid;
|
||||
}
|
||||
} else if(isset($_GET['id'])) {
|
||||
$banId = verifyparam( 'id', "/^\d{1,9}$/");
|
||||
} else if (isset($_GET['id'])) {
|
||||
$banId = verifyparam('id', "/^\d{1,9}$/");
|
||||
$link = connect();
|
||||
$ban = select_one_row("select banid,(unix_timestamp(dtmtill)-unix_timestamp(CURRENT_TIMESTAMP)) as days,address,comment from ${mysqlprefix}chatban where banid = $banId", $link);
|
||||
mysql_close($link);
|
||||
|
||||
if( $ban ) {
|
||||
if ($ban) {
|
||||
$page['banId'] = topage($ban['banid']);
|
||||
$page['formaddress'] = topage($ban['address']);
|
||||
$page['formdays'] = topage(round($ban['days']/86400));
|
||||
$page['formdays'] = topage(round($ban['days'] / 86400));
|
||||
$page['formcomment'] = topage($ban['comment']);
|
||||
} else {
|
||||
$errors[] = "Wrong id";
|
||||
}
|
||||
} else if(isset($_GET['thread'])) {
|
||||
$threadid = verifyparam( 'thread', "/^\d{1,9}$/");
|
||||
} else if (isset($_GET['thread'])) {
|
||||
$threadid = verifyparam('thread', "/^\d{1,9}$/");
|
||||
$thread = thread_by_id($threadid);
|
||||
if( $thread ) {
|
||||
if ($thread) {
|
||||
$page['thread'] = topage($thread['userName']);
|
||||
$page['threadid'] = $threadid;
|
||||
$page['formaddress'] = topage($thread['remote']);
|
||||
|
@ -32,22 +32,22 @@ setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
$link = connect();
|
||||
|
||||
if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
||||
if (isset($_GET['act']) && $_GET['act'] == 'del') {
|
||||
$banId = isset($_GET['id']) ? $_GET['id'] : "";
|
||||
|
||||
if( !preg_match( "/^\d+$/", $banId )) {
|
||||
if (!preg_match("/^\d+$/", $banId)) {
|
||||
$errors[] = "Cannot delete: wrong argument";
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
perform_query("delete from ${mysqlprefix}chatban where banid = $banId",$link);
|
||||
if (count($errors) == 0) {
|
||||
perform_query("delete from ${mysqlprefix}chatban where banid = $banId", $link);
|
||||
header("Location: $webimroot/operator/blocked.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = mysql_query("select banid,unix_timestamp(dtmtill) as till,address,comment from ${mysqlprefix}chatban", $link)
|
||||
or die(' Query failed: ' .mysql_error());
|
||||
or die(' Query failed: ' . mysql_error());
|
||||
|
||||
$blockedList = array();
|
||||
while ($ban = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
|
@ -31,33 +31,34 @@ loadsettings();
|
||||
$errors = array();
|
||||
$page = array();
|
||||
|
||||
function load_canned_messages($locale, $groupid) {
|
||||
function load_canned_messages($locale, $groupid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = "select id, vcvalue from ${mysqlprefix}chatresponses ".
|
||||
"where locale = '".$locale."' AND (".
|
||||
($groupid
|
||||
? "groupid = $groupid"
|
||||
: "groupid is NULL OR groupid = 0").
|
||||
$query = "select id, vcvalue from ${mysqlprefix}chatresponses " .
|
||||
"where locale = '" . $locale . "' AND (" .
|
||||
($groupid
|
||||
? "groupid = $groupid"
|
||||
: "groupid is NULL OR groupid = 0") .
|
||||
") order by vcvalue";
|
||||
|
||||
|
||||
$result = select_multi_assoc($query, $link);
|
||||
if(!$groupid && count($result) == 0) {
|
||||
foreach(explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
if (!$groupid && count($result) == 0) {
|
||||
foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||
$result[] = array('id' => '', 'vcvalue' => $answer);
|
||||
}
|
||||
if(count($result) > 0) {
|
||||
if (count($result) > 0) {
|
||||
$updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values ";
|
||||
for($i=0;$i<count($result);$i++) {
|
||||
if($i > 0) {
|
||||
for ($i = 0; $i < count($result); $i++) {
|
||||
if ($i > 0) {
|
||||
$updatequery .= ", ";
|
||||
}
|
||||
$updatequery .= "('".mysql_real_escape_string($result[$i]['vcvalue'], $link)."','$locale', NULL)";
|
||||
$updatequery .= "('" . mysql_real_escape_string($result[$i]['vcvalue'], $link) . "','$locale', NULL)";
|
||||
}
|
||||
perform_query($updatequery, $link);
|
||||
$result = select_multi_assoc($query, $link);
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_close($link);
|
||||
return $result;
|
||||
}
|
||||
@ -66,24 +67,24 @@ function load_canned_messages($locale, $groupid) {
|
||||
|
||||
$all_locales = get_available_locales();
|
||||
$locales_with_label = array();
|
||||
foreach($all_locales as $id) {
|
||||
$locales_with_label[] = array('id' => $id, 'name' => getlocal_($id,"names"));
|
||||
foreach ($all_locales as $id) {
|
||||
$locales_with_label[] = array('id' => $id, 'name' => getlocal_($id, "names"));
|
||||
}
|
||||
$page['locales'] = $locales_with_label;
|
||||
|
||||
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
if( !$lang || !in_array($lang,$all_locales) ) {
|
||||
$lang = in_array($current_locale,$all_locales) ? $current_locale : $all_locales[0];
|
||||
if (!$lang || !in_array($lang, $all_locales)) {
|
||||
$lang = in_array($current_locale, $all_locales) ? $current_locale : $all_locales[0];
|
||||
}
|
||||
|
||||
# groups
|
||||
|
||||
$groupid = "";
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$groupid = verifyparam( "group", "/^\d{0,8}$/", "");
|
||||
if($groupid) {
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$groupid = verifyparam("group", "/^\d{0,8}$/", "");
|
||||
if ($groupid) {
|
||||
$group = group_by_id($groupid);
|
||||
if(!$group) {
|
||||
if (!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
$groupid = "";
|
||||
}
|
||||
@ -94,23 +95,23 @@ if($settings['enablegroups'] == '1') {
|
||||
mysql_close($link);
|
||||
$page['groups'] = array();
|
||||
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
foreach($allgroups as $g) {
|
||||
foreach ($allgroups as $g) {
|
||||
$page['groups'][] = $g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# delete
|
||||
|
||||
if(isset($_GET['act']) && $_GET['act'] == 'delete') {
|
||||
if (isset($_GET['act']) && $_GET['act'] == 'delete') {
|
||||
$key = isset($_GET['key']) ? $_GET['key'] : "";
|
||||
|
||||
if( !preg_match( "/^\d+$/", $key )) {
|
||||
if (!preg_match("/^\d+$/", $key)) {
|
||||
$errors[] = "Wrong key";
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
if (count($errors) == 0) {
|
||||
$link = connect();
|
||||
perform_query("delete from ${mysqlprefix}chatresponses where id = $key",$link);
|
||||
perform_query("delete from ${mysqlprefix}chatresponses where id = $key", $link);
|
||||
mysql_close($link);
|
||||
header("Location: $webimroot/operator/canned.php?lang=$lang&group=$groupid");
|
||||
exit;
|
||||
|
@ -23,7 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/pagination.php');
|
||||
|
||||
function load_message($key) {
|
||||
function load_message($key)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$result = select_one_row("select vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
|
||||
@ -31,20 +32,22 @@ function load_message($key) {
|
||||
return $result ? $result['vcvalue'] : null;
|
||||
}
|
||||
|
||||
function save_message($key,$message) {
|
||||
function save_message($key, $message)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '".mysql_real_escape_string($message,$link)."' ".
|
||||
"where id = $key", $link);
|
||||
perform_query("update ${mysqlprefix}chatresponses set vcvalue = '" . mysql_real_escape_string($message, $link) . "' " .
|
||||
"where id = $key", $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function add_message($locale,$groupid,$message) {
|
||||
function add_message($locale, $groupid, $message)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale',".
|
||||
($groupid ? "$groupid, " : "null, ").
|
||||
"'".mysql_real_escape_string($message,$link)."')", $link);
|
||||
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale'," .
|
||||
($groupid ? "$groupid, " : "null, ") .
|
||||
"'" . mysql_real_escape_string($message, $link) . "')", $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
@ -56,9 +59,9 @@ $stringid = verifyparam("key", "/^\d{0,9}$/", "");
|
||||
$errors = array();
|
||||
$page = array();
|
||||
|
||||
if($stringid) {
|
||||
if ($stringid) {
|
||||
$message = load_message($stringid);
|
||||
if(!$message) {
|
||||
if (!$message) {
|
||||
$errors[] = getlocal("cannededit.no_such");
|
||||
$stringid = "";
|
||||
}
|
||||
@ -66,19 +69,19 @@ if($stringid) {
|
||||
$message = "";
|
||||
$page['locale'] = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
$page['groupid'] = "";
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$page['groupid'] = verifyparam( "group", "/^\d{0,8}$/");
|
||||
if ($settings['enablegroups'] == '1') {
|
||||
$page['groupid'] = verifyparam("group", "/^\d{0,8}$/");
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['message'])) {
|
||||
if (isset($_POST['message'])) {
|
||||
$message = getparam('message');
|
||||
if(!$message) {
|
||||
if (!$message) {
|
||||
$errors[] = no_field("form.field.message");
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
if($stringid) {
|
||||
if (count($errors) == 0) {
|
||||
if ($stringid) {
|
||||
save_message($stringid, $message);
|
||||
} else {
|
||||
add_message($page['locale'], $page['groupid'], $message);
|
||||
|
@ -29,30 +29,30 @@ $page = array('agentId' => '');
|
||||
$errors = array();
|
||||
|
||||
$options = array(
|
||||
'enableban', 'usercanchangename', 'enablegroups', 'enablestatistics', 'enablejabber',
|
||||
'enablessl', 'forcessl',
|
||||
'enablepresurvey', 'surveyaskmail', 'surveyaskgroup', 'surveyaskmessage',
|
||||
'enablepopupnotification', 'showonlineoperators',
|
||||
'enablecaptcha');
|
||||
'enableban', 'usercanchangename', 'enablegroups', 'enablestatistics', 'enablejabber',
|
||||
'enablessl', 'forcessl',
|
||||
'enablepresurvey', 'surveyaskmail', 'surveyaskgroup', 'surveyaskmessage',
|
||||
'enablepopupnotification', 'showonlineoperators',
|
||||
'enablecaptcha');
|
||||
|
||||
loadsettings();
|
||||
if($settings['featuresversion'] != $featuresversion) {
|
||||
if ($settings['featuresversion'] != $featuresversion) {
|
||||
$settings['featuresversion'] = $featuresversion;
|
||||
update_settings();
|
||||
}
|
||||
$params = array();
|
||||
foreach($options as $opt) {
|
||||
foreach ($options as $opt) {
|
||||
$params[$opt] = $settings[$opt];
|
||||
}
|
||||
|
||||
if (isset($_POST['sent'])) {
|
||||
if (is_capable($can_administrate, $operator)) {
|
||||
foreach($options as $opt) {
|
||||
$settings[$opt] = verifyparam($opt,"/^on$/", "") == "on" ? "1" : "0";
|
||||
foreach ($options as $opt) {
|
||||
$settings[$opt] = verifyparam($opt, "/^on$/", "") == "on" ? "1" : "0";
|
||||
}
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/features.php?stored");
|
||||
exit;
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/features.php?stored");
|
||||
exit;
|
||||
} else {
|
||||
$errors[] = "Not an administrator";
|
||||
}
|
||||
@ -60,8 +60,8 @@ if (isset($_POST['sent'])) {
|
||||
|
||||
$page['canmodify'] = is_capable($can_administrate, $operator);
|
||||
$page['stored'] = isset($_GET['stored']);
|
||||
foreach($options as $opt) {
|
||||
$page["form$opt"] = $params[$opt] == "1";
|
||||
foreach ($options as $opt) {
|
||||
$page["form$opt"] = $params[$opt] == "1";
|
||||
}
|
||||
|
||||
prepare_menu($operator);
|
||||
|
@ -29,7 +29,7 @@ loadsettings();
|
||||
|
||||
$imageLocales = get_image_locales_map("../locales");
|
||||
$image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\w+$/", "webim");
|
||||
if(!isset($imageLocales[$image])) {
|
||||
if (!isset($imageLocales[$image])) {
|
||||
$errors[] = "Unknown image: $image";
|
||||
$avail = array_keys($imageLocales);
|
||||
$image = $avail[0];
|
||||
@ -37,31 +37,31 @@ if(!isset($imageLocales[$image])) {
|
||||
$image_locales = $imageLocales[$image];
|
||||
|
||||
$stylelist = get_style_list("../styles");
|
||||
$style = verifyparam("style","/^\w*$/", "");
|
||||
if($style && !in_array($style, $stylelist)) {
|
||||
$style = verifyparam("style", "/^\w*$/", "");
|
||||
if ($style && !in_array($style, $stylelist)) {
|
||||
$style = "";
|
||||
}
|
||||
|
||||
$groupid = verifyparam_groupid("group");
|
||||
$showhost = verifyparam("hostname","/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure","/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity","/^on$/", "") == "on";
|
||||
$showhost = verifyparam("hostname", "/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure", "/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity", "/^on$/", "") == "on";
|
||||
|
||||
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
if( !$lang || !in_array($lang,$image_locales) )
|
||||
$lang = in_array($current_locale,$image_locales) ? $current_locale : $image_locales[0];
|
||||
if (!$lang || !in_array($lang, $image_locales))
|
||||
$lang = in_array($current_locale, $image_locales) ? $current_locale : $image_locales[0];
|
||||
|
||||
$file = "../locales/${lang}/button/${image}_on.gif";
|
||||
$size = get_gifimage_size($file);
|
||||
|
||||
$imagehref = get_app_location($showhost,$forcesecure)."/b.php?i=$image&lang=$lang";
|
||||
if($groupid) {
|
||||
$imagehref = get_app_location($showhost, $forcesecure) . "/b.php?i=$image&lang=$lang";
|
||||
if ($groupid) {
|
||||
$imagehref .= "&group=$groupid";
|
||||
}
|
||||
$message = get_image($imagehref,$size[0],$size[1]);
|
||||
$message = get_image($imagehref, $size[0], $size[1]);
|
||||
|
||||
$page = array();
|
||||
$page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure,$modsecurity);
|
||||
$page['buttonCode'] = generate_button("", $lang, $style, $groupid, $message, $showhost, $forcesecure, $modsecurity);
|
||||
$page['availableImages'] = array_keys($imageLocales);
|
||||
$page['availableLocales'] = $image_locales;
|
||||
$page['availableStyles'] = $stylelist;
|
||||
|
@ -28,26 +28,26 @@ $operator = check_login();
|
||||
loadsettings();
|
||||
|
||||
$stylelist = get_style_list("../styles");
|
||||
$style = verifyparam("style","/^\w*$/", "");
|
||||
if($style && !in_array($style, $stylelist)) {
|
||||
$style = verifyparam("style", "/^\w*$/", "");
|
||||
if ($style && !in_array($style, $stylelist)) {
|
||||
$style = "";
|
||||
}
|
||||
|
||||
$groupid = verifyparam_groupid("group");
|
||||
$showhost = verifyparam("hostname","/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure","/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity","/^on$/", "") == "on";
|
||||
$showhost = verifyparam("hostname", "/^on$/", "") == "on";
|
||||
$forcesecure = verifyparam("secure", "/^on$/", "") == "on";
|
||||
$modsecurity = verifyparam("modsecurity", "/^on$/", "") == "on";
|
||||
|
||||
$allLocales = get_available_locales();
|
||||
|
||||
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
||||
if( !$lang || !in_array($lang,$allLocales) )
|
||||
$lang = in_array($current_locale,$allLocales) ? $current_locale : $allLocales[0];
|
||||
if (!$lang || !in_array($lang, $allLocales))
|
||||
$lang = in_array($current_locale, $allLocales) ? $current_locale : $allLocales[0];
|
||||
|
||||
$message = "Click to chat"; // TODO
|
||||
|
||||
$page = array();
|
||||
$page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure,$modsecurity);
|
||||
$page['buttonCode'] = generate_button("", $lang, $style, $groupid, $message, $showhost, $forcesecure, $modsecurity);
|
||||
$page['availableLocales'] = $allLocales;
|
||||
$page['availableStyles'] = $stylelist;
|
||||
$page['groups'] = get_groups_list();
|
||||
|
@ -29,34 +29,37 @@ $page = array('grid' => '');
|
||||
$errors = array();
|
||||
$groupid = '';
|
||||
|
||||
function group_by_name($name) {
|
||||
function group_by_name($name)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$group = select_one_row(
|
||||
"select * from ${mysqlprefix}chatgroup where vclocalname = '".mysql_real_escape_string($name)."'", $link );
|
||||
"select * from ${mysqlprefix}chatgroup where vclocalname = '" . mysql_real_escape_string($name) . "'", $link);
|
||||
mysql_close($link);
|
||||
return $group;
|
||||
}
|
||||
|
||||
function create_group($name,$descr,$commonname,$commondescr) {
|
||||
function create_group($name, $descr, $commonname, $commondescr)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatgroup (vclocalname,vclocaldescription,vccommonname,vccommondescription) values ('%s','%s','%s','%s')",
|
||||
mysql_real_escape_string($name),
|
||||
mysql_real_escape_string($descr),
|
||||
mysql_real_escape_string($commonname),
|
||||
mysql_real_escape_string($commondescr));
|
||||
|
||||
perform_query($query,$link);
|
||||
mysql_real_escape_string($name),
|
||||
mysql_real_escape_string($descr),
|
||||
mysql_real_escape_string($commonname),
|
||||
mysql_real_escape_string($commondescr));
|
||||
|
||||
perform_query($query, $link);
|
||||
$id = mysql_insert_id($link);
|
||||
|
||||
$newdep = select_one_row("select * from ${mysqlprefix}chatgroup where groupid = $id", $link );
|
||||
$newdep = select_one_row("select * from ${mysqlprefix}chatgroup where groupid = $id", $link);
|
||||
mysql_close($link);
|
||||
return $newdep;
|
||||
}
|
||||
|
||||
function update_group($groupid,$name,$descr,$commonname,$commondescr) {
|
||||
function update_group($groupid, $name, $descr, $commonname, $commondescr)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = sprintf(
|
||||
@ -65,35 +68,35 @@ function update_group($groupid,$name,$descr,$commonname,$commondescr) {
|
||||
mysql_real_escape_string($descr),
|
||||
mysql_real_escape_string($commonname),
|
||||
mysql_real_escape_string($commondescr),
|
||||
$groupid );
|
||||
$groupid);
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
|
||||
if( isset($_POST['name'])) {
|
||||
$groupid = verifyparam( "gid", "/^(\d{1,9})?$/", "");
|
||||
if (isset($_POST['name'])) {
|
||||
$groupid = verifyparam("gid", "/^(\d{1,9})?$/", "");
|
||||
$name = getparam('name');
|
||||
$description = getparam('description');
|
||||
$commonname = getparam('commonname');
|
||||
$commondescription = getparam('commondescription');
|
||||
|
||||
if( !$name )
|
||||
|
||||
if (!$name)
|
||||
$errors[] = no_field("form.field.groupname");
|
||||
|
||||
$existing_group = group_by_name($name);
|
||||
if( (!$groupid && $existing_group) ||
|
||||
( $groupid && $existing_group && $groupid != $existing_group['groupid']) )
|
||||
if ((!$groupid && $existing_group) ||
|
||||
($groupid && $existing_group && $groupid != $existing_group['groupid']))
|
||||
$errors[] = getlocal("page.group.duplicate_name");
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
if (count($errors) == 0) {
|
||||
if (!$groupid) {
|
||||
$newdep = create_group($name,$description,$commonname,$commondescription);
|
||||
header("Location: $webimroot/operator/groupmembers.php?gid=".$newdep['groupid']);
|
||||
$newdep = create_group($name, $description, $commonname, $commondescription);
|
||||
header("Location: $webimroot/operator/groupmembers.php?gid=" . $newdep['groupid']);
|
||||
exit;
|
||||
} else {
|
||||
update_group($groupid,$name,$description,$commonname,$commondescription);
|
||||
update_group($groupid, $name, $description, $commonname, $commondescription);
|
||||
header("Location: $webimroot/operator/group.php?gid=$groupid&stored");
|
||||
exit;
|
||||
}
|
||||
@ -105,11 +108,11 @@ if( isset($_POST['name'])) {
|
||||
$page['grid'] = topage($groupid);
|
||||
}
|
||||
|
||||
} else if( isset($_GET['gid']) ) {
|
||||
$groupid = verifyparam( 'gid', "/^\d{1,9}$/");
|
||||
} else if (isset($_GET['gid'])) {
|
||||
$groupid = verifyparam('gid', "/^\d{1,9}$/");
|
||||
$group = group_by_id($groupid);
|
||||
|
||||
if( !$group ) {
|
||||
if (!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
$page['grid'] = topage($groupid);
|
||||
} else {
|
||||
|
@ -25,7 +25,8 @@ require_once('../libs/groups.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
function get_group_members($groupid) {
|
||||
function get_group_members($groupid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = "select operatorid from ${mysqlprefix}chatgroupoperator where groupid = $groupid";
|
||||
@ -34,17 +35,19 @@ function get_group_members($groupid) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function update_group_members($groupid,$newvalue) {
|
||||
function update_group_members($groupid, $newvalue)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid", $link);
|
||||
foreach($newvalue as $opid) {
|
||||
foreach ($newvalue as $opid) {
|
||||
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
function get_operators() {
|
||||
function get_operators()
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
|
||||
@ -54,25 +57,25 @@ function get_operators() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$groupid = verifyparam( "gid","/^\d{1,9}$/");
|
||||
$groupid = verifyparam("gid", "/^\d{1,9}$/");
|
||||
$page = array('groupid' => $groupid);
|
||||
$page['operators'] = get_operators();
|
||||
$errors = array();
|
||||
|
||||
$group = group_by_id($groupid);
|
||||
|
||||
if( !$group ) {
|
||||
if (!$group) {
|
||||
$errors[] = getlocal("page.group.no_such");
|
||||
|
||||
} else if( isset($_POST['gid']) ) {
|
||||
} else if (isset($_POST['gid'])) {
|
||||
|
||||
$new_members = array();
|
||||
foreach($page['operators'] as $op) {
|
||||
if( verifyparam("op".$op['operatorid'],"/^on$/", "") == "on") {
|
||||
foreach ($page['operators'] as $op) {
|
||||
if (verifyparam("op" . $op['operatorid'], "/^on$/", "") == "on") {
|
||||
$new_members[] = $op['operatorid'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
update_group_members($groupid, $new_members);
|
||||
header("Location: $webimroot/operator/groupmembers.php?gid=$groupid&stored");
|
||||
exit;
|
||||
@ -81,7 +84,7 @@ if( !$group ) {
|
||||
$page['formop'] = array();
|
||||
$page['currentgroup'] = $group ? topage(htmlspecialchars($group['vclocalname'])) : "";
|
||||
|
||||
foreach(get_group_members($groupid) as $rel) {
|
||||
foreach (get_group_members($groupid) as $rel) {
|
||||
$page['formop'][] = $rel['operatorid'];
|
||||
}
|
||||
|
||||
|
@ -24,37 +24,39 @@ require_once('../libs/operator.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
||||
|
||||
if (isset($_GET['act']) && $_GET['act'] == 'del') {
|
||||
|
||||
$groupid = isset($_GET['gid']) ? $_GET['gid'] : "";
|
||||
|
||||
if( !preg_match( "/^\d+$/", $groupid )) {
|
||||
if (!preg_match("/^\d+$/", $groupid)) {
|
||||
$errors[] = "Cannot delete: wrong argument";
|
||||
}
|
||||
|
||||
if( !is_capable($can_administrate, $operator)) {
|
||||
|
||||
if (!is_capable($can_administrate, $operator)) {
|
||||
$errors[] = "You are not allowed to remove groups";
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$link = connect();
|
||||
perform_query("delete from ${mysqlprefix}chatgroup where groupid = $groupid",$link);
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid",$link);
|
||||
perform_query("update ${mysqlprefix}chatthread set groupid = 0 where groupid = $groupid",$link);
|
||||
perform_query("delete from ${mysqlprefix}chatgroup where groupid = $groupid", $link);
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid", $link);
|
||||
perform_query("update ${mysqlprefix}chatthread set groupid = 0 where groupid = $groupid", $link);
|
||||
mysql_close($link);
|
||||
header("Location: $webimroot/operator/groups.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function is_online($group) {
|
||||
function is_online($group)
|
||||
{
|
||||
global $settings;
|
||||
return $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function is_away($group) {
|
||||
function is_away($group)
|
||||
{
|
||||
global $settings;
|
||||
return $group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,31 +33,31 @@ setlocale(LC_TIME, getstring("time.locale"));
|
||||
$page = array();
|
||||
$query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']) : false;
|
||||
|
||||
if($query !== false) {
|
||||
if ($query !== false) {
|
||||
$link = connect();
|
||||
|
||||
$result = mysql_query("select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname ".
|
||||
"from ${mysqlprefix}chatgroup order by vclocalname", $link);
|
||||
|
||||
$result = mysql_query("select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname " .
|
||||
"from ${mysqlprefix}chatgroup order by vclocalname", $link);
|
||||
$groupName = array();
|
||||
while ($group = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$groupName[$group['groupid']] = $group['vclocalname'];
|
||||
}
|
||||
mysql_free_result($result);
|
||||
$page['groupName'] = $groupName;
|
||||
|
||||
$escapedQuery = mysql_real_escape_string($query,$link);
|
||||
select_with_pagintation("DISTINCT unix_timestamp(${mysqlprefix}chatthread.dtmcreated) as created, ".
|
||||
"unix_timestamp(${mysqlprefix}chatthread.dtmmodified) as modified, ${mysqlprefix}chatthread.threadid, ".
|
||||
"${mysqlprefix}chatthread.remote, ${mysqlprefix}chatthread.agentName, ${mysqlprefix}chatthread.userName, groupid, ".
|
||||
"messageCount as size",
|
||||
"${mysqlprefix}chatthread, ${mysqlprefix}chatmessage",
|
||||
array(
|
||||
"${mysqlprefix}chatmessage.threadid = ${mysqlprefix}chatthread.threadid",
|
||||
"((${mysqlprefix}chatthread.userName LIKE '%%$escapedQuery%%') or (${mysqlprefix}chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
|
||||
),
|
||||
"order by created DESC",
|
||||
"DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
|
||||
|
||||
|
||||
$escapedQuery = mysql_real_escape_string($query, $link);
|
||||
select_with_pagintation("DISTINCT unix_timestamp(${mysqlprefix}chatthread.dtmcreated) as created, " .
|
||||
"unix_timestamp(${mysqlprefix}chatthread.dtmmodified) as modified, ${mysqlprefix}chatthread.threadid, " .
|
||||
"${mysqlprefix}chatthread.remote, ${mysqlprefix}chatthread.agentName, ${mysqlprefix}chatthread.userName, groupid, " .
|
||||
"messageCount as size",
|
||||
"${mysqlprefix}chatthread, ${mysqlprefix}chatmessage",
|
||||
array(
|
||||
"${mysqlprefix}chatmessage.threadid = ${mysqlprefix}chatthread.threadid",
|
||||
"((${mysqlprefix}chatthread.userName LIKE '%%$escapedQuery%%') or (${mysqlprefix}chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
|
||||
),
|
||||
"order by created DESC",
|
||||
"DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
|
||||
|
||||
mysql_close($link);
|
||||
|
||||
$page['formq'] = topage($query);
|
||||
|
@ -23,21 +23,21 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
|
||||
$errors = array();
|
||||
$page = array( 'formisRemember' => true, 'version' => $version);
|
||||
$page = array('formisRemember' => true, 'version' => $version);
|
||||
|
||||
if( isset($_POST['login']) && isset($_POST['password']) ) {
|
||||
if (isset($_POST['login']) && isset($_POST['password'])) {
|
||||
$login = getparam('login');
|
||||
$password = getparam('password');
|
||||
$remember = isset($_POST['isRemember']) && $_POST['isRemember'] == "on";
|
||||
|
||||
$operator = operator_by_login( $login );
|
||||
if( $operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password) ) {
|
||||
$operator = operator_by_login($login);
|
||||
if ($operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password)) {
|
||||
|
||||
$target = isset($_SESSION['backpath'])
|
||||
? $_SESSION['backpath']
|
||||
: "$webimroot/operator/index.php";
|
||||
|
||||
login_operator($operator,$remember);
|
||||
login_operator($operator, $remember);
|
||||
header("Location: $target");
|
||||
exit;
|
||||
} else {
|
||||
|
@ -29,18 +29,19 @@ $page = array();
|
||||
|
||||
setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
function notification_info($id) {
|
||||
function notification_info($id)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$notification = select_one_row(db_build_select(
|
||||
"id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", "${mysqlprefix}chatnotification",
|
||||
array("id = $id"), ""), $link);
|
||||
"id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", "${mysqlprefix}chatnotification",
|
||||
array("id = $id"), ""), $link);
|
||||
mysql_close($link);
|
||||
return $notification;
|
||||
}
|
||||
|
||||
|
||||
$notificationid = verifyparam( "id", "/^(\d{1,9})$/");
|
||||
$notificationid = verifyparam("id", "/^(\d{1,9})$/");
|
||||
$page['notification'] = notification_info($notificationid);
|
||||
|
||||
prepare_menu($operator, false);
|
||||
|
@ -28,7 +28,7 @@ $operator = check_login();
|
||||
$page = array();
|
||||
$errors = array();
|
||||
|
||||
if( !is_capable($can_administrate, $operator)) {
|
||||
if (!is_capable($can_administrate, $operator)) {
|
||||
die("Permission denied.");
|
||||
}
|
||||
|
||||
@ -38,13 +38,13 @@ setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
$all_locales = get_available_locales();
|
||||
$locales_with_label = array(array('id' => '', 'name' => getlocal("notifications.locale.all")));
|
||||
foreach($all_locales as $id) {
|
||||
$locales_with_label[] = array('id' => $id, 'name' => getlocal_($id,"names"));
|
||||
foreach ($all_locales as $id) {
|
||||
$locales_with_label[] = array('id' => $id, 'name' => getlocal_($id, "names"));
|
||||
}
|
||||
$page['locales'] = $locales_with_label;
|
||||
|
||||
$lang = verifyparam("lang", "/^([\w-]{2,5})?$/", "");
|
||||
if( $lang && !in_array($lang,$all_locales) ) {
|
||||
if ($lang && !in_array($lang, $all_locales)) {
|
||||
$lang = "";
|
||||
}
|
||||
|
||||
@ -56,10 +56,10 @@ $page['allkinds'] = array('', 'mail', 'xmpp');
|
||||
# fetch
|
||||
|
||||
$conditions = array();
|
||||
if($kind) {
|
||||
if ($kind) {
|
||||
$conditions[] = "vckind = '$kind'";
|
||||
}
|
||||
if($lang) {
|
||||
}
|
||||
if ($lang) {
|
||||
$conditions[] = "locale = '$lang'";
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ $errors = array();
|
||||
$opId = '';
|
||||
|
||||
loadsettings();
|
||||
if( isset($_POST['login']) && isset($_POST['password']) ) {
|
||||
$opId = verifyparam( "opid", "/^(\d{1,9})?$/", "");
|
||||
if (isset($_POST['login']) && isset($_POST['password'])) {
|
||||
$opId = verifyparam("opid", "/^(\d{1,9})?$/", "");
|
||||
$login = getparam('login');
|
||||
$email = getparam('email');
|
||||
$jabber = getparam('jabber');
|
||||
@ -39,58 +39,58 @@ if( isset($_POST['login']) && isset($_POST['password']) ) {
|
||||
$passwordConfirm = getparam('passwordConfirm');
|
||||
$localname = getparam('name');
|
||||
$commonname = getparam('commonname');
|
||||
$jabbernotify = verifyparam("jabbernotify","/^on$/", "") == "on";
|
||||
$jabbernotify = verifyparam("jabbernotify", "/^on$/", "") == "on";
|
||||
|
||||
if( !$localname )
|
||||
if (!$localname)
|
||||
$errors[] = no_field("form.field.agent_name");
|
||||
|
||||
if( !$commonname )
|
||||
if (!$commonname)
|
||||
$errors[] = no_field("form.field.agent_commonname");
|
||||
|
||||
if( !$login ) {
|
||||
if (!$login) {
|
||||
$errors[] = no_field("form.field.login");
|
||||
} else if( !preg_match( "/^[\w_\.]+$/",$login) ) {
|
||||
} else if (!preg_match("/^[\w_\.]+$/", $login)) {
|
||||
$errors[] = getlocal("page_agent.error.wrong_login");
|
||||
}
|
||||
|
||||
if($email != '' && !is_valid_email($email))
|
||||
if ($email != '' && !is_valid_email($email))
|
||||
$errors[] = wrong_field("form.field.mail");
|
||||
|
||||
if($jabber != '' && !is_valid_email($jabber))
|
||||
if ($jabber != '' && !is_valid_email($jabber))
|
||||
$errors[] = wrong_field("form.field.jabber");
|
||||
|
||||
if($jabbernotify && $jabber == '') {
|
||||
if( $settings['enablejabber'] == "1" ) {
|
||||
|
||||
if ($jabbernotify && $jabber == '') {
|
||||
if ($settings['enablejabber'] == "1") {
|
||||
$errors[] = no_field("form.field.jabber");
|
||||
} else {
|
||||
$jabbernotify = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$opId && !$password )
|
||||
|
||||
if (!$opId && !$password)
|
||||
$errors[] = no_field("form.field.password");
|
||||
|
||||
if( $password != $passwordConfirm )
|
||||
if ($password != $passwordConfirm)
|
||||
$errors[] = getlocal("my_settings.error.password_match");
|
||||
|
||||
$existing_operator = operator_by_login($login);
|
||||
if( (!$opId && $existing_operator) ||
|
||||
( $opId && $existing_operator && $opId != $existing_operator['operatorid']) )
|
||||
if ((!$opId && $existing_operator) ||
|
||||
($opId && $existing_operator && $opId != $existing_operator['operatorid']))
|
||||
$errors[] = getlocal("page_agent.error.duplicate_login");
|
||||
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
if(!$canmodify) {
|
||||
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
if (!$canmodify) {
|
||||
$errors[] = getlocal('page_agent.cannot_modify');
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
|
||||
if (count($errors) == 0) {
|
||||
if (!$opId) {
|
||||
$newop = create_operator($login,$email,$jabber,$password,$localname,$commonname,$jabbernotify ? 1 : 0);
|
||||
header("Location: $webimroot/operator/avatar.php?op=".$newop['operatorid']);
|
||||
$newop = create_operator($login, $email, $jabber, $password, $localname, $commonname, $jabbernotify ? 1 : 0);
|
||||
header("Location: $webimroot/operator/avatar.php?op=" . $newop['operatorid']);
|
||||
exit;
|
||||
} else {
|
||||
update_operator($opId,$login,$email,$jabber,$password,$localname,$commonname,$jabbernotify ? 1 : 0);
|
||||
update_operator($opId, $login, $email, $jabber, $password, $localname, $commonname, $jabbernotify ? 1 : 0);
|
||||
header("Location: $webimroot/operator/operator.php?op=$opId&stored");
|
||||
exit;
|
||||
}
|
||||
@ -104,11 +104,11 @@ if( isset($_POST['login']) && isset($_POST['password']) ) {
|
||||
$page['opid'] = topage($opId);
|
||||
}
|
||||
|
||||
} else if( isset($_GET['op']) ) {
|
||||
$opId = verifyparam( 'op', "/^\d{1,9}$/");
|
||||
} else if (isset($_GET['op'])) {
|
||||
$opId = verifyparam('op', "/^\d{1,9}$/");
|
||||
$op = operator_by_id($opId);
|
||||
|
||||
if( !$op ) {
|
||||
if (!$op) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
$page['opid'] = topage($opId);
|
||||
} else {
|
||||
@ -122,19 +122,19 @@ if( isset($_POST['login']) && isset($_POST['password']) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!$opId && !is_capable($can_administrate, $operator)) {
|
||||
if (!$opId && !is_capable($can_administrate, $operator)) {
|
||||
$errors[] = "You are not allowed to create operators";
|
||||
}
|
||||
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
|
||||
$page['stored'] = isset($_GET['stored']);
|
||||
$page['canmodify'] = $canmodify ? "1" : "";
|
||||
$page['showjabber'] = $settings['enablejabber'] == "1";
|
||||
$page['showjabber'] = $settings['enablejabber'] == "1";
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_operator_settings_tabs($opId,0);
|
||||
setup_operator_settings_tabs($opId, 0);
|
||||
start_html_output();
|
||||
require('../view/agent.php');
|
||||
?>
|
@ -24,36 +24,36 @@ require_once('../libs/operator.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
||||
if (isset($_GET['act']) && $_GET['act'] == 'del') {
|
||||
$operatorid = isset($_GET['id']) ? $_GET['id'] : "";
|
||||
|
||||
if( !preg_match( "/^\d+$/", $operatorid )) {
|
||||
if (!preg_match("/^\d+$/", $operatorid)) {
|
||||
$errors[] = "Cannot delete: wrong argument";
|
||||
}
|
||||
|
||||
if( !is_capable($can_administrate, $operator)) {
|
||||
if (!is_capable($can_administrate, $operator)) {
|
||||
$errors[] = "You are not allowed to remove operators";
|
||||
}
|
||||
|
||||
if( $operatorid == $operator['operatorid']) {
|
||||
|
||||
if ($operatorid == $operator['operatorid']) {
|
||||
$errors[] = "Cannot remove self";
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
if (count($errors) == 0) {
|
||||
$op = operator_by_id($operatorid);
|
||||
if( !$op ) {
|
||||
if (!$op) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
} else if($op['vclogin'] == 'admin') {
|
||||
$errors[] = 'Cannot remove operator "admin"';
|
||||
}
|
||||
} else if ($op['vclogin'] == 'admin') {
|
||||
$errors[] = 'Cannot remove operator "admin"';
|
||||
}
|
||||
}
|
||||
|
||||
if( count($errors) == 0 ) {
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$link = connect();
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid",$link);
|
||||
perform_query("delete from ${mysqlprefix}chatoperator where operatorid = $operatorid",$link);
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
|
||||
perform_query("delete from ${mysqlprefix}chatoperator where operatorid = $operatorid", $link);
|
||||
mysql_close($link);
|
||||
|
||||
|
||||
header("Location: $webimroot/operator/operators.php");
|
||||
exit;
|
||||
}
|
||||
|
@ -25,65 +25,66 @@ require_once('../libs/operator_settings.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
function update_operator_groups($operatorid,$newvalue) {
|
||||
function update_operator_groups($operatorid, $newvalue)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
|
||||
foreach($newvalue as $groupid) {
|
||||
foreach ($newvalue as $groupid) {
|
||||
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
|
||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||
$opId = verifyparam("op", "/^\d{1,9}$/");
|
||||
$page = array('opid' => $opId);
|
||||
$link = connect();
|
||||
$page['groups'] = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$errors = array();
|
||||
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
$canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator))
|
||||
|| is_capable($can_administrate, $operator);
|
||||
|
||||
$op = operator_by_id($opId);
|
||||
|
||||
if( !$op ) {
|
||||
if (!$op) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
|
||||
} else if( isset($_POST['op']) ) {
|
||||
} else if (isset($_POST['op'])) {
|
||||
|
||||
if(!$canmodify) {
|
||||
if (!$canmodify) {
|
||||
$errors[] = getlocal('page_agent.cannot_modify');
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
if (count($errors) == 0) {
|
||||
$new_groups = array();
|
||||
foreach($page['groups'] as $group) {
|
||||
if( verifyparam("group".$group['groupid'],"/^on$/", "") == "on") {
|
||||
foreach ($page['groups'] as $group) {
|
||||
if (verifyparam("group" . $group['groupid'], "/^on$/", "") == "on") {
|
||||
$new_groups[] = $group['groupid'];
|
||||
}
|
||||
}
|
||||
|
||||
update_operator_groups($op['operatorid'],$new_groups);
|
||||
|
||||
update_operator_groups($op['operatorid'], $new_groups);
|
||||
header("Location: $webimroot/operator/opgroups.php?op=$opId&stored");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$page['formgroup'] = array();
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : "-not found-";
|
||||
$page['canmodify'] = $canmodify ? "1" : "";
|
||||
|
||||
if($op) {
|
||||
foreach(get_operator_groupids($opId) as $rel) {
|
||||
if ($op) {
|
||||
foreach (get_operator_groupids($opId) as $rel) {
|
||||
$page['formgroup'][] = $rel['groupid'];
|
||||
}
|
||||
}
|
||||
|
||||
$page['stored'] = isset($_GET['stored']);
|
||||
prepare_menu($operator);
|
||||
setup_operator_settings_tabs($opId,2);
|
||||
setup_operator_settings_tabs($opId, 2);
|
||||
start_html_output();
|
||||
require('../view/operator_groups.php');
|
||||
?>
|
||||
|
@ -29,49 +29,49 @@ $page = array('agentId' => '');
|
||||
$errors = array();
|
||||
|
||||
$options = array(
|
||||
'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat',
|
||||
'updatefrequency_oldchat', 'max_connections_from_one_host');
|
||||
'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat',
|
||||
'updatefrequency_oldchat', 'max_connections_from_one_host');
|
||||
|
||||
loadsettings();
|
||||
$params = array();
|
||||
foreach($options as $opt) {
|
||||
foreach ($options as $opt) {
|
||||
$params[$opt] = $settings[$opt];
|
||||
}
|
||||
|
||||
if (isset($_POST['onlinetimeout'])) {
|
||||
$params['online_timeout'] = getparam('onlinetimeout');
|
||||
if(!is_numeric($params['online_timeout'])) {
|
||||
$errors[] = wrong_field("settings.onlinetimeout");
|
||||
}
|
||||
|
||||
$params['updatefrequency_operator'] = getparam('frequencyoperator');
|
||||
if(!is_numeric($params['updatefrequency_operator'])) {
|
||||
$errors[] = wrong_field("settings.frequencyoperator");
|
||||
}
|
||||
|
||||
$params['updatefrequency_chat'] = getparam('frequencychat');
|
||||
if(!is_numeric($params['updatefrequency_chat'])) {
|
||||
$errors[] = wrong_field("settings.frequencychat");
|
||||
}
|
||||
|
||||
$params['updatefrequency_oldchat'] = getparam('frequencyoldchat');
|
||||
if(!is_numeric($params['updatefrequency_oldchat'])) {
|
||||
$errors[] = wrong_field("settings.frequencyoldchat");
|
||||
}
|
||||
$params['online_timeout'] = getparam('onlinetimeout');
|
||||
if (!is_numeric($params['online_timeout'])) {
|
||||
$errors[] = wrong_field("settings.onlinetimeout");
|
||||
}
|
||||
|
||||
$params['updatefrequency_operator'] = getparam('frequencyoperator');
|
||||
if (!is_numeric($params['updatefrequency_operator'])) {
|
||||
$errors[] = wrong_field("settings.frequencyoperator");
|
||||
}
|
||||
|
||||
$params['updatefrequency_chat'] = getparam('frequencychat');
|
||||
if (!is_numeric($params['updatefrequency_chat'])) {
|
||||
$errors[] = wrong_field("settings.frequencychat");
|
||||
}
|
||||
|
||||
$params['updatefrequency_oldchat'] = getparam('frequencyoldchat');
|
||||
if (!is_numeric($params['updatefrequency_oldchat'])) {
|
||||
$errors[] = wrong_field("settings.frequencyoldchat");
|
||||
}
|
||||
|
||||
$params['max_connections_from_one_host'] = getparam('onehostconnections');
|
||||
if(!is_numeric($params['max_connections_from_one_host'])) {
|
||||
$errors[] = getlocal("settings.wrong.onehostconnections");
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach($options as $opt) {
|
||||
if (!is_numeric($params['max_connections_from_one_host'])) {
|
||||
$errors[] = getlocal("settings.wrong.onehostconnections");
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach ($options as $opt) {
|
||||
$settings[$opt] = $params[$opt];
|
||||
}
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/performance.php?stored");
|
||||
exit;
|
||||
}
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/performance.php?stored");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$page['formonlinetimeout'] = $params['online_timeout'];
|
||||
|
@ -25,42 +25,43 @@ require_once('../libs/operator_settings.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
function update_operator_permissions($operatorid,$newvalue) {
|
||||
function update_operator_permissions($operatorid, $newvalue)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$query = "update ${mysqlprefix}chatoperator set iperm = $newvalue where operatorid = $operatorid";
|
||||
|
||||
perform_query($query,$link);
|
||||
perform_query($query, $link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||
$opId = verifyparam("op", "/^\d{1,9}$/");
|
||||
$page = array('opid' => $opId, 'canmodify' => is_capable($can_administrate, $operator) ? "1" : "");
|
||||
$errors = array();
|
||||
|
||||
$op = operator_by_id($opId);
|
||||
|
||||
if( !$op ) {
|
||||
if (!$op) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
|
||||
} else if( isset($_POST['op']) ) {
|
||||
} else if (isset($_POST['op'])) {
|
||||
|
||||
if(!is_capable($can_administrate, $operator)) {
|
||||
if (!is_capable($can_administrate, $operator)) {
|
||||
$errors[] = getlocal('page_agent.cannot_modify');
|
||||
}
|
||||
|
||||
$new_permissions = isset($op['iperm']) ? $op['iperm'] : 0;
|
||||
|
||||
foreach($permission_ids as $perm => $id) {
|
||||
if( verifyparam("permissions$id","/^on$/", "") == "on") {
|
||||
foreach ($permission_ids as $perm => $id) {
|
||||
if (verifyparam("permissions$id", "/^on$/", "") == "on") {
|
||||
$new_permissions |= (1 << $perm);
|
||||
} else {
|
||||
$new_permissions &= ~ (1 << $perm);
|
||||
$new_permissions &= ~(1 << $perm);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
update_operator_permissions($op['operatorid'],$new_permissions);
|
||||
if (count($errors) == 0) {
|
||||
update_operator_permissions($op['operatorid'], $new_permissions);
|
||||
|
||||
if ($opId && $_SESSION["${mysqlprefix}operator"] && $operator['operatorid'] == $opId) {
|
||||
$_SESSION["${mysqlprefix}operator"]['iperm'] = $new_permissions;
|
||||
@ -73,11 +74,11 @@ if( !$op ) {
|
||||
|
||||
$page['permissionsList'] = get_permission_list();
|
||||
$page['formpermissions'] = array("");
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "-not found-";
|
||||
$page['currentop'] = $op ? topage(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : "-not found-";
|
||||
|
||||
if($op) {
|
||||
foreach($permission_ids as $perm => $id) {
|
||||
if(is_capable($perm,$op)) {
|
||||
if ($op) {
|
||||
foreach ($permission_ids as $perm => $id) {
|
||||
if (is_capable($perm, $op)) {
|
||||
$page['formpermissions'][] = $id;
|
||||
}
|
||||
}
|
||||
@ -85,7 +86,7 @@ if($op) {
|
||||
|
||||
$page['stored'] = isset($_GET['stored']);
|
||||
prepare_menu($operator);
|
||||
setup_operator_settings_tabs($opId,3);
|
||||
setup_operator_settings_tabs($opId, 3);
|
||||
start_html_output();
|
||||
require('../view/permissions.php');
|
||||
?>
|
||||
|
@ -27,30 +27,30 @@ require_once('../libs/groups.php');
|
||||
|
||||
$operator = check_login();
|
||||
|
||||
$threadid = verifyparam( "thread", "/^\d{1,8}$/");
|
||||
$token = verifyparam( "token", "/^\d{1,8}$/");
|
||||
$threadid = verifyparam("thread", "/^\d{1,8}$/");
|
||||
$token = verifyparam("token", "/^\d{1,8}$/");
|
||||
|
||||
$thread = thread_by_id($threadid);
|
||||
if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
|
||||
if (!$thread || !isset($thread['ltoken']) || $token != $thread['ltoken']) {
|
||||
die("wrong thread");
|
||||
}
|
||||
|
||||
$page = array();
|
||||
$errors = array();
|
||||
|
||||
if(isset($_GET['nextGroup'])) {
|
||||
$nextid = verifyparam( "nextGroup", "/^\d{1,8}$/");
|
||||
if (isset($_GET['nextGroup'])) {
|
||||
$nextid = verifyparam("nextGroup", "/^\d{1,8}$/");
|
||||
$nextGroup = group_by_id($nextid);
|
||||
|
||||
if( $nextGroup ) {
|
||||
$page['message'] = getlocal2("chat.redirected.group.content",array(topage(get_group_name($nextGroup))));
|
||||
if( $thread['istate'] == $state_chatting ) {
|
||||
|
||||
if ($nextGroup) {
|
||||
$page['message'] = getlocal2("chat.redirected.group.content", array(topage(get_group_name($nextGroup))));
|
||||
if ($thread['istate'] == $state_chatting) {
|
||||
$link = connect();
|
||||
commit_thread( $threadid,
|
||||
array("istate" => $state_waiting, "nextagent" => 0, "groupid" => $nextid, "agentId" => 0, "agentName" => "''"), $link);
|
||||
commit_thread($threadid,
|
||||
array("istate" => $state_waiting, "nextagent" => 0, "groupid" => $nextid, "agentId" => 0, "agentName" => "''"), $link);
|
||||
post_message_($thread['threadid'], $kind_events,
|
||||
getstring2_("chat.status.operator.redirect",
|
||||
array(get_operator_name($operator)),$thread['locale']), $link);
|
||||
getstring2_("chat.status.operator.redirect",
|
||||
array(get_operator_name($operator)), $thread['locale']), $link);
|
||||
mysql_close($link);
|
||||
} else {
|
||||
$errors[] = getlocal("chat.redirect.cannot");
|
||||
@ -60,23 +60,23 @@ if(isset($_GET['nextGroup'])) {
|
||||
}
|
||||
|
||||
} else {
|
||||
$nextid = verifyparam( "nextAgent", "/^\d{1,8}$/");
|
||||
$nextid = verifyparam("nextAgent", "/^\d{1,8}$/");
|
||||
$nextOperator = operator_by_id($nextid);
|
||||
|
||||
if( $nextOperator ) {
|
||||
$page['message'] = getlocal2("chat.redirected.content",array(topage(get_operator_name($nextOperator))));
|
||||
if( $thread['istate'] == $state_chatting ) {
|
||||
if ($nextOperator) {
|
||||
$page['message'] = getlocal2("chat.redirected.content", array(topage(get_operator_name($nextOperator))));
|
||||
if ($thread['istate'] == $state_chatting) {
|
||||
$link = connect();
|
||||
$threadupdate = array("istate" => $state_waiting, "nextagent" => $nextid, "agentId" => 0);
|
||||
if($thread['groupid'] != 0) {
|
||||
if(FALSE === select_one_row("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $nextid and groupid = ".$thread['groupid'], $link)) {
|
||||
if ($thread['groupid'] != 0) {
|
||||
if (FALSE === select_one_row("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $nextid and groupid = " . $thread['groupid'], $link)) {
|
||||
$threadupdate['groupid'] = 0;
|
||||
}
|
||||
}
|
||||
commit_thread( $threadid, $threadupdate, $link);
|
||||
commit_thread($threadid, $threadupdate, $link);
|
||||
post_message_($thread['threadid'], $kind_events,
|
||||
getstring2_("chat.status.operator.redirect",
|
||||
array(get_operator_name($operator)),$thread['locale']), $link);
|
||||
getstring2_("chat.status.operator.redirect",
|
||||
array(get_operator_name($operator)), $thread['locale']), $link);
|
||||
mysql_close($link);
|
||||
} else {
|
||||
$errors[] = getlocal("chat.redirect.cannot");
|
||||
@ -87,7 +87,7 @@ if(isset($_GET['nextGroup'])) {
|
||||
}
|
||||
|
||||
setup_logo();
|
||||
if( count($errors) > 0 ) {
|
||||
if (count($errors) > 0) {
|
||||
expand("../styles", getchatstyle(), "error.tpl");
|
||||
} else {
|
||||
expand("../styles", getchatstyle(), "redirected.tpl");
|
||||
|
@ -26,15 +26,15 @@ require_once('../libs/settings.php');
|
||||
$errors = array();
|
||||
$page = array('version' => $version, 'showform' => true);
|
||||
|
||||
$opId = verifyparam( "id", "/^\d{1,9}$/");
|
||||
$opId = verifyparam("id", "/^\d{1,9}$/");
|
||||
$token = verifyparam("token", "/^[\dabcdef]+$/");
|
||||
|
||||
$operator = operator_by_id($opId);
|
||||
|
||||
if(!$operator) {
|
||||
if (!$operator) {
|
||||
$errors[] = "No such operator";
|
||||
$page['showform'] = false;
|
||||
} else if($token != $operator['vcrestoretoken']) {
|
||||
} else if ($token != $operator['vcrestoretoken']) {
|
||||
$errors[] = "Wrong token";
|
||||
$page['showform'] = false;
|
||||
}
|
||||
@ -42,25 +42,25 @@ if(!$operator) {
|
||||
if (count($errors) == 0 && isset($_POST['password'])) {
|
||||
$password = getparam('password');
|
||||
$passwordConfirm = getparam('passwordConfirm');
|
||||
|
||||
if( !$password )
|
||||
|
||||
if (!$password)
|
||||
$errors[] = no_field("form.field.password");
|
||||
|
||||
if( $password != $passwordConfirm )
|
||||
if ($password != $passwordConfirm)
|
||||
$errors[] = getlocal("my_settings.error.password_match");
|
||||
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$page['isdone'] = true;
|
||||
|
||||
$link = connect();
|
||||
$query = "update ${mysqlprefix}chatoperator set vcpassword = '".md5($password)."', vcrestoretoken = '' where operatorid = ".$opId;
|
||||
$query = "update ${mysqlprefix}chatoperator set vcpassword = '" . md5($password) . "', vcrestoretoken = '' where operatorid = " . $opId;
|
||||
perform_query($query, $link);
|
||||
mysql_close($link);
|
||||
|
||||
|
||||
start_html_output();
|
||||
require('../view/resetpwd.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page['id'] = $opId;
|
||||
|
@ -30,32 +30,32 @@ $loginoremail = "";
|
||||
|
||||
if (isset($_POST['loginoremail'])) {
|
||||
$loginoremail = getparam("loginoremail");
|
||||
|
||||
|
||||
$torestore = is_valid_email($loginoremail) ? operator_by_email($loginoremail) : operator_by_login($loginoremail);
|
||||
if(!$torestore) {
|
||||
if (!$torestore) {
|
||||
$errors[] = getlocal("no_such_operator");
|
||||
}
|
||||
|
||||
|
||||
$email = $torestore['vcemail'];
|
||||
if(count($errors) == 0 && !is_valid_email($email)) {
|
||||
if (count($errors) == 0 && !is_valid_email($email)) {
|
||||
$errors[] = "Operator hasn't set his e-mail";
|
||||
}
|
||||
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$token = md5((time() + microtime()).rand(0,99999999));
|
||||
|
||||
$token = md5((time() + microtime()) . rand(0, 99999999));
|
||||
|
||||
$link = connect();
|
||||
$query = "update ${mysqlprefix}chatoperator set dtmrestore = CURRENT_TIMESTAMP, vcrestoretoken = '$token' where operatorid = ".$torestore['operatorid'];
|
||||
$query = "update ${mysqlprefix}chatoperator set dtmrestore = CURRENT_TIMESTAMP, vcrestoretoken = '$token' where operatorid = " . $torestore['operatorid'];
|
||||
perform_query($query, $link);
|
||||
|
||||
$href = get_app_location(true,false)."/operator/resetpwd.php?id=".$torestore['operatorid']."&token=$token";
|
||||
webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext",array(get_operator_name($torestore), $href)), $link);
|
||||
|
||||
$href = get_app_location(true, false) . "/operator/resetpwd.php?id=" . $torestore['operatorid'] . "&token=$token";
|
||||
webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext", array(get_operator_name($torestore), $href)), $link);
|
||||
mysql_close($link);
|
||||
|
||||
$page['isdone'] = true;
|
||||
require('../view/restore.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page['formloginoremail'] = topage($loginoremail);
|
||||
|
@ -30,7 +30,7 @@ $errors = array();
|
||||
|
||||
$stylelist = array();
|
||||
$stylesfolder = "../styles";
|
||||
if($handle = opendir($stylesfolder)) {
|
||||
if ($handle = opendir($stylesfolder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
||||
$stylelist[] = $file;
|
||||
@ -40,57 +40,57 @@ if($handle = opendir($stylesfolder)) {
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'email', 'title', 'logo', 'hosturl', 'usernamepattern',
|
||||
'chatstyle', 'chattitle', 'geolink', 'geolinkparams', 'sendmessagekey');
|
||||
'email', 'title', 'logo', 'hosturl', 'usernamepattern',
|
||||
'chatstyle', 'chattitle', 'geolink', 'geolinkparams', 'sendmessagekey');
|
||||
|
||||
loadsettings();
|
||||
$params = array();
|
||||
foreach($options as $opt) {
|
||||
foreach ($options as $opt) {
|
||||
$params[$opt] = $settings[$opt];
|
||||
}
|
||||
|
||||
if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) {
|
||||
$params['email'] = getparam('email');
|
||||
$params['title'] = getparam('title');
|
||||
$params['logo'] = getparam('logo');
|
||||
$params['hosturl'] = getparam('hosturl');
|
||||
$params['usernamepattern'] = getparam('usernamepattern');
|
||||
$params['chattitle'] = getparam('chattitle');
|
||||
$params['geolink'] = getparam('geolink');
|
||||
$params['email'] = getparam('email');
|
||||
$params['title'] = getparam('title');
|
||||
$params['logo'] = getparam('logo');
|
||||
$params['hosturl'] = getparam('hosturl');
|
||||
$params['usernamepattern'] = getparam('usernamepattern');
|
||||
$params['chattitle'] = getparam('chattitle');
|
||||
$params['geolink'] = getparam('geolink');
|
||||
$params['geolinkparams'] = getparam('geolinkparams');
|
||||
$params['sendmessagekey'] = verifyparam('sendmessagekey', "/^c?enter$/");
|
||||
|
||||
$params['chatstyle'] = verifyparam("chatstyle","/^\w+$/", $params['chatstyle']);
|
||||
if(!in_array($params['chatstyle'], $stylelist)) {
|
||||
$params['chatstyle'] = verifyparam("chatstyle", "/^\w+$/", $params['chatstyle']);
|
||||
if (!in_array($params['chatstyle'], $stylelist)) {
|
||||
$params['chatstyle'] = $stylelist[0];
|
||||
}
|
||||
|
||||
if($params['email'] && !is_valid_email($params['email'])) {
|
||||
$errors[] = getlocal("settings.wrong.email");
|
||||
}
|
||||
|
||||
if($params['geolinkparams']) {
|
||||
foreach(preg_split("/,/", $params['geolinkparams']) as $oneparam) {
|
||||
if(!preg_match("/^\s*(toolbar|scrollbars|location|status|menubar|width|height|resizable)=\d{1,4}$/", $oneparam)) {
|
||||
$errors[] = "Wrong link parameter: \"$oneparam\", should be one of 'toolbar, scrollbars, location, status, menubar, width, height or resizable'";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($params['email'] && !is_valid_email($params['email'])) {
|
||||
$errors[] = getlocal("settings.wrong.email");
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach($options as $opt) {
|
||||
if ($params['geolinkparams']) {
|
||||
foreach (preg_split("/,/", $params['geolinkparams']) as $oneparam) {
|
||||
if (!preg_match("/^\s*(toolbar|scrollbars|location|status|menubar|width|height|resizable)=\d{1,4}$/", $oneparam)) {
|
||||
$errors[] = "Wrong link parameter: \"$oneparam\", should be one of 'toolbar, scrollbars, location, status, menubar, width, height or resizable'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach ($options as $opt) {
|
||||
$settings[$opt] = $params[$opt];
|
||||
}
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/settings.php?stored");
|
||||
exit;
|
||||
}
|
||||
update_settings();
|
||||
header("Location: $webimroot/operator/settings.php?stored");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$page['formemail'] = topage($params['email']);
|
||||
$page['formtitle'] = topage($params['title']);
|
||||
$page['formlogo'] = topage($params['logo']);
|
||||
$page['formhosturl'] = topage($params['hosturl']);
|
||||
$page['formlogo'] = topage($params['logo']);
|
||||
$page['formhosturl'] = topage($params['hosturl']);
|
||||
$page['formgeolink'] = topage($params['geolink']);
|
||||
$page['formgeolinkparams'] = topage($params['geolinkparams']);
|
||||
$page['formusernamepattern'] = topage($params['usernamepattern']);
|
||||
|
@ -29,55 +29,55 @@ setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
$page = array();
|
||||
$page['operator'] = topage(get_operator_name($operator));
|
||||
$page['availableDays'] = range(1,31);
|
||||
$page['availableMonth'] = get_month_selection(time()-400*24*60*60,time()+50*24*60*60 );
|
||||
$page['availableDays'] = range(1, 31);
|
||||
$page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60);
|
||||
$page['showresults'] = false;
|
||||
$errors = array();
|
||||
|
||||
if(isset($_GET['startday'])) {
|
||||
$startday = verifyparam("startday","/^\d+$/");
|
||||
$startmonth = verifyparam("startmonth","/^\d{2}.\d{2}$/");
|
||||
$endday = verifyparam("endday","/^\d+$/");
|
||||
$endmonth = verifyparam("endmonth","/^\d{2}.\d{2}$/");
|
||||
$start = get_form_date($startday,$startmonth);
|
||||
$end = get_form_date($endday, $endmonth)+24*60*60;
|
||||
if (isset($_GET['startday'])) {
|
||||
$startday = verifyparam("startday", "/^\d+$/");
|
||||
$startmonth = verifyparam("startmonth", "/^\d{2}.\d{2}$/");
|
||||
$endday = verifyparam("endday", "/^\d+$/");
|
||||
$endmonth = verifyparam("endmonth", "/^\d{2}.\d{2}$/");
|
||||
$start = get_form_date($startday, $startmonth);
|
||||
$end = get_form_date($endday, $endmonth) + 24 * 60 * 60;
|
||||
|
||||
} else {
|
||||
$curr = getdate(time());
|
||||
if( $curr['mday'] < 7 ) {
|
||||
if ($curr['mday'] < 7) {
|
||||
// previous month
|
||||
if($curr['mon'] == 1) {
|
||||
$month = 12;
|
||||
$year = $curr['year']-1;
|
||||
if ($curr['mon'] == 1) {
|
||||
$month = 12;
|
||||
$year = $curr['year'] - 1;
|
||||
} else {
|
||||
$month = $curr['mon']-1;
|
||||
$month = $curr['mon'] - 1;
|
||||
$year = $curr['year'];
|
||||
}
|
||||
$start = mktime(0,0,0,$month,1,$year);
|
||||
$end = mktime(0,0,0,$month, date("t",$start),$year)+24*60*60;
|
||||
$start = mktime(0, 0, 0, $month, 1, $year);
|
||||
$end = mktime(0, 0, 0, $month, date("t", $start), $year) + 24 * 60 * 60;
|
||||
} else {
|
||||
$start = mktime(0,0,0,$curr['mon'],1,$curr['year']);
|
||||
$end = time()+24*60*60;
|
||||
$start = mktime(0, 0, 0, $curr['mon'], 1, $curr['year']);
|
||||
$end = time() + 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
set_form_date($start, "start");
|
||||
set_form_date($end-24*60*60, "end");
|
||||
set_form_date($end - 24 * 60 * 60, "end");
|
||||
|
||||
if( $start > $end ) {
|
||||
if ($start > $end) {
|
||||
$errors[] = getlocal("statistics.wrong.dates");
|
||||
}
|
||||
|
||||
$link = connect();
|
||||
|
||||
$page['reportByDate'] = select_multi_assoc("select DATE(dtmcreated) as date, COUNT(distinct threadid) as threads, SUM(${mysqlprefix}chatmessage.ikind = $kind_agent) as agents, SUM(${mysqlprefix}chatmessage.ikind = $kind_user) as users ".
|
||||
"from ${mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by DATE(dtmcreated) order by dtmcreated desc", $link);
|
||||
$page['reportByDate'] = select_multi_assoc("select DATE(dtmcreated) as date, COUNT(distinct threadid) as threads, SUM(${mysqlprefix}chatmessage.ikind = $kind_agent) as agents, SUM(${mysqlprefix}chatmessage.ikind = $kind_user) as users " .
|
||||
"from ${mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by DATE(dtmcreated) order by dtmcreated desc", $link);
|
||||
|
||||
$page['reportByDateTotal'] = select_one_row("select COUNT(distinct threadid) as threads, SUM(${mysqlprefix}chatmessage.ikind = $kind_agent) as agents, SUM(${mysqlprefix}chatmessage.ikind = $kind_user) as users ".
|
||||
"from ${mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end", $link);
|
||||
$page['reportByDateTotal'] = select_one_row("select COUNT(distinct threadid) as threads, SUM(${mysqlprefix}chatmessage.ikind = $kind_agent) as agents, SUM(${mysqlprefix}chatmessage.ikind = $kind_user) as users " .
|
||||
"from ${mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end", $link);
|
||||
|
||||
$page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(distinct threadid) as threads, SUM(ikind = $kind_agent) as msgs, AVG(CHAR_LENGTH(tmessage)) as avglen ".
|
||||
"from ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator ".
|
||||
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
||||
$page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(distinct threadid) as threads, SUM(ikind = $kind_agent) as msgs, AVG(CHAR_LENGTH(tmessage)) as avglen " .
|
||||
"from ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator " .
|
||||
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
||||
|
||||
$page['showresults'] = count($errors) == 0;
|
||||
|
||||
|
@ -31,7 +31,7 @@ $operator = check_login();
|
||||
|
||||
$stylelist = array();
|
||||
$stylesfolder = "../styles";
|
||||
if($handle = opendir($stylesfolder)) {
|
||||
if ($handle = opendir($stylesfolder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
||||
$stylelist[] = $file;
|
||||
@ -40,55 +40,55 @@ if($handle = opendir($stylesfolder)) {
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
$preview = verifyparam("preview","/^\w+$/", "default");
|
||||
if(!in_array($preview, $stylelist)) {
|
||||
$preview = verifyparam("preview", "/^\w+$/", "default");
|
||||
if (!in_array($preview, $stylelist)) {
|
||||
$preview = $stylelist[0];
|
||||
}
|
||||
|
||||
$show = verifyparam("show", "/^(chat|chatsimple|nochat|mail|mailsent|survey|leavemessage|leavemessagesent|redirect|redirected|agentchat|agentrochat|error)$/", "");
|
||||
$showerrors = verifyparam("showerr", "/^on$/", "") == "on";
|
||||
$errors = array();
|
||||
if($showerrors || $show == 'error') {
|
||||
if ($showerrors || $show == 'error') {
|
||||
$errors[] = "Test error";
|
||||
}
|
||||
|
||||
if($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'leavemessagesent' || $show == 'chatsimple' || $show == 'nochat') {
|
||||
setup_chatview_for_user(array('threadid' => 0,'userName' => getstring("chat.default.username"), 'ltoken' => 123), "ajaxed");
|
||||
if ($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'leavemessagesent' || $show == 'chatsimple' || $show == 'nochat') {
|
||||
setup_chatview_for_user(array('threadid' => 0, 'userName' => getstring("chat.default.username"), 'ltoken' => 123), "ajaxed");
|
||||
$page['mailLink'] = "$webimroot/operator/themes.php?preview=$preview&show=mail";
|
||||
$page['info'] = "";
|
||||
expand("../styles", "$preview", "$show.tpl");
|
||||
exit;
|
||||
}
|
||||
if($show == 'survey') {
|
||||
if ($show == 'survey') {
|
||||
loadsettings();
|
||||
setup_survey("Visitor", "", "", "", "http://google.com");
|
||||
setup_logo();
|
||||
expand("../styles", "$preview", "$show.tpl");
|
||||
exit;
|
||||
}
|
||||
if($show == 'mailsent' || $show == 'error') {
|
||||
if ($show == 'mailsent' || $show == 'error') {
|
||||
$page['email'] = "admin@yourdomain.com";
|
||||
setup_logo();
|
||||
expand("../styles", "$preview", "$show.tpl");
|
||||
exit;
|
||||
}
|
||||
if($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat' ) {
|
||||
if ($show == 'redirect' || $show == 'redirected' || $show == 'agentchat' || $show == 'agentrochat') {
|
||||
setup_chatview_for_operator(
|
||||
array(
|
||||
'threadid' => 0,
|
||||
'userName' => getstring("chat.default.username"),
|
||||
'remote' => "1.2.3.4",
|
||||
'agentId' => 1,
|
||||
'userid' => 'visitor1',
|
||||
'locale' => $current_locale,
|
||||
'ltoken' => $show=='agentrochat' ? 124 : 123),
|
||||
'threadid' => 0,
|
||||
'userName' => getstring("chat.default.username"),
|
||||
'remote' => "1.2.3.4",
|
||||
'agentId' => 1,
|
||||
'userid' => 'visitor1',
|
||||
'locale' => $current_locale,
|
||||
'ltoken' => $show == 'agentrochat' ? 124 : 123),
|
||||
array(
|
||||
'operatorid' => ($show=='agentrochat' ? 2 : 1),
|
||||
));
|
||||
if($show=='redirect') {
|
||||
setup_redirect_links( 0,$show=='agentrochat' ? 124 : 123);
|
||||
} elseif($show=='redirected') {
|
||||
$page['message'] = getlocal2("chat.redirected.content",array("Administrator"));
|
||||
'operatorid' => ($show == 'agentrochat' ? 2 : 1),
|
||||
));
|
||||
if ($show == 'redirect') {
|
||||
setup_redirect_links(0, $show == 'agentrochat' ? 124 : 123);
|
||||
} elseif ($show == 'redirected') {
|
||||
$page['message'] = getlocal2("chat.redirected.content", array("Administrator"));
|
||||
}
|
||||
$page['redirectLink'] = "$webimroot/operator/themes.php?preview=$preview&show=redirect";
|
||||
expand("../styles", "$preview", "$show.tpl");
|
||||
@ -126,12 +126,12 @@ $page['availableTemplates'] = array(
|
||||
"agentchat", "agentrochat", "error",
|
||||
"all");
|
||||
|
||||
$page['showlink'] = "$webimroot/operator/themes.php?preview=$preview&".($showerrors?"showerr=on&":"")."show=";
|
||||
$page['showlink'] = "$webimroot/operator/themes.php?preview=$preview&" . ($showerrors ? "showerr=on&" : "") . "show=";
|
||||
|
||||
$page['previewList'] = array();
|
||||
foreach($templateList as $tpl) {
|
||||
if($tpl['id'] == $template || $template == 'all') {
|
||||
$page['previewList'][] = $tpl;
|
||||
foreach ($templateList as $tpl) {
|
||||
if ($tpl['id'] == $template || $template == 'all') {
|
||||
$page['previewList'][] = $tpl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,23 +31,24 @@ $page = array();
|
||||
loadsettings();
|
||||
setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
function thread_info($id) {
|
||||
function thread_info($id)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
$link = connect();
|
||||
$thread = select_one_row("select userName,agentName,remote,userAgent,".
|
||||
"unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created,".
|
||||
"vclocalname as groupName ".
|
||||
"from ${mysqlprefix}chatthread left join ${mysqlprefix}chatgroup on ${mysqlprefix}chatthread.groupid = ${mysqlprefix}chatgroup.groupid ".
|
||||
"where threadid = ". $id, $link );
|
||||
$thread = select_one_row("select userName,agentName,remote,userAgent," .
|
||||
"unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created," .
|
||||
"vclocalname as groupName " .
|
||||
"from ${mysqlprefix}chatthread left join ${mysqlprefix}chatgroup on ${mysqlprefix}chatthread.groupid = ${mysqlprefix}chatgroup.groupid " .
|
||||
"where threadid = " . $id, $link);
|
||||
mysql_close($link);
|
||||
return $thread;
|
||||
}
|
||||
|
||||
|
||||
if( isset($_GET['threadid'])) {
|
||||
$threadid = verifyparam( "threadid", "/^(\d{1,9})?$/", "");
|
||||
if (isset($_GET['threadid'])) {
|
||||
$threadid = verifyparam("threadid", "/^(\d{1,9})?$/", "");
|
||||
$lastid = -1;
|
||||
$page['threadMessages'] = get_messages($threadid,"html",false,$lastid);
|
||||
$page['threadMessages'] = get_messages($threadid, "html", false, $lastid);
|
||||
$page['thread'] = thread_info($threadid);
|
||||
}
|
||||
|
||||
|
@ -23,27 +23,30 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/pagination.php');
|
||||
|
||||
function compare_localization_by_l1($a, $b) {
|
||||
if ($a == $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['l1'] < $b['l1']) ? -1 : 1;
|
||||
function compare_localization_by_l1($a, $b)
|
||||
{
|
||||
if ($a == $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['l1'] < $b['l1']) ? -1 : 1;
|
||||
}
|
||||
|
||||
function compare_localization_by_id($a, $b) {
|
||||
if ($a == $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['id'] < $b['id']) ? -1 : 1;
|
||||
function compare_localization_by_id($a, $b)
|
||||
{
|
||||
if ($a == $b) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['id'] < $b['id']) ? -1 : 1;
|
||||
}
|
||||
|
||||
function load_idlist($name) {
|
||||
function load_idlist($name)
|
||||
{
|
||||
$result = array();
|
||||
$fp = @fopen(dirname(__FILE__)."/../locales/names/$name", "r");
|
||||
if($fp !== FALSE) {
|
||||
$fp = @fopen(dirname(__FILE__) . "/../locales/names/$name", "r");
|
||||
if ($fp !== FALSE) {
|
||||
while (!feof($fp)) {
|
||||
$line = trim(fgets($fp, 4096));
|
||||
if($line && preg_match("/^[\w_\.]+$/", $line)) {
|
||||
if ($line && preg_match("/^[\w_\.]+$/", $line)) {
|
||||
$result[] = $line;
|
||||
}
|
||||
}
|
||||
@ -52,62 +55,64 @@ function load_idlist($name) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function save_message($locale,$key,$value) {
|
||||
function save_message($locale, $key, $value)
|
||||
{
|
||||
global $webim_encoding;
|
||||
$result = "";
|
||||
$added = false;
|
||||
$current_encoding = $webim_encoding;
|
||||
$fp = fopen(dirname(__FILE__)."/../locales/$locale/properties", "r");
|
||||
$fp = fopen(dirname(__FILE__) . "/../locales/$locale/properties", "r");
|
||||
while (!feof($fp)) {
|
||||
$line = fgets($fp, 4096);
|
||||
$keyval = preg_split("/=/", $line, 2 );
|
||||
if( isset($keyval[1]) ) {
|
||||
if($keyval[0] == 'encoding') {
|
||||
$keyval = preg_split("/=/", $line, 2);
|
||||
if (isset($keyval[1])) {
|
||||
if ($keyval[0] == 'encoding') {
|
||||
$current_encoding = trim($keyval[1]);
|
||||
} else if(!$added && $keyval[0] == $key) {
|
||||
$line = "$key=".myiconv($webim_encoding, $current_encoding, str_replace("\r", "",str_replace("\n", "\\n",trim($value))))."\n";
|
||||
} else if (!$added && $keyval[0] == $key) {
|
||||
$line = "$key=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n";
|
||||
$added = true;
|
||||
}
|
||||
}
|
||||
$result .= $line;
|
||||
}
|
||||
fclose($fp);
|
||||
if(!$added) {
|
||||
$result .= "$key=".myiconv($webim_encoding, $current_encoding, str_replace("\r", "",str_replace("\n", "\\n",trim($value))))."\n";
|
||||
if (!$added) {
|
||||
$result .= "$key=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n";
|
||||
}
|
||||
$fp = @fopen(dirname(__FILE__)."/../locales/$locale/properties", "w");
|
||||
if($fp !== FALSE) {
|
||||
$fp = @fopen(dirname(__FILE__) . "/../locales/$locale/properties", "w");
|
||||
if ($fp !== FALSE) {
|
||||
fwrite($fp, $result);
|
||||
fclose($fp);
|
||||
} else {
|
||||
die("cannot write /locales/$locale/properties, please check file permissions on your server");
|
||||
}
|
||||
$fp = @fopen(dirname(__FILE__)."/../locales/$locale/properties.log", "a");
|
||||
if($fp !== FALSE) {
|
||||
$fp = @fopen(dirname(__FILE__) . "/../locales/$locale/properties.log", "a");
|
||||
if ($fp !== FALSE) {
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'];
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) &&
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) {
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'].' ('.$_SERVER['HTTP_X_FORWARDED_FOR'].')';
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) {
|
||||
$extAddr = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')';
|
||||
}
|
||||
$userbrowser = $_SERVER['HTTP_USER_AGENT'];
|
||||
$remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr;
|
||||
|
||||
fwrite($fp,"# ".date(DATE_RFC822)." by $remoteHost using $userbrowser\n");
|
||||
fwrite($fp,"$key=".myiconv($webim_encoding, $current_encoding, str_replace("\r", "",str_replace("\n", "\\n",trim($value))))."\n");
|
||||
fwrite($fp, "# " . date(DATE_RFC822) . " by $remoteHost using $userbrowser\n");
|
||||
fwrite($fp, "$key=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function get_auxiliary($s) {
|
||||
function get_auxiliary($s)
|
||||
{
|
||||
$res = "";
|
||||
if(preg_match_all("/<[^>]+?>|[:]|\{\d+\}|[Mm]ibew|[Ww]ebim/", $s, $matches, PREG_PATTERN_ORDER)) {
|
||||
if (preg_match_all("/<[^>]+?>|[:]|\{\d+\}|[Mm]ibew|[Ww]ebim/", $s, $matches, PREG_PATTERN_ORDER)) {
|
||||
foreach ($matches[0] as $val) {
|
||||
if($val != "<br/>") {
|
||||
if ($val != "<br/>") {
|
||||
$res .= $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(substr(trim($s),-1) == "." || substr(trim($s),-1) == "?") {
|
||||
if (substr(trim($s), -1) == "." || substr(trim($s), -1) == "?") {
|
||||
$res .= ".";
|
||||
}
|
||||
return $res;
|
||||
@ -119,11 +124,11 @@ $source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
|
||||
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);
|
||||
$stringid = verifyparam("key", "/^[_\.\w]+$/", "");
|
||||
|
||||
if(!isset($messages[$source])) {
|
||||
if (!isset($messages[$source])) {
|
||||
load_messages($source);
|
||||
}
|
||||
$lang1 = $messages[$source];
|
||||
if(!isset($messages[$target])) {
|
||||
if (!isset($messages[$target])) {
|
||||
load_messages($target);
|
||||
}
|
||||
$lang2 = $messages[$target];
|
||||
@ -136,16 +141,16 @@ $page = array(
|
||||
'title2' => isset($lang2["localeid"]) ? $lang2["localeid"] : $target
|
||||
);
|
||||
|
||||
if($stringid) {
|
||||
if ($stringid) {
|
||||
$translation = isset($lang2[$stringid]) ? $lang2[$stringid] : "";
|
||||
if(isset($_POST['translation'])) {
|
||||
if (isset($_POST['translation'])) {
|
||||
|
||||
$translation = getparam('translation');
|
||||
if(!$translation) {
|
||||
if (!$translation) {
|
||||
$errors[] = no_field("form.field.translation");
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
if (count($errors) == 0) {
|
||||
save_message($target, $stringid, $translation);
|
||||
|
||||
$page['saved'] = true;
|
||||
@ -169,7 +174,7 @@ if($stringid) {
|
||||
|
||||
$localesList = array();
|
||||
$allLocales = get_available_locales();
|
||||
foreach($allLocales as $loc) {
|
||||
foreach ($allLocales as $loc) {
|
||||
$localesList[] = array("id" => $loc, "name" => getlocal_("localeid", $loc));
|
||||
}
|
||||
|
||||
@ -177,35 +182,35 @@ $show = verifyparam("show", "/^(all|s1|s2|s3)$/", "all");
|
||||
|
||||
$result = array();
|
||||
$allkeys = array_keys($lang1);
|
||||
if($show == 's1') {
|
||||
if ($show == 's1') {
|
||||
$allkeys = array_intersect($allkeys, load_idlist('level1'));
|
||||
} else if($show == 's2') {
|
||||
} else if ($show == 's2') {
|
||||
$allkeys = array_intersect($allkeys, load_idlist('level2'));
|
||||
} else if($show == 's3') {
|
||||
} else if ($show == 's3') {
|
||||
$allkeys = array_diff($allkeys, load_idlist('level1'), load_idlist('level2'));
|
||||
}
|
||||
|
||||
foreach($allkeys as $key) {
|
||||
if($key != 'output_charset') {
|
||||
foreach ($allkeys as $key) {
|
||||
if ($key != 'output_charset') {
|
||||
$tsource = htmlspecialchars($lang1[$key]);
|
||||
if(isset($lang2[$key])) {
|
||||
if (isset($lang2[$key])) {
|
||||
$value = htmlspecialchars($lang2[$key]);
|
||||
if(get_auxiliary($lang2[$key]) != get_auxiliary($lang1[$key])) {
|
||||
if (get_auxiliary($lang2[$key]) != get_auxiliary($lang1[$key])) {
|
||||
$value = "<font color=\"#6030c1\"><b>$value</b></font> <strong>(wrong formatting)</strong>";
|
||||
}
|
||||
} else {
|
||||
$value = "<font color=\"#c13030\"><b>absent</b></font>";
|
||||
$value = "<font color=\"#c13030\"><b>absent</b></font>";
|
||||
}
|
||||
$result[] = array(
|
||||
'id' => $key,
|
||||
'l1' => $tsource,
|
||||
'l2' => $value );
|
||||
'id' => $key,
|
||||
'l1' => $tsource,
|
||||
'l2' => $value);
|
||||
}
|
||||
}
|
||||
|
||||
$order = verifyparam("sort", "/^(id|l1)$/", "id");
|
||||
usort($result, "compare_localization_by_$order");
|
||||
setup_pagination($result,100);
|
||||
setup_pagination($result, 100);
|
||||
|
||||
$page['formtarget'] = $target;
|
||||
$page['formsource'] = $source;
|
||||
|
@ -26,9 +26,9 @@ require_once('../libs/operator.php');
|
||||
require_once('../libs/groups.php');
|
||||
|
||||
$operator = get_logged_in();
|
||||
if( !$operator ) {
|
||||
if (!$operator) {
|
||||
start_xml_output();
|
||||
echo "<error><descr>".myiconv($webim_encoding,"utf-8",escape_with_cdata(getstring("agent.not_logged_in")))."</descr></error>";
|
||||
echo "<error><descr>" . myiconv($webim_encoding, "utf-8", escape_with_cdata(getstring("agent.not_logged_in"))) . "</descr></error>";
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -49,110 +49,113 @@ $threadstate_key = array(
|
||||
$state_loading => "chat.thread.state_loading"
|
||||
);
|
||||
|
||||
function thread_to_xml($thread,$link) {
|
||||
function thread_to_xml($thread, $link)
|
||||
{
|
||||
global $state_chatting, $threadstate_to_string, $threadstate_key,
|
||||
$webim_encoding, $operator, $settings,
|
||||
$can_viewthreads, $can_takeover, $mysqlprefix;
|
||||
$webim_encoding, $operator, $settings,
|
||||
$can_viewthreads, $can_takeover, $mysqlprefix;
|
||||
$state = $threadstate_to_string[$thread['istate']];
|
||||
$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
|
||||
if( $state == "closed" )
|
||||
return $result."/>";
|
||||
$result = "<thread id=\"" . $thread['threadid'] . "\" stateid=\"$state\"";
|
||||
if ($state == "closed")
|
||||
return $result . "/>";
|
||||
|
||||
$state = getstring($threadstate_key[$thread['istate']]);
|
||||
$nextagent = $thread['nextagent'] != 0 ? operator_by_id_($thread['nextagent'],$link) : null;
|
||||
$nextagent = $thread['nextagent'] != 0 ? operator_by_id_($thread['nextagent'], $link) : null;
|
||||
$threadoperator = $nextagent ? get_operator_name($nextagent)
|
||||
: ($thread['agentName'] ? $thread['agentName'] : "-");
|
||||
|
||||
if($threadoperator == "-" && $thread['groupname']) {
|
||||
$threadoperator = "- ".$thread['groupname']." -";
|
||||
: ($thread['agentName'] ? $thread['agentName'] : "-");
|
||||
|
||||
if ($threadoperator == "-" && $thread['groupname']) {
|
||||
$threadoperator = "- " . $thread['groupname'] . " -";
|
||||
}
|
||||
|
||||
if(!($thread['istate'] == $state_chatting && $thread['agentId'] != $operator['operatorid'] && !is_capable($can_takeover,$operator))) {
|
||||
if (!($thread['istate'] == $state_chatting && $thread['agentId'] != $operator['operatorid'] && !is_capable($can_takeover, $operator))) {
|
||||
$result .= " canopen=\"true\"";
|
||||
}
|
||||
if ($thread['agentId'] != $operator['operatorid'] && $thread['nextagent'] != $operator['operatorid']
|
||||
&& is_capable($can_viewthreads, $operator)) {
|
||||
&& is_capable($can_viewthreads, $operator)) {
|
||||
$result .= " canview=\"true\"";
|
||||
}
|
||||
if ($settings['enableban'] == "1") {
|
||||
$result .= " canban=\"true\"";
|
||||
}
|
||||
|
||||
$banForThread = $settings['enableban'] == "1" ? ban_for_addr_($thread['remote'],$link) : false;
|
||||
if($banForThread) {
|
||||
$result .= " ban=\"blocked\" banid=\"".$banForThread['banid']."\"";
|
||||
$banForThread = $settings['enableban'] == "1" ? ban_for_addr_($thread['remote'], $link) : false;
|
||||
if ($banForThread) {
|
||||
$result .= " ban=\"blocked\" banid=\"" . $banForThread['banid'] . "\"";
|
||||
}
|
||||
|
||||
$result .= " state=\"$state\" typing=\"".$thread['userTyping']."\">";
|
||||
$result .="<name>";
|
||||
if($banForThread) {
|
||||
$result .= " state=\"$state\" typing=\"" . $thread['userTyping'] . "\">";
|
||||
$result .= "<name>";
|
||||
if ($banForThread) {
|
||||
$result .= htmlspecialchars(getstring('chat.client.spam.prefix'));
|
||||
}
|
||||
$result .= htmlspecialchars(htmlspecialchars(get_user_name($thread['userName'],$thread['remote'], $thread['userid'])))."</name>";
|
||||
$result .= "<addr>".htmlspecialchars(get_user_addr($thread['remote']))."</addr>";
|
||||
$result .= "<agent>".htmlspecialchars(htmlspecialchars($threadoperator))."</agent>";
|
||||
$result .= "<time>".$thread['unix_timestamp(dtmcreated)']."000</time>";
|
||||
$result .= "<modified>".$thread['unix_timestamp(dtmmodified)']."000</modified>";
|
||||
$result .= htmlspecialchars(htmlspecialchars(get_user_name($thread['userName'], $thread['remote'], $thread['userid']))) . "</name>";
|
||||
$result .= "<addr>" . htmlspecialchars(get_user_addr($thread['remote'])) . "</addr>";
|
||||
$result .= "<agent>" . htmlspecialchars(htmlspecialchars($threadoperator)) . "</agent>";
|
||||
$result .= "<time>" . $thread['unix_timestamp(dtmcreated)'] . "000</time>";
|
||||
$result .= "<modified>" . $thread['unix_timestamp(dtmmodified)'] . "000</modified>";
|
||||
|
||||
if($banForThread) {
|
||||
$result .= "<reason>".$banForThread['comment']."</reason>";
|
||||
if ($banForThread) {
|
||||
$result .= "<reason>" . $banForThread['comment'] . "</reason>";
|
||||
}
|
||||
|
||||
$userAgent = get_useragent_version($thread['userAgent']);
|
||||
$result .= "<useragent>".$userAgent."</useragent>";
|
||||
if( $thread["shownmessageid"] != 0 ) {
|
||||
$query = "select tmessage from ${mysqlprefix}chatmessage where messageid = ".$thread["shownmessageid"];
|
||||
$result .= "<useragent>" . $userAgent . "</useragent>";
|
||||
if ($thread["shownmessageid"] != 0) {
|
||||
$query = "select tmessage from ${mysqlprefix}chatmessage where messageid = " . $thread["shownmessageid"];
|
||||
$line = select_one_row($query, $link);
|
||||
if( $line ) {
|
||||
if ($line) {
|
||||
$message = preg_replace("/[\r\n\t]+/", " ", $line["tmessage"]);
|
||||
$result .= "<message>".htmlspecialchars(htmlspecialchars($message))."</message>";
|
||||
$result .= "<message>" . htmlspecialchars(htmlspecialchars($message)) . "</message>";
|
||||
}
|
||||
}
|
||||
$result .= "</thread>";
|
||||
return $result;
|
||||
}
|
||||
|
||||
function print_pending_threads($groupids,$since) {
|
||||
function print_pending_threads($groupids, $since)
|
||||
{
|
||||
global $webim_encoding, $settings, $state_closed, $state_left, $mysqlprefix;
|
||||
$link = connect();
|
||||
|
||||
$revision = $since;
|
||||
$output = array();
|
||||
$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, ".
|
||||
"unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent, (select vclocalname from ${mysqlprefix}chatgroup where ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatthread.groupid) as groupname ".
|
||||
"from ${mysqlprefix}chatthread where lrevision > $since ".
|
||||
($since <= 0
|
||||
? "AND istate <> $state_closed AND istate <> $state_left "
|
||||
: "").
|
||||
$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, " .
|
||||
"unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent, (select vclocalname from ${mysqlprefix}chatgroup where ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatthread.groupid) as groupname " .
|
||||
"from ${mysqlprefix}chatthread where lrevision > $since " .
|
||||
($since <= 0
|
||||
? "AND istate <> $state_closed AND istate <> $state_left "
|
||||
: "") .
|
||||
($settings['enablegroups'] == '1'
|
||||
? "AND (groupid is NULL".($groupids
|
||||
? " OR groupid IN ($groupids)"
|
||||
: "").
|
||||
") "
|
||||
: "").
|
||||
? "AND (groupid is NULL" . ($groupids
|
||||
? " OR groupid IN ($groupids)"
|
||||
: "") .
|
||||
") "
|
||||
: "") .
|
||||
"ORDER BY threadid";
|
||||
$rows = select_multi_assoc($query, $link);
|
||||
foreach ($rows as $row) {
|
||||
$thread = thread_to_xml($row,$link);
|
||||
$thread = thread_to_xml($row, $link);
|
||||
$output[] = $thread;
|
||||
if( $row['lrevision'] > $revision )
|
||||
if ($row['lrevision'] > $revision)
|
||||
$revision = $row['lrevision'];
|
||||
}
|
||||
|
||||
mysql_close($link);
|
||||
|
||||
echo "<threads revision=\"$revision\" time=\"".time()."000\">";
|
||||
foreach( $output as $thr ) {
|
||||
print myiconv($webim_encoding,"utf-8",$thr);
|
||||
echo "<threads revision=\"$revision\" time=\"" . time() . "000\">";
|
||||
foreach ($output as $thr) {
|
||||
print myiconv($webim_encoding, "utf-8", $thr);
|
||||
}
|
||||
echo "</threads>";
|
||||
}
|
||||
|
||||
function print_operators() {
|
||||
function print_operators()
|
||||
{
|
||||
echo "<operators>";
|
||||
$operators = operator_get_all();
|
||||
|
||||
foreach($operators as $operator) {
|
||||
foreach ($operators as $operator) {
|
||||
if (!operator_is_online($operator))
|
||||
continue;
|
||||
|
||||
@ -161,27 +164,27 @@ function print_operators() {
|
||||
|
||||
echo "<operator name=\"$name\"$away/>";
|
||||
}
|
||||
echo "</operators>";
|
||||
echo "</operators>";
|
||||
}
|
||||
|
||||
$since = verifyparam( "since", "/^\d{1,9}$/", 0);
|
||||
$status = verifyparam( "status", "/^\d{1,2}$/", 0);
|
||||
$showonline = verifyparam( "showonline", "/^1$/", 0);
|
||||
$since = verifyparam("since", "/^\d{1,9}$/", 0);
|
||||
$status = verifyparam("status", "/^\d{1,2}$/", 0);
|
||||
$showonline = verifyparam("showonline", "/^1$/", 0);
|
||||
|
||||
$link = connect();
|
||||
loadsettings_($link);
|
||||
if(!isset($_SESSION['operatorgroups'])) {
|
||||
$_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link);
|
||||
if (!isset($_SESSION['operatorgroups'])) {
|
||||
$_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
$groupids = $_SESSION['operatorgroups'];
|
||||
|
||||
start_xml_output();
|
||||
echo '<update>';
|
||||
if($showonline) {
|
||||
if ($showonline) {
|
||||
print_operators();
|
||||
}
|
||||
print_pending_threads($groupids,$since);
|
||||
print_pending_threads($groupids, $since);
|
||||
echo '</update>';
|
||||
notify_operator_alive($operator['operatorid'], $status);
|
||||
exit;
|
||||
|
@ -34,8 +34,8 @@ $page = array(
|
||||
'version' => $version,
|
||||
);
|
||||
|
||||
foreach($default_extensions as $ext) {
|
||||
if(!extension_loaded($ext)) {
|
||||
foreach ($default_extensions as $ext) {
|
||||
if (!extension_loaded($ext)) {
|
||||
$page['phpVersion'] .= " $ext/absent";
|
||||
} else {
|
||||
$ver = phpversion($ext);
|
||||
|
@ -33,23 +33,24 @@ $page = array();
|
||||
setlocale(LC_TIME, getstring("time.locale"));
|
||||
|
||||
$userid = "";
|
||||
if( isset($_GET['userid'])) {
|
||||
$userid = verifyparam( "userid", "/^.{0,63}$/", "");
|
||||
if (isset($_GET['userid'])) {
|
||||
$userid = verifyparam("userid", "/^.{0,63}$/", "");
|
||||
}
|
||||
|
||||
function threads_by_userid($userid) {
|
||||
function threads_by_userid($userid)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
if ($userid == "") {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
$link = connect();
|
||||
|
||||
$query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, ".
|
||||
" threadid, remote, agentName, userName ".
|
||||
"from ${mysqlprefix}chatthread ".
|
||||
"where userid=\"$userid\" order by created DESC", $userid);
|
||||
$query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, " .
|
||||
" threadid, remote, agentName, userName " .
|
||||
"from ${mysqlprefix}chatthread " .
|
||||
"where userid=\"$userid\" order by created DESC", $userid);
|
||||
|
||||
$result = mysql_query($query, $link) or die(' Query failed: ' .mysql_error().": ".$query);
|
||||
$result = mysql_query($query, $link) or die(' Query failed: ' . mysql_error() . ": " . $query);
|
||||
|
||||
$foundThreads = array();
|
||||
while ($thread = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
@ -64,7 +65,7 @@ function threads_by_userid($userid) {
|
||||
$found = threads_by_userid($userid);
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_pagination($found,6);
|
||||
setup_pagination($found, 6);
|
||||
start_html_output();
|
||||
require('../view/userhistory.php');
|
||||
?>
|
||||
|
@ -30,7 +30,7 @@ notify_operator_alive($operator['operatorid'], $status);
|
||||
|
||||
$link = connect();
|
||||
loadsettings_($link);
|
||||
$_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link);
|
||||
$_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link);
|
||||
mysql_close($link);
|
||||
|
||||
$page = array();
|
||||
|
Loading…
Reference in New Issue
Block a user