public static function getImageNameFromParam($pImage, $pDepartmentKey = null, $pLang = null, $pImagePostfix = null, $hasOnline = null) { if (!preg_match('/\\.(gif|jpg|png)$/i', $pImage)) { $image = $pImage . '.gif'; } else { $image = $pImage; } if (empty($pLang) || !Resources::IsLocaleAvailable($pLang)) { $lang = Resources::getCurrentLocale(); } else { $lang = $pLang; } if (empty($pImagePostfix)) { if (empty($hasOnline)) { $image_postfix = Operator::getInstance()->hasOnlineOperators($pDepartmentKey, $lang) ? 'on' : 'off'; } else { $image_postfix = $hasOnline ? 'on' : 'off'; } } else { $image_postfix = $pImagePostfix; } $image = preg_replace('/\\.(gif|jpg|png)/i', '_' . $image_postfix . '.\\1', $image); return "/themes/.buttons/{$lang}/{$image}"; }
$tmlPage['formendday'] = date('d', $currTime); $tmlPage['formendmonth'] = date('m.y', $currTime); } } // // This function should be defined before it's used otherwise on // some PHP verions it can fail with Fatal error: Call to undefined function // 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; } $tmlPage['availableDays'] = range(1, 31); $currTime = getCurrentTime(); $tmlPage['availableMonth'] = get_month_selection($currTime - 400 * 24 * 60 * 60, $currTime); $tmlPage['operatorList'] = get_operators_list(); $TML->assign('departments', Operator::getInstance()->enumAvailableDepartmentsForOperator($operator['operatorid'], Resources::getCurrentLocale())); $TML->assign('locales', getAvailableLocalesForChat()); $tmlPage['show_empty'] = $show_empty; $TML->assign('page_settings', $tmlPage); $TML->assign('advanced', true); $TML->display('thread_search.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
require_once '../classes/class.smartyclass.php'; $TML = new SmartyClass(); $operator = Operator::getInstance()->GetLoggedOperator(); $threadid = verify_param("thread", "/^\\d{1,8}\$/"); $token = verify_param("token", "/^\\d{1,8}\$/"); $thread = Thread::getInstance()->GetThreadById($threadid); $visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']); $TML->assign('visit_session', $visitSession); if (!$thread || !isset($thread['token']) || $token != $thread['token']) { die("wrong thread"); } $nextid = verify_param("nextoperatorid", "/^\\d{1,8}\$/"); $nextdepartmentid = verify_param("nextdepartmentid", "/^\\d{1,8}\$/"); $page = array(); if (!empty($nextid)) { $nextOperator = Operator::getInstance()->GetOperatorById($nextid); $TML->assign('nextoperator', $nextOperator); } if (!empty($nextdepartmentid)) { $nextdepartment = Department::getInstance()->getById($nextdepartmentid, Resources::getCurrentLocale()); $TML->assign('nextdepartment', $nextdepartment); } $errors = array(); ThreadProcessor::getInstance()->ProcessThread($threadid, 'redirect', array('nextoperatorid' => $nextid, 'nextdepartmentid' => $nextdepartmentid, 'operator' => Operator::getInstance()->GetLoggedOperator())); $TML->assign('page_settings', $page); if (count($errors) > 0) { $TML->assign('errors', $errors); $TML->display('chat_error.tpl'); } else { $TML->display('redirected.tpl'); }
$image = verify_param('image', "/^[\\w\\.]+\$/", 'webim'); $theme = verify_param('theme', "/^\\w+\$/", 'default'); $TML->assign('theme', $theme); //$TML->assign('availableImages', Button::enumAvailableImages(WEBIM_CURRENT_LOCALE)); //$TML->assign('availableThemes', enumAvailableThemes()); //$TML->assign('availableDepartments', MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale())); $TML->assign('params', Button::getParameters()); $lang = Resources::getCurrentLocale(); $showhost = verify_param('include_host_url', '/^y$/', '') == 'y'; $includeTracker = verify_param('add_track_code', '/^y$/', '') == 'y'; $forcesecure = verify_param('secure', '/^y$/', '') == 'y'; $chooseoperator = verify_param('choose_operator', "/^\\w+\$/", ''); $chatimmediately = verify_param('chat_immediately', '/^y$/', '') == 'y'; $departmentkey = verify_param('department_key', "/^\\w+\$/"); $choosedepartment = verify_param('choose_department', '/^y$/', '') == 'y'; $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');
$image = verify_param("image", "/^[\\w\\.]+\$/", "webim"); $theme = verify_param("theme", "/^\\w+\$/", "default"); $TML->assign('theme', $theme); //$TML->assign('availableImages', Button::enumAvailableImages(WEBIM_CURRENT_LOCALE)); //$TML->assign('availableThemes', enumAvailableThemes()); //$TML->assign('availableDepartments', MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale())); $TML->assign('params', Button::getParameters()); $lang = Resources::getCurrentLocale(); $showhost = verify_param("include_host_url", "/^y\$/", "") == "y"; $includeTracker = verify_param("add_track_code", "/^y\$/", "") == "y"; $forcesecure = verify_param("secure", "/^y\$/", "") == "y"; $chooseoperator = verify_param("choose_operator", "/^\\w+\$/", ""); $chatimmediately = verify_param("chat_immediately", "/^y\$/", "") == "y"; $departmentkey = verify_param("department_key", "/^\\w+\$/"); $choosedepartment = verify_param("choose_department", "/^y\$/", "") == "y"; $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');
* */ $TITLE_KEY = 'statistics.title'; require_once dirname(__FILE__) . '/inc/admin_prolog.php'; require_once '../classes/functions.php'; require_once '../classes/class.thread.php'; require_once '../classes/class.operator.php'; require_once '../classes/class.smartyclass.php'; Operator::getInstance()->IsCurrentUserAdminOrRedirect(); $tmlPage = null; $TML = new SmartyClass($TITLE_KEY); $tmlPage['availableDays'] = range(1, 31); $currTime = getCurrentTime(); $tmlPage['availableMonth'] = get_month_selection($currTime - 400 * 24 * 60 * 60, $currTime + 50 * 24 * 60 * 60); $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"); }
public function enumAvailableDepartmentsForOperator($operatorid, $locale) { $departmentsExist = MapperFactory::getMapper('Department')->departmentsExist(); return MapperFactory::getMapper('OperatorDepartment')->enumAvailableDepartmentsForOperator($operatorid, Resources::getCurrentLocale(), $departmentsExist); }
<?php /* * * Данный файл является частью проекта Веб Мессенджер. * * Все права защищены. (c) 2005-2009 ООО "ТОП". * Данное программное обеспечение и все сопутствующие материалы * предоставляются на условиях лицензии, доступной по адресу * http://webim.ru/license.html * */ $TITLE_KEY = 'leftMenu.departments'; require_once dirname(__FILE__) . '/inc/admin_prolog.php'; require_once '../classes/functions.php'; require_once '../classes/class.operator.php'; require_once '../classes/class.smartyclass.php'; require_once '../classes/models/generic/class.mapperfactory.php'; Operator::getInstance()->IsCurrentUserAdminOrRedirect(); $TML = new SmartyClass($TITLE_KEY); $departments = MapperFactory::getMapper('Department')->enumDepartments(Resources::getCurrentLocale()); $TML->assign('departments', $departments); $TML->display('departments.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
static function SetLocaleLanguage() { if (Resources::getCurrentLocale() == 'ru') { $locale = 'ru_RU'; } else { $locale = 'en_EN'; } if (setlocale(LC_ALL, $locale . '.' . (defined('WEBIM_ENCODING') ? WEBIM_ENCODING : 'UTF-8')) === false) { setlocale(LC_ALL, Resources::getCurrentLocale()); } }
public function getListThreads($currentoperatorid, $q, $show_empty = true, $checkDepartmentsAccess = true, $start_date = null, $end_date = null, $operatorid = null, $offset = null, $limit = null, $departmentid = null, $locale = null, $rate = null) { $departmentsExist = count(MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale())); // TODO probably not the best place $query_params = array(); $sql = ' SELECT WM_UNIX_TIMESTAMP(t."created") "created", WM_UNIX_TIMESTAMP(t."modified") "modified", t."threadid", t."operatorfullname", t."visitormessagecount" as "size", v."ip" as "remote", v."remotehost", v."visitorname" FROM "{thread}" t LEFT JOIN "{visitsession}" v ON v."visitsessionid" = t."visitsessionid" WHERE 1=1'; if (!empty($q)) { $query_params['query'] = "%%{$q}%%"; $sql .= ' AND (t."threadid" IN ( SELECT "threadid" FROM "{message}" m WHERE m."sendername" LIKE :query OR m."message" LIKE :query ) OR v."visitorid" LIKE :query OR v."ip" LIKE :query OR v."remotehost" LIKE :query OR t."operatorfullname" LIKE :query )'; } if (!empty($rate)) { $sign = $rate == 'positive' ? '>' : '<'; $sql .= ' AND EXISTS(SELECT * FROM "{rate}" r WHERE r."threadid"=t."threadid" AND r."rate" ' . $sign . ' 0 AND r."deldate" IS NULL)'; } if ($checkDepartmentsAccess) { $sql .= ' AND (t."departmentid" IS NULL OR EXISTS(SELECT * FROM "{operatordepartment}" od WHERE od."operatorid"=:currentoperatorid AND od."departmentid"=t."departmentid"))'; $query_params['currentoperatorid'] = $currentoperatorid; } if (!$show_empty) { $sql .= ' AND t."visitormessagecount" > 0 '; } if ($start_date !== null) { $query_params['start_date'] = $start_date; $sql .= ' AND WM_UNIX_TIMESTAMP(t."created") >= :start_date'; } if ($end_date !== null) { $query_params['end_date'] = $end_date; $sql .= ' AND WM_UNIX_TIMESTAMP(t."created") < :end_date'; } if ($operatorid !== null) { $query_params['operatorid'] = $operatorid; $sql .= ' AND (:operatorid IS NULL OR t."operatorid"=:operatorid)'; } if (!empty($departmentid)) { $query_params['departmentid'] = $departmentid; $sql .= ' AND t."departmentid" = :departmentid '; } if (!empty($locale)) { $query_params['locale'] = $locale; $sql .= ' AND t."locale" = :locale '; } if ($limit !== null && $offset !== null) { $query_params['limit'] = $limit; $query_params['offset'] = $offset; $sql .= " AND rownum BETWEEN :offset AND :limit"; } $sql .= ' ORDER BY t."created" DESC'; try { $this->db->query($sql, $query_params); $result = $this->db->getArrayOfRows(); } catch (Exception $e) { return array(); } foreach ($result as $k => $v) { $geodata = GeoIPLookup::getGeoDataByIP($v['remote']); //for testing purpose //$geodata = GeoIPLookup::getGeoDataByIP('89.113.218.99'); if ($geodata == NULL) { $geodata = array('city' => null, 'country' => null, 'lat' => null, 'lng' => null); } $result[$k] = array_merge($v, $geodata); $result[$k]['created'] = date(getDateTimeFormat(), $v['created']); $result[$k]['modified'] = date(getDateTimeFormat(), $v['modified']); $result[$k]['diff'] = webim_date_diff($v['modified'] - $v['created']); } return $result; }
function setAllDepartments() { global $TML; $operator = Operator::getInstance()->GetLoggedOperator(false); $departments = MapperFactory::getMapper("OperatorDepartment")->enumDepartmentsWithOperator($operator['operatorid'], Resources::getCurrentLocale()); $TML->assign('departments', $departments); }
public function getListThreadsCount($currentoperatorid, $q, $show_empty = true, $checkDepartmentsAccess = true, $start_date = null, $end_date = null, $operatorid = null, $departmentid = null, $locale = null, $rate = null, $offline = null) { $departmentsExist = count(MapperFactory::getMapper('Department')->enumDepartments(Resources::getCurrentLocale())); // TODO probably not the best place $query_params = array(); $sWhere = ''; $nTotal = 0; $sCountSql = 'SELECT COUNT(*) AS cnt FROM {thread} as t LEFT JOIN {visitsession} as v ON v.visitsessionid = t.visitsessionid WHERE 1'; if (!empty($q)) { $query_params['query'] = "%%{$q}%%"; $sWhere .= ' AND (t.threadid IN ( SELECT threadid FROM {message} as m WHERE m.sendername LIKE :query OR m.message LIKE :query ) OR v.visitorid LIKE :query OR v.ip LIKE :query OR v.remotehost LIKE :query OR t.operatorfullname LIKE :query )'; } if (!empty($rate)) { $sign = $rate == 'positive' ? '>' : '<'; $sWhere .= " AND EXISTS (SELECT * FROM {rate} r WHERE r.threadid=t.threadid AND r.rate {$sign} 0 AND r.deldate IS NULL) "; } if ($checkDepartmentsAccess) { $sWhere .= ' AND (t.departmentid IS NULL OR EXISTS(SELECT * FROM {operatordepartment} od WHERE od.operatorid=:currentoperatorid AND od.departmentid=t.departmentid)) '; $query_params['currentoperatorid'] = $currentoperatorid; } if (!$show_empty) { $sWhere .= ' AND t.visitormessagecount > 0 '; } if ($start_date !== null) { $query_params['start_date'] = $start_date; $sWhere .= ' AND unix_timestamp(t.created) >= :start_date'; } if ($end_date !== null) { $query_params['end_date'] = $end_date; $sWhere .= ' AND unix_timestamp(t.created) < :end_date'; } if ($operatorid !== null) { $query_params['operatorid'] = $operatorid; $sWhere .= ' AND (:operatorid IS NULL OR t.operatorid=:operatorid)'; } if (!empty($departmentid)) { $query_params['departmentid'] = $departmentid; $sWhere .= ' AND t.departmentid = :departmentid '; } if (!empty($locale)) { $query_params['locale'] = $locale; $sWhere .= ' AND t.locale = :locale '; } if ($offline !== null) { $query_params['offline'] = $offline; $sWhere .= ' AND t.offline=:offline'; } $sCountSql .= $sWhere; try { $this->db->query($sCountSql, $query_params); $this->db->nextRecord(); $nTotal = $this->db->getRow('cnt'); } catch (Exception $e) { return 0; } return $nTotal; }
require_once('../classes/models/generic/class.mapperfactory.php'); require_once('../classes/class.json.php'); require_once('../classes/class.thread.php'); if(!session_id()) { session_start(); } $theme = verify_param("theme", "/^\w+$/", "default"); $isSecure = verify_param("issecure", "/^\d+$/", 0) == 1; $location = get_app_location(true, $isSecure); $lang = Resources::getCurrentLocale(); $link = $location."/client.php?theme=$theme".(!empty($lang) ? "&lang=".$lang : ""); $temp = get_popup_onclick($link, "webim_".getWindowNameSuffix(), "toolbar=0, scrollbars=0, location=0, menubar=0, width=528, height=456, resizable=1", true); // папка online в мэмкэш -------------------- //$operators = Operator::getInstance()->getOnlineOperatorsFromFiles(); $operators = Operator::getInstance()->getOnlineOperatorsFromMemBuff(); $operators_count = count($operators); $no_operators = false; if($operators_count == 0) { $no_operators = true; } if(!isset($_COOKIE[WEBIM_COOKIE_VISITOR_IN_CHAT])) { $visitor = GetVisitorFromRequestAndSetCookie();
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; }
static function Init() { Resources::SetLocaleLanguage(); session_start(); // if (isset($_SESSION['WEBIM_TRACELOG']) && strlen($_SESSION['WEBIM_TRACELOG']) > 200*200) { // } $locale = Resources::getCurrentLocale(); define('WEBIM_CURRENT_LOCALE', $locale); self::initRequests(); if (function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { @date_default_timezone_set(@date_default_timezone_get()); } }
public function sendFirstMessageWithVisitorInfo($thread, $params = array()) { $visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']); $firstPage = null; $visted_pages = ""; if (!session_id()) { session_start(); } if (isset($_SESSION['user_stats'])) { $stats = $_SESSION['user_stats']; } else { $stats = getUsersStatsFromCookie(); } if (isset($stats['visited_pages']) && is_array($stats['visited_pages'])) { if (count($stats['visited_pages']) > 0) { $firstPage = $stats['visited_pages'][0]; } $visted_pages = "\n" . Resources::Get("chat.visited_pages"); foreach ($stats['visited_pages'] as $vp) { $title = isset($_SESSION['titles'], $_SESSION['titles'][$vp['url']]) ? $_SESSION['titles'][$vp['url']] : ""; if (WEBIM_ENCODING != 'UTF-8') { $title = smarticonv('utf-8', WEBIM_ENCODING, $title); } if (empty($title)) { $title = Resources::Get("chat.visited_page.no_title"); } $visted_pages .= "\n" . Resources::Get("chat.visited_page", array($title, HTTP_PREFIX . $_SERVER['HTTP_HOST'] . $vp['url'], $vp['time'])); } } $openerText = self::formatOpenerWithTitle(); $message = Resources::Get(empty($openerText) ? 'chat.came.from.unknown' : 'chat.came.from', $openerText); $simple = "\n%PARAM%: %VALUE%"; $link = "\n%PARAM%: %VALUE% %URL%"; if (!empty($thread['departmentid'])) { $departmentid = $thread['departmentid']; $dep = MapperFactory::getMapper("DepartmentLocale")->getDepartmentLocale($departmentid, Resources::getCurrentLocale()); $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('pending.table.head.department'), $dep['departmentname']), $simple); } if ($firstPage !== null) { if (!empty($firstPage['referrer'])) { $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.referrer'), parseReferrer($firstPage['referrer'], 'chat.window.referrer')), $simple); } if (!empty($firstPage['url'])) { $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.landingpage'), $firstPage['url']), $simple); } } $visitor_geodata = GeoIPLookup::getGeoDataByIP($visitSession['ip']); if (!empty($visitor_geodata)) { $message .= str_replace(array('%PARAM%', '%URL%', '%VALUE%'), array(Resources::Get('chat.window.geolocation'), "http://maps.google.com/maps?q=" . $visitor_geodata['lat'] . "," . $visitor_geodata['lng'], $visitor_geodata['city'] . ' ' . $visitor_geodata['country']), $link); } $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.browser'), get_user_agent($visitSession['useragent'])), $simple); $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.ip'), WEBIM_WHOIS_LINK . urlencode($visitSession['ip'])), $simple); if (!empty($visitSession['remotehost'])) { $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.remotehost'), $visitSession['remotehost']), $simple); } if (!empty($params['email'])) { $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.email'), $params['email']), $simple); } $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.fl_login'), $visitSession['fl_login']), $simple); $chats = Thread::getInstance()->CountNonEmptyThreads($visitSession['visitorid']); if ($chats > 0) { $message .= str_replace(array('%PARAM%', '%URL%', '%VALUE%'), array(Resources::Get('chat.window.chats'), HTTP_PREFIX . $_SERVER['HTTP_HOST'] . WEBIM_ROOT . '/operator/history.php?q=' . $visitSession['visitorid'], $chats), $link); } $message .= $visted_pages; Thread::getInstance()->PostMessage($thread['threadid'], KIND_FOR_AGENT, $message); }
function createNewThread() { $extAddr = Browser::GetExtAddr(); $remoteHost = !empty($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr; $visitSessionId = VisitSession::GetInstance()->updateCurrentOrCreateSession(); $params = array(); $params['visitsessionid'] = $visitSessionId; $params['lastpingvisitor'] = null; // $canChangeName = Visitor::getInstance()->canVisitorChangeName(); // if (!empty($_REQUEST['visitorname']) && $canChangeName) { // Visitor::getInstance()->setVisitorNameCookie($_REQUEST['visitorname']); // $params['visitorname'] = $_REQUEST['visitorname']; // } $operatorid = verify_param('operatorid', "/^(\\d)\$/"); $departmentkey = verify_param('departmentkey', "/^\\w+\$/"); $autoinviteid = verify_param('autoinviteid', "/^\\d+\$/"); if (!empty($departmentkey)) { $department = MapperFactory::getMapper('Department')->getByDepartmentKey($departmentkey); $params['departmentid'] = $department['departmentid']; } // else { // $departments = MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale()); // // if (count($departments) == 1) { // $params['departmentid'] = $departments[0]['departmentid']; // } // } // $startThreadState = null; if (!empty($operatorid) && ($operator = Operator::GetOperatorById($operatorid))) { $params['nextoperatorid'] = $operator['operatorid']; $startThreadState = STATE_LOADING_FOR_EXACT_OPERATOR; } else { $startThreadState = STATE_LOADING; } $thread = Thread::getInstance()->CreateThread(Resources::getCurrentLocale(), $startThreadState, $params); VisitSession::GetInstance()->UpdateVisitSession($visitSessionId, array('hasthread' => 1)); set_has_threads(HAS_THREADS_FILE); // если пользователь не ввел email, то по умолчанию сообщаем email с основной базы if (empty($_REQUEST['email']) && !empty($_SESSION['uid'])) { $_REQUEST['email'] = $GLOBALS['DB']->val('SELECT email FROM users WHERE uid = ?', $_SESSION['uid']); } Thread::getInstance()->sendFirstMessageWithVisitorInfo($thread, $_REQUEST); if (!empty($autoinviteid)) { Thread::getInstance()->sendAutoIniviteTextToOperator($thread, $autoinviteid); } $visitor = GetVisitorFromRequestAndSetCookie(); $opener = Thread::getInstance()->getOpenerWithTitle(); VisitSession::GetInstance()->setVisitSessionCurrentPage($visitor['id'], $opener[0], $opener[1]); if (!empty($_REQUEST['message'])) { $v = GetVisitorFromRequestAndSetCookie(); $hash = array(); $hash['sendername'] = $v['name']; $hash['message'] = $_REQUEST['message']; ThreadProcessor::getInstance()->ProcessThread($thread['threadid'], 'visitor_message', $hash); } if (!empty($email) || !empty($phone)) { Thread::getInstance()->PostMessage($thread['threadid'], KIND_FOR_AGENT, Resources::get('start.chat.info', array($email, $phone))); } // MapperFactory::getMapper("Thread")->incrementVisitorMessageCount($threadid); return $thread; }
* */ require_once '../classes/functions.php'; require_once '../classes/class.thread.php'; require_once '../classes/class.pagination.php'; require_once '../classes/class.smartyclass.php'; $operator = Operator::getInstance()->GetLoggedOperator(); $TML = new SmartyClass(); $action = $_REQUEST['action']; $TML->assign('action', $action); $threadid = verify_param('thread', "/^\\d{1,8}\$/"); $token = verify_param('token', "/^\\d{1,8}\$/"); $TML->assign('threadid', $threadid); $TML->assign('token', $token); if ($action == 'operators') { $found = Operator::getInstance()->getOnlineOperatorsWithDepartments($operator['operatorid'], Resources::getCurrentLocale()); $TML->assign('operators', $found); // $out = setupPage($found, $action, 'operatorid', 'fullname'); // $TML->assign('out', $out); } elseif ($action == 'visitor_redirected') { $TML->Assign('link', WEBIM_ROOT . '/operator/agent.php?thread=' . $threadid . '&token=' . $token . '&level=ajaxed&viewonly=true'); } elseif ($action == 'chat_closed') { $TML->Assign('link', WEBIM_ROOT . '/operator/agent.php?thread=' . $threadid . '&token=' . $token . '&level=ajaxed&viewonly=true&history=true'); } $TML->display('popup.tpl'); function setupPage($list, $action, $idfield, $valuefield) { global $token, $threadid, $TML; $pagination = setup_pagination($list); if (!empty($pagination)) { $page = array();