From 0ebad2dda72d5006f9aea903ebe7e2bf7cf12cd2 Mon Sep 17 00:00:00 2001
From: Evgeny Gryaznov <inspirer@users.sourceforge.net>
Date: Mon, 29 Sep 2008 23:07:06 +0000
Subject: [PATCH] settings page, remove some options from config, add index
 into db

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@117 c66351dc-e62f-0410-b875-e3a5c0b9693f
---
 src/messenger/webim/install/dbinfo.php    |  28 +++--
 src/messenger/webim/install/dbperform.php |  42 +++++---
 src/messenger/webim/libs/common.php       |  67 ++++++++----
 src/messenger/webim/libs/config.php       |  31 ++----
 src/messenger/webim/operator/settings.php |  72 +++++++++++++
 src/messenger/webim/view/menu.php         |  10 +-
 src/messenger/webim/view/settings.php     | 118 ++++++++++++++++++++++
 7 files changed, 295 insertions(+), 73 deletions(-)
 create mode 100644 src/messenger/webim/operator/settings.php
 create mode 100644 src/messenger/webim/view/settings.php

diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php
index 3ec2e9ff..a3111770 100644
--- a/src/messenger/webim/install/dbinfo.php
+++ b/src/messenger/webim/install/dbinfo.php
@@ -51,9 +51,15 @@ $dbtables = array(
 		"vccommonname" => "varchar(64) NOT NULL",
 		"dtmlastvisited" => "datetime DEFAULT 0",
 	),
-	
+
 	"chatrevision" => array(
 		"id" => "INT NOT NULL"
+	),
+
+	"chatconfig" => array (
+		"id" => "INT NOT NULL auto_increment PRIMARY KEY",
+		"vckey" => "varchar(255)",
+		"vcvalue" => "varchar(255)",
 	)
 );
 
@@ -66,30 +72,30 @@ $dbtables_can_update = array(
 
 function show_install_err($text) {
 	global $page, $version, $errors, $webimroot;
-	$page = array( 
+	$page = array(
 		'version' => $version,
 		'localeLinks' => get_locale_links("$webimroot/install/index.php")
 	);
 	$errors = array($text);
 	start_html_output();
 	require('view_installerr.php');
-	exit;	
+	exit;
 }
 
 function create_table($id,$link) {
 	global $dbtables, $memtables, $dbencoding;
-	
+
 	if(!isset($dbtables[$id])) {
 		show_install_err("Unknown table: $id, ".mysql_error());
 	}
-	
-	$query = 
+
+	$query =
 		"CREATE TABLE $id\n".
 		"(\n";
 	foreach( $dbtables[$id] as $k => $v ) {
-		$query .= "	$k $v,\n"; 
+		$query .= "	$k $v,\n";
 	}
-	
+
 	$query = preg_replace("/,\n$/", "", $query);
 	$query .= ") charset $dbencoding";
 	if (in_array($id, $memtables)) {
@@ -97,11 +103,11 @@ function create_table($id,$link) {
 	} else {
 		$query .= " TYPE=InnoDb";
 	}
+
 	mysql_query($query,$link) or show_install_err(' Query failed: '.mysql_error());
-	
-	// post create
+
 	if( $id == 'chatoperator' ) {
-		create_operator_("admin", "", "Administrator", "Administrator", $link);	
+		create_operator_("admin", "", "Administrator", "Administrator", $link);
 	} else if( $id == 'chatrevision' ) {
 		perform_query("INSERT INTO chatrevision VALUES (1)",$link);
 	}
diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php
index 3d57350e..6cbf9d77 100644
--- a/src/messenger/webim/install/dbperform.php
+++ b/src/messenger/webim/install/dbperform.php
@@ -17,24 +17,31 @@ require_once('../libs/operator.php');
 require_once('dbinfo.php');
 
 function runsql($query,$link) {
-	mysql_query($query,$link)
+	$res = mysql_query($query,$link)
 		or show_install_err(' Query failed: '.mysql_error());
+	return $res;
 }
 
-$act = verifyparam( "act", "/^(createdb|createtables|droptables|addcolumns)$/");
+$act = verifyparam( "act", "/^(silentcreateall|createdb|createtables|droptables|addcolumns)$/");
 $link = @mysql_connect($mysqlhost,$mysqllogin ,$mysqlpass )
 	or show_install_err('Could not connect: ' . mysql_error());
 
-if($act == "createdb") {
-	mysql_query("CREATE DATABASE $mysqldb",$link) 
+if ($act == "silentcreateall") {
+	mysql_query("CREATE DATABASE $mysqldb",$link)
+		or show_install_err(' Query failed: '.mysql_error());
+	foreach($dbtables as $id) {
+		create_table($id, $link);
+   	}
+} else if($act == "createdb") {
+	mysql_query("CREATE DATABASE $mysqldb",$link)
 		or show_install_err(' Query failed: '.mysql_error());
 } else {
-	mysql_select_db($mysqldb,$link) 
+	mysql_select_db($mysqldb,$link)
 		or show_install_err('Could not select database');
 	if( $force_charset_in_connection ) {
 		mysql_query("SET character set $dbencoding", $link);
 	}
-	
+
 	if( $act == "createtables") {
 		$curr_tables = get_tables($link);
 		if( $curr_tables === false) {
@@ -48,45 +55,50 @@ if($act == "createdb") {
 		foreach( array_keys($dbtables) as $id) {
 			mysql_query("DROP TABLE IF EXISTS $id",$link)
 				or show_install_err(' Query failed: '.mysql_error());
-		}	
+		}
 	} else if( $act == "addcolumns") {
 		$absent = array();
 		foreach( $dbtables as $id => $columns) {
 			$curr_columns = get_columns($id, $link);
 			if( $curr_columns === false ) {
-				show_install_err($errors[0]);	
+				show_install_err($errors[0]);
 			}
 			$tocreate = array_diff(array_keys($columns), $curr_columns);
 			foreach($tocreate as $v) {
 				$absent[] = "$id.$v";
 			}
 		}
-		
+
 		if( in_array("chatmessage.agentId", $absent) ) {
 			runsql("ALTER TABLE chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind", $link);
-			runsql("update chatmessage,chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname)", $link); 
+			runsql("update chatmessage,chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname)", $link);
 		}
-		
+
 		if( in_array("chatthread.agentId", $absent) ) {
 			runsql("ALTER TABLE chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName", $link);
-			runsql("update chatthread,chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)", $link); 
+			runsql("update chatthread,chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName)", $link);
 		}
 
 		if( in_array("chatthread.agentTyping", $absent) ) {
 			runsql("ALTER TABLE chatthread ADD agentTyping int DEFAULT 0", $link);
 		}
-		
+
 		if( in_array("chatthread.userTyping", $absent) ) {
 			runsql("ALTER TABLE chatthread ADD userTyping int DEFAULT 0", $link);
 		}
 
 		if( in_array("chatthread.messageCount", $absent) ) {
 			runsql("ALTER TABLE chatthread ADD messageCount varchar(16)", $link);
-			runsql("ALTER TABLE chatmessage ADD index idx_threadid_ikind (threadid, ikind)", $link);
-			runsql("UPDATE chatthread t SET t.messageCount = (SELECT COUNT(*) FROM chatmessage WHERE chatmessage.threadid = t.threadid AND ikind = 1)", $link); 
+			runsql("ALTER TABLE chatmessage ADD INDEX idx_threadid_ikind (threadid, ikind)", $link);
+			runsql("UPDATE chatthread t SET t.messageCount = (SELECT COUNT(*) FROM chatmessage WHERE chatmessage.threadid = t.threadid AND ikind = 1)", $link);
 			runsql("ALTER TABLE chatmessage DROP INDEX idx_threadid_ikind", $link);
 		}
 
+		$res = runsql("select null from information_schema.statistics where table_name = 'chatmessage' and index_name = 'idx_agentid'", $link);
+		if(mysql_num_rows($res) == 0) {
+			runsql("ALTER TABLE chatmessage ADD INDEX idx_agentid (agentid)", $link);
+
+		}
 	}
 }
 
diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php
index 3fd0bf19..2d3f1832 100644
--- a/src/messenger/webim/libs/common.php
+++ b/src/messenger/webim/libs/common.php
@@ -17,7 +17,7 @@ session_start();
 require_once(dirname(__FILE__).'/converter.php');
 require_once(dirname(__FILE__).'/config.php');
 
-$version = 'v1.0.10';
+$version = 'v1.4.0';
 
 function myiconv($in_enc, $out_enc, $string) {
 	global $_utf8win1251, $_win1251utf8;
@@ -25,8 +25,8 @@ function myiconv($in_enc, $out_enc, $string) {
 		return $string;
 	}
 	if( function_exists('iconv') ) {
-	    $converted = @iconv($in_enc, $out_enc, $string);
-	    if( $converted !== FALSE ) {
+		$converted = @iconv($in_enc, $out_enc, $string);
+		if( $converted !== FALSE ) {
 			return $converted;
 		}
 	}
@@ -39,7 +39,6 @@ function myiconv($in_enc, $out_enc, $string) {
 }
 
 function verifyparam( $name, $regexp, $default = null ) {
-
 	if( isset( $_GET[$name] ) ) {
 		$val = $_GET[$name];
 		if( preg_match( $regexp, $val ) )
@@ -54,7 +53,6 @@ function verifyparam( $name, $regexp, $default = null ) {
 		if( isset( $default ) )
 			return $default;
 	}
-
 	echo "<html><head></head><body>Wrong parameter used or absent: ".$name."</body></html>";
 	exit;
 }
@@ -101,7 +99,7 @@ function get_locale() {
 		$_SESSION['locale'] = $locale;
 		setcookie('webim_locale', $locale, time()+60*60*24*1000, "$webimroot/");
 	} else if( isset($_SESSION['locale']) ){
-	    $locale = $_SESSION['locale'];
+		$locale = $_SESSION['locale'];
 	}
 
 	if( !$locale || !in_array($locale,$available_locales) )
@@ -132,18 +130,18 @@ function load_messages($locale) {
 	global $messages, $webim_encoding, $output_encoding;
 	$hash = array();
 	$current_encoding = $webim_encoding;
-	$fp = fopen(dirname(__FILE__)."/../locales/$locale/properties","r");
+	$fp = fopen(dirname(__FILE__)."/../locales/$locale/properties", "r");
 	while (!feof($fp)) {
-    	$line = fgets($fp, 4096);
+		$line = fgets($fp, 4096);
 		$keyval = split("=", $line, 2 );
 		if( isset($keyval[1]) ) {
 			if($keyval[0] == 'encoding') {
 				$current_encoding = trim($keyval[1]);
 			} else if($keyval[0] == 'output_encoding') {
-				$output_encoding[$locale] = trim($keyval[1]); 
+				$output_encoding[$locale] = trim($keyval[1]);
 			} else if( $current_encoding == $webim_encoding ) {
 				$hash[$keyval[0]] = str_replace("\\n", "\n",trim($keyval[1]));
-			} else { 
+			} else {
 				$hash[$keyval[0]] = myiconv($current_encoding, $webim_encoding, str_replace("\\n", "\n",trim($keyval[1])));
 			}
 		}
@@ -241,20 +239,20 @@ function connect() {
 }
 
 function perform_query($query,$link) {
-	mysql_query($query,$link) 
+	mysql_query($query,$link)
 		or die(' Query failed: '.mysql_error()/*.": ".$query*/);
 }
 
 function select_one_row($query,$link) {
-	$result = mysql_query($query,$link) or die(' Query failed: ' . 
+	$result = mysql_query($query,$link) or die(' Query failed: ' .
 		mysql_error().": ".$query);
 	$line = mysql_fetch_array($result, MYSQL_ASSOC);
 	mysql_free_result($result);
 	return $line;
 }
 
-function select_multi_assoc($query,$link) {
-	$sqlresult = mysql_query($query,$link) or die(' Query failed: ' . 
+function select_multi_assoc($query, $link) {
+	$sqlresult = mysql_query($query,$link) or die(' Query failed: ' .
 		mysql_error().": ".$query);
 
 	$result = array();
@@ -266,14 +264,18 @@ function select_multi_assoc($query,$link) {
 }
 
 function start_xml_output() {
+	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 	header("Cache-Control: no-store, no-cache, must-revalidate");
+	header("Pragma: no-cache");
 	header("Content-type: text/xml; charset=utf-8");
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
 }
 
 function start_html_output() {
 	$charset = getstring("output_charset");
+	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 	header("Cache-Control: no-store, no-cache, must-revalidate");
+	header("Pragma: no-cache");
 	header("Content-type: text/html".(isset($charset)?"; charset=".$charset:""));
 }
 
@@ -299,7 +301,6 @@ function no_field($key) {
 	return getlocal2("errors.required",array(getlocal($key)));
 }
 
-
 function wrong_field($key) {
 	return getlocal2("errors.wrong_field",array(getlocal($key)));
 }
@@ -309,7 +310,7 @@ function get_popup($href,$message,$title,$wndName,$options) {
 }
 
 function get_image($href,$width,$height) {
-	if( $width != 0 && $height != 0 )                   
+	if( $width != 0 && $height != 0 )
 		return "<img src=\"$href\" border=\"0\" width=\"$width\" height=\"$height\"/>";
 	return "<img src=\"$href\" border=\"0\"/>";
 }
@@ -342,11 +343,11 @@ function add_params($servlet, $params) {
 }
 
 function div($a,$b) {
-    return ($a-($a % $b)) / $b;
+	return ($a-($a % $b)) / $b;
 }
 
 function date_diff($seconds) {
-    $minutes = div($seconds,60);
+	$minutes = div($seconds,60);
 	$seconds = $seconds % 60;
 	if( $minutes < 60 ) {
 		return sprintf("%02d:%02d",$minutes, $seconds);
@@ -388,7 +389,7 @@ function get_month_selection($fromtime,$totime) {
 		$month++;
 		if( $month > 12 ) {
 			$month = 1;
-			$year++; 
+			$year++;
 		}
 	} while( $current < $totime );
 	return $result;
@@ -420,4 +421,32 @@ function webim_mail($toaddr, $reply_to, $subject, $body) {
 	mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers);
 }
 
+$settings = array(
+	'email' => '',				/* inbox for left messages */
+	'title' => 'Company',
+	'hosturl' => 'http://www.webim.ru',
+	'logo' => ''
+);
+$settingsloaded = false;
+$settings_in_db = array();
+
+function loadsettings() {
+	global $settingsloaded, $settings_in_db, $settings;
+	if($settingsloaded) {
+		return;
+	}
+	$settingsloaded = true;
+
+	$link = connect();
+	$sqlresult = mysql_query('select vckey,vcvalue from chatconfig',$link) or die(' Query failed: '.mysql_error().": ".$query);
+
+	while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
+		$name = $row['vckey'];
+		$settings[$name] = $row['vcvalue'];
+		$settings_in_db[$name] = true;
+	}
+	mysql_free_result($sqlresult);
+	mysql_close($link);
+}
+
 ?>
\ No newline at end of file
diff --git a/src/messenger/webim/libs/config.php b/src/messenger/webim/libs/config.php
index 29a6e767..1e61cf86 100644
--- a/src/messenger/webim/libs/config.php
+++ b/src/messenger/webim/libs/config.php
@@ -12,8 +12,8 @@
  *    Evgeny Gryaznov - initial API and implementation
  */
 
-/* 
- * Application path on server 
+/*
+ * Application path on server
  */
 $webimroot = "/webim";
 
@@ -51,32 +51,16 @@ $mail_encoding = $webim_encoding;
 $webim_from_email = "webim@yourdomain.com"; /* email from field */
 
 /*
- *   Inbox for left messages
+ *   Inbox for left messages encoding
  */
-$webim_messages_mail = "operators@yourdomain.com";
 $webim_messages_locale = "en";
 
 /*
- *   Company international name.
- */
-$company_name = "My Company Ltd.";
-
-/*
- *   Company logo. 
- */
-$company_logo_link = "";
-
-/*
- * Web Messenger host
- */
-$webim_host = "";
-
-/*
- *   Locales 
+ *   Locales
  */
 $available_locales = array("en", "ru");
-$home_locale = "ru";                        /* native name will be used in this locale */
-$default_locale = "en";                     /* if user does not provide known lang */
+$home_locale = "ru";						/* native name will be used in this locale */
+$default_locale = "en";						/* if user does not provide known lang */
 
 /*
  *   Allows users to change their names
@@ -85,7 +69,7 @@ $user_can_change_name = true;
 
 /*
  *   How to build presentable visitor name from {name} or {addr}. Default: {name}
- */ 
+ */
 $presentable_name_pattern = "{name}";
 
 /*
@@ -99,5 +83,4 @@ $remote_visitor = 'visitor_from_request';
  */
 $online_timeout = 30;
 
-
 ?>
diff --git a/src/messenger/webim/operator/settings.php b/src/messenger/webim/operator/settings.php
new file mode 100644
index 00000000..6055c5b6
--- /dev/null
+++ b/src/messenger/webim/operator/settings.php
@@ -0,0 +1,72 @@
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2008 Internet Services Ltd.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require_once('../libs/common.php');
+require_once('../libs/operator.php');
+
+$operator = check_login();
+
+function update_settings() {
+	global $settings, $settings_in_db;
+	$link = connect();
+	foreach ($settings as $key => $value) {
+		if(!isset($settings_in_db[$key])) {
+			perform_query("insert into chatconfig (vckey) values ('$key')",$link);
+		}
+        $query = sprintf("update chatconfig set vcvalue='%s' where vckey='$key'", mysql_real_escape_string($value));
+		perform_query($query,$link);
+	}
+
+	mysql_close($link);
+}
+
+$page = array('agentId' => '');
+$errors = array();
+
+loadsettings();
+$email = $settings['email'];
+$title = $settings['title'];
+$logo  = $settings['logo'];
+$hosturl = $settings['hosturl'];
+
+if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) {
+    $email = getparam('email');
+    $title = getparam('title');
+    $logo  = getparam('logo');
+    $hosturl = getparam('hosturl');
+
+    if($email && !is_valid_email($email)) {
+        $errors[] = getlocal("settings.wrong.email");
+    }
+
+    if (count($errors) == 0) {
+    	$settings['email'] = $email;
+    	$settings['title'] = $title;
+    	$settings['logo'] = $logo;
+    	$settings['hosturl'] = $hosturl;
+        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);
+
+start_html_output();
+require('../view/settings.php');
+?>
\ No newline at end of file
diff --git a/src/messenger/webim/view/menu.php b/src/messenger/webim/view/menu.php
index c77397a6..740eb3a3 100644
--- a/src/messenger/webim/view/menu.php
+++ b/src/messenger/webim/view/menu.php
@@ -34,11 +34,11 @@
 <table width="100%" cellpadding="2" cellspacing="0" border="0">
 <tr>
 <td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top">
 		<h1><?php echo getlocal("topMenu.admin") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getlocal2("menu.operator",array($page['operator'])) ?></td></tr></table></td></tr></table> 
-	
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getlocal2("menu.operator",array($page['operator'])) ?></td></tr></table></td></tr></table>
+
 
 	<?php echo getlocal("admin.content.description") ?>
 <br>
@@ -54,6 +54,8 @@
 
 	<tr><td width='20' valign='top'><img src='<?php echo $webimroot ?>/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='<?php echo $webimroot ?>/operator/history.php'><?php echo getlocal('page_analysis.search.title') ?></a><br><img src='<?php echo $webimroot ?>/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getlocal('content.history') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
 
+	<tr><td width='20' valign='top'><img src='<?php echo $webimroot ?>/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='<?php echo $webimroot ?>/operator/settings.php'><?php echo getlocal('leftMenu.client_settings') ?></a><br><img src='<?php echo $webimroot ?>/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getlocal('admin.content.client_settings') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
 	<tr><td width='20' valign='top'><img src='<?php echo $webimroot ?>/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='<?php echo $webimroot ?>/operator/logout.php'><?php echo getlocal('topMenu.logoff') ?></a><br><img src='<?php echo $webimroot ?>/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getlocal('content.logoff') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
 
 </table>
diff --git a/src/messenger/webim/view/settings.php b/src/messenger/webim/view/settings.php
new file mode 100644
index 00000000..edce38cd
--- /dev/null
+++ b/src/messenger/webim/view/settings.php
@@ -0,0 +1,118 @@
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2008 Internet Services Ltd.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="<?php echo $webimroot ?>/styles.css" />
+
+
+<link rel="shortcut icon" href="<?php echo $webimroot ?>/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getlocal("app.title") ?>	- <?php echo getlocal("settings.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getlocal("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getlocal("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top">
+		<h1><?php echo getlocal("settings.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getlocal2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='<?php echo $webimroot ?>/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="<?php echo $webimroot ?>/operator/index.php" title="<?php echo getlocal("menu.main") ?>"><?php echo getlocal("menu.main") ?></a></td></tr></table></td></tr></table>
+
+
+	<?php echo getlocal("page_settings.intro") ?>
+<br />
+<br />
+<?php if( isset($errors) && count($errors) > 0 ) { ?>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td valign="top"><img src='<?php echo $webimroot ?>/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
+	    <td width="10"></td>
+	    <td class="text">
+		    <?php	if( isset($errors) && count($errors) > 0 ) {
+		print getlocal("errors.header");
+		foreach( $errors as $e ) {
+			print getlocal("errors.prefix");
+			print $e;
+			print getlocal("errors.suffix");
+		}
+		print getlocal("errors.footer");
+	} ?>
+
+		</td>
+		</tr>
+		</table>
+	<?php } ?>
+
+<form name="settings" method="post" action="<?php echo $webimroot ?>/operator/settings.php">
+	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='<?php echo $webimroot ?>/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+		<tr><td class='formauth'><?php echo getlocal('settings.email') ?></td><td width='10'><img width='10' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="email" size="40" value="<?php echo form_value('email') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getlocal('settings.email.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getlocal('settings.company.title') ?></td><td width='10'><img width='10' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="title" size="40" value="<?php echo form_value('title') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getlocal('settings.company.title.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getlocal('settings.logo') ?></td><td width='10'><img width='10' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="logo" size="40" value="<?php echo form_value('logo') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getlocal('settings.logo.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getlocal('settings.host') ?></td><td width='10'><img width='10' height='1' border='0' alt='' src='<?php echo $webimroot ?>/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="hosturl" size="40" value="<?php echo form_value('hosturl') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getlocal('settings.host.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td colspan='3' height='20'></td></tr><tr><td colspan='3' background='<?php echo $webimroot ?>/images/formline.gif'><img src='<?php echo $webimroot ?>/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='3' height='10'></td></tr>
+		<tr>
+			<td class="formauth" colspan="3">
+			        <input type="image" name="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' border="0" alt='<?php echo getlocal("button.save") ?>'/>
+			</td>
+		</tr>
+
+	</table></td><td></td></tr><tr><td><img src='<?php echo $webimroot ?>/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='<?php echo $webimroot ?>/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+
+
+
+
+
+
+<table cellspacing="0" cellpadding="0" border="0">
+	<tr>
+		<td colspan="2" height="10"></td>
+	</tr>
+	<tr>
+		<td width="30"></td>
+		<td class="formauth"><span class="formdescr"><?php echo getlocal("common.asterisk_explanation") ?></span></td>
+	</tr>
+</table>
+
+
+</form>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+