diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php index e02e9417..692c1b1c 100644 --- a/src/messenger/webim/libs/chat.php +++ b/src/messenger/webim/libs/chat.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 96623c9e..d355dbf8 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ session_start(); require_once(dirname(__FILE__).'/converter.php'); require_once(dirname(__FILE__).'/config.php'); -$version = '1.5.0'; +$version = '1.5.1'; function myiconv($in_enc, $out_enc, $string) { global $_utf8win1251, $_win1251utf8; @@ -64,12 +64,33 @@ function debugexit_print( $var ) { exit; } +$locale_pattern = "/^[\w-]{2,5}$/"; + +function locale_exists($locale) { + return file_exists(dirname(__FILE__)."/../locales/$locale/properties"); +} + +function get_available_locales() { + global $locale_pattern; + $list = array(); + $folder = dirname(__FILE__)."/../locales"; + if($handle = opendir($folder)) { + while (false !== ($file = readdir($handle))) { + if (preg_match($locale_pattern, $file) && $file != 'names' && is_dir("$folder/$file")) { + $list[] = $file; + } + } + closedir($handle); + } + return $list; +} + function get_user_locale() { - global $available_locales, $default_locale; + global $default_locale; if( isset($_COOKIE['webim_locale']) ) { $requested_lang = $_COOKIE['webim_locale']; - if( in_array($requested_lang,$available_locales) ) + if( locale_exists($requested_lang) ) return $requested_lang; } @@ -79,30 +100,30 @@ function get_user_locale() { if( strlen($requested_lang) > 2 ) $requested_lang = substr($requested_lang,0,2); - if( in_array($requested_lang,$available_locales) ) + if( locale_exists($requested_lang) ) return $requested_lang; } } - if( in_array($default_locale,$available_locales) ) + if( locale_exists($default_locale) ) return $default_locale; return 'en'; } function get_locale() { - global $available_locales, $webimroot; + global $webimroot, $locale_pattern; - $locale = verifyparam("locale", "/^[\w-]{2,5}$/", ""); + $locale = verifyparam("locale", $locale_pattern, ""); - if( $locale && in_array($locale,$available_locales) ) { + if( $locale && locale_exists($locale) ) { $_SESSION['locale'] = $locale; setcookie('webim_locale', $locale, time()+60*60*24*1000, "$webimroot/"); } else if( isset($_SESSION['locale']) ){ $locale = $_SESSION['locale']; } - if( !$locale || !in_array($locale,$available_locales) ) + if( !$locale || !locale_exists($locale) ) $locale = get_user_locale(); return $locale; } @@ -113,9 +134,10 @@ $messages = array(); $output_encoding = array(); function get_locale_links($href) { - global $available_locales, $current_locale; + global $current_locale; $localeLinks = ""; - foreach($available_locales as $k) { + $allLocales = get_available_locales(); + foreach($allLocales as $k) { if( strlen($localeLinks) > 0 ) $localeLinks .= " • "; if( $k == $current_locale ) @@ -449,6 +471,8 @@ $settings = array( 'chattitle' => 'Live Support', 'geolink' => 'http://api.hostip.info/get_html.php?ip={ip}', 'geolinkparams' => 'width=440,height=100,toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1', + 'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */ + 'max_uploaded_file_size' => 100000, ); $settingsloaded = false; $settings_in_db = array(); diff --git a/src/messenger/webim/libs/config.php b/src/messenger/webim/libs/config.php index ce65bbb8..07c875da 100644 --- a/src/messenger/webim/libs/config.php +++ b/src/messenger/webim/libs/config.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -58,8 +58,7 @@ $webim_messages_locale = "en"; /* * Locales */ -$available_locales = array("en", "ru" /* preliminary: "sp", "fr" */); -$home_locale = "ru"; /* native name will be used in this locale */ +$home_locale = "en"; /* native name will be used in this locale */ $default_locale = "en"; /* if user does not provide known lang */ /* @@ -68,14 +67,4 @@ $default_locale = "en"; /* if user does not provide known lang */ */ $remote_visitor = 'visitor_from_request'; -/* - * Timeout (in seconds) when online operator becomes offline. - */ -$online_timeout = 30; - -/* - * Maximum uploaded file size. - */ -$max_uploaded_file_size = 100000; - ?> diff --git a/src/messenger/webim/libs/converter.php b/src/messenger/webim/libs/converter.php index 0755dae6..3256e9cc 100644 --- a/src/messenger/webim/libs/converter.php +++ b/src/messenger/webim/libs/converter.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/libs/demothread.php b/src/messenger/webim/libs/demothread.php index a93485c7..0f895ff5 100644 --- a/src/messenger/webim/libs/demothread.php +++ b/src/messenger/webim/libs/demothread.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/libs/expand.php b/src/messenger/webim/libs/expand.php index 81500339..5e596403 100644 --- a/src/messenger/webim/libs/expand.php +++ b/src/messenger/webim/libs/expand.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,6 +44,8 @@ function expand_var($matches) { return $webimroot; } else if($var == 'tplroot') { return "$webimroot/styles/$current_style"; + } else if($var == 'styleid') { + return $current_style; } else if($var == 'pagination') { return generate_pagination($page['pagination']); } else if($var == 'errors' || $var == 'harderrors') { diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 388db8f8..1c8b8389 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -109,11 +109,12 @@ function notify_operator_alive($operatorid) { } function has_online_operators() { - global $online_timeout; + global $settings; + loadsettings(); $link = connect(); $row = select_one_row("select min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator",$link); mysql_close($link); - return $row['time'] < $online_timeout; + return $row['time'] < $settings['online_timeout']; } function get_operator_name($operator) { diff --git a/src/messenger/webim/libs/pagination.php b/src/messenger/webim/libs/pagination.php index a75c6157..793bf767 100644 --- a/src/messenger/webim/libs/pagination.php +++ b/src/messenger/webim/libs/pagination.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/libs/settings.php b/src/messenger/webim/libs/settings.php index 9013d4f6..e9c48c91 100644 --- a/src/messenger/webim/libs/settings.php +++ b/src/messenger/webim/libs/settings.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,7 @@ function setup_settings_tabs($active) { getlocal("page_settings.tab.main") => $active != 0 ? "$webimroot/operator/settings.php" : "", getlocal("page_settings.tab.features") => $active != 1 ? "$webimroot/operator/features.php" : "", getlocal("page_settings.tab.departments") => $active != 2 ? "$webimroot/operator/departments.php" : "", + getlocal("page_settings.tab.themes") => $active != 3 ? "$webimroot/operator/preview.php" : "", ); } diff --git a/src/messenger/webim/operator/agent.php b/src/messenger/webim/operator/agent.php index 13c244a1..fd8dae90 100644 --- a/src/messenger/webim/operator/agent.php +++ b/src/messenger/webim/operator/agent.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/avatar.php b/src/messenger/webim/operator/avatar.php index e70a74fa..baba4295 100644 --- a/src/messenger/webim/operator/avatar.php +++ b/src/messenger/webim/operator/avatar.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,10 +36,12 @@ if( !$op ) { $orig_filename = $_FILES['avatarFile']['name']; $tmp_file_name = $_FILES['avatarFile']['tmp_name']; - $ext = substr($orig_filename, 1 + strrpos($orig_filename, ".")); + $ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, "."))); $new_file_name = "$opId.$ext"; + loadsettings(); - if ($_FILES['avatarFile']['size'] > $max_uploaded_file_size) { + $file_size = $_FILES['avatarFile']['size']; + if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) { $errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded"); } elseif(!in_array($ext, $valid_types)) { $errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type"); diff --git a/src/messenger/webim/operator/ban.php b/src/messenger/webim/operator/ban.php index cf711b13..c7784efd 100644 --- a/src/messenger/webim/operator/ban.php +++ b/src/messenger/webim/operator/ban.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/blocked.php b/src/messenger/webim/operator/blocked.php index 00ddd334..401bbdac 100644 --- a/src/messenger/webim/operator/blocked.php +++ b/src/messenger/webim/operator/blocked.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/features.php b/src/messenger/webim/operator/features.php index 2cb25158..ee3af9e9 100644 --- a/src/messenger/webim/operator/features.php +++ b/src/messenger/webim/operator/features.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/getcode.php b/src/messenger/webim/operator/getcode.php index 2a802b6d..dbcd261e 100644 --- a/src/messenger/webim/operator/getcode.php +++ b/src/messenger/webim/operator/getcode.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,8 @@ require_once('../libs/operator.php'); $operator = check_login(); $imageLocales = array(); -foreach($available_locales as $curr) { +$allLocales = get_available_locales(); +foreach($allLocales as $curr) { $imagesDir = "../locales/$curr/button"; if($handle = opendir($imagesDir)) { while (false !== ($file = readdir($handle))) { diff --git a/src/messenger/webim/operator/history.php b/src/messenger/webim/operator/history.php index dbb8a662..2689bb9e 100644 --- a/src/messenger/webim/operator/history.php +++ b/src/messenger/webim/operator/history.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/index.php b/src/messenger/webim/operator/index.php index 29c01d7b..c3914504 100644 --- a/src/messenger/webim/operator/index.php +++ b/src/messenger/webim/operator/index.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/login.php b/src/messenger/webim/operator/login.php index bc1a1074..89cdaa72 100644 --- a/src/messenger/webim/operator/login.php +++ b/src/messenger/webim/operator/login.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/logout.php b/src/messenger/webim/operator/logout.php index 2a503a84..1c2f3761 100644 --- a/src/messenger/webim/operator/logout.php +++ b/src/messenger/webim/operator/logout.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/operator.php b/src/messenger/webim/operator/operator.php index e5945a64..fb5ae8e0 100644 --- a/src/messenger/webim/operator/operator.php +++ b/src/messenger/webim/operator/operator.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/operators.php b/src/messenger/webim/operator/operators.php index 0b8de6d0..17d7d596 100644 --- a/src/messenger/webim/operator/operators.php +++ b/src/messenger/webim/operator/operators.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/permissions.php b/src/messenger/webim/operator/permissions.php index 923f8464..f7777a16 100644 --- a/src/messenger/webim/operator/permissions.php +++ b/src/messenger/webim/operator/permissions.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/preview.php b/src/messenger/webim/operator/preview.php index a4e9112f..6221da24 100644 --- a/src/messenger/webim/operator/preview.php +++ b/src/messenger/webim/operator/preview.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ require_once('../libs/chat.php'); require_once('../libs/pagination.php'); require_once('../libs/operator.php'); require_once('../libs/expand.php'); +require_once('../libs/settings.php'); $operator = check_login(); @@ -118,5 +119,6 @@ foreach($templateList as $tpl) { } start_html_output(); +setup_settings_tabs(3); require('../view/preview.php'); ?> \ No newline at end of file diff --git a/src/messenger/webim/operator/redirect.php b/src/messenger/webim/operator/redirect.php index 6caa252a..cd1841e9 100644 --- a/src/messenger/webim/operator/redirect.php +++ b/src/messenger/webim/operator/redirect.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/settings.php b/src/messenger/webim/operator/settings.php index edc63358..5b251bfb 100644 --- a/src/messenger/webim/operator/settings.php +++ b/src/messenger/webim/operator/settings.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/threadprocessor.php b/src/messenger/webim/operator/threadprocessor.php index bdaea52b..15e3bae5 100644 --- a/src/messenger/webim/operator/threadprocessor.php +++ b/src/messenger/webim/operator/threadprocessor.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/translate.php b/src/messenger/webim/operator/translate.php index 42884ee2..b70b1acf 100644 --- a/src/messenger/webim/operator/translate.php +++ b/src/messenger/webim/operator/translate.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,7 +112,8 @@ if($stringid) { } $localesList = array(); -foreach($available_locales as $loc) { +$allLocales = get_available_locales(); +foreach($allLocales as $loc) { $localesList[] = array("id" => $loc, "name" => getlocal_("localeid", $loc)); } diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index 7377c434..f68dad50 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/userhistory.php b/src/messenger/webim/operator/userhistory.php index 93711033..4daf3f62 100644 --- a/src/messenger/webim/operator/userhistory.php +++ b/src/messenger/webim/operator/userhistory.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/src/messenger/webim/operator/users.php b/src/messenger/webim/operator/users.php index bbe70de5..4ffdbae1 100644 --- a/src/messenger/webim/operator/users.php +++ b/src/messenger/webim/operator/users.php @@ -2,7 +2,7 @@ /* * This file is part of Web Instant Messenger project. * - * Copyright (c) 2005-2008 Web Messenger Community + * Copyright (c) 2005-2009 Web Messenger Community * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at