Example #1
0
function demo_process_thread($act, $outformat, $lastid, $isuser, $canpost, $istyping, $postmessage)
{
    global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent, $webimroot, $settings;
    loadsettings();
    if ($act == "refresh" || $act == "post") {
        $lastid++;
        if ($outformat == "xml") {
            start_xml_output();
            print "<thread lastid=\"{$lastid}\" typing=\"" . ($istyping ? 1 : 0) . "\" canpost=\"" . ($canpost ? 1 : 0) . "\">";
        } else {
            start_html_output();
            $url = "{$webimroot}/thread.php?act=refresh&amp;thread=0&amp;token=123&amp;html=on&amp;user="******"true" : "false");
            print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . "<html>\n<head>\n" . "<link href=\"{$webimroot}/styles/default/chat.css\" rel=\"stylesheet\" type=\"text/css\">\n" . "<meta http-equiv=\"Refresh\" content=\"" . $settings['updatefrequency_oldchat'] . "; URL={$url}&amp;sn=11\">\n" . "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n" . "<title>chat</title>\n" . "</head>\n" . "<body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>" . "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>";
        }
        if ($lastid == 1) {
            demo_print_message(array('ikind' => $kind_for_agent, 'created' => time() - 15, 'tname' => '', 'tmessage' => getstring2('chat.came.from', array("http://google.com"))), $outformat);
            demo_print_message(array('ikind' => $kind_info, 'created' => time() - 15, 'tname' => '', 'tmessage' => getstring('chat.wait')), $outformat);
            demo_print_message(array('ikind' => $kind_events, 'created' => time() - 10, 'tname' => '', 'tmessage' => getstring2("chat.status.operator.joined", array("Administrator"))), $outformat);
            demo_print_message(array('ikind' => $kind_agent, 'created' => time() - 9, 'tname' => 'Administrator', 'tmessage' => getstring("demo.chat.welcome")), $outformat);
            demo_print_message(array('ikind' => $kind_user, 'created' => time() - 5, 'tname' => getstring("chat.default.username"), 'tmessage' => getstring("demo.chat.question")), $outformat);
            if ($canpost && $outformat == 'xml') {
                demo_print_message(array('ikind' => $kind_info, 'created' => time() - 5, 'tname' => '', 'tmessage' => 'Hint: type something in message field to see typing notification'), $outformat);
            }
        }
        if ($act == 'post') {
            demo_print_message(array('ikind' => $isuser ? $kind_user : $kind_agent, 'created' => time(), 'tmessage' => $postmessage, 'tname' => $isuser ? getstring("chat.default.username") : "Administrator"), $outformat);
        }
        if ($outformat == "xml") {
            print "</thread>";
        } else {
            print "</td></tr></table><a name='aend'></a>" . "</body></html>";
        }
    }
}
Example #2
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 #3
0
$page['email'] = $email;
if (!$email) {
    $errors[] = no_field("form.field.email");
} else {
    if (!is_valid_email($email)) {
        $errors[] = wrong_field("form.field.email");
    }
}
if (count($errors) > 0) {
    $page['formemail'] = $email;
    $page['ct.chatThreadId'] = $thread['threadid'];
    $page['ct.token'] = $thread['ltoken'];
    $page['level'] = "";
    setup_logo();
    expand("styles", getchatstyle(), "mail.tpl");
    exit;
}
$history = "";
$lastid = -1;
$output = get_messages($threadid, "text", true, $lastid);
foreach ($output as $msg) {
    $history .= $msg;
}
$subject = getstring("mail.user.history.subject");
$body = getstring2("mail.user.history.body", array($thread['userName'], $history));
$link = connect();
webim_mail($email, $webim_mailbox, $subject, $body, $link);
mysql_close($link);
setup_logo();
expand("styles", getchatstyle(), "mailsent.tpl");
exit;
Example #4
0
$errors = array();
$page = array('version' => $version);
$loginoremail = "";
if (isset($_POST['loginoremail'])) {
    $loginoremail = getparam("loginoremail");
    $torestore = is_valid_email($loginoremail) ? operator_by_email($loginoremail) : operator_by_login($loginoremail);
    if (!$torestore) {
        $errors[] = getlocal("no_such_operator");
    }
    $email = $torestore['vcemail'];
    if (count($errors) == 0 && !is_valid_email($email)) {
        $errors[] = "Operator hasn't set his e-mail";
    }
    if (count($errors) == 0) {
        $token = md5(time() + microtime() . rand(0, 99999999));
        $link = connect();
        $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}";
        webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext", array(get_operator_name($torestore), $href)), $link);
        mysql_close($link);
        $page['isdone'] = true;
        require '../view/restore.php';
        exit;
    }
}
$page['formloginoremail'] = topage($loginoremail);
$page['localeLinks'] = get_locale_links("{$webimroot}/operator/restore.php");
$page['isdone'] = false;
start_html_output();
require '../view/restore.php';
Example #5
0
     $thread = create_thread($groupid, $visitor['name'], $remoteHost, $referrer, $current_locale, $visitor['id'], $userbrowser, $state_loading, $link);
     $_SESSION['threadid'] = $thread['threadid'];
     // Store own thread ids to restrict access for other people
     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}" : ""));
Example #6
0
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);
            }
        }
    }
}