示例#1
0
    $oldtime = date("YmdHis", $prev);
    $query = "SELECT user_id,lastaction,sessionid FROM livehelp_users WHERE isoperator='Y' AND authenticated='Y' AND (ismobile='Y' OR ismobile='P') AND lastaction<'{$oldtime}'";
    $data2 = $mydatabase->query($query);
    while ($row = $data2->fetchRow(DB_FETCHMODE_ASSOC)) {
        $opid = $row['user_id'];
        $lastaction = $row['lastaction'];
        $sessionid = $row['sessionid'];
        // get when they logged in and how many seconds they have been online:
        $query = "SELECT dateof FROM livehelp_operator_history WHERE opid={$opid} AND action='login' ORDER by dateof DESC LIMIT 1";
        $data3 = $mydatabase->query($query);
        $row3 = $data3->fetchRow(DB_FETCHMODE_ASSOC);
        $seconds = timediff($lastaction, $row3['dateof']);
        // update history for operator to show login:
        $query = "INSERT INTO livehelp_operator_history (opid,action,dateof,sessionid,totaltime) VALUES ({$opid},'Logout','{$lastaction}','{$sessionid}',{$seconds})";
        $mydatabase->query($query);
        // log them off:
        $query = "UPDATE livehelp_users set authenticated='N',isonline='N',status='offline' WHERE user_id={$opid}";
        $mydatabase->query($query);
    }
}
// chatters who closed their chat window timeout after a minute of inactivity..:
$aminute = mktime(date("H"), date("i") - 1, date("s") - 30, date("m"), date("d"), date("Y"));
$oldchat = date("YmdHis", $aminute);
$sqlquery = "SELECT sessionid,user_id FROM livehelp_users WHERE status='chat' AND isoperator='N' AND chataction<{$oldchat}";
$old_people = $mydatabase->query($sqlquery);
while ($old_chat = $old_people->fetchRow(DB_FETCHMODE_ORDERED)) {
    $sessionid = $old_chat[0];
    $user_id = $old_chat[1];
    stopchat($sessionid);
}
// end of old chats where user closed chat window.
// --------------------------------------------------------------------------
// LICENSE:
//     This program is free software; you can redistribute it and/or
//     modify it under the terms of the GNU General Public License
//     as published by the Free Software Foundation;
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with this program in a file named LICENSE.txt .
//===========================================================================
require_once "visitor_common.php";
// stop chat.
stopchat($identity['SESSIONID']);
// get department information...
$where = "";
if ($UNTRUSTED['department'] != 0) {
    $where = " WHERE recno=" . intval($UNTRUSTED['department']);
}
$sqlquery = "SELECT * FROM livehelp_departments {$where} ";
$data_d = $mydatabase->query($sqlquery);
$department_a = $data_d->fetchRow(DB_FETCHMODE_ASSOC);
$department = $department_a['recno'];
$topframeheight = $department_a['topframeheight'];
$topbackground = $department_a['topbackground'];
$botbackcolor = $department_a['botbackcolor'];
$botbackground = $department_a['botbackground'];
$midbackcolor = $department_a['midbackcolor'];
$midbackground = $department_a['midbackground'];