From fa3e71779f64f7b01e5537134bbfcff6f68e03ae Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Tue, 9 Dec 2008 01:12:08 +0000 Subject: [PATCH] settings for geolocation link git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@223 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/libs/common.php | 2 +- src/messenger/webim/locales/en/properties | 4 ++ src/messenger/webim/locales/ru/properties | 4 ++ src/messenger/webim/operator/settings.php | 85 ++++++++++++----------- src/messenger/webim/operator/update.php | 2 +- src/messenger/webim/view/settings.php | 8 +++ 6 files changed, 63 insertions(+), 42 deletions(-) diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 6d82512e..a08ae385 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -445,7 +445,7 @@ $settings = array( 'chatstyle' => 'default', 'chattitle' => 'Live Support', 'geolink' => 'http://api.hostip.info/get_html.php?ip={ip}', - 'geolinkparams' => 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=440,height=100,resizable=1', + 'geolinkparams' => 'width=440,height=100,toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1', ); $settingsloaded = false; $settings_in_db = array(); diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 8b986505..12e8a681 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -281,6 +281,10 @@ settings.email=Email settings.email.description=Enter email to receive system messages settings.enableban=Enable feature "Malicious Visitors" settings.enableban.description=Using it you can block attacks from specific IPs +settings.geolink=Link to an external geolocation service +settings.geolink.description=Each IP becomes a link opening in new window. {ip} is substituted with a real ip. +settings.geolinkparams=Geolocation window options +settings.geolinkparams.description=Window size and toolbars hiding settings.host=URL of your website settings.host.description=Destination for you company name or logo link settings.logo=Your company logo diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index 321d7b59..30cf65f2 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -281,6 +281,10 @@ settings.email= settings.email.description=Введите адрес электронной почты для получения сообщений от системы settings.enableban=Включить функцию "Нежелательные посетители" settings.enableban.description=С ее помощью можно блокировать атаки с определенных адресов +settings.geolink=Ссылка на внешний geolocation сервис +settings.geolink.description=На любом IP адресе можно будет открыть небольшое окно с геоинформацией. Можно использовать {ip}. +settings.geolinkparams=Опции для окна с геоинформацией +settings.geolinkparams.description=Размер окна и наличие тулбаров settings.host=Ссылка на ваш веб сайт settings.host.description=Будет открываться по нажатию на логотип или название компании в чат окне settings.logo=Лого компании diff --git a/src/messenger/webim/operator/settings.php b/src/messenger/webim/operator/settings.php index 71af67a1..032f910f 100644 --- a/src/messenger/webim/operator/settings.php +++ b/src/messenger/webim/operator/settings.php @@ -45,62 +45,67 @@ if($handle = opendir($stylesfolder)) { closedir($handle); } +$options = array( + 'email', 'title', 'logo', 'hosturl', 'enableban', 'usernamepattern', 'usercanchangename', + 'chatstyle', 'chattitle', 'geolink', 'geolinkparams'); + loadsettings(); -$email = $settings['email']; -$title = $settings['title']; -$logo = $settings['logo']; -$hosturl = $settings['hosturl']; -$enableban = $settings['enableban']; -$usernamepattern = $settings['usernamepattern']; -$usercanchangename = $settings['usercanchangename']; -$chatstyle = $settings['chatstyle']; -$chattitle = $settings['chattitle']; +$params = array(); +foreach($options as $opt) { + $params[$opt] = $settings[$opt]; +} if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { - $email = getparam('email'); - $title = getparam('title'); - $logo = getparam('logo'); - $hosturl = getparam('hosturl'); - $enableban = verifyparam("enableban","/^on$/", "") == "on" ? "1" : "0"; - $usernamepattern = getparam('usernamepattern'); - $usercanchangename = verifyparam("usercanchangename", "/^on$/", "") == "on" ? "1" : "0"; - $chattitle = getparam('chattitle'); + $params['email'] = getparam('email'); + $params['title'] = getparam('title'); + $params['logo'] = getparam('logo'); + $params['hosturl'] = getparam('hosturl'); + $params['enableban'] = verifyparam("enableban","/^on$/", "") == "on" ? "1" : "0"; + $params['usernamepattern'] = getparam('usernamepattern'); + $params['usercanchangename'] = verifyparam("usercanchangename", "/^on$/", "") == "on" ? "1" : "0"; + $params['chattitle'] = getparam('chattitle'); + $params['geolink'] = getparam('geolink'); + $params['geolinkparams'] = getparam('geolinkparams'); - $chatstyle = verifyparam("chatstyle","/^\w+$/", $chatstyle); - if(!in_array($chatstyle, $stylelist)) { - $chatstyle = $stylelist[0]; + $params['chatstyle'] = verifyparam("chatstyle","/^\w+$/", $params['chatstyle']); + if(!in_array($params['chatstyle'], $stylelist)) { + $params['chatstyle'] = $stylelist[0]; } - if($email && !is_valid_email($email)) { + if($params['email'] && !is_valid_email($params['email'])) { $errors[] = getlocal("settings.wrong.email"); } + if($params['geolinkparams']) { + foreach(split(",", $params['geolinkparams']) as $oneparam) { + if(!preg_match("/^\s*(toolbar|scrollbars|location|status|menubar|width|height|resizable)=\d{1,4}$/", $oneparam)) { + $errors[] = "Wrong link parameter: \"$oneparam\", should be one of 'toolbar, scrollbars, location, status, menubar, width, height or resizable'"; + } + } + } + if (count($errors) == 0) { - $settings['email'] = $email; - $settings['title'] = $title; - $settings['logo'] = $logo; - $settings['hosturl'] = $hosturl; - $settings['enableban'] = $enableban; - $settings['usernamepattern'] = $usernamepattern; - $settings['usercanchangename'] = $usercanchangename; - $settings['chatstyle'] = $chatstyle; - $settings['chattitle'] = $chattitle; - update_settings(); + foreach($options as $opt) { + $settings[$opt] = $params[$opt]; + } + update_settings(); header("Location: $webimroot/operator/index.php"); exit; } } $page['operator'] = topage(get_operator_name($operator)); -$page['formemail'] = topage($email); -$page['formtitle'] = topage($title); -$page['formlogo'] = topage($logo); -$page['formhosturl'] = topage($hosturl); -$page['formenableban'] = $enableban == "1"; -$page['formusernamepattern'] = topage($usernamepattern); -$page['formusercanchangename'] = $usercanchangename == "1"; -$page['formchatstyle'] = $chatstyle; -$page['formchattitle'] = topage($chattitle); +$page['formemail'] = topage($params['email']); +$page['formtitle'] = topage($params['title']); +$page['formlogo'] = topage($params['logo']); +$page['formhosturl'] = topage($params['hosturl']); +$page['formgeolink'] = topage($params['geolink']); +$page['formgeolinkparams'] = topage($params['geolinkparams']); +$page['formenableban'] = $params['enableban'] == "1"; +$page['formusernamepattern'] = topage($params['usernamepattern']); +$page['formusercanchangename'] = $params['usercanchangename'] == "1"; +$page['formchatstyle'] = $params['chatstyle']; +$page['formchattitle'] = topage($params['chattitle']); $page['availableStyles'] = $stylelist; start_html_output(); diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index d50bc958..081b71cc 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -70,7 +70,7 @@ function get_useragent_version($userAgent) { function get_user_addr($addr) { global $settings; - if(preg_match( "/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches )) { + if($settings['geolink'] && preg_match( "/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches )) { $userip = $matches[1]; return get_popup(str_replace("{ip}", $userip, $settings['geolink']), htmlspecialchars($addr), "GeoLocation", "ip$userip", $settings['geolinkparams']); } diff --git a/src/messenger/webim/view/settings.php b/src/messenger/webim/view/settings.php index 945f7234..c3b6cf9c 100644 --- a/src/messenger/webim/view/settings.php +++ b/src/messenger/webim/view/settings.php @@ -86,6 +86,14 @@ + + + + + + + +