diff --git a/src/messenger/.idea/inspectionProfiles/Project_Default.xml b/src/messenger/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..c66df003
--- /dev/null
+++ b/src/messenger/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/messenger/.idea/inspectionProfiles/profiles_settings.xml b/src/messenger/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..3b312839
--- /dev/null
+++ b/src/messenger/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php
index 738d4f94..fa5b75ff 100644
--- a/src/messenger/webim/install/dbinfo.php
+++ b/src/messenger/webim/install/dbinfo.php
@@ -20,7 +20,7 @@
*/
$dbtables = array(
- $mysqlprefix . "chatgroup" => array(
+ "${mysqlprefix}chatgroup" => array(
"groupid" => "int NOT NULL auto_increment PRIMARY KEY",
"vcemail" => "varchar(64)",
"vclocalname" => "varchar(64) NOT NULL",
@@ -29,7 +29,7 @@ $dbtables = array(
"vccommondescription" => "varchar(1024) NOT NULL",
),
- $mysqlprefix . "chatthread" => array(
+ "${mysqlprefix}chatthread" => array(
"threadid" => "int NOT NULL auto_increment PRIMARY KEY",
"userName" => "varchar(64) NOT NULL",
"userid" => "varchar(255)",
@@ -51,12 +51,12 @@ $dbtables = array(
"shownmessageid" => "int NOT NULL DEFAULT 0",
"userAgent" => "varchar(255)",
"messageCount" => "varchar(16)",
- "groupid" => "int references " . $mysqlprefix . "chatgroup(groupid)",
+ "groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
),
- $mysqlprefix . "chatmessage" => array(
+ "${mysqlprefix}chatmessage" => array(
"messageid" => "int NOT NULL auto_increment PRIMARY KEY",
- "threadid" => "int NOT NULL references " . $mysqlprefix . "chatthread(threadid)",
+ "threadid" => "int NOT NULL references ${mysqlprefix}chatthread(threadid)",
"ikind" => "int NOT NULL",
"agentId" => "int NOT NULL DEFAULT 0",
"tmessage" => "text NOT NULL",
@@ -64,7 +64,7 @@ $dbtables = array(
"tname" => "varchar(64)"
),
- $mysqlprefix . "chatoperator" => array(
+ "${mysqlprefix}chatoperator" => array(
"operatorid" => "int NOT NULL auto_increment PRIMARY KEY",
"vclogin" => "varchar(64) NOT NULL",
"vcpassword" => "varchar(64) NOT NULL",
@@ -81,16 +81,16 @@ $dbtables = array(
"vcrestoretoken" => "varchar(64)",
),
- $mysqlprefix . "chatrevision" => array(
+ "${mysqlprefix}chatrevision" => array(
"id" => "INT NOT NULL"
),
- $mysqlprefix . "chatgroupoperator" => array(
- "groupid" => "int NOT NULL references " . $mysqlprefix . "chatgroup(groupid)",
- "operatorid" => "int NOT NULL references " . $mysqlprefix . "chatoperator(operatorid)",
+ "${mysqlprefix}chatgroupoperator" => array(
+ "groupid" => "int NOT NULL references ${mysqlprefix}chatgroup(groupid)",
+ "operatorid" => "int NOT NULL references ${mysqlprefix}chatoperator(operatorid)",
),
- $mysqlprefix . "chatban" => array(
+ "${mysqlprefix}chatban" => array(
"banid" => "INT NOT NULL auto_increment PRIMARY KEY",
"dtmcreated" => "datetime DEFAULT 0",
"dtmtill" => "datetime DEFAULT 0",
@@ -99,20 +99,20 @@ $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)",
),
- $mysqlprefix . "chatresponses" => array(
+ "${mysqlprefix}chatresponses" => array(
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
"locale" => "varchar(8)",
- "groupid" => "int references " . $mysqlprefix . "chatgroup(groupid)",
+ "groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
"vcvalue" => "varchar(1024) NOT NULL",
),
- $mysqlprefix . "chatnotification" => array(
+ "${mysqlprefix}chatnotification" => array(
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
"locale" => "varchar(8)",
"vckind" => "varchar(16)",
@@ -120,21 +120,21 @@ $dbtables = array(
"dtmcreated" => "datetime DEFAULT 0",
"vcsubject" => "varchar(256)",
"tmessage" => "text NOT NULL",
- "refoperator" => "int NOT NULL references " . $mysqlprefix . "chatoperator(operatorid)",
+ "refoperator" => "int NOT NULL references ${mysqlprefix}chatoperator(operatorid)",
),
);
$memtables = array();
$dbtables_can_update = array(
- $mysqlprefix . "chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
- $mysqlprefix . "chatmessage" => array("agentId"),
- $mysqlprefix . "chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken", "inotify"),
- $mysqlprefix . "chatban" => array(),
- $mysqlprefix . "chatgroup" => array("vcemail"),
- $mysqlprefix . "chatgroupoperator" => array(),
- $mysqlprefix . "chatresponses" => array(),
- $mysqlprefix . "chatnotification" => array(),
+ "${mysqlprefix}chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
+ "${mysqlprefix}chatmessage" => array("agentId"),
+ "${mysqlprefix}chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken", "inotify"),
+ "${mysqlprefix}chatban" => array(),
+ "${mysqlprefix}chatgroup" => array("vcemail"),
+ "${mysqlprefix}chatgroupoperator" => array(),
+ "${mysqlprefix}chatresponses" => array(),
+ "${mysqlprefix}chatnotification" => array(),
);
function show_install_err($text) {
@@ -173,10 +173,10 @@ function create_table($id,$link) {
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);
}
}
diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php
index dee7b50e..475ef1f3 100644
--- a/src/messenger/webim/install/dbperform.php
+++ b/src/messenger/webim/install/dbperform.php
@@ -77,90 +77,90 @@ if ($act == "silentcreateall") {
}
}
- 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}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) ) {
- 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.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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD agentTyping int DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD userTyping int DEFAULT 0", $link);
+ 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) ) {
- 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.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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD nextagent int NOT NULL DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD shownmessageid int NOT NULL DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD userid varchar(255) DEFAULT \"\"", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD iperm int DEFAULT 65535", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD istatus int DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD inotify int DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD vcavatar varchar(255)", $link);
+ if( in_array("${mysqlprefix}chatoperator.vcavatar", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcavatar varchar(255)", $link);
}
- if( in_array($mysqlprefix . "chatoperator.vcjabbername", $absent) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD vcjabbername varchar(255)", $link);
+ if( in_array("${mysqlprefix}chatoperator.vcjabbername", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcjabbername varchar(255)", $link);
}
- if( in_array($mysqlprefix . "chatoperator.vcemail", $absent) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD vcemail varchar(64)", $link);
+ if( in_array("${mysqlprefix}chatoperator.vcemail", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcemail varchar(64)", $link);
}
- if( in_array($mysqlprefix . "chatoperator.dtmrestore", $absent) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD dtmrestore datetime DEFAULT 0", $link);
+ 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) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatoperator ADD vcrestoretoken varchar(64)", $link);
+ if( in_array("${mysqlprefix}chatoperator.vcrestoretoken", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcrestoretoken varchar(64)", $link);
}
- 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.groupid", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatthread ADD groupid int references ${mysqlprefix}chatgroup(groupid)", $link);
}
- if( in_array($mysqlprefix . "chatthread.userAgent", $absent) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatthread ADD userAgent varchar(255)", $link);
+ if( in_array("${mysqlprefix}chatthread.userAgent", $absent) ) {
+ runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userAgent varchar(255)", $link);
}
- if( in_array($mysqlprefix . "chatgroup.vcemail", $absent) ) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatgroup ADD vcemail varchar(64)", $link);
+ 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);
+ $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) {
- runsql("ALTER TABLE " . $mysqlprefix . "chatmessage ADD INDEX idx_agentid (agentid)", $link);
+ runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link);
}
}
}
diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php
index 03a6c276..9a4d8934 100644
--- a/src/messenger/webim/libs/chat.php
+++ b/src/messenger/webim/libs/chat.php
@@ -53,7 +53,7 @@ function next_token() {
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;
}
@@ -61,7 +61,7 @@ function next_revision($link) {
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)",
+ "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),
@@ -119,7 +119,7 @@ function get_messages($threadid,$meth,$isuser,&$lastid) {
$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" : "" );
@@ -374,7 +374,7 @@ function load_canned_messages($locale, $groupid) {
global $mysqlprefix;
$link = connect();
$result = select_multi_assoc(
- "select vcvalue from " . $mysqlprefix . "chatresponses where locale = '".$locale."' ".
+ "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) {
@@ -383,7 +383,7 @@ function load_canned_messages($locale, $groupid) {
}
if($groupid) {
$result2 = select_multi_assoc(
- "select vcvalue from " . $mysqlprefix . "chatresponses where locale = '".$locale."' ".
+ "select vcvalue from ${mysqlprefix}chatresponses where locale = '".$locale."' ".
"AND groupid = $groupid order by vcvalue", $link);
foreach($result as $r) {
$result2[] = $r;
@@ -444,7 +444,7 @@ function update_thread_access($threadid, $params, $link) {
$clause .= $k."=".$v;
}
perform_query(
- "update " . $mysqlprefix . "chatthread set $clause ".
+ "update ${mysqlprefix}chatthread set $clause ".
"where threadid = ".$threadid,$link);
}
@@ -487,7 +487,7 @@ function ping_thread($thread, $isuser,$istyping) {
function commit_thread($threadid,$params,$link) {
global $mysqlprefix;
- $query = "update " . $mysqlprefix . "chatthread t set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
+ $query = "update ${mysqlprefix}chatthread t set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
foreach( $params as $k => $v ) {
$query .= ", ".$k."=".$v;
}
@@ -515,7 +515,7 @@ function close_thread($thread,$isuser) {
$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);
+ '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'])
@@ -529,12 +529,12 @@ function thread_by_id_($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 );
+ " from ${mysqlprefix}chatthread where threadid = ". $id, $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) {
@@ -547,7 +547,7 @@ function thread_by_id($id) {
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 ".
+ "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),
@@ -655,9 +655,9 @@ function notify_operators($thread,$firstmessage,$link) {
global $settings, $mysqlprefix;
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";
+ $query = "select ${mysqlprefix}chatoperator.operatorid as opid, inotify, vcjabbername, vcemail, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
if($groupid) {
- $query .= ", " . $mysqlprefix . "chatgroupoperator where groupid = $groupid and " . $mysqlprefix . "chatoperator.operatorid = " . $mysqlprefix . "chatgroupoperator.operatorid and istatus = 0";
+ $query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = ${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
} else {
$query .= " where istatus = 0";
}
@@ -684,7 +684,7 @@ function check_connections_from_remote($remote,$link) {
return true;
}
$result = select_one_row(
- "select count(*) as opened from " . $mysqlprefix . "chatthread ".
+ "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'];
@@ -707,7 +707,6 @@ function visitor_from_request() {
$userName = getgetparam('name', $userName);
}
- $userId = "";
if (isset($_COOKIE[$usercookie])) {
$userId = $_COOKIE[$usercookie];
} else {
diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php
index 0abd5847..34a0bd86 100644
--- a/src/messenger/webim/libs/common.php
+++ b/src/messenger/webim/libs/common.php
@@ -600,7 +600,7 @@ function loadsettings_($link) {
}
$settingsloaded = true;
- $sqlresult = mysql_query("select vckey,vcvalue from " . $mysqlprefix . "chatconfig",$link) or die(' Query failed: '.mysql_error($link).": ".$query);
+ $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'];
diff --git a/src/messenger/webim/libs/groups.php b/src/messenger/webim/libs/groups.php
index 3a2aeaef..1688558e 100644
--- a/src/messenger/webim/libs/groups.php
+++ b/src/messenger/webim/libs/groups.php
@@ -23,7 +23,7 @@ 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;
}
@@ -52,7 +52,7 @@ function get_operator_groupslist($operatorid, $link) {
global $settings, $mysqlprefix;
if($settings['enablegroups'] == '1') {
$groupids = array(0);
- $allgroups = select_multi_assoc("select groupid from " . $mysqlprefix . "chatgroupoperator where operatorid = $operatorid order by groupid",$link);
+ $allgroups = select_multi_assoc("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid order by groupid",$link);
foreach($allgroups as $g) {
$groupids[] = $g['groupid'];
}
diff --git a/src/messenger/webim/libs/notify.php b/src/messenger/webim/libs/notify.php
index c34dc72c..113b2691 100644
--- a/src/messenger/webim/libs/notify.php
+++ b/src/messenger/webim/libs/notify.php
@@ -22,7 +22,7 @@
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)",
+ "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),
diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php
index fc0dc9b1..8bfc5114 100755
--- a/src/messenger/webim/libs/operator.php
+++ b/src/messenger/webim/libs/operator.php
@@ -37,7 +37,7 @@ 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;
}
@@ -46,7 +46,7 @@ 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;
}
@@ -54,7 +54,7 @@ function operator_by_email($mail) {
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) {
@@ -69,7 +69,7 @@ function operator_get_all() {
$link = connect();
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
- "from " . $mysqlprefix . "chatoperator order by vclogin";
+ "from ${mysqlprefix}chatoperator order by vclogin";
$operators = select_multi_assoc($query, $link);
mysql_close($link);
return $operators;
@@ -94,7 +94,7 @@ function update_operator($operatorid,$login,$email,$jabber,$password,$localename
global $mysqlprefix;
$link = connect();
$query = sprintf(
- "update " . $mysqlprefix . "chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%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),
@@ -114,7 +114,7 @@ function update_operator_avatar($operatorid,$avatar) {
global $mysqlprefix;
$link = connect();
$query = sprintf(
- "update " . $mysqlprefix . "chatoperator set vcavatar = '%s' where operatorid = %s",
+ "update ${mysqlprefix}chatoperator set vcavatar = '%s' where operatorid = %s",
mysql_real_escape_string($avatar), $operatorid );
perform_query($query,$link);
@@ -124,7 +124,7 @@ function update_operator_avatar($operatorid,$avatar) {
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)",
+ "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),
@@ -137,7 +137,7 @@ function create_operator_($login,$email,$jabber,$password,$localename,$commonnam
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) {
@@ -150,7 +150,7 @@ function create_operator($login,$email,$jabber,$password,$localename,$commonname
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);
}
@@ -158,10 +158,10 @@ 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";
+ $query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
if($groupid) {
- $query .= ", " . $mysqlprefix . "chatgroupoperator where groupid = $groupid and " . $mysqlprefix . "chatoperator.operatorid = " .
- $mysqlprefix . "chatgroupoperator.operatorid and istatus = 0";
+ $query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = " .
+ "${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
} else {
$query .= " where istatus = 0";
}
@@ -174,7 +174,7 @@ 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 ".
- "from " . $mysqlprefix . "chatoperator where operatorid = $operatorid";
+ "from ${mysqlprefix}chatoperator where operatorid = $operatorid";
$row = select_one_row($query,$link);
return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
}
@@ -196,12 +196,12 @@ function append_query($link,$pv) {
function check_login($redirect=true) {
global $webimroot, $mysqlprefix;
- if( !isset( $_SESSION[$mysqlprefix . 'operator'] ) ) {
+ 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 ) {
- $_SESSION[$mysqlprefix . 'operator'] = $op;
+ $_SESSION["${mysqlprefix}operator"] = $op;
return $op;
}
}
@@ -217,17 +217,17 @@ function check_login($redirect=true) {
return null;
}
}
- return $_SESSION[$mysqlprefix . 'operator'];
+ return $_SESSION["${mysqlprefix}operator"];
}
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) {
global $webimroot, $mysqlprefix;
- $_SESSION[$mysqlprefix . 'operator'] = $operator;
+ $_SESSION["${mysqlprefix}operator"] = $operator;
if( $remember ) {
$value = $operator['vclogin'].",".md5($operator['vcpassword']);
setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/");
@@ -239,7 +239,7 @@ function login_operator($operator,$remember) {
function logout_operator() {
global $webimroot, $mysqlprefix;
- unset($_SESSION[$mysqlprefix . 'operator']);
+ unset($_SESSION["${mysqlprefix}operator"]);
unset($_SESSION['backpath']);
if( isset($_COOKIE['webim_lite']) ) {
setcookie('webim_lite', '', time() - 3600, "$webimroot/");
@@ -251,11 +251,11 @@ function setup_redirect_links($threadid,$token) {
loadsettings();
$link = connect();
- $operatorscount = db_rows_count($mysqlprefix . "chatoperator", array(), "", $link);
+ $operatorscount = db_rows_count("${mysqlprefix}chatoperator", array(), "", $link);
$groupscount = 0;
+ $groups = array();
if($settings['enablegroups'] == "1") {
- $groups = array();
foreach(get_groups($link, true) as $group) {
if($group['inumofagents'] == 0) {
continue;
@@ -271,10 +271,9 @@ function setup_redirect_links($threadid,$token) {
$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);
+ "${mysqlprefix}chatoperator", array(), "order by vclogin $limit"), $link);
$groups = array_slice($groups, $p['start'], $p['end']-$p['start']);
-
mysql_close($link);
$agent_list = "";
@@ -348,34 +347,34 @@ function prepare_menu($operator,$hasright=true) {
function get_all_groups($link) {
global $mysqlprefix;
- $query = "select " . $mysqlprefix . "chatgroup.groupid as groupid, vclocalname, vclocaldescription from " . $mysqlprefix . "chatgroup order by vclocalname";
+ $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) {
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".
+ $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".
+ "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}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";
+ " from ${mysqlprefix}chatgroup order by vclocalname";
return select_multi_assoc($query, $link);
}
function get_operator_groupids($operatorid) {
global $mysqlprefix;
$link = connect();
- $query = "select groupid from " . $mysqlprefix . "chatgroupoperator where operatorid = $operatorid";
+ $query = "select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
diff --git a/src/messenger/webim/libs/settings.php b/src/messenger/webim/libs/settings.php
index 10904afd..9159867b 100644
--- a/src/messenger/webim/libs/settings.php
+++ b/src/messenger/webim/libs/settings.php
@@ -24,9 +24,9 @@ function update_settings() {
$link = connect();
foreach ($settings as $key => $value) {
if(!isset($settings_in_db[$key])) {
- perform_query("insert into " . $mysqlprefix . "chatconfig (vckey) values ('$key')",$link);
+ 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));
+ $query = sprintf("update ${mysqlprefix}chatconfig set vcvalue='%s' where vckey='$key'", mysql_real_escape_string($value));
perform_query($query,$link);
}
diff --git a/src/messenger/webim/operator/ban.php b/src/messenger/webim/operator/ban.php
index d038fd27..72a98b0e 100644
--- a/src/messenger/webim/operator/ban.php
+++ b/src/messenger/webim/operator/ban.php
@@ -64,14 +64,14 @@ if( isset($_POST['address']) ) {
$utime = time() + $days * 24*60*60;
if (!$banId) {
$query = sprintf(
- "insert into " . $mysqlprefix . "chatban (dtmcreated,dtmtill,address,comment) values (CURRENT_TIMESTAMP,%s,'%s','%s')",
+ "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);
} else {
$query = sprintf(
- "update " . $mysqlprefix . "chatban set dtmtill = %s,address = '%s',comment = '%s' where banid = $banId",
+ "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));
@@ -96,7 +96,7 @@ if( isset($_POST['address']) ) {
} 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);
+ $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 ) {
diff --git a/src/messenger/webim/operator/blocked.php b/src/messenger/webim/operator/blocked.php
index e6ab371e..9581edab 100644
--- a/src/messenger/webim/operator/blocked.php
+++ b/src/messenger/webim/operator/blocked.php
@@ -40,13 +40,13 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
}
if( count($errors) == 0 ) {
- perform_query("delete from " . $mysqlprefix . "chatban where banid = $banId",$link);
+ 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)
+$result = mysql_query("select banid,unix_timestamp(dtmtill) as till,address,comment from ${mysqlprefix}chatban", $link)
or die(' Query failed: ' .mysql_error());
$blockedList = array();
diff --git a/src/messenger/webim/operator/canned.php b/src/messenger/webim/operator/canned.php
index ef92a5fc..033acc69 100644
--- a/src/messenger/webim/operator/canned.php
+++ b/src/messenger/webim/operator/canned.php
@@ -34,7 +34,7 @@ $page = array();
function load_canned_messages($locale, $groupid) {
global $mysqlprefix;
$link = connect();
- $query = "select id, vcvalue from " . $mysqlprefix . "chatresponses ".
+ $query = "select id, vcvalue from ${mysqlprefix}chatresponses ".
"where locale = '".$locale."' AND (".
($groupid
? "groupid = $groupid"
@@ -47,7 +47,7 @@ function load_canned_messages($locale, $groupid) {
$result[] = array('id' => '', 'vcvalue' => $answer);
}
if(count($result) > 0) {
- $updatequery = "insert into " . $mysqlprefix . "chatresponses (vcvalue,locale,groupid) values ";
+ $updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values ";
for($i=0;$i 0) {
$updatequery .= ", ";
@@ -110,7 +110,7 @@ if(isset($_GET['act']) && $_GET['act'] == 'delete') {
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;
diff --git a/src/messenger/webim/operator/cannededit.php b/src/messenger/webim/operator/cannededit.php
index 6b8ffe10..0c137296 100644
--- a/src/messenger/webim/operator/cannededit.php
+++ b/src/messenger/webim/operator/cannededit.php
@@ -26,7 +26,7 @@ require_once('../libs/pagination.php');
function load_message($key) {
global $mysqlprefix;
$link = connect();
- $result = select_one_row("select vcvalue from " . $mysqlprefix . "chatresponses where id = $key", $link);
+ $result = select_one_row("select vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
mysql_close($link);
return $result ? $result['vcvalue'] : null;
}
@@ -34,7 +34,7 @@ function load_message($key) {
function save_message($key,$message) {
global $mysqlprefix;
$link = connect();
- perform_query("update " . $mysqlprefix . "chatresponses set vcvalue = '".mysql_real_escape_string($message,$link)."' ".
+ perform_query("update ${mysqlprefix}chatresponses set vcvalue = '".mysql_real_escape_string($message,$link)."' ".
"where id = $key", $link);
mysql_close($link);
}
@@ -42,7 +42,7 @@ function save_message($key,$message) {
function add_message($locale,$groupid,$message) {
global $mysqlprefix;
$link = connect();
- perform_query("insert into " . $mysqlprefix . "chatresponses (locale,groupid,vcvalue) values ('$locale',".
+ perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale',".
($groupid ? "$groupid, " : "null, ").
"'".mysql_real_escape_string($message,$link)."')", $link);
mysql_close($link);
diff --git a/src/messenger/webim/operator/group.php b/src/messenger/webim/operator/group.php
index 1b327ebf..8ba2cb82 100644
--- a/src/messenger/webim/operator/group.php
+++ b/src/messenger/webim/operator/group.php
@@ -33,7 +33,7 @@ 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;
}
@@ -42,7 +42,7 @@ 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')",
+ "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),
@@ -51,7 +51,7 @@ function create_group($name,$descr,$commonname,$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;
}
@@ -60,7 +60,7 @@ function update_group($groupid,$name,$descr,$commonname,$commondescr) {
global $mysqlprefix;
$link = connect();
$query = sprintf(
- "update " . $mysqlprefix . "chatgroup set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s' where groupid = %s",
+ "update ${mysqlprefix}chatgroup set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s' where groupid = %s",
mysql_real_escape_string($name),
mysql_real_escape_string($descr),
mysql_real_escape_string($commonname),
diff --git a/src/messenger/webim/operator/groupmembers.php b/src/messenger/webim/operator/groupmembers.php
index 3035d3f2..694b7759 100644
--- a/src/messenger/webim/operator/groupmembers.php
+++ b/src/messenger/webim/operator/groupmembers.php
@@ -28,7 +28,7 @@ $operator = check_login();
function get_group_members($groupid) {
global $mysqlprefix;
$link = connect();
- $query = "select operatorid from " . $mysqlprefix . "chatgroupoperator where groupid = $groupid";
+ $query = "select operatorid from ${mysqlprefix}chatgroupoperator where groupid = $groupid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
@@ -37,9 +37,9 @@ function get_group_members($groupid) {
function update_group_members($groupid,$newvalue) {
global $mysqlprefix;
$link = connect();
- perform_query("delete from " . $mysqlprefix . "chatgroupoperator where groupid = $groupid", $link);
+ perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid", $link);
foreach($newvalue as $opid) {
- perform_query("insert into " . $mysqlprefix . "chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
+ perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
}
mysql_close($link);
}
@@ -48,7 +48,7 @@ function get_operators() {
global $mysqlprefix;
$link = connect();
- $query = "select * from " . $mysqlprefix . "chatoperator order by vclogin";
+ $query = "select * from ${mysqlprefix}chatoperator order by vclogin";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
diff --git a/src/messenger/webim/operator/groups.php b/src/messenger/webim/operator/groups.php
index 7c83d9d1..57566822 100644
--- a/src/messenger/webim/operator/groups.php
+++ b/src/messenger/webim/operator/groups.php
@@ -38,9 +38,9 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
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;
diff --git a/src/messenger/webim/operator/history.php b/src/messenger/webim/operator/history.php
index 06d52635..3c26ce94 100644
--- a/src/messenger/webim/operator/history.php
+++ b/src/messenger/webim/operator/history.php
@@ -36,8 +36,8 @@ $query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']
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'];
@@ -46,17 +46,17 @@ if($query !== false) {
$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, ".
+ 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",
+ "${mysqlprefix}chatthread, ${mysqlprefix}chatmessage",
array(
- $mysqlprefix . "chatmessage.threadid = " . $mysqlprefix . "chatthread.threadid",
- "((" . $mysqlprefix . "chatthread.userName LIKE '%%$escapedQuery%%') or (" . $mysqlprefix . "chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
+ "${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);
+ "DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
mysql_close($link);
diff --git a/src/messenger/webim/operator/notification.php b/src/messenger/webim/operator/notification.php
index 6014b2df..d68e1393 100644
--- a/src/messenger/webim/operator/notification.php
+++ b/src/messenger/webim/operator/notification.php
@@ -33,7 +33,7 @@ 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",
+ "id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", "${mysqlprefix}chatnotification",
array("id = $id"), ""), $link);
mysql_close($link);
return $notification;
diff --git a/src/messenger/webim/operator/notifications.php b/src/messenger/webim/operator/notifications.php
index 0d35f0f0..4ea11352 100644
--- a/src/messenger/webim/operator/notifications.php
+++ b/src/messenger/webim/operator/notifications.php
@@ -65,7 +65,7 @@ if($lang) {
$link = connect();
select_with_pagintation(
- "id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", $mysqlprefix . "chatnotification",
+ "id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", "${mysqlprefix}chatnotification",
$conditions,
"order by created desc", "", $link);
diff --git a/src/messenger/webim/operator/operators.php b/src/messenger/webim/operator/operators.php
index 949b5158..f6a88dc6 100644
--- a/src/messenger/webim/operator/operators.php
+++ b/src/messenger/webim/operator/operators.php
@@ -50,8 +50,8 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
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");
diff --git a/src/messenger/webim/operator/opgroups.php b/src/messenger/webim/operator/opgroups.php
index a536ebdc..62999868 100644
--- a/src/messenger/webim/operator/opgroups.php
+++ b/src/messenger/webim/operator/opgroups.php
@@ -28,9 +28,9 @@ $operator = check_login();
function update_operator_groups($operatorid,$newvalue) {
global $mysqlprefix;
$link = connect();
- perform_query("delete from " . $mysqlprefix . "chatgroupoperator where operatorid = $operatorid", $link);
+ perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
foreach($newvalue as $groupid) {
- perform_query("insert into " . $mysqlprefix . "chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
+ perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
}
mysql_close($link);
}
diff --git a/src/messenger/webim/operator/permissions.php b/src/messenger/webim/operator/permissions.php
index 7cb9e34e..0c18e9e5 100755
--- a/src/messenger/webim/operator/permissions.php
+++ b/src/messenger/webim/operator/permissions.php
@@ -28,7 +28,7 @@ $operator = check_login();
function update_operator_permissions($operatorid,$newvalue) {
global $mysqlprefix;
$link = connect();
- $query = "update " . $mysqlprefix . "chatoperator set iperm = $newvalue where operatorid = $operatorid";
+ $query = "update ${mysqlprefix}chatoperator set iperm = $newvalue where operatorid = $operatorid";
perform_query($query,$link);
mysql_close($link);
@@ -62,8 +62,8 @@ if( !$op ) {
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;
+ if ($opId && $_SESSION["${mysqlprefix}operator"] && $operator['operatorid'] == $opId) {
+ $_SESSION["${mysqlprefix}operator"]['iperm'] = $new_permissions;
}
header("Location: $webimroot/operator/permissions.php?op=$opId&stored");
exit;
diff --git a/src/messenger/webim/operator/redirect.php b/src/messenger/webim/operator/redirect.php
index 78541eaa..08339919 100644
--- a/src/messenger/webim/operator/redirect.php
+++ b/src/messenger/webim/operator/redirect.php
@@ -69,7 +69,7 @@ if(isset($_GET['nextGroup'])) {
$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(FALSE === select_one_row("select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $nextid and groupid = ".$thread['groupid'], $link)) {
$threadupdate['groupid'] = 0;
}
}
diff --git a/src/messenger/webim/operator/resetpwd.php b/src/messenger/webim/operator/resetpwd.php
index 718c60f6..d8e194a2 100644
--- a/src/messenger/webim/operator/resetpwd.php
+++ b/src/messenger/webim/operator/resetpwd.php
@@ -53,7 +53,7 @@ if (count($errors) == 0 && isset($_POST['password'])) {
$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);
diff --git a/src/messenger/webim/operator/restore.php b/src/messenger/webim/operator/restore.php
index 610ad123..d86af70c 100644
--- a/src/messenger/webim/operator/restore.php
+++ b/src/messenger/webim/operator/restore.php
@@ -45,7 +45,7 @@ if (isset($_POST['loginoremail'])) {
$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";
diff --git a/src/messenger/webim/operator/statistics.php b/src/messenger/webim/operator/statistics.php
index d93d0f84..fc257049 100644
--- a/src/messenger/webim/operator/statistics.php
+++ b/src/messenger/webim/operator/statistics.php
@@ -69,14 +69,14 @@ if( $start > $end ) {
$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 ".
+ "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;
diff --git a/src/messenger/webim/operator/threadprocessor.php b/src/messenger/webim/operator/threadprocessor.php
index 6ff8aeee..663e1acf 100644
--- a/src/messenger/webim/operator/threadprocessor.php
+++ b/src/messenger/webim/operator/threadprocessor.php
@@ -37,7 +37,7 @@ function thread_info($id) {
$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 ".
+ "from ${mysqlprefix}chatthread left join ${mysqlprefix}chatgroup on ${mysqlprefix}chatthread.groupid = ${mysqlprefix}chatgroup.groupid ".
"where threadid = ". $id, $link );
mysql_close($link);
return $thread;
diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php
index cf1fbd95..04913461 100644
--- a/src/messenger/webim/operator/update.php
+++ b/src/messenger/webim/operator/update.php
@@ -50,9 +50,9 @@ $threadstate_key = array(
);
function thread_to_xml($thread,$link) {
- global $state_chatting, $threadstate_to_string, $threadstate_key, $mysqlprefix,
+ global $state_chatting, $threadstate_to_string, $threadstate_key,
$webim_encoding, $operator, $settings,
- $can_viewthreads, $can_takeover;
+ $can_viewthreads, $can_takeover, $mysqlprefix;
$state = $threadstate_to_string[$thread['istate']];
$result = "";
if( $thread["shownmessageid"] != 0 ) {
- $query = "select tmessage from " . $mysqlprefix . "chatmessage where messageid = ".$thread["shownmessageid"];
+ $query = "select tmessage from ${mysqlprefix}chatmessage where messageid = ".$thread["shownmessageid"];
$line = select_one_row($query, $link);
if( $line ) {
$message = preg_replace("/[\r\n\t]+/", " ", $line["tmessage"]);
@@ -119,8 +119,8 @@ function print_pending_threads($groupids,$since) {
$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 ".
+ "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 "
: "").
@@ -151,8 +151,7 @@ function print_pending_threads($groupids,$since) {
function print_operators() {
echo "";
$operators = operator_get_all();
- $names = array();
-
+
foreach($operators as $operator) {
if (!operator_is_online($operator))
continue;
diff --git a/src/messenger/webim/operator/userhistory.php b/src/messenger/webim/operator/userhistory.php
index c77674f1..2484ff4d 100644
--- a/src/messenger/webim/operator/userhistory.php
+++ b/src/messenger/webim/operator/userhistory.php
@@ -46,7 +46,7 @@ function threads_by_userid($userid) {
$query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, ".
" threadid, remote, agentName, userName ".
- "from " . $mysqlprefix . "chatthread ".
+ "from ${mysqlprefix}chatthread ".
"where userid=\"$userid\" order by created DESC", $userid);
$result = mysql_query($query, $link) or die(' Query failed: ' .mysql_error().": ".$query);