Exemplo n.º 1
0
 public static function getParameters($lang = null)
 {
     if ($lang === null) {
         $lang = Resources::getCurrentLocale();
     }
     $themes = enumAvailableThemes();
     $images = self::enumAvailableImages($lang);
     $departments = MapperFactory::getMapper('Department')->enumDepartments(Resources::getCurrentLocale());
     $departmentsParam = array(array('key' => '', 'value' => Resources::Get('page.gen.anydepartment')));
     foreach ($departments as $d) {
         $item = array();
         $item['key'] = $d['departmentkey'];
         $item['value'] = $d['departmentname'];
         $departmentsParam[] = $item;
     }
     $locales = getAvailableLocalesForChat();
     $localesParam = array(array('key' => 'N', 'value' => Resources::Get('page.gen.autolocale')));
     //      $localesParam = array();
     foreach ($locales as $l) {
         $item = array();
         $item['key'] = $l['localeid'];
         $item['value'] = $l['localename'];
         $localesParam[] = $item;
     }
     $params = array('button' => array('name_key' => 'page.gen.choose_image', 'type' => 'list', 'values' => self::listToArray($images), 'default' => 'webim'), 'theme' => array('name_key' => 'page.gen.choose_theme', 'type' => 'list', 'values' => self::listToArray($themes), 'default' => 'default'), 'include_host_url' => array('name_key' => 'page.gen.include_site_name', 'type' => 'checkbox', 'default' => 'N'), 'secure' => array('name_key' => 'page.gen.secure_links', 'type' => 'checkbox', 'default' => 'N'), 'add_track_code' => array('name_key' => 'page.gen.include_tracker_code', 'type' => 'checkbox', 'default' => 'N'), 'choose_department' => array('name_key' => 'page.gen.choosedepartment', 'type' => 'checkbox', 'default' => 'N'), 'department_key' => array('name_key' => 'page.gen.department', 'type' => 'list', 'values' => $departmentsParam, 'default' => ''), 'choose_operator' => array('name_key' => 'page.gen.chooseoperator', 'type' => 'list', 'values' => array(array('key' => 'N', 'value' => Resources::Get('choose_operator.no')), array('key' => 'optional', 'value' => Resources::Get('choose_operator.optional')), array('key' => 'mandatory', 'value' => Resources::Get('choose_operator.mandatory'))), 'default' => 'N'), 'chat_immediately' => array('name_key' => 'page.gen.chatimmediately', 'type' => 'checkbox', 'default' => 'N'), 'locale' => array('name_key' => 'page.gen.locale', 'type' => 'list', 'values' => $localesParam, 'default' => Resources::getCurrentLocale()));
     return $params;
 }
Exemplo n.º 2
0
 public static function getParameters($lang = NULL)
 {
     if ($lang === NULL) {
         $lang = Resources::getCurrentLocale();
     }
     $themes = enumAvailableThemes();
     $images = Button::enumAvailableImages($lang);
     $departments = MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale());
     $departmentsParam = array(array('key' => '', 'value' => Resources::Get('page.gen.anydepartment')));
     foreach ($departments as $d) {
         $item = array();
         $item['key'] = $d['departmentkey'];
         $item['value'] = $d['departmentname'];
         $departmentsParam[] = $item;
     }
     $locales = getAvailableLocalesForChat();
     $localesParam = array(array('key' => 'N', 'value' => Resources::Get('page.gen.autolocale')));
     //      $localesParam = array();
     foreach ($locales as $l) {
         $item = array();
         $item['key'] = $l['localeid'];
         $item['value'] = $l['localename'];
         $localesParam[] = $item;
     }
     $params = array("button" => array("name_key" => 'page.gen.choose_image', "type" => "list", "values" => Button::listToArray($images), "default" => "webim"), "theme" => array("name_key" => 'page.gen.choose_theme', "type" => "list", "values" => Button::listToArray($themes), "default" => "default"), "include_host_url" => array("name_key" => 'page.gen.include_site_name', "type" => "checkbox", "default" => "N"), "secure" => array("name_key" => 'page.gen.secure_links', "type" => "checkbox", "default" => "N"), "add_track_code" => array("name_key" => 'page.gen.include_tracker_code', "type" => "checkbox", "default" => "N"), "choose_department" => array("name_key" => 'page.gen.choosedepartment', "type" => "checkbox", "default" => "N"), "department_key" => array("name_key" => 'page.gen.department', "type" => "list", "values" => $departmentsParam, "default" => ""), "choose_operator" => array("name_key" => 'page.gen.chooseoperator', "type" => "list", "values" => array(array('key' => 'N', 'value' => Resources::Get('choose_operator.no')), array('key' => 'optional', 'value' => Resources::Get('choose_operator.optional')), array('key' => 'mandatory', 'value' => Resources::Get('choose_operator.mandatory'))), "default" => "N"), "chat_immediately" => array("name_key" => 'page.gen.chatimmediately', "type" => "checkbox", "default" => "N"), "locale" => array("name_key" => 'page.gen.locale', "type" => "list", "values" => $localesParam, "default" => Resources::getCurrentLocale()));
     return $params;
 }
Exemplo n.º 3
0
 function assignCompanyInfoAndTheme()
 {
     $this->assign('url', Settings::Get('hosturl', Resources::Get('site.url')));
     $this->assign('company', Settings::Get('company_name', Resources::Get('company.webim')));
     $this->assign('logo', Settings::Get('logo', WEBIM_ROOT . '/themes/default/images/logo.gif'));
     $this->assign('theme', Browser::getCurrentTheme());
 }
Exemplo n.º 4
0
function generate_pagination($pagination)
{
    $result = Resources::Get('tag.pagination.info', array($pagination['page'], $pagination['total'], $pagination['start'] + 1, $pagination['end'], $pagination['count'])) . '<br/>';
    if ($pagination['total'] > 1) {
        $result .= "<br/><div class='pagination'>";
        $curr_page = $pagination['page'];
        $minPage = max($curr_page - LINKS_ON_PAGE, 1);
        $maxPage = min($curr_page + LINKS_ON_PAGE, $pagination['total']);
        if ($curr_page > 1) {
            $result .= generate_pagination_link($curr_page - 1, generate_pagination_image('prevpage')) . PAGINATION_SPACING;
        }
        for ($i = $minPage; $i <= $maxPage; ++$i) {
            $title = abs($curr_page - $i) >= LINKS_ON_PAGE && $i != 1 ? '...' : $i;
            if ($i != $curr_page) {
                $result .= generate_pagination_link($i, $title);
            } else {
                $result .= "<span class=\"pagecurrent\">{$title}</span>";
            }
            if ($i < $maxPage) {
                $result .= PAGINATION_SPACING;
            }
        }
        if ($curr_page < $pagination['total']) {
            $result .= PAGINATION_SPACING . generate_pagination_link($curr_page + 1, generate_pagination_image('nextpage'));
        }
        $result .= '</div>';
    }
    return $result;
}
Exemplo n.º 5
0
function smarty_function_get_res($params, &$smarty)
{
    if (!isset($params['code'])) {
        return '';
    }
    return Resources::Get($params['code'], $params, $smarty->_tpl_vars['current_locale']);
}
Exemplo n.º 6
0
function operatorSubmitted()
{
    $operator = Operator::getInstance()->GetLoggedOperator();
    $TML = new SmartyClass();
    setOperator($TML);
    $TML->assign('mode', 'profile');
    $toCheck = array('login' => 'form.field.login', 'fullname' => 'form.field.agent_name', 'email' => 'form.field.agent_email');
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (empty($errors) && !preg_match("/^[\\w_]+\$/", $_REQUEST['login'])) {
        $errors[] = Resources::Get("page_agent.error.wrong_login");
    }
    if ($_REQUEST['password'] != $_REQUEST['password_confirm']) {
        $errors[] = Resources::Get('my_settings.error.password_match');
    }
    if (!empty($_REQUEST['password']) && md5($_REQUEST['password_existing']) != $operator['password']) {
        $errors[] = Resources::Get('my_settings.error.password_existing');
    }
    $hash = array();
    $requestFile = $_FILES['avatarFile'];
    if (empty($errors) && isset($requestFile) && !empty($requestFile['name']) && $requestFile['size'] > 0 && $requestFile['error'] == 0) {
        $res = Operator::getInstance()->UploadOperatorAvatar($operator['operatorid'], $requestFile);
        if (isset($res)) {
            $errors[] = $res;
        }
        if (empty($errors)) {
            $hash['avatar'] = Operator::getInstance()->getAvatarURL($operator['operatorid'], $requestFile['name']);
        }
    }
    if (empty($errors)) {
        $hash['login'] = $_REQUEST['login'];
        $hash['email'] = $_REQUEST['email'];
        $hash['fullname'] = $_REQUEST['fullname'];
        if (!empty($_REQUEST['password'])) {
            $hash['password'] = md5($_REQUEST['password']);
        }
        Operator::getInstance()->UpdateOperator($operator['operatorid'], $hash);
        Operator::getInstance()->RefreshSessionOperator();
        header("Location: " . WEBIM_ROOT . "/operator/profile.php");
        exit;
    }
    foreach (array('login', 'email', 'fullname') as $f) {
        $TML->assign($f, $_REQUEST[$f]);
    }
    $TML->assign('errors', $errors);
    $TML->display('../templates/operator.tpl');
    exit;
}
Exemplo n.º 7
0
function getInvitationContent($avatar, $message, $isSecure)
{
    $host = ($isSecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
    $TML = new SmartyClass();
    $TML->assign('message', empty($message) ? Resources::Get('invite.default.message') : $message);
    $TML->assign('operatorimage', empty($avatar) ? null : $host . $avatar);
    $TML->assign('theme', Browser::getCurrentTheme());
    $TML->assign('addressprefix', $host);
    $invitation = $TML->fetch('invite.tpl');
    $invitation = addslashes($invitation);
    $invitation = str_replace("\n", "' + \n'", $invitation);
    $invitation = str_replace("\r", '', $invitation);
    return $invitation;
}
Exemplo n.º 8
0
function departmentSubmitted()
{
    global $TITLE_KEY;
    $TML = new SmartyClass($TITLE_KEY);
    setDepartment($TML);
    $isNew = empty($_REQUEST['id']);
    $toCheck = array('departmentname' => 'form.field.departmentname');
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (empty($errors) && !preg_match("/^[a-z_\\.\\d]*\$/", $_REQUEST['departmentkey'])) {
        $errors[] = Resources::Get("page_department.error.wrong_departmentkey");
    }
    if (empty($errors) && !empty($_REQUEST['departmentkey'])) {
        $existing = MapperFactory::getMapper("Department")->getByDepartmentKey($_REQUEST['departmentkey']);
        $exists = !empty($existing);
        if ($exists) {
            if ($isNew || !$isNew && $_REQUEST['id'] != $existing['departmentid']) {
                $errors[] = Resources::Get('page_department.error.duplicate_department_departmentkey');
            }
        }
    }
    $hash = array();
    $department_key = empty($_REQUEST['departmentkey']) ? makeKeyUnique(generateDepartmentKey()) : makeKeyUnique($_REQUEST['departmentkey'], !empty($_REQUEST['id']) ? $_REQUEST['id'] : null);
    if (!$department_key) {
        $errors[] = Resources::Get('page_department.error.unable_make_unique_key');
    }
    if (empty($errors)) {
        $hash['departmentkey'] = $department_key;
        //    $hash['departmentkey'] = empty($_REQUEST['departmentkey']) ? iconv(WEBIM_ENCODING, 'latin-1', $_REQUEST['departmentname']) : $_REQUEST['departmentkey']; // translit
        $hash['departmentname'] = $_REQUEST['departmentname'];
        if (isset($_REQUEST['id'])) {
            $hash['departmentid'] = $_REQUEST['id'];
        }
        $id = Department::getInstance()->save($hash, Resources::getCurrentLocale());
        $url = AdminURL::getInstance()->getURL('departments');
        header("Location: " . $url);
    }
    foreach (array('departmentkey', 'departmentname') as $f) {
        if (!empty($_REQUEST[$f])) {
            $TML->assign($f, $_REQUEST[$f]);
        }
    }
    $TML->assign('errors', $errors);
    $TML->display('department.tpl');
    exit;
}
Exemplo n.º 9
0
function parseReferrer($ref, $code)
{
    if (strpos($ref, "yandex.ru") !== false && preg_match("/text=([^&]+)/", $ref, $m)) {
        $query = urldecode($m[1]);
        if (WEBIM_ENCODING != 'UTF-8') {
            $query = smarticonv('utf-8', 'cp1251', $query);
        }
        return Resources::Get($code . '.yandex', array($query, $ref));
    } else {
        if (strpos($ref, "rambler.ru") !== false && preg_match("/query=([^&]+)/", $ref, $m)) {
            $query = urldecode($m[1]);
            if (WEBIM_ENCODING != 'UTF-8') {
                $query = smarticonv('utf-8', 'cp1251', $query);
            }
            return Resources::Get($code . '.rambler', array($query, $ref));
        } else {
            if ((strpos($ref, "google.ru") !== false || strpos($ref, "google.com") !== false) && preg_match("/q=([^&]+)/", $ref, $m)) {
                $query = urldecode($m[1]);
                if (WEBIM_ENCODING != 'UTF-8') {
                    $query = smarticonv('utf-8', 'cp1251', $query);
                }
                return Resources::Get($code . '.google', array($query, $ref));
            } else {
                if (strpos($ref, "bing.com") !== false && preg_match("/q=([^&]+)/", $ref, $m)) {
                    $query = urldecode($m[1]);
                    if (WEBIM_ENCODING != 'UTF-8') {
                        $query = smarticonv('utf-8', 'cp1251', $query);
                    }
                    return Resources::Get($code . '.bing', array($query, $ref));
                }
            }
        }
    }
    return $ref;
}
Exemplo n.º 10
0
         $stats_emails = array_map("trim", explode(",", $params[$key]));
         foreach ($stats_emails as $e) {
             if (!isValidEmail($e)) {
                 $errors[] = Resources::Get("errors.email.format", Resources::Get($res));
                 break;
             }
         }
     } elseif (!isValidEmail($params[$key])) {
         $errors[] = Resources::Get("errors.email.format", Resources::Get($res));
     }
 }
 if (isset($params['max_sessions']) && notEmpty($params['max_sessions']) && (!is_numeric($params['max_sessions']) || $params['max_sessions'] < 0)) {
     $errors[] = Resources::Get("error.max_sessions.value");
 }
 if (empty($params['company_name'])) {
     $errors[] = Resources::Get("errors.required", array(Resources::Get('settings.company.webim')));
 }
 $requestFile = $_FILES['logo'];
 if (empty($errors) && isset($requestFile) && !empty($requestFile['name']) && $requestFile['size'] > 0 && $requestFile['error'] == 0) {
     $dir = "../images/logo/";
     $destFilename = "site_logo";
     $uploadResult = uploadFile($requestFile, $dir, $destFilename);
     if (!empty($uploadResult)) {
         $errors[] = $uploadResult;
     }
     if (empty($errors)) {
         $hash = array();
         $params['logo'] = WEBIM_ROOT . '/images/logo/' . constructFileNameFromUploadedFile($requestFile, $destFilename);
     }
 }
 if (empty($errors)) {
Exemplo n.º 11
0
 private function joinThreadAndSendMessage($thread, $operatorId)
 {
     $threadid = $thread['threadid'];
     $operator = Operator::getInstance()->GetOperatorById($operatorId);
     if ($operatorId != $thread['operatorid']) {
         $message = Resources::Get("chat.status.operator.joined", array($operator['fullname']), $thread['locale']);
         Thread::getInstance()->PostMessage($threadid, KIND_EVENTS, $message);
         // should explicitly send empty string for unset avatar
         $avatar = isset($operator['avatar']) && !empty($operator['avatar']) ? $operator['avatar'] : "";
         Thread::getInstance()->PostMessage($threadid, KIND_AVATAR, $avatar);
     }
     $this->joinThread($thread, $operatorId);
 }
Exemplo n.º 12
0
$locale = verify_param('locale', '/^([a-z]{2})$/', Resources::getCurrentLocale());
$size = array();
if (function_exists('gd_info')) {
    // TODO: for other file types
    $info = gd_info();
    $filename = dirname(__FILE__) . '/../' . Button::getImageNameFromParam($image, null, $lang, null, true);
    if (file_exists($filename)) {
        // isset($info['GIF Read Support']) && $info['GIF Read Support'] && TODO check other file types
        $size = @getimagesize($filename);
    }
}
$location = WEBIM_ROOT;
if ($showhost) {
    $location = ($forcesecure ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . WEBIM_ROOT;
}
$alt = Resources::Get('webim.online.consultant');
$departmentParam = !empty($departmentkey) ? '&departmentkey=' . $departmentkey : '';
$button_img = '<img alt="' . $alt . '" src="' . $location . '/button.php?bim=' . $image . '&amp;lang=' . $locale . $departmentParam . '" border="0"';
if (!empty($size)) {
    $button_img .= ' width="' . $size[0] . '" height="' . $size[1] . '" ';
}
$button_img .= ' />';
$chooseOperatorParam = !empty($chooseoperator) ? '&chooseoperator=' . $chooseoperator : '';
$chooseDepartmentParam = !empty($choosedepartment) ? '&choosedepartment=1' : '';
$chatimmediatelyParam = !empty($chatimmediately) ? '&chatimmediately=1' : '';
$link = $location . "/client.php?theme={$theme}" . '&amp;lang=' . $locale . $chooseOperatorParam . $chooseDepartmentParam . $departmentParam . $chatimmediatelyParam;
$temp = get_popup($link, $button_img, '', 'webim_' . getWindowNameSuffix(), 'toolbar=0, scrollbars=0, location=0, menubar=0, width=540, height=480, resizable=1', empty($chatimmediately));
$buttonCode = '<!-- webim button -->' . $temp . '<!-- /webim button -->';
$trackerCode = getTrackerCode($location, $theme, $forcesecure);
$buttonCode .= getAutoInviteCode($location, $theme);
$code = $includeTracker ? $trackerCode . $buttonCode : $buttonCode;
Exemplo n.º 13
0
function operatorSubmitted()
{
    global $TML, $isNew;
    $valid_types = array("gif", "jpg", "png", "jpeg");
    $operator = Operator::getInstance()->GetLoggedOperator(false);
    setOperator();
    $toCheck = array('login' => 'form.field.login', 'fullname' => 'form.field.agent_name', 'email' => 'form.field.agent_email');
    if ($isNew) {
        $toCheck['password'] = '******';
    }
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (empty($errors) && !preg_match("/^[\\w_\\.]+\$/", $_REQUEST['login'])) {
        $errors[] = Resources::Get("page_agent.error.wrong_login");
    }
    if ($_REQUEST['password'] != $_REQUEST['password_confirm']) {
        $errors[] = Resources::Get('my_settings.error.password_match');
    }
    if (empty($errors)) {
        $existingOperator = MapperFactory::getMapper("Operator")->getByLogin($_REQUEST['login']);
        $exists = !empty($existingOperator);
        if ($exists) {
            if ($isNew || !$isNew && $_REQUEST['operatorid'] != $existingOperator['operatorid']) {
                $errors[] = Resources::Get('page_agent.error.duplicate_login');
            }
        }
    }
    if (empty($errors) && !is_valid_email($_REQUEST['email'])) {
        $errors[] = Resources::Get('errors.email.format', array(Resources::Get('form.field.agent_email')));
    }
    $departments = array();
    foreach ($_REQUEST as $key => $value) {
        if (!preg_match("/^departments::(.+)\$/", $key, $matches)) {
            continue;
        }
        if (isset($_REQUEST[$key]) && $_REQUEST[$key] == 'on') {
            $departments[] = $matches[1];
        }
    }
    $locales = array();
    foreach ($_REQUEST as $key => $value) {
        if (!preg_match("/^locales::([a-z]{2})\$/", $key, $matches)) {
            continue;
        }
        if (isset($_REQUEST[$key]) && $_REQUEST[$key] == 'on') {
            $locales[] = $matches[1];
        }
    }
    // restore departments on the page
    $operator = Operator::getInstance()->GetLoggedOperator(false);
    $orig = MapperFactory::getMapper("OperatorDepartment")->enumDepartmentsWithOperator($operator['operatorid'], Resources::getCurrentLocale());
    $toAssign = array();
    foreach ($orig as $d) {
        $d['isindepartment'] = in_array($d['departmentid'], $departments);
        $toAssign[] = $d;
    }
    $TML->assign('departments', $toAssign);
    $orig_locales = getAvailableLocalesForChat();
    $to_assign_locales = array();
    foreach ($orig_locales as $d) {
        $d['ishaslocale'] = in_array($d['localeid'], $locales);
        $to_assign_locales[] = $d;
    }
    $TML->assign('locales', $to_assign_locales);
    $hash = array();
    if (empty($errors)) {
        $hash['login'] = $_REQUEST['login'];
        $hash['email'] = $_REQUEST['email'];
        $hash['fullname'] = $_REQUEST['fullname'];
        $hash['role'] = empty($_REQUEST['is_admin']) ? 'operator' : 'admin';
        $op_data_hash['locales'] = implode(",", $locales);
        $op_data_hash['locales'] = empty($op_data_hash['locales']) ? null : $op_data_hash['locales'];
        //Force mapper to set null for column in DB;
        if (!empty($_REQUEST['password'])) {
            $hash['password'] = md5($_REQUEST['password']);
        }
        $operatorToUpdateId = null;
        if ($isNew) {
            $operatorToUpdateId = MapperFactory::getMapper("Operator")->save($hash);
            MapperFactory::getMapper("Operator")->insertOperatorTime($operatorToUpdateId);
        } else {
            $operatorToUpdateId = $_REQUEST['operatorid'];
            $hash['operatorid'] = $operatorToUpdateId;
            MapperFactory::getMapper("Operator")->save($hash);
        }
        $op_data_hash['operatorid'] = $operatorToUpdateId;
        MapperFactory::getMapper("OperatorLastAccess")->save($op_data_hash);
        Operator::getInstance()->setOperatorDepartments($operatorToUpdateId, $departments);
        $requestFile = $_FILES['avatarFile'];
        if (empty($errors) && isset($requestFile) && !empty($requestFile['name']) && $requestFile['size'] > 0 && $requestFile['error'] == 0) {
            $res = Operator::getInstance()->UploadOperatorAvatar($operatorToUpdateId, $requestFile);
            if (!empty($res)) {
                $errors[] = $res;
            }
            if (empty($errors)) {
                $hash = array();
                $hash['avatar'] = Operator::getInstance()->getAvatarURL($operatorToUpdateId, $requestFile['name']);
                Operator::getInstance()->UpdateOperator($operatorToUpdateId, $hash);
            }
        }
        if (empty($errors)) {
            if ($operatorToUpdateId == $operator['operatorid']) {
                Operator::getInstance()->RefreshSessionOperator();
            }
            header("Location: " . AdminURL::getInstance()->getURL('operators'));
            exit;
        }
    }
    foreach (array('login', 'email', 'fullname', 'is_admin') as $f) {
        if (!empty($_REQUEST[$f])) {
            $TML->assign($f, $_REQUEST[$f]);
        }
    }
    $TML->assign('errors', $errors);
    $TML->display('operator.tpl');
    exit;
}
Exemplo n.º 14
0
 * 
 * Все права защищены. (c) 2005-2009 ООО "ТОП".
 * Данное программное обеспечение и все сопутствующие материалы
 * предоставляются на условиях лицензии, доступной по адресу
 * http://webim.ru/license.html
 * 
 */
require_once '../classes/functions.php';
require_once '../classes/class.thread.php';
require_once '../classes/class.operator.php';
require_once '../classes/class.visitsession.php';
require_once '../classes/class.visitedpage.php';
require_once '../classes/class.invitation.php';
$operator = Operator::getInstance()->GetLoggedOperator();
$pageId = verify_param('pageid', '/^([a-z0-9]{32})?$/', '');
if (empty($pageId)) {
    die('invalid or absent pageid');
}
$visitSession = VisitSession::GetInstance()->GetVisitSessionByPageId($pageId);
$remoteLevel = Browser::GetRemoteLevel($visitSession['useragent']);
$thread = VisitedPage::GetInstance()->GetInvitationThread($pageId);
if (empty($thread) || $thread['state'] == STATE_CLOSED) {
    $thread = Thread::getInstance()->CreateThread(WEBIM_CURRENT_LOCALE, STATE_INVITE, array('operatorfullname' => $operator['fullname'], 'operatorid' => $operator['operatorid'], 'visitsessionid' => $visitSession['visitsessionid']));
    VisitSession::GetInstance()->UpdateVisitSession($visitSession['visitsessionid'], array('hasthread' => 1));
    $introMessage = Resources::Get('invite.intro.message', array($visitSession['visitorname']), WEBIM_CURRENT_LOCALE);
    Thread::getInstance()->PostMessage($thread['threadid'], KIND_FOR_AGENT, $introMessage);
    $invitationId = Invitation::getInstance()->CreateInvitation($thread['threadid']);
    VisitedPage::GetInstance()->UpdateVisitedPage($pageId, array('invitationid' => $invitationId));
}
header('Location: ' . WEBIM_ROOT . '/operator/agent.php?thread=' . $thread['threadid'] . '&token=' . $thread['token'] . '&level=' . $remoteLevel . '&force=false');
exit;
Exemplo n.º 15
0
function setupChatViewForVisitor($thread, $level)
{
    $visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
    $page['agent'] = false;
    $page['visitor'] = true;
    $page['canpost'] = true;
    $nameisset = Resources::Get('chat.default.visitorname') != $visitSession['visitorname'];
    $page['displ1'] = $nameisset ? 'none' : 'inline';
    $page['displ2'] = $nameisset ? 'inline' : 'none';
    $page['level'] = $level;
    $page['ct_chatThreadId'] = $thread['threadid'];
    $page['ct_token'] = $thread['token'];
    $page['ct_visitor_name'] = $visitSession['visitorname'];
    $page['canChangeName'] = Visitor::getInstance()->canVisitorChangeName();
    $page['ct_company_name'] = Settings::Get('company_name');
    $page['ct_company_chatLogoURL'] = Settings::Get('logo');
    $page['webimHost'] = Settings::Get('hosturl');
    $page['send_shortcut'] = 'Enter';
    $params = 'thread=' . $thread['threadid'] . '&token=' . $thread['token'];
    $page['selfLink'] = WEBIM_ROOT . '/client.php?' . $params . '&level=' . $level;
    $page['isOpera95'] = is_agent_opera95();
    $page['displayrate'] = !empty($thread['rate']) ? 'none' : 'inline';
    $page['rateList'] = explode('|', Resources::Get('chat.operator_rates'));
    if (!empty($res)) {
        foreach ($res as $k => $v) {
            $page[$k] = $v;
        }
    }
    $page['viewonly'] = '0';
    return $page;
}
Exemplo n.º 16
0
 public static function displayAjaxError($text)
 {
     $message = Resources::Get('agent.not_logged_in');
     $message = self::AddCdata($message);
     echo '<error type="1"><descr>' . $message . '</descr></error>';
 }
Exemplo n.º 17
0
 static function ConvertWebIMToEncoding($encoding, $dir)
 {
     if (Resources::compareEncodings(WEBIM_ORIGINAL_ENCODING, $encoding)) {
         return null;
     }
     $resources = listConvertableFiles($dir);
     foreach ($resources as $item) {
         $content = file_get_contents($item);
         $w_content = smarticonv(WEBIM_ORIGINAL_ENCODING, $encoding, $content);
         $result = file_put_contents($item, $w_content);
         if ($result === FALSE) {
             return Resources::Get("errors.write.failed", array($item));
         }
     }
     return null;
 }
Exemplo n.º 18
0
 public static function GetProductName()
 {
     $product = Resources::Get('webim.pro.title');
     return $product;
 }
Exemplo n.º 19
0
function notifyOperatorOnHideInvitation($pageid, $event)
{
    $invitation = Invitation::GetInstance()->GetInvitationByVisitedPageId($pageid);
    $threadid = $invitation['threadid'];
    if (!empty($threadid)) {
        $reasonText = null;
        if ($event == "reject") {
            $reasonText = Resources::Get('invite.visitor.closed.invitation', array(), WEBIM_CURRENT_LOCALE);
        } elseif ($event == "timeout") {
            $reasonText = Resources::Get('invite.invitation.timout', array(), WEBIM_CURRENT_LOCALE);
        } elseif ($event == "left") {
            $reasonText = Resources::Get('invite.window.closed', array(), WEBIM_CURRENT_LOCALE);
        }
        if (!empty($reasonText)) {
            ThreadProcessor::GetInstance()->ProcessThread($threadid, 'visitor_invite_close', array('message' => $reasonText));
        }
    }
}
Exemplo n.º 20
0
function inviteSubmitted()
{
    global $TITLE_KEY;
    $TML = new SmartyClass($TITLE_KEY);
    $isNew = empty($_REQUEST['autoinviteid']);
    $toCheck = array('text' => 'form.field.text');
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (!isset($_REQUEST['number_of_pages']) || !empty($_REQUEST['number_of_pages']) && !is_numeric($_REQUEST['number_of_pages'])) {
        $errors[] = Resources::Get("errors.not_numeric.number_of_pages");
    }
    if (!isset($_REQUEST['time_on_site']) || !is_numeric($_REQUEST['time_on_site'])) {
        $errors[] = Resources::Get("errors.not_numeric.time_on_site");
    }
    $visited_pages = array();
    if (isset($_REQUEST['visited_page']) && is_array($_REQUEST['visited_page']) && isset($_REQUEST['visited_page_time']) && is_array($_REQUEST['visited_page_time'])) {
        foreach ($_REQUEST['visited_page'] as $k => $v) {
            if (!empty($v)) {
                if (!isset($_REQUEST['visited_page_time'][$k]) || !is_numeric($_REQUEST['visited_page_time'][$k])) {
                    $errors[] = Resources::Get("errors.not_numeric.visited_page_time");
                } else {
                    array_push($visited_pages, array("url" => $v, "time" => $_REQUEST['visited_page_time'][$k]));
                }
            }
        }
    }
    $hash = array();
    if (empty($errors)) {
        $hash['text'] = $_REQUEST['text'];
        $hash['conditions'] = array();
        if (isset($_REQUEST['came_from']) && !empty($_REQUEST['came_from'])) {
            $hash['conditions']['came_from'] = $_REQUEST['came_from'];
        }
        if (isset($_REQUEST['number_of_pages']) && !empty($_REQUEST['number_of_pages'])) {
            $hash['conditions']['number_of_pages'] = $_REQUEST['number_of_pages'];
        }
        if (isset($_REQUEST['time_on_site']) && !empty($_REQUEST['time_on_site'])) {
            $hash['conditions']['time_on_site'] = $_REQUEST['time_on_site'];
        }
        if (isset($_REQUEST['order_matters']) && !empty($_REQUEST['order_matters'])) {
            $hash['conditions']['order_matters'] = 1;
        }
        if (count($visited_pages) > 0) {
            $hash['conditions']['visited_pages'] = $visited_pages;
        }
        $json = new Json();
        $hash['conditions'] = $json->encode($hash['conditions']);
        if ($isNew) {
            $autoinviteToUpdateId = MapperFactory::getMapper("AutoInvite")->save($hash);
        } else {
            $autoinviteToUpdateId = $_REQUEST['autoinviteid'];
            $hash['autoinviteid'] = $autoinviteToUpdateId;
            MapperFactory::getMapper("AutoInvite")->save($hash);
        }
        header("Location: " . AdminURL::getInstance()->getURL('auto_invites'));
        exit;
    }
    foreach (array('order_matters', 'text', 'came_from', 'visited_page', 'visited_page_time', 'time_on_site', 'number_of_pages') as $f) {
        if (isset($_REQUEST[$f]) && !empty($_REQUEST[$f])) {
            $TML->assign($f, $_REQUEST[$f]);
        }
    }
    $TML->assign('errors', $errors);
    $TML->display('auto_invite.tpl');
}
Exemplo n.º 21
0
function sendFormSubmitted()
{
    $login = trim($_REQUEST['login']);
    if (empty($login)) {
        return Resources::Get("errors.required", array(Resources::Get('form.field.login')));
    }
    $o = Operator::getInstance()->GetOperatorByLogin($login);
    if (empty($o)) {
        return Resources::Get("errors.operator_not_found", array(Resources::Get('form.field.login')));
    }
    Operator::getInstance()->SendRecoverPasswordMail($o['operatorid'], $_SERVER['HTTP_HOST']);
}
Exemplo n.º 22
0
function get_operators_list()
{
    $operators = Operator::getInstance()->GetAllAccessedOperators();
    $result = array();
    $result[''] = Resources::Get('search.any.operator');
    if (!empty($operators)) {
        foreach ($operators as $op) {
            $result[$op['operatorid']] = $op['fullname'];
        }
    }
    return $result;
}
Exemplo n.º 23
0
    }
    if (empty($till)) {
        $errors[] = Resources::Get('errors.required', Resources::Get('form.field.till'));
    }
    $isCreateMode = empty($banid);
    if (empty($errors)) {
        $existingBan = $banMapper->getBanBydAddress($address);
        if ($isCreateMode && !empty($existingBan) || !$isCreateMode && !empty($existingBan) && $banid != $existingBan['banid']) {
            $url = WEBIM_ROOT . '/operator/ban.php';
            $errors[] = Resources::Get('ban.error.duplicate', array($address, $url . '?banid=' . $existingBan['banid']));
        }
    }
    if (empty($errors)) {
        $time = strtotime($till);
        if ($time < 1) {
            $errors[] = Resources::Get('errors.format', Resources::Get('form.field.till'));
        }
        $hashTable = array('till' => date('Y-m-d H:i:s', $time), 'address' => $address, 'comment' => $comment);
        if ($isCreateMode) {
            $hashTable['created'] = null;
        } else {
            $hashTable['banid'] = $banid;
        }
        $banMapper->save($hashTable);
        header('Location: ' . AdminURL::getInstance()->getURL('blocked'));
        exit;
    }
    $TML->assign('address', $address);
    $TML->assign('till', $till);
    $TML->assign('comment', $comment);
} elseif (isset($_REQUEST['banid'])) {
Exemplo n.º 24
0
 private static function formatStatistics($start, $end)
 {
     $result = '';
     $report = MapperFactory::getMapper('Thread')->getReportByDate($start, $end);
     if (count($report) == 0) {
         $report = array(array(date(getDateFormat(), $start), 0, 0, 0));
     }
     if (count($report) > 1) {
         $report_total = MapperFactory::getMapper('Thread')->getReportTotalByDate($start, $end);
         $report_total = array_values($report_total);
         array_unshift($report_total, Resources::Get('report.total'));
         $report[] = $report_total;
         unset($report_total);
     }
     $result .= Resources::Get('report.bydate.title') . "\n";
     $result .= self::formatTable(array(Resources::Get('report.bydate.1'), Resources::Get('report.bydate.2'), Resources::Get('report.bydate.3'), Resources::Get('report.bydate.4')), $report, self::FIELD_LENGTH) . "\n\n";
     $report = MapperFactory::getMapper('Operator')->getAdvancedReportByDate($start, $end);
     $result .= Resources::Get('report.byoperator_date.title') . "\n";
     $result .= Resources::Get('report.no_items');
     $dates_count = count($report);
     if (count($report) > 0) {
         $header = array(Resources::Get('report.byoperator.1'), Resources::Get('report.byoperator.2'), Resources::Get('report.byoperator.3'), Resources::Get('report.byoperator.6'), Resources::Get('report.byoperator.7'), Resources::Get('report.byoperator.11'));
         $field_count = count($header);
         $length_chars = $field_count * self::FIELD_LENGTH + $field_count;
         $result .= self::makeBorder($field_count, self::FIELD_LENGTH) . "\n";
         $result .= self::formatTableLine($header, self::FIELD_LENGTH) . "\n";
         $result .= self::makeBorder($field_count, self::FIELD_LENGTH) . "\n";
         $middle = floor($length_chars / 2);
         foreach ($report as $d => $r) {
             if ($dates_count > 1) {
                 $result .= sprintf('%' . ($middle + strlen($d)) . 's', $d) . "\n";
                 $result .= self::makeBorder($field_count, self::FIELD_LENGTH) . "\n";
             }
             foreach ($r as $v) {
                 $v = array($v['name'], $v['threads'], isset($v['messages']) ? $v['messages'] : '', $v['online_time'], $v['online_chatting_time'], $v['invited_users']);
                 $result .= self::formatTableLine($v, self::FIELD_LENGTH) . "\n";
                 $result .= self::makeBorder($field_count, self::FIELD_LENGTH) . "\n";
             }
         }
     }
     $result .= "\n\n";
     if ($dates_count > 1) {
         $report = Thread::getInstance()->GetReportByAgent($start, $end);
         $data = array();
         foreach ($report as $v) {
             $data[] = array($v['name'], $v['threads'], $v['messages'], $v['online_time'], $v['online_chatting_time'], $v['invited_users']);
         }
         $result .= Resources::Get('report.byoperator.title') . "\n";
         $result .= self::formatTable($header, $data, self::FIELD_LENGTH) . "\n\n";
     }
     $result .= Resources::Get('report.lostvisitors.title') . "\n";
     $report = MapperFactory::getMapper('LostVisitor')->getReportByOperator($start, $end);
     $data = array();
     $header = array(Resources::Get('report.lostvisitors.1'), Resources::Get('report.lostvisitors.2'), Resources::Get('report.lostvisitors.3'));
     if (!empty($report)) {
         foreach ($report as $v) {
             $data[] = array($v['name'], isset($v['lost_vistors_count']) ? $v['lost_vistors_count'] : 0, isset($v['avg_waittime_str']) ? $v['avg_waittime_str'] : 0);
         }
     }
     $result .= self::formatTable($header, $data, self::FIELD_LENGTH) . "\n\n";
     $result .= Resources::Get('report.interceptedvisitors.title') . "\n";
     $report = MapperFactory::getMapper('LostVisitor')->getReportInterceptedByOperator($start, $end);
     $data = array();
     $header = array(Resources::Get('report.interceptedvisitors.1'), Resources::Get('report.interceptedvisitors.2'), Resources::Get('report.interceptedvisitors.3'));
     if (!empty($report)) {
         foreach ($report as $v) {
             $data[] = array($v['name'], isset($v['lost_vistors_count']) ? $v['lost_vistors_count'] : 0, isset($v['avg_waittime_str']) ? $v['avg_waittime_str'] : 0);
         }
     }
     $result .= self::formatTable($header, $data, self::FIELD_LENGTH);
     return $result;
 }
Exemplo n.º 25
0
 public function sendAutoIniviteTextToOperator($thread, $autoinviteid)
 {
     $ainvite = MapperFactory::getMapper("AutoInvite")->getById($autoinviteid);
     if (empty($ainvite)) {
         return;
     }
     $message = Resources::Get("chat.window.auto_invite_text", array($ainvite['text']));
     Thread::getInstance()->PostMessage($thread['threadid'], KIND_FOR_AGENT, $message);
 }
Exemplo n.º 26
0
    $TML->assign('phone', getSecureText($phone));
    $TML->assign('message', getSecureText($message));
    $TML->assign('canChangeName', getSecureText($canChangeName));
    $TML->assign('captcha_num', '');
    $TML->display('leave-message.tpl');
    exit;
}
$visitSessionId = VisitSession::GetInstance()->updateCurrentOrCreateSession();
$params = array();
$params['visitsessionid'] = $visitSessionId;
$params['lastpingvisitor'] = null;
$params['offline'] = 1;
$threads_count = MapperFactory::getMapper('Thread')->getNonEmptyThreadsCountByVisitorId($visitorid);
$thread = Thread::getInstance()->CreateThread(WEBIM_CURRENT_LOCALE, STATE_CLOSED, $params);
VisitSession::GetInstance()->UpdateVisitSession($visitSessionId, array('hasthread' => 1));
Thread::getInstance()->sendFirstMessageWithVisitorInfo($thread);
Thread::getInstance()->PostMessage($thread['threadid'], KIND_USER, Resources::Get('chat.window.offline_message', array($message)));
MapperFactory::getMapper('Thread')->incrementVisitorMessageCount($thread['threadid']);
$first_message = MapperFactory::getMapper('Message')->getFirstMessage($thread['threadid']);
Visitor::getInstance()->setVisitorNameCookie($visitor_name);
// отправке диалогов из мессенджера
$subject = $dept && isset($aDko[$dept]['subject']) ? $subject = $aDko[$dept]['subject'] : Resources::Get('leavemail.subject', array($visitor_name), WEBIM_CURRENT_LOCALE);
$body = Resources::Get('leavemail.body', array($visitor_name, $email, $message, $phone, Thread::getInstance()->formatOpenerWithTitle(), HTTP_PREFIX . $_SERVER['HTTP_HOST'] . WEBIM_ROOT . '/operator/threadprocessor.php?threadid=' . $thread['threadid'], str_replace("\n", "\n\n", $first_message['message'])), WEBIM_CURRENT_LOCALE);
// отправке диалогов из мессенджера
if ($dept && ($feedback = feedbackAdd($dept, $visitor_name, $email, $body, get_uid(false)))) {
    $body .= "\n" . '[[UCODE::{' . $feedback['uc'] . '},FID::{' . $feedback['id'] . '}]]';
}
// отправке диалогов из мессенджера
$inbox_mail = $dept && isset($aDko[$dept]['email']) ? $aDko[$dept]['email'] : Settings::Get('offline_email');
webim_mail($inbox_mail, $visitor_name . '<' . $email . '>', $subject, $body);
$TML->display('leave-message-sent.tpl');
Exemplo n.º 27
0
}
$eHistory = $history = "";
$lastid = -1;
$output = Thread::getInstance()->GetMessages($threadid, "text", true, $lastid);
foreach ($output as $msg) {
    $history .= $msg;
    $eHistory .= $msg;
}
$visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
$systemInfo = "Системная информация\nимя: " . $visitSession['visitorname'] . "\nсоздан: " . date('Y-m-d', $visitSession['created']) . "\nip: {$visitSession['ip']}\nбраузер: " . get_user_agent($visitSession['useragent']) . "\n\n";
$history = $systemInfo . $history;
$subject = Resources::Get("mail.visitor.history.subject");
// отправке диалогов из мессенджера ------------
if ($dept && isset($aDko[$dept]['subject'])) {
    $subject = $aDko[$dept]['subject'];
}
$visitor_name = $visitSession['visitorname'];
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
// отправке диалогов из мессенджера
if ($dept && ($feedback = feedbackAdd($dept, $visitor_name, $email_from, $body, 0))) {
    $body .= "\n" . '[[UCODE::{' . $feedback['uc'] . '},FID::{' . $feedback['id'] . '}]]';
}
$webim_from_email = $email_from ? $email_from : Settings::Get("from_email");
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
webim_mail($email, $webim_from_email, $subject, $body, 0);
// отправке диалогов из мессенджера ------------
if ($dept && isset($aDko[$dept]['option'])) {
    $sMsg = 'Диалог был отправлен в раздел: ' . $aDko[$dept]['option'];
    Thread::getInstance()->PostMessage($threadid, KIND_EVENTS, $sMsg);
}
$TML->display('send-history-sent.tpl');
Exemplo n.º 28
0
 public function SendRecoverPasswordMail($operatorid, $host)
 {
     $op = MapperFactory::getMapper('Operator')->getById($operatorid);
     $hash['recoverytoken'] = $this->generateToken(16);
     $hash['recoverytime'] = null;
     // MySQL auto update
     $hash['operatorid'] = $operatorid;
     MapperFactory::getMapper('Operator')->save($hash);
     $link = HTTP_PREFIX . $host . WEBIM_ROOT . '/operator/recover_password.php?act=recover&login='******'login'] . '&token=' . $hash['recoverytoken'];
     $subject = Resources::Get('mail.password_recover.subject', Resources::getCurrentLocale());
     $body = Resources::Get('mail.password_recover.body', array($op['fullname'], $link), Resources::getCurrentLocale());
     webim_mail($op['fullname'] . '<' . $op['email'] . '>', Settings::Get('from_email'), $subject, $body);
     // TODO send link
 }
Exemplo n.º 29
0
    }
    if (empty($till)) {
        $errors[] = Resources::Get("errors.required", Resources::Get('form.field.till'));
    }
    $isCreateMode = empty($banid);
    if (empty($errors)) {
        $existingBan = $banMapper->getBanBydAddress($address);
        if ($isCreateMode && !empty($existingBan) || !$isCreateMode && !empty($existingBan) && $banid != $existingBan['banid']) {
            $url = WEBIM_ROOT . '/operator/ban.php';
            $errors[] = Resources::Get("ban.error.duplicate", array($address, $url . '?banid=' . $existingBan['banid']));
        }
    }
    if (empty($errors)) {
        $time = strtotime($till);
        if ($time < 1) {
            $errors[] = Resources::Get("errors.format", Resources::Get("form.field.till"));
        }
        $hashTable = array('till' => date('Y-m-d H:i:s', $time), 'address' => $address, 'comment' => $comment);
        if ($isCreateMode) {
            $hashTable['created'] = null;
        } else {
            $hashTable['banid'] = $banid;
        }
        $banMapper->save($hashTable);
        header("Location: " . AdminURL::getInstance()->getURL('blocked'));
        exit;
    }
    $TML->assign('address', $address);
    $TML->assign('till', $till);
    $TML->assign('comment', $comment);
} elseif (isset($_REQUEST['banid'])) {
Exemplo n.º 30
0
$tmlPage['showresults'] = false;
$tmlPage['departments'] = MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale());
$tmlPage['locales'] = getAvailableLocalesForChat();
Operator::getInstance()->ensureOperatorsAreInLastAccess();
$errors = array();
if (isset($_GET['startday'])) {
    $startday = verify_param("startday", "/^\\d+\$/");
    $startmonth = verify_param("startmonth", "/^\\d{2}.\\d{2}\$/");
    $endday = verify_param("endday", "/^\\d+\$/");
    $endmonth = verify_param("endmonth", "/^\\d{2}.\\d{2}\$/");
    $start = get_form_date($startday, $startmonth);
    $end = get_form_date($endday, $endmonth) + 24 * 60 * 60;
    $locale = verify_param("locale", "/^(en|ru)\$/");
    $departmentid = verify_param("departmentid", "/^\\d+\$/");
    if ($start > $end) {
        $errors[] = Resources::Get("statistics.wrong.dates");
    }
    Operator::getInstance()->loadOnlineStatsIntoDB();
    $tmlPage['reportByDate'] = MapperFactory::getMapper("Thread")->getReportByDate($start, $end, $departmentid, $locale);
    $tmlPage['reportByDateTotal'] = MapperFactory::getMapper("Thread")->getReportTotalByDate($start, $end, $departmentid, $locale);
    $tmlPage['reportByAgent'] = Thread::getInstance()->GetReportByAgent($start, $end, $departmentid, $locale);
    $tmlPage['reportLostVisitors'] = MapperFactory::getMapper("LostVisitor")->getReportByOperator($start, $end, $departmentid, $locale);
    $tmlPage['reportInterceptedVisitors'] = MapperFactory::getMapper("LostVisitor")->getReportInterceptedByOperator($start, $end, $departmentid, $locale);
    $tmlPage['reportByAgentByDate'] = MapperFactory::getMapper("Operator")->getAdvancedReportByDate($start, $end, $departmentid, $locale);
    $tmlPage['locale'] = $locale;
    $tmlPage['departmentid'] = $departmentid;
    $tmlPage['showresults'] = count($errors) ? 0 : 1;
    $tmlPage["formstartday"] = date("d", $start);
    $tmlPage["formstartmonth"] = date("m.y", $start);
    $tmlPage["formendday"] = date("d", $end - 24 * 60 * 60);
    $tmlPage["formendmonth"] = date("m.y", $end - 24 * 60 * 60);