Example #1
0
function store_message($name, $email, $info, $message, $groupid, $referrer)
{
    global $state_left, $current_locale, $kind_for_agent, $kind_user;
    $remoteHost = get_remote_host();
    $userbrowser = $_SERVER['HTTP_USER_AGENT'];
    $visitor = visitor_from_request();
    $link = connect();
    $thread = create_thread($groupid, $name, $remoteHost, $referrer, $current_locale, $visitor['id'], $userbrowser, $state_left, $link);
    if ($referrer) {
        post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.came.from', array($referrer)), $link);
    }
    if ($email) {
        post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.email', array($email)), $link);
    }
    if ($info) {
        post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.info', array($info)), $link);
    }
    post_message_($thread['threadid'], $kind_user, $message, $link, $name);
    mysql_close($link);
}
Example #2
0
function reopen_thread($threadid)
{
    global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events;
    $link = connect();
    $thread = thread_by_id_($threadid, $link);
    if (!$thread) {
        return FALSE;
    }
    if ($thread['istate'] == $state_closed || $thread['istate'] == $state_left) {
        return FALSE;
    }
    if ($thread['istate'] != $state_chatting && $thread['istate'] != $state_queue && $thread['istate'] != $state_loading) {
        commit_thread($threadid, array("istate" => $state_waiting, "nextagent" => 0), $link);
    }
    post_message_($thread['threadid'], $kind_events, getstring_("chat.status.user.reopenedthread", $thread['locale']), $link);
    mysql_close($link);
    return $thread;
}
Example #3
0
        $errors[] = getlocal("chat.redirect.unknown_group");
    }
} else {
    $nextid = verifyparam("nextAgent", "/^\\d{1,10}\$/");
    $nextOperator = operator_by_id($nextid);
    if ($nextOperator) {
        $page['message'] = getlocal2("chat.redirected.content", array(safe_htmlspecialchars(topage(get_operator_name($nextOperator)))));
        if ($thread['istate'] == $state_chatting) {
            $link = connect();
            $threadupdate = array("istate" => intval($state_waiting), "nextagent" => intval($nextid), "agentId" => 0);
            if ($thread['groupid'] != 0) {
                if (FALSE === select_one_row("select groupid from {$mysqlprefix}chatgroupoperator where operatorid = " . intval($nextid) . " and groupid = " . intval($thread['groupid']), $link)) {
                    $threadupdate['groupid'] = 0;
                }
            }
            commit_thread($threadid, $threadupdate, $link);
            post_message_($thread['threadid'], $kind_events, getstring2_("chat.status.operator.redirect", array(get_operator_name($operator)), $thread['locale'], true), $link);
            mysql_close($link);
        } else {
            $errors[] = getlocal("chat.redirect.cannot");
        }
    } else {
        $errors[] = getlocal("chat.redirect.unknown_operator");
    }
}
setup_logo();
if (count($errors) > 0) {
    expand("../styles", getchatstyle(), "error.tpl");
} else {
    expand("../styles", getchatstyle(), "redirected.tpl");
}
Example #4
0
        if (!isset($_SESSION['own_threads'])) {
            $_SESSION['own_threads'] = array();
        }
        $_SESSION['own_threads'][] = $thread['threadid'];
        if ($referrer) {
            post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.came.from', array($referrer), true), $link);
        }
        post_message_($thread['threadid'], $kind_info, getstring('chat.wait', true), $link);
        if ($email) {
            post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.email', array($email), true), $link);
        }
        if ($info) {
            post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.info', array($info), true), $link);
        }
        if ($firstmessage) {
            $postedid = post_message_($thread['threadid'], $kind_user, $firstmessage, $link, $visitor['name']);
            if ($postedid) {
                commit_thread($thread['threadid'], array('shownmessageid' => intval($postedid)), $link);
            }
        }
        notify_operators($thread, $firstmessage, $link);
        mysql_close($link);
    }
    $threadid = $thread['threadid'];
    $token = $thread['ltoken'];
    $level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
    $chatstyle = verifyparam("style", "/^\\w+\$/", "");
    header("Location: {$mibewroot}/client.php?thread={$threadid}&token={$token}&level={$level}" . ($chatstyle ? "&style={$chatstyle}" : ""));
    exit;
}
$token = verifyparam("token", "/^\\d{1,10}\$/");
Example #5
0
 * with the notice and other provisions required by the GPL.
 * 
 * Contributors:
 *    Evgeny Gryaznov - initial API and implementation
 */
require_once 'libs/common.php';
require_once 'libs/chat.php';
require_once 'libs/operator.php';
require_once 'libs/groups.php';
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
if ($referer && isset($_SESSION['threadid'])) {
    $link = connect();
    $thread = thread_by_id_($_SESSION['threadid'], $link);
    if ($thread && $thread['istate'] != $state_closed) {
        $msg = getstring2_("chat.client.visited.page", array($referer), $thread['locale']);
        post_message_($thread['threadid'], $kind_for_agent, $msg, $link);
    }
    mysql_close($link);
}
$image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\\w+\$/", "webim");
$lang = verifyparam(isset($_GET['language']) ? "language" : "lang", "/^[\\w-]{2,5}\$/", "");
if (!$lang || !locale_exists($lang)) {
    $lang = $current_locale;
}
$groupid = verifyparam("group", "/^\\d{1,8}\$/", "");
if ($groupid) {
    loadsettings();
    if ($settings['enablegroups'] == '1') {
        $group = group_by_id($groupid);
        if (!$group) {
            $groupid = "";
Example #6
0
}
if ($act == "refresh") {
    $lastid = verifyparam("lastid", "/^\\d{1,10}\$/", -1);
    print_thread_messages($thread, $token, $lastid, $isuser, $outformat, $isuser ? null : $operator['operatorid']);
    exit;
} else {
    if ($act == "post") {
        $lastid = verifyparam("lastid", "/^\\d{1,10}\$/", -1);
        $message = getrawparam('message');
        $kind = $isuser ? $kind_user : $kind_agent;
        $from = $isuser ? $thread['userName'] : $thread['agentName'];
        if (!$isuser && $operator['operatorid'] != $thread['agentId']) {
            show_error("cannot send");
        }
        $link = connect();
        $postedid = post_message_($threadid, $kind, $message, $link, $from, null, $isuser ? null : $operator['operatorid']);
        if ($isuser && $postedid && $thread["shownmessageid"] == 0) {
            commit_thread($thread['threadid'], array('shownmessageid' => intval($postedid)), $link);
        }
        mysql_close($link);
        print_thread_messages($thread, $token, $lastid, $isuser, $outformat, $isuser ? null : $operator['operatorid']);
        exit;
    } else {
        if ($act == "rename") {
            loadsettings();
            if ($settings['usercanchangename'] != "1") {
                show_error("server: forbidden to change name");
            }
            $newname = getrawparam('name');
            if (!preg_match('/^\\s*$/', $newname)) {
                rename_user($thread, $newname);