예제 #1
0
function load_canned_messages($locale, $groupid)
{
    global $mysqlprefix;
    $link = connect();
    $query = "select id, vcvalue from {$mysqlprefix}chatresponses " . "where locale = '" . $locale . "' AND (" . ($groupid ? "groupid = {$groupid}" : "groupid is NULL OR groupid = 0") . ") order by vcvalue";
    $result = select_multi_assoc($query, $link);
    if (!$groupid && count($result) == 0) {
        foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
            $result[] = array('id' => '', 'vcvalue' => $answer);
        }
        if (count($result) > 0) {
            $updatequery = "insert into {$mysqlprefix}chatresponses (vcvalue,locale,groupid) values ";
            for ($i = 0; $i < count($result); $i++) {
                if ($i > 0) {
                    $updatequery .= ", ";
                }
                $updatequery .= "('" . mysql_real_escape_string($result[$i]['vcvalue'], $link) . "','{$locale}', NULL)";
            }
            perform_query($updatequery, $link);
            $result = select_multi_assoc($query, $link);
        }
    }
    mysql_close($link);
    return $result;
}
예제 #2
0
function get_operators()
{
    global $mysqlprefix;
    $link = connect();
    $query = "select * from {$mysqlprefix}chatoperator order by vclogin";
    $result = select_multi_assoc($query, $link);
    mysql_close($link);
    return $result;
}
예제 #3
0
function select_with_pagintation($fields, $table, $conditions, $order, $countfields, $link)
{
    global $page;
    $count = db_rows_count($table, $conditions, $countfields, $link);
    prepare_pagination($count);
    if ($count) {
        $p = $page['pagination'];
        $limit = $p['limit'];
        $page['pagination.items'] = select_multi_assoc(db_build_select($fields, $table, $conditions, $order) . " " . $limit, $link);
    } else {
        $page['pagination.items'] = false;
    }
}
예제 #4
0
파일: groups.php 프로젝트: paulcn/mibew
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);
        foreach ($allgroups as $g) {
            $groupids[] = $g['groupid'];
        }
        return implode(",", $groupids);
    } else {
        return "";
    }
}
예제 #5
0
파일: chat.php 프로젝트: laiello/cartonbank
function load_canned_messages($locale, $groupid)
{
    global $mysqlprefix;
    $link = connect();
    $result = select_multi_assoc("select vcvalue from {$mysqlprefix}chatresponses where locale = '{$locale}' " . "AND (groupid is NULL OR groupid = 0) order by vcvalue", $link);
    if (count($result) == 0) {
        foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) {
            $result[] = array('vcvalue' => $answer);
        }
    }
    if ($groupid) {
        $result2 = select_multi_assoc("select vcvalue from {$mysqlprefix}chatresponses where locale = '{$locale}' " . "AND groupid = {$groupid} order by vcvalue", $link);
        foreach ($result as $r) {
            $result2[] = $r;
        }
        $result = $result2;
    }
    mysql_close($link);
    return $result;
}
예제 #6
0
파일: operator.php 프로젝트: kuell/chat
function get_operator_groupids($operatorid)
{
    global $mysqlprefix;
    $link = connect();
    $query = "select groupid from {$mysqlprefix}chatgroupoperator where operatorid = " . intval($operatorid);
    $result = select_multi_assoc($query, $link);
    mysql_close($link);
    return $result;
}
예제 #7
0
파일: statistics.php 프로젝트: paulcn/mibew
    $curr = getdate(time());
    if ($curr['mday'] < 7) {
        // previous month
        if ($curr['mon'] == 1) {
            $month = 12;
            $year = $curr['year'] - 1;
        } else {
            $month = $curr['mon'] - 1;
            $year = $curr['year'];
        }
        $start = mktime(0, 0, 0, $month, 1, $year);
        $end = mktime(0, 0, 0, $month, date("t", $start), $year) + 24 * 60 * 60;
    } else {
        $start = mktime(0, 0, 0, $curr['mon'], 1, $curr['year']);
        $end = time() + 24 * 60 * 60;
    }
}
set_form_date($start, "start");
set_form_date($end - 24 * 60 * 60, "end");
if ($start > $end) {
    $errors[] = getlocal("statistics.wrong.dates");
}
$link = connect();
$page['reportByDate'] = select_multi_assoc("select DATE(dtmcreated) as date, COUNT(distinct threadid) as threads, SUM({$mysqlprefix}chatmessage.ikind = {$kind_agent}) as agents, SUM({$mysqlprefix}chatmessage.ikind = {$kind_user}) as users " . "from {$mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= {$start} AND unix_timestamp(dtmcreated) < {$end} group by DATE(dtmcreated) order by dtmcreated desc", $link);
$page['reportByDateTotal'] = select_one_row("select COUNT(distinct threadid) as threads, SUM({$mysqlprefix}chatmessage.ikind = {$kind_agent}) as agents, SUM({$mysqlprefix}chatmessage.ikind = {$kind_user}) as users " . "from {$mysqlprefix}chatmessage where unix_timestamp(dtmcreated) >= {$start} AND unix_timestamp(dtmcreated) < {$end}", $link);
$page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(distinct threadid) as threads, SUM(ikind = {$kind_agent}) as msgs, AVG(CHAR_LENGTH(tmessage)) as avglen " . "from {$mysqlprefix}chatmessage, {$mysqlprefix}chatoperator " . "where agentId = operatorid AND unix_timestamp(dtmcreated) >= {$start} AND unix_timestamp(dtmcreated) < {$end} group by operatorid", $link);
$page['showresults'] = count($errors) == 0;
mysql_close($link);
prepare_menu($operator);
start_html_output();
require '../view/statistics.php';
예제 #8
0
파일: chat.php 프로젝트: paulcn/mibew
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";
        if ($groupid) {
            $query .= ", {$mysqlprefix}chatgroupoperator where groupid = {$groupid} and {$mysqlprefix}chatoperator.operatorid = {$mysqlprefix}chatgroupoperator.operatorid and istatus = 0";
        } else {
            $query .= " where istatus = 0";
        }
        $query .= " and inotify = 1";
        $result = select_multi_assoc($query, $link);
        $text = getstring2_("notify.new.text", array(get_app_location(true, $settings['enablessl'] == '1' && $settings['forcessl'] == '1') . "/operator/agent.php?thread=" . $thread['threadid'], $thread['userName']), $thread['locale']);
        if ($firstmessage) {
            $text .= "\n{$firstmessage}";
        }
        foreach ($result as $op) {
            if ($op['time'] < $settings['online_timeout'] && is_valid_email($op['vcjabbername'])) {
                webim_xmpp($op['vcjabbername'], getstring2("notify.new.subject", array($thread['userName'])), $text, $link);
            }
        }
    }
}
예제 #9
0
파일: update.php 프로젝트: kuell/chat
function print_pending_threads($groupids, $since)
{
    global $mibew_encoding, $settings, $state_closed, $state_left, $mysqlprefix;
    $link = connect();
    $revision = $since;
    $output = array();
    $groupids = join(",", array_map("intval", preg_split('/,/', $groupids)));
    $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 > " . intval($since) . ($since <= 0 ? " AND istate <> " . intval($state_closed) . " AND istate <> " . intval($state_left) : "") . ($settings['enablegroups'] == '1' ? " AND (groupid is NULL" . ($groupids ? " OR groupid IN ({$groupids})" : "") . ")" : "") . " ORDER BY threadid";
    $rows = select_multi_assoc($query, $link);
    foreach ($rows as $row) {
        $thread = thread_to_xml($row, $link);
        $output[] = $thread;
        if ($row['lrevision'] > $revision) {
            $revision = $row['lrevision'];
        }
    }
    mysql_close($link);
    echo "<threads revision=\"{$revision}\" time=\"" . time() . "000\">";
    foreach ($output as $thr) {
        print myiconv($mibew_encoding, "utf-8", $thr);
    }
    echo "</threads>";
}