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
This commit is contained in:
Evgeny Gryaznov 2008-09-29 23:07:06 +00:00
parent ef39c0a1fe
commit 0ebad2dda7
7 changed files with 295 additions and 73 deletions

View File

@ -54,6 +54,12 @@ $dbtables = array(
"chatrevision" => array(
"id" => "INT NOT NULL"
),
"chatconfig" => array (
"id" => "INT NOT NULL auto_increment PRIMARY KEY",
"vckey" => "varchar(255)",
"vcvalue" => "varchar(255)",
)
);
@ -97,9 +103,9 @@ 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);
} else if( $id == 'chatrevision' ) {

View File

@ -17,15 +17,22 @@ 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") {
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 {
@ -82,11 +89,16 @@ if($act == "createdb") {
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("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);
}
}
}

View File

@ -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;
@ -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;
}
@ -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)));
}
@ -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);
}
?>

View File

@ -51,26 +51,10 @@ $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
*/
@ -99,5 +83,4 @@ $remote_visitor = 'visitor_from_request';
*/
$online_timeout = 30;
?>

View File

@ -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');
?>

View File

@ -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>

View File

@ -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>