mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
$mysqlprefix variable added
This commit is contained in:
parent
00e9c651d5
commit
b18085de38
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$dbtables = array(
|
$dbtables = array(
|
||||||
"chatgroup" => array(
|
"${mysqlprefix}chatgroup" => array(
|
||||||
"groupid" => "int NOT NULL auto_increment PRIMARY KEY",
|
"groupid" => "int NOT NULL auto_increment PRIMARY KEY",
|
||||||
"vcemail" => "varchar(64)",
|
"vcemail" => "varchar(64)",
|
||||||
"vclocalname" => "varchar(64) NOT NULL",
|
"vclocalname" => "varchar(64) NOT NULL",
|
||||||
@ -29,7 +29,7 @@ $dbtables = array(
|
|||||||
"vccommondescription" => "varchar(1024) NOT NULL",
|
"vccommondescription" => "varchar(1024) NOT NULL",
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatthread" => array(
|
"${mysqlprefix}chatthread" => array(
|
||||||
"threadid" => "int NOT NULL auto_increment PRIMARY KEY",
|
"threadid" => "int NOT NULL auto_increment PRIMARY KEY",
|
||||||
"userName" => "varchar(64) NOT NULL",
|
"userName" => "varchar(64) NOT NULL",
|
||||||
"userid" => "varchar(255)",
|
"userid" => "varchar(255)",
|
||||||
@ -51,12 +51,12 @@ $dbtables = array(
|
|||||||
"shownmessageid" => "int NOT NULL DEFAULT 0",
|
"shownmessageid" => "int NOT NULL DEFAULT 0",
|
||||||
"userAgent" => "varchar(255)",
|
"userAgent" => "varchar(255)",
|
||||||
"messageCount" => "varchar(16)",
|
"messageCount" => "varchar(16)",
|
||||||
"groupid" => "int references chatgroup(groupid)",
|
"groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatmessage" => array(
|
"${mysqlprefix}chatmessage" => array(
|
||||||
"messageid" => "int NOT NULL auto_increment PRIMARY KEY",
|
"messageid" => "int NOT NULL auto_increment PRIMARY KEY",
|
||||||
"threadid" => "int NOT NULL references chatthread(threadid)",
|
"threadid" => "int NOT NULL references ${mysqlprefix}chatthread(threadid)",
|
||||||
"ikind" => "int NOT NULL",
|
"ikind" => "int NOT NULL",
|
||||||
"agentId" => "int NOT NULL DEFAULT 0",
|
"agentId" => "int NOT NULL DEFAULT 0",
|
||||||
"tmessage" => "text NOT NULL",
|
"tmessage" => "text NOT NULL",
|
||||||
@ -64,7 +64,7 @@ $dbtables = array(
|
|||||||
"tname" => "varchar(64)"
|
"tname" => "varchar(64)"
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatoperator" => array(
|
"${mysqlprefix}chatoperator" => array(
|
||||||
"operatorid" => "int NOT NULL auto_increment PRIMARY KEY",
|
"operatorid" => "int NOT NULL auto_increment PRIMARY KEY",
|
||||||
"vclogin" => "varchar(64) NOT NULL",
|
"vclogin" => "varchar(64) NOT NULL",
|
||||||
"vcpassword" => "varchar(64) NOT NULL",
|
"vcpassword" => "varchar(64) NOT NULL",
|
||||||
@ -80,16 +80,16 @@ $dbtables = array(
|
|||||||
"vcrestoretoken" => "varchar(64)",
|
"vcrestoretoken" => "varchar(64)",
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatrevision" => array(
|
"${mysqlprefix}chatrevision" => array(
|
||||||
"id" => "INT NOT NULL"
|
"id" => "INT NOT NULL"
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatgroupoperator" => array(
|
"${mysqlprefix}chatgroupoperator" => array(
|
||||||
"groupid" => "int NOT NULL references chatgroup(groupid)",
|
"groupid" => "int NOT NULL references ${mysqlprefix}chatgroup(groupid)",
|
||||||
"operatorid" => "int NOT NULL references chatoperator(operatorid)",
|
"operatorid" => "int NOT NULL references ${mysqlprefix}chatoperator(operatorid)",
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatban" => array(
|
"${mysqlprefix}chatban" => array(
|
||||||
"banid" => "INT NOT NULL auto_increment PRIMARY KEY",
|
"banid" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||||
"dtmcreated" => "datetime DEFAULT 0",
|
"dtmcreated" => "datetime DEFAULT 0",
|
||||||
"dtmtill" => "datetime DEFAULT 0",
|
"dtmtill" => "datetime DEFAULT 0",
|
||||||
@ -98,16 +98,16 @@ $dbtables = array(
|
|||||||
"blockedCount" => "int DEFAULT 0"
|
"blockedCount" => "int DEFAULT 0"
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatconfig" => array (
|
"${mysqlprefix}chatconfig" => array (
|
||||||
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||||
"vckey" => "varchar(255)",
|
"vckey" => "varchar(255)",
|
||||||
"vcvalue" => "varchar(255)",
|
"vcvalue" => "varchar(255)",
|
||||||
),
|
),
|
||||||
|
|
||||||
"chatresponses" => array(
|
"${mysqlprefix}chatresponses" => array(
|
||||||
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||||
"locale" => "varchar(8)",
|
"locale" => "varchar(8)",
|
||||||
"groupid" => "int references chatgroup(groupid)",
|
"groupid" => "int references ${mysqlprefix}chatgroup(groupid)",
|
||||||
"vcvalue" => "varchar(1024) NOT NULL",
|
"vcvalue" => "varchar(1024) NOT NULL",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -115,13 +115,13 @@ $dbtables = array(
|
|||||||
$memtables = array();
|
$memtables = array();
|
||||||
|
|
||||||
$dbtables_can_update = array(
|
$dbtables_can_update = array(
|
||||||
"chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
|
"${mysqlprefix}chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
|
||||||
"chatmessage" => array("agentId"),
|
"${mysqlprefix}chatmessage" => array("agentId"),
|
||||||
"chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken"),
|
"${mysqlprefix}chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken"),
|
||||||
"chatban" => array(),
|
"${mysqlprefix}chatban" => array(),
|
||||||
"chatgroup" => array("vcemail"),
|
"${mysqlprefix}chatgroup" => array("vcemail"),
|
||||||
"chatgroupoperator" => array(),
|
"${mysqlprefix}chatgroupoperator" => array(),
|
||||||
"chatresponses" => array(),
|
"${mysqlprefix}chatresponses" => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
function show_install_err($text) {
|
function show_install_err($text) {
|
||||||
@ -137,7 +137,7 @@ function show_install_err($text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create_table($id,$link) {
|
function create_table($id,$link) {
|
||||||
global $dbtables, $memtables, $dbencoding;
|
global $dbtables, $memtables, $dbencoding, $mysqlprefix;
|
||||||
|
|
||||||
if(!isset($dbtables[$id])) {
|
if(!isset($dbtables[$id])) {
|
||||||
show_install_err("Unknown table: $id, ".mysql_error());
|
show_install_err("Unknown table: $id, ".mysql_error());
|
||||||
@ -160,10 +160,10 @@ function create_table($id,$link) {
|
|||||||
|
|
||||||
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 == 'chatoperator' ) {
|
if( $id == "${mysqlprefix}chatoperator" ) {
|
||||||
create_operator_("admin", "", "", "Administrator", "Administrator", "", $link);
|
create_operator_("admin", "", "", "Administrator", "Administrator", "", $link);
|
||||||
} else if( $id == 'chatrevision' ) {
|
} else if( $id == "${mysqlprefix}chatrevision" ) {
|
||||||
perform_query("INSERT INTO chatrevision VALUES (1)",$link);
|
perform_query("INSERT INTO ${mysqlprefix}chatrevision VALUES (1)",$link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,86 +77,86 @@ if ($act == "silentcreateall") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatmessage.agentId", $absent) ) {
|
if( in_array("${mysqlprefix}chatmessage.agentId", $absent) ) {
|
||||||
runsql("ALTER TABLE chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind", $link);
|
||||||
runsql("update chatmessage,chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname)", $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("chatthread.agentId", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.agentId", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName", $link);
|
||||||
runsql("update chatthread,chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)", $link);
|
runsql("update ${mysqlprefix}chatthread,${mysqlprefix}chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.agentTyping", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.agentTyping", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD agentTyping int DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD agentTyping int DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.userTyping", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.userTyping", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD userTyping int DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userTyping int DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.messageCount", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.messageCount", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD messageCount varchar(16)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD messageCount varchar(16)", $link);
|
||||||
runsql("ALTER TABLE chatmessage ADD INDEX idx_threadid_ikind (threadid, ikind)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_threadid_ikind (threadid, ikind)", $link);
|
||||||
runsql("UPDATE chatthread t SET t.messageCount = (SELECT COUNT(*) FROM chatmessage WHERE chatmessage.threadid = t.threadid AND ikind = 1)", $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 chatmessage DROP INDEX idx_threadid_ikind", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatmessage DROP INDEX idx_threadid_ikind", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.nextagent", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.nextagent", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD nextagent int NOT NULL DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD nextagent int NOT NULL DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.shownmessageid", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.shownmessageid", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD shownmessageid int NOT NULL DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD shownmessageid int NOT NULL DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.userid", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.userid", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD userid varchar(255) DEFAULT \"\"", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userid varchar(255) DEFAULT \"\"", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.iperm", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.iperm", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD iperm int DEFAULT 65535", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD iperm int DEFAULT 65535", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.istatus", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.istatus", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD istatus int DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD istatus int DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.vcavatar", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.vcavatar", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD vcavatar varchar(255)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcavatar varchar(255)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.vcjabbername", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.vcjabbername", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD vcjabbername varchar(255)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcjabbername varchar(255)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.vcemail", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.vcemail", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD vcemail varchar(64)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcemail varchar(64)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.dtmrestore", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.dtmrestore", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD dtmrestore datetime DEFAULT 0", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD dtmrestore datetime DEFAULT 0", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatoperator.vcrestoretoken", $absent) ) {
|
if( in_array("${mysqlprefix}chatoperator.vcrestoretoken", $absent) ) {
|
||||||
runsql("ALTER TABLE chatoperator ADD vcrestoretoken varchar(64)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatoperator ADD vcrestoretoken varchar(64)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.groupid", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.groupid", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD groupid int references chatgroup(groupid)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD groupid int references ${mysqlprefix}chatgroup(groupid)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatthread.userAgent", $absent) ) {
|
if( in_array("${mysqlprefix}chatthread.userAgent", $absent) ) {
|
||||||
runsql("ALTER TABLE chatthread ADD userAgent varchar(255)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatthread ADD userAgent varchar(255)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( in_array("chatgroup.vcemail", $absent) ) {
|
if( in_array("${mysqlprefix}chatgroup.vcemail", $absent) ) {
|
||||||
runsql("ALTER TABLE chatgroup ADD vcemail varchar(64)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatgroup ADD vcemail varchar(64)", $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = mysql_query("select null from information_schema.statistics where table_name = '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) {
|
if($res && mysql_num_rows($res) == 0) {
|
||||||
runsql("ALTER TABLE chatmessage ADD INDEX idx_agentid (agentid)", $link);
|
runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,16 @@ function next_token() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function next_revision($link) {
|
function next_revision($link) {
|
||||||
perform_query("update chatrevision set id=LAST_INSERT_ID(id+1)",$link);
|
global $mysqlprefix;
|
||||||
|
perform_query("update ${mysqlprefix}chatrevision set id=LAST_INSERT_ID(id+1)",$link);
|
||||||
$val = mysql_insert_id($link);
|
$val = mysql_insert_id($link);
|
||||||
return $val;
|
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(
|
$query = sprintf(
|
||||||
"insert into 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,
|
$threadid,
|
||||||
$kind,
|
$kind,
|
||||||
mysql_real_escape_string($message,$link),
|
mysql_real_escape_string($message,$link),
|
||||||
@ -113,11 +115,11 @@ function message_to_text($msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_messages($threadid,$meth,$isuser,&$lastid) {
|
function get_messages($threadid,$meth,$isuser,&$lastid) {
|
||||||
global $kind_for_agent, $kind_avatar, $webim_encoding;
|
global $kind_for_agent, $kind_avatar, $webim_encoding, $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from chatmessage ".
|
"select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from ${mysqlprefix}chatmessage ".
|
||||||
"where threadid = %s and messageid > %s %s order by messageid",
|
"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" : "" );
|
||||||
|
|
||||||
@ -369,9 +371,10 @@ function setup_chatview_for_user($thread,$level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function load_canned_messages($locale, $groupid) {
|
function load_canned_messages($locale, $groupid) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$result = select_multi_assoc(
|
$result = select_multi_assoc(
|
||||||
"select vcvalue from chatresponses where locale = '".$locale."' ".
|
"select vcvalue from ${mysqlprefix}chatresponses where locale = '".$locale."' ".
|
||||||
"AND (groupid is NULL OR groupid = 0) order by vcvalue", $link);
|
"AND (groupid is NULL OR groupid = 0) order by vcvalue", $link);
|
||||||
if(count($result) == 0) {
|
if(count($result) == 0) {
|
||||||
foreach(explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
foreach(explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
|
||||||
@ -380,7 +383,7 @@ function load_canned_messages($locale, $groupid) {
|
|||||||
}
|
}
|
||||||
if($groupid) {
|
if($groupid) {
|
||||||
$result2 = select_multi_assoc(
|
$result2 = select_multi_assoc(
|
||||||
"select vcvalue from chatresponses where locale = '".$locale."' ".
|
"select vcvalue from ${mysqlprefix}chatresponses where locale = '".$locale."' ".
|
||||||
"AND groupid = $groupid order by vcvalue", $link);
|
"AND groupid = $groupid order by vcvalue", $link);
|
||||||
foreach($result as $r) {
|
foreach($result as $r) {
|
||||||
$result2[] = $r;
|
$result2[] = $r;
|
||||||
@ -433,6 +436,7 @@ function setup_chatview_for_operator($thread,$operator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_thread_access($threadid, $params, $link) {
|
function update_thread_access($threadid, $params, $link) {
|
||||||
|
global $mysqlprefix;
|
||||||
$clause = "";
|
$clause = "";
|
||||||
foreach( $params as $k => $v ) {
|
foreach( $params as $k => $v ) {
|
||||||
if( strlen($clause) > 0 )
|
if( strlen($clause) > 0 )
|
||||||
@ -440,7 +444,7 @@ function update_thread_access($threadid, $params, $link) {
|
|||||||
$clause .= $k."=".$v;
|
$clause .= $k."=".$v;
|
||||||
}
|
}
|
||||||
perform_query(
|
perform_query(
|
||||||
"update chatthread set $clause ".
|
"update ${mysqlprefix}chatthread set $clause ".
|
||||||
"where threadid = ".$threadid,$link);
|
"where threadid = ".$threadid,$link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +486,8 @@ function ping_thread($thread, $isuser,$istyping) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function commit_thread($threadid,$params,$link) {
|
function commit_thread($threadid,$params,$link) {
|
||||||
$query = "update chatthread t set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
|
global $mysqlprefix;
|
||||||
|
$query = "update ${mysqlprefix}chatthread t set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
|
||||||
foreach( $params as $k => $v ) {
|
foreach( $params as $k => $v ) {
|
||||||
$query .= ", ".$k."=".$v;
|
$query .= ", ".$k."=".$v;
|
||||||
}
|
}
|
||||||
@ -505,12 +510,12 @@ function rename_user($thread, $newname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function close_thread($thread,$isuser) {
|
function close_thread($thread,$isuser) {
|
||||||
global $state_closed, $kind_events;
|
global $state_closed, $kind_events, $mysqlprefix;
|
||||||
|
|
||||||
$link = connect();
|
$link = connect();
|
||||||
if( $thread['istate'] != $state_closed ) {
|
if( $thread['istate'] != $state_closed ) {
|
||||||
commit_thread( $thread['threadid'], array('istate' => $state_closed,
|
commit_thread( $thread['threadid'], array('istate' => $state_closed,
|
||||||
'messageCount' => '(SELECT COUNT(*) FROM chatmessage WHERE 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'])
|
$message = $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
|
||||||
@ -520,14 +525,16 @@ function close_thread($thread,$isuser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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".
|
return select_one_row("select threadid,userName,agentName,agentId,lrevision,istate,ltoken,userTyping,agentTyping".
|
||||||
",unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created".
|
",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".
|
",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 chatthread where threadid = ". $id, $link );
|
" from ${mysqlprefix}chatthread where threadid = ". $id, $link );
|
||||||
}
|
}
|
||||||
|
|
||||||
function ban_for_addr_($addr,$link) {
|
function ban_for_addr_($addr,$link) {
|
||||||
return select_one_row("select banid,comment from chatban where unix_timestamp(dtmtill) > unix_timestamp(CURRENT_TIMESTAMP) AND address = '".mysql_real_escape_string($addr,$link)."'", $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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
function thread_by_id($id) {
|
function thread_by_id($id) {
|
||||||
@ -538,8 +545,9 @@ function thread_by_id($id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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(
|
$query = sprintf(
|
||||||
"insert into 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":"").")",
|
"('%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($username, $link),
|
||||||
mysql_real_escape_string($userid, $link),
|
mysql_real_escape_string($userid, $link),
|
||||||
@ -644,12 +652,12 @@ function check_for_reassign($thread,$operator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_connections_from_remote($remote,$link) {
|
function check_connections_from_remote($remote,$link) {
|
||||||
global $settings, $state_closed, $state_left;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
$result = select_one_row(
|
$result = select_one_row(
|
||||||
"select count(*) as opened from 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 );
|
"where remote = '". mysql_real_escape_string($remote, $link)."' AND istate <> $state_closed AND istate <> $state_left", $link );
|
||||||
if($result && isset($result['opened'])) {
|
if($result && isset($result['opened'])) {
|
||||||
return $result['opened'] < $settings['max_connections_from_one_host'];
|
return $result['opened'] < $settings['max_connections_from_one_host'];
|
||||||
@ -672,7 +680,6 @@ function visitor_from_request() {
|
|||||||
$userName = getgetparam('name', $userName);
|
$userName = getgetparam('name', $userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$userId = "";
|
|
||||||
if (isset($_COOKIE[$usercookie])) {
|
if (isset($_COOKIE[$usercookie])) {
|
||||||
$userId = $_COOKIE[$usercookie];
|
$userId = $_COOKIE[$usercookie];
|
||||||
} else {
|
} else {
|
||||||
|
@ -593,13 +593,13 @@ $settingsloaded = false;
|
|||||||
$settings_in_db = array();
|
$settings_in_db = array();
|
||||||
|
|
||||||
function loadsettings_($link) {
|
function loadsettings_($link) {
|
||||||
global $settingsloaded, $settings_in_db, $settings;
|
global $settingsloaded, $settings_in_db, $settings, $mysqlprefix;
|
||||||
if($settingsloaded) {
|
if($settingsloaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$settingsloaded = true;
|
$settingsloaded = true;
|
||||||
|
|
||||||
$sqlresult = mysql_query("select vckey,vcvalue from 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)) {
|
while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
|
||||||
$name = $row['vckey'];
|
$name = $row['vckey'];
|
||||||
|
@ -36,6 +36,7 @@ $mysqlhost = "localhost";
|
|||||||
$mysqldb = "webim_db";
|
$mysqldb = "webim_db";
|
||||||
$mysqllogin = "webim_lite";
|
$mysqllogin = "webim_lite";
|
||||||
$mysqlpass = "123";
|
$mysqlpass = "123";
|
||||||
|
$mysqlprefix = "";
|
||||||
|
|
||||||
$dbencoding = "utf8";
|
$dbencoding = "utf8";
|
||||||
$force_charset_in_connection = true;
|
$force_charset_in_connection = true;
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function group_by_id($id) {
|
function group_by_id($id) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$group = select_one_row(
|
$group = select_one_row(
|
||||||
"select * from chatgroup where groupid = $id", $link );
|
"select * from ${mysqlprefix}chatgroup where groupid = $id", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
@ -48,10 +49,10 @@ function setup_group_settings_tabs($gid, $active) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_operator_groupslist($operatorid, $link) {
|
function get_operator_groupslist($operatorid, $link) {
|
||||||
global $settings;
|
global $settings, $mysqlprefix;
|
||||||
if($settings['enablegroups'] == '1') {
|
if($settings['enablegroups'] == '1') {
|
||||||
$groupids = array(0);
|
$groupids = array(0);
|
||||||
$allgroups = select_multi_assoc("select groupid from 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) {
|
foreach($allgroups as $g) {
|
||||||
$groupids[] = $g['groupid'];
|
$groupids[] = $g['groupid'];
|
||||||
}
|
}
|
||||||
|
@ -34,24 +34,27 @@ $permission_ids = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function operator_by_login($login) {
|
function operator_by_login($login) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$operator = select_one_row(
|
$operator = select_one_row(
|
||||||
"select * from chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
|
"select * from ${mysqlprefix}chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_email($mail) {
|
function operator_by_email($mail) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$operator = select_one_row(
|
$operator = select_one_row(
|
||||||
"select * from chatoperator where vcemail = '".mysql_real_escape_string($mail)."'", $link );
|
"select * from ${mysqlprefix}chatoperator where vcemail = '".mysql_real_escape_string($mail)."'", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_id_($id,$link) {
|
function operator_by_id_($id,$link) {
|
||||||
|
global $mysqlprefix;
|
||||||
return select_one_row(
|
return select_one_row(
|
||||||
"select * from chatoperator where operatorid = $id", $link );
|
"select * from ${mysqlprefix}chatoperator where operatorid = $id", $link );
|
||||||
}
|
}
|
||||||
|
|
||||||
function operator_by_id($id) {
|
function operator_by_id($id) {
|
||||||
@ -62,10 +65,11 @@ function operator_by_id($id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function operator_get_all() {
|
function operator_get_all() {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$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 chatoperator order by vclogin";
|
"from ${mysqlprefix}chatoperator order by vclogin";
|
||||||
$operators = select_multi_assoc($query, $link);
|
$operators = select_multi_assoc($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operators;
|
return $operators;
|
||||||
@ -87,9 +91,10 @@ function operator_is_away($operator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_operator($operatorid,$login,$email,$password,$localename,$commonname) {
|
function update_operator($operatorid,$login,$email,$password,$localename,$commonname) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
|
"update ${mysqlprefix}chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'".
|
||||||
", vcemail = '%s', vcjabbername= '%s'".
|
", vcemail = '%s', vcjabbername= '%s'".
|
||||||
" where operatorid = %s",
|
" where operatorid = %s",
|
||||||
mysql_real_escape_string($login),
|
mysql_real_escape_string($login),
|
||||||
@ -105,9 +110,10 @@ function update_operator($operatorid,$login,$email,$password,$localename,$common
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_operator_avatar($operatorid,$avatar) {
|
function update_operator_avatar($operatorid,$avatar) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update chatoperator set vcavatar = '%s' where operatorid = %s",
|
"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);
|
||||||
@ -115,8 +121,9 @@ function update_operator_avatar($operatorid,$avatar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create_operator_($login,$email,$password,$localename,$commonname,$avatar,$link) {
|
function create_operator_($login,$email,$password,$localename,$commonname,$avatar,$link) {
|
||||||
|
global $mysqlprefix;
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername) values ('%s','%s','%s','%s','%s','%s','%s')",
|
"insert into ${mysqlprefix}chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername) values ('%s','%s','%s','%s','%s','%s','%s')",
|
||||||
mysql_real_escape_string($login),
|
mysql_real_escape_string($login),
|
||||||
md5($password),
|
md5($password),
|
||||||
mysql_real_escape_string($localename),
|
mysql_real_escape_string($localename),
|
||||||
@ -127,7 +134,7 @@ function create_operator_($login,$email,$password,$localename,$commonname,$avata
|
|||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
$id = mysql_insert_id($link);
|
$id = mysql_insert_id($link);
|
||||||
|
|
||||||
return select_one_row("select * from chatoperator where operatorid = $id", $link );
|
return select_one_row("select * from ${mysqlprefix}chatoperator where operatorid = $id", $link );
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_operator($login,$email,$password,$localename,$commonname,$avatar) {
|
function create_operator($login,$email,$password,$localename,$commonname,$avatar) {
|
||||||
@ -138,18 +145,19 @@ function create_operator($login,$email,$password,$localename,$commonname,$avatar
|
|||||||
}
|
}
|
||||||
|
|
||||||
function notify_operator_alive($operatorid, $istatus) {
|
function notify_operator_alive($operatorid, $istatus) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("update 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);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function has_online_operators($groupid="") {
|
function has_online_operators($groupid="") {
|
||||||
global $settings;
|
global $settings, $mysqlprefix;
|
||||||
loadsettings();
|
loadsettings();
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator";
|
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from ${mysqlprefix}chatoperator";
|
||||||
if($groupid) {
|
if($groupid) {
|
||||||
$query .= ", chatgroupoperator where groupid = $groupid and chatoperator.operatorid = chatgroupoperator.operatorid and istatus = 0";
|
$query .= ", ${mysqlprefix}chatgroupoperator where groupid = $groupid and ${mysqlprefix}chatoperator.operatorid = ${mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
|
||||||
} else {
|
} else {
|
||||||
$query .= " where istatus = 0";
|
$query .= " where istatus = 0";
|
||||||
}
|
}
|
||||||
@ -159,10 +167,10 @@ function has_online_operators($groupid="") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function is_operator_online($operatorid, $link) {
|
function is_operator_online($operatorid, $link) {
|
||||||
global $settings;
|
global $settings, $mysqlprefix;
|
||||||
loadsettings_($link);
|
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 chatoperator where operatorid = $operatorid";
|
"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;
|
return $row['time'] < $settings['online_timeout'] && $row['total'] == 1;
|
||||||
}
|
}
|
||||||
@ -234,15 +242,15 @@ function logout_operator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup_redirect_links($threadid,$token) {
|
function setup_redirect_links($threadid,$token) {
|
||||||
global $page, $webimroot, $settings;
|
global $page, $webimroot, $settings, $mysqlprefix;
|
||||||
loadsettings();
|
loadsettings();
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$operatorscount = db_rows_count("chatoperator", array(), "", $link);
|
$operatorscount = db_rows_count("${mysqlprefix}chatoperator", array(), "", $link);
|
||||||
|
|
||||||
$groupscount = 0;
|
$groupscount = 0;
|
||||||
|
$groups = array();
|
||||||
if($settings['enablegroups'] == "1") {
|
if($settings['enablegroups'] == "1") {
|
||||||
$groups = array();
|
|
||||||
foreach(get_groups($link, true) as $group) {
|
foreach(get_groups($link, true) as $group) {
|
||||||
if($group['inumofagents'] == 0) {
|
if($group['inumofagents'] == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -258,10 +266,9 @@ function setup_redirect_links($threadid,$token) {
|
|||||||
|
|
||||||
$operators = select_multi_assoc(db_build_select(
|
$operators = select_multi_assoc(db_build_select(
|
||||||
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
"operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time",
|
||||||
"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']);
|
$groups = array_slice($groups, $p['start'], $p['end']-$p['start']);
|
||||||
|
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
|
||||||
$agent_list = "";
|
$agent_list = "";
|
||||||
@ -334,29 +341,32 @@ function prepare_menu($operator,$hasright=true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_all_groups($link) {
|
function get_all_groups($link) {
|
||||||
$query = "select chatgroup.groupid as groupid, vclocalname, vclocaldescription from chatgroup order by vclocalname";
|
global $mysqlprefix;
|
||||||
|
$query = "select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname, vclocaldescription from ${mysqlprefix}chatgroup order by vclocalname";
|
||||||
return select_multi_assoc($query, $link);
|
return select_multi_assoc($query, $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_groups($link,$checkaway) {
|
function get_groups($link,$checkaway) {
|
||||||
$query = "select chatgroup.groupid as groupid, vclocalname, vclocaldescription".
|
global $mysqlprefix;
|
||||||
", (SELECT count(*) from chatgroupoperator where chatgroup.groupid = 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 ".
|
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
"from chatgroupoperator, chatoperator where istatus = 0 and chatgroup.groupid = chatgroupoperator.groupid ".
|
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus = 0 and ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid ".
|
||||||
"and chatgroupoperator.operatorid = chatoperator.operatorid) as ilastseen".
|
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseen".
|
||||||
($checkaway
|
($checkaway
|
||||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||||
"from chatgroupoperator, chatoperator where istatus <> 0 and chatgroup.groupid = chatgroupoperator.groupid ".
|
"from ${mysqlprefix}chatgroupoperator, ${mysqlprefix}chatoperator where istatus <> 0 and ${mysqlprefix}chatgroup.groupid = ${mysqlprefix}chatgroupoperator.groupid ".
|
||||||
"and chatgroupoperator.operatorid = chatoperator.operatorid) as ilastseenaway"
|
"and ${mysqlprefix}chatgroupoperator.operatorid = ${mysqlprefix}chatoperator.operatorid) as ilastseenaway"
|
||||||
: ""
|
: ""
|
||||||
).
|
).
|
||||||
" from chatgroup order by vclocalname";
|
" from ${mysqlprefix}chatgroup order by vclocalname";
|
||||||
return select_multi_assoc($query, $link);
|
return select_multi_assoc($query, $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_operator_groupids($operatorid) {
|
function get_operator_groupids($operatorid) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "select groupid from chatgroupoperator where operatorid = $operatorid";
|
$query = "select groupid from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid";
|
||||||
$result = select_multi_assoc($query, $link);
|
$result = select_multi_assoc($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function update_settings() {
|
function update_settings() {
|
||||||
global $settings, $settings_in_db;
|
global $settings, $settings_in_db, $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
foreach ($settings as $key => $value) {
|
foreach ($settings as $key => $value) {
|
||||||
if(!isset($settings_in_db[$key])) {
|
if(!isset($settings_in_db[$key])) {
|
||||||
perform_query("insert into chatconfig (vckey) values ('$key')",$link);
|
perform_query("insert into ${mysqlprefix}chatconfig (vckey) values ('$key')",$link);
|
||||||
}
|
}
|
||||||
$query = sprintf("update 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);
|
perform_query($query,$link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ if( isset($_POST['address']) ) {
|
|||||||
$utime = time() + $days * 24*60*60;
|
$utime = time() + $days * 24*60*60;
|
||||||
if (!$banId) {
|
if (!$banId) {
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"insert into 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)",
|
"FROM_UNIXTIME($utime)",
|
||||||
mysql_real_escape_string($address,$link),
|
mysql_real_escape_string($address,$link),
|
||||||
mysql_real_escape_string($comment,$link));
|
mysql_real_escape_string($comment,$link));
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
} else {
|
} else {
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update 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)",
|
"FROM_UNIXTIME($utime)",
|
||||||
mysql_real_escape_string($address,$link),
|
mysql_real_escape_string($address,$link),
|
||||||
mysql_real_escape_string($comment,$link));
|
mysql_real_escape_string($comment,$link));
|
||||||
@ -96,7 +96,7 @@ if( isset($_POST['address']) ) {
|
|||||||
} else if(isset($_GET['id'])) {
|
} else if(isset($_GET['id'])) {
|
||||||
$banId = verifyparam( 'id', "/^\d{1,9}$/");
|
$banId = verifyparam( 'id', "/^\d{1,9}$/");
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$ban = select_one_row("select banid,(unix_timestamp(dtmtill)-unix_timestamp(CURRENT_TIMESTAMP)) as days,address,comment from 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);
|
mysql_close($link);
|
||||||
|
|
||||||
if( $ban ) {
|
if( $ban ) {
|
||||||
|
@ -40,13 +40,13 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( count($errors) == 0 ) {
|
if( count($errors) == 0 ) {
|
||||||
perform_query("delete from chatban where banid = $banId",$link);
|
perform_query("delete from ${mysqlprefix}chatban where banid = $banId",$link);
|
||||||
header("Location: $webimroot/operator/blocked.php");
|
header("Location: $webimroot/operator/blocked.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = mysql_query("select banid,unix_timestamp(dtmtill) as till,address,comment from chatban", $link)
|
$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();
|
$blockedList = array();
|
||||||
|
@ -32,8 +32,9 @@ $errors = array();
|
|||||||
$page = array();
|
$page = array();
|
||||||
|
|
||||||
function load_canned_messages($locale, $groupid) {
|
function load_canned_messages($locale, $groupid) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "select id, vcvalue from chatresponses ".
|
$query = "select id, vcvalue from ${mysqlprefix}chatresponses ".
|
||||||
"where locale = '".$locale."' AND (".
|
"where locale = '".$locale."' AND (".
|
||||||
($groupid
|
($groupid
|
||||||
? "groupid = $groupid"
|
? "groupid = $groupid"
|
||||||
@ -46,7 +47,7 @@ function load_canned_messages($locale, $groupid) {
|
|||||||
$result[] = array('id' => '', 'vcvalue' => $answer);
|
$result[] = array('id' => '', 'vcvalue' => $answer);
|
||||||
}
|
}
|
||||||
if(count($result) > 0) {
|
if(count($result) > 0) {
|
||||||
$updatequery = "insert into chatresponses (vcvalue,locale,groupid) values ";
|
$updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values ";
|
||||||
for($i=0;$i<count($result);$i++) {
|
for($i=0;$i<count($result);$i++) {
|
||||||
if($i > 0) {
|
if($i > 0) {
|
||||||
$updatequery .= ", ";
|
$updatequery .= ", ";
|
||||||
@ -109,7 +110,7 @@ if(isset($_GET['act']) && $_GET['act'] == 'delete') {
|
|||||||
|
|
||||||
if( count($errors) == 0 ) {
|
if( count($errors) == 0 ) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("delete from chatresponses where id = $key",$link);
|
perform_query("delete from ${mysqlprefix}chatresponses where id = $key",$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
header("Location: $webimroot/operator/canned.php?lang=$lang&group=$groupid");
|
header("Location: $webimroot/operator/canned.php?lang=$lang&group=$groupid");
|
||||||
exit;
|
exit;
|
||||||
|
@ -24,22 +24,25 @@ require_once('../libs/operator.php');
|
|||||||
require_once('../libs/pagination.php');
|
require_once('../libs/pagination.php');
|
||||||
|
|
||||||
function load_message($key) {
|
function load_message($key) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$result = select_one_row("select vcvalue from chatresponses where id = $key", $link);
|
$result = select_one_row("select vcvalue from ${mysqlprefix}chatresponses where id = $key", $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $result ? $result['vcvalue'] : null;
|
return $result ? $result['vcvalue'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_message($key,$message) {
|
function save_message($key,$message) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("update 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);
|
"where id = $key", $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_message($locale,$groupid,$message) {
|
function add_message($locale,$groupid,$message) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("insert into chatresponses (locale,groupid,vcvalue) values ('$locale',".
|
perform_query("insert into ${mysqlprefix}chatresponses (locale,groupid,vcvalue) values ('$locale',".
|
||||||
($groupid ? "$groupid, " : "null, ").
|
($groupid ? "$groupid, " : "null, ").
|
||||||
"'".mysql_real_escape_string($message,$link)."')", $link);
|
"'".mysql_real_escape_string($message,$link)."')", $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
@ -30,17 +30,19 @@ $errors = array();
|
|||||||
$groupid = '';
|
$groupid = '';
|
||||||
|
|
||||||
function group_by_name($name) {
|
function group_by_name($name) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$group = select_one_row(
|
$group = select_one_row(
|
||||||
"select * from chatgroup where vclocalname = '".mysql_real_escape_string($name)."'", $link );
|
"select * from ${mysqlprefix}chatgroup where vclocalname = '".mysql_real_escape_string($name)."'", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_group($name,$descr,$commonname,$commondescr) {
|
function create_group($name,$descr,$commonname,$commondescr) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"insert into 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($name),
|
||||||
mysql_real_escape_string($descr),
|
mysql_real_escape_string($descr),
|
||||||
mysql_real_escape_string($commonname),
|
mysql_real_escape_string($commonname),
|
||||||
@ -49,15 +51,16 @@ function create_group($name,$descr,$commonname,$commondescr) {
|
|||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
$id = mysql_insert_id($link);
|
$id = mysql_insert_id($link);
|
||||||
|
|
||||||
$newdep = select_one_row("select * from chatgroup where groupid = $id", $link );
|
$newdep = select_one_row("select * from ${mysqlprefix}chatgroup where groupid = $id", $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $newdep;
|
return $newdep;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_group($groupid,$name,$descr,$commonname,$commondescr) {
|
function update_group($groupid,$name,$descr,$commonname,$commondescr) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"update 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($name),
|
||||||
mysql_real_escape_string($descr),
|
mysql_real_escape_string($descr),
|
||||||
mysql_real_escape_string($commonname),
|
mysql_real_escape_string($commonname),
|
||||||
|
@ -26,26 +26,29 @@ require_once('../libs/groups.php');
|
|||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
function get_group_members($groupid) {
|
function get_group_members($groupid) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "select operatorid from chatgroupoperator where groupid = $groupid";
|
$query = "select operatorid from ${mysqlprefix}chatgroupoperator where groupid = $groupid";
|
||||||
$result = select_multi_assoc($query, $link);
|
$result = select_multi_assoc($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_group_members($groupid,$newvalue) {
|
function update_group_members($groupid,$newvalue) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("delete from chatgroupoperator where groupid = $groupid", $link);
|
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid", $link);
|
||||||
foreach($newvalue as $opid) {
|
foreach($newvalue as $opid) {
|
||||||
perform_query("insert into chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
|
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
|
||||||
}
|
}
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_operators() {
|
function get_operators() {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$query = "select * from chatoperator order by vclogin";
|
$query = "select * from ${mysqlprefix}chatoperator order by vclogin";
|
||||||
$result = select_multi_assoc($query, $link);
|
$result = select_multi_assoc($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -38,9 +38,9 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
|||||||
|
|
||||||
if( count($errors) == 0 ) {
|
if( count($errors) == 0 ) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("delete from chatgroup where groupid = $groupid",$link);
|
perform_query("delete from ${mysqlprefix}chatgroup where groupid = $groupid",$link);
|
||||||
perform_query("delete from chatgroupoperator where groupid = $groupid",$link);
|
perform_query("delete from ${mysqlprefix}chatgroupoperator where groupid = $groupid",$link);
|
||||||
perform_query("update chatthread set groupid = 0 where groupid = $groupid",$link);
|
perform_query("update ${mysqlprefix}chatthread set groupid = 0 where groupid = $groupid",$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
header("Location: $webimroot/operator/groups.php");
|
header("Location: $webimroot/operator/groups.php");
|
||||||
exit;
|
exit;
|
||||||
|
@ -36,8 +36,8 @@ $query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']
|
|||||||
if($query !== false) {
|
if($query !== false) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$result = mysql_query("select chatgroup.groupid as groupid, vclocalname ".
|
$result = mysql_query("select ${mysqlprefix}chatgroup.groupid as groupid, vclocalname ".
|
||||||
"from chatgroup order by vclocalname", $link);
|
"from ${mysqlprefix}chatgroup order by vclocalname", $link);
|
||||||
$groupName = array();
|
$groupName = array();
|
||||||
while ($group = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
while ($group = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||||
$groupName[$group['groupid']] = $group['vclocalname'];
|
$groupName[$group['groupid']] = $group['vclocalname'];
|
||||||
@ -46,17 +46,17 @@ if($query !== false) {
|
|||||||
$page['groupName'] = $groupName;
|
$page['groupName'] = $groupName;
|
||||||
|
|
||||||
$escapedQuery = mysql_real_escape_string($query,$link);
|
$escapedQuery = mysql_real_escape_string($query,$link);
|
||||||
select_with_pagintation("DISTINCT unix_timestamp(chatthread.dtmcreated) as created, ".
|
select_with_pagintation("DISTINCT unix_timestamp(${mysqlprefix}chatthread.dtmcreated) as created, ".
|
||||||
"unix_timestamp(chatthread.dtmmodified) as modified, chatthread.threadid, ".
|
"unix_timestamp(${mysqlprefix}chatthread.dtmmodified) as modified, ${mysqlprefix}chatthread.threadid, ".
|
||||||
"chatthread.remote, chatthread.agentName, chatthread.userName, groupid, ".
|
"${mysqlprefix}chatthread.remote, ${mysqlprefix}chatthread.agentName, ${mysqlprefix}chatthread.userName, groupid, ".
|
||||||
"messageCount as size",
|
"messageCount as size",
|
||||||
"chatthread, chatmessage",
|
"${mysqlprefix}chatthread, ${mysqlprefix}chatmessage",
|
||||||
array(
|
array(
|
||||||
"chatmessage.threadid = chatthread.threadid",
|
"${mysqlprefix}chatmessage.threadid = ${mysqlprefix}chatthread.threadid",
|
||||||
"((chatthread.userName LIKE '%%$escapedQuery%%') or (chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
|
"((${mysqlprefix}chatthread.userName LIKE '%%$escapedQuery%%') or (${mysqlprefix}chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
|
||||||
),
|
),
|
||||||
"order by created DESC",
|
"order by created DESC",
|
||||||
"DISTINCT chatthread.dtmcreated", $link);
|
"DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
|
||||||
|
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
|||||||
|
|
||||||
if( count($errors) == 0 ) {
|
if( count($errors) == 0 ) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("delete from chatgroupoperator where operatorid = $operatorid",$link);
|
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid",$link);
|
||||||
perform_query("delete from chatoperator where operatorid = $operatorid",$link);
|
perform_query("delete from ${mysqlprefix}chatoperator where operatorid = $operatorid",$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
|
||||||
header("Location: $webimroot/operator/operators.php");
|
header("Location: $webimroot/operator/operators.php");
|
||||||
|
@ -26,10 +26,11 @@ require_once('../libs/operator_settings.php');
|
|||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
function update_operator_groups($operatorid,$newvalue) {
|
function update_operator_groups($operatorid,$newvalue) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
perform_query("delete from chatgroupoperator where operatorid = $operatorid", $link);
|
perform_query("delete from ${mysqlprefix}chatgroupoperator where operatorid = $operatorid", $link);
|
||||||
foreach($newvalue as $groupid) {
|
foreach($newvalue as $groupid) {
|
||||||
perform_query("insert into chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
|
perform_query("insert into ${mysqlprefix}chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
|
||||||
}
|
}
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,9 @@ require_once('../libs/operator_settings.php');
|
|||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
function update_operator_permissions($operatorid,$newvalue) {
|
function update_operator_permissions($operatorid,$newvalue) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "update chatoperator set iperm = $newvalue where operatorid = $operatorid";
|
$query = "update ${mysqlprefix}chatoperator set iperm = $newvalue where operatorid = $operatorid";
|
||||||
|
|
||||||
perform_query($query,$link);
|
perform_query($query,$link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
@ -69,7 +69,7 @@ if(isset($_GET['nextGroup'])) {
|
|||||||
$link = connect();
|
$link = connect();
|
||||||
$threadupdate = array("istate" => $state_waiting, "nextagent" => $nextid, "agentId" => 0);
|
$threadupdate = array("istate" => $state_waiting, "nextagent" => $nextid, "agentId" => 0);
|
||||||
if($thread['groupid'] != 0) {
|
if($thread['groupid'] != 0) {
|
||||||
if(FALSE === select_one_row("select groupid from 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;
|
$threadupdate['groupid'] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ if (count($errors) == 0 && isset($_POST['password'])) {
|
|||||||
$page['isdone'] = true;
|
$page['isdone'] = true;
|
||||||
|
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "update 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);
|
perform_query($query, $link);
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ if (isset($_POST['loginoremail'])) {
|
|||||||
$token = md5((time() + microtime()).rand(0,99999999));
|
$token = md5((time() + microtime()).rand(0,99999999));
|
||||||
|
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$query = "update 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);
|
perform_query($query, $link);
|
||||||
|
|
||||||
$href = get_app_location(true,false)."/operator/resetpwd.php?id=".$torestore['operatorid']."&token=$token";
|
$href = get_app_location(true,false)."/operator/resetpwd.php?id=".$torestore['operatorid']."&token=$token";
|
||||||
|
@ -69,14 +69,14 @@ if( $start > $end ) {
|
|||||||
|
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$page['reportByDate'] = select_multi_assoc("select DATE(dtmcreated) as date, COUNT(distinct threadid) as threads, SUM(chatmessage.ikind = $kind_agent) as agents, SUM(chatmessage.ikind = $kind_user) as users ".
|
$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 chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by DATE(dtmcreated) order by dtmcreated desc", $link);
|
"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(chatmessage.ikind = $kind_agent) as agents, SUM(chatmessage.ikind = $kind_user) as users ".
|
$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 chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end", $link);
|
"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 ".
|
$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 chatmessage, chatoperator ".
|
"from ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator ".
|
||||||
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
||||||
|
|
||||||
$page['showresults'] = count($errors) == 0;
|
$page['showresults'] = count($errors) == 0;
|
||||||
|
@ -32,11 +32,12 @@ loadsettings();
|
|||||||
setlocale(LC_TIME, getstring("time.locale"));
|
setlocale(LC_TIME, getstring("time.locale"));
|
||||||
|
|
||||||
function thread_info($id) {
|
function thread_info($id) {
|
||||||
|
global $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
$thread = select_one_row("select userName,agentName,remote,userAgent,".
|
$thread = select_one_row("select userName,agentName,remote,userAgent,".
|
||||||
"unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created,".
|
"unix_timestamp(dtmmodified) as modified, unix_timestamp(dtmcreated) as created,".
|
||||||
"vclocalname as groupName ".
|
"vclocalname as groupName ".
|
||||||
"from chatthread left join chatgroup on chatthread.groupid = chatgroup.groupid ".
|
"from ${mysqlprefix}chatthread left join ${mysqlprefix}chatgroup on ${mysqlprefix}chatthread.groupid = ${mysqlprefix}chatgroup.groupid ".
|
||||||
"where threadid = ". $id, $link );
|
"where threadid = ". $id, $link );
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $thread;
|
return $thread;
|
||||||
|
@ -51,7 +51,7 @@ $threadstate_key = array(
|
|||||||
function thread_to_xml($thread,$link) {
|
function thread_to_xml($thread,$link) {
|
||||||
global $state_chatting, $threadstate_to_string, $threadstate_key,
|
global $state_chatting, $threadstate_to_string, $threadstate_key,
|
||||||
$webim_encoding, $operator, $settings,
|
$webim_encoding, $operator, $settings,
|
||||||
$can_viewthreads, $can_takeover;
|
$can_viewthreads, $can_takeover, $mysqlprefix;
|
||||||
$state = $threadstate_to_string[$thread['istate']];
|
$state = $threadstate_to_string[$thread['istate']];
|
||||||
$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
|
$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
|
||||||
if( $state == "closed" )
|
if( $state == "closed" )
|
||||||
@ -100,7 +100,7 @@ function thread_to_xml($thread,$link) {
|
|||||||
$userAgent = get_useragent_version($thread['userAgent']);
|
$userAgent = get_useragent_version($thread['userAgent']);
|
||||||
$result .= "<useragent>".$userAgent."</useragent>";
|
$result .= "<useragent>".$userAgent."</useragent>";
|
||||||
if( $thread["shownmessageid"] != 0 ) {
|
if( $thread["shownmessageid"] != 0 ) {
|
||||||
$query = "select tmessage from chatmessage where messageid = ".$thread["shownmessageid"];
|
$query = "select tmessage from ${mysqlprefix}chatmessage where messageid = ".$thread["shownmessageid"];
|
||||||
$line = select_one_row($query, $link);
|
$line = select_one_row($query, $link);
|
||||||
if( $line ) {
|
if( $line ) {
|
||||||
$message = preg_replace("/[\r\n\t]+/", " ", $line["tmessage"]);
|
$message = preg_replace("/[\r\n\t]+/", " ", $line["tmessage"]);
|
||||||
@ -112,14 +112,14 @@ function thread_to_xml($thread,$link) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function print_pending_threads($groupids,$since) {
|
function print_pending_threads($groupids,$since) {
|
||||||
global $webim_encoding, $settings, $state_closed, $state_left;
|
global $webim_encoding, $settings, $state_closed, $state_left, $mysqlprefix;
|
||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$revision = $since;
|
$revision = $since;
|
||||||
$output = array();
|
$output = array();
|
||||||
$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, ".
|
$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, ".
|
||||||
"unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent, (select vclocalname from chatgroup where chatgroup.groupid = chatthread.groupid) as groupname ".
|
"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 chatthread where lrevision > $since ".
|
"from ${mysqlprefix}chatthread where lrevision > $since ".
|
||||||
($since <= 0
|
($since <= 0
|
||||||
? "AND istate <> $state_closed AND istate <> $state_left "
|
? "AND istate <> $state_closed AND istate <> $state_left "
|
||||||
: "").
|
: "").
|
||||||
|
@ -38,6 +38,7 @@ if( isset($_GET['userid'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function threads_by_userid($userid) {
|
function threads_by_userid($userid) {
|
||||||
|
global $mysqlprefix;
|
||||||
if ($userid == "") {
|
if ($userid == "") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -45,7 +46,7 @@ function threads_by_userid($userid) {
|
|||||||
|
|
||||||
$query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, ".
|
$query = sprintf("select unix_timestamp(dtmcreated) as created, unix_timestamp(dtmmodified) as modified, ".
|
||||||
" threadid, remote, agentName, userName ".
|
" threadid, remote, agentName, userName ".
|
||||||
"from chatthread ".
|
"from ${mysqlprefix}chatthread ".
|
||||||
"where userid=\"$userid\" order by created DESC", $userid);
|
"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);
|
||||||
|
Loading…
Reference in New Issue
Block a user