Commit 92bc670e authored by tbrehm's avatar tbrehm
Browse files

- Added a mailserver configuration form.

- Fixed several bugs.
parent 098b2f06
......@@ -341,10 +341,10 @@ class db
if($database_name == ''){
$database_name = $this->dbName;
}
$result = mysql_list_tables($database_name);
$result = @mysql_list_tables($database_name);
$tb_names = array();
for ($i = 0; $i < mysql_num_rows($result); $i++) {
$tb_names[$i] = mysql_tablename($result, $i);
for ($i = 0; $i < @mysql_num_rows($result); $i++) {
$tb_names[$i] = @mysql_tablename($result, $i);
}
return $tb_names;
}
......
......@@ -39,7 +39,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class ini_parser{
private $config;
//* Converts a ini string to array
public function parse_ini_string($ini) {
$ini = str_replace("\r\n", "\n", $ini);
$lines = explode("\n", $ini);
......@@ -56,19 +57,27 @@ class ini_parser{
}
return $this->config;
}
public function get_ini_string($file) {
//* Converts a config array to a string
public function get_ini_string($config_array = '') {
if($config_array == '') $config_array = $this->config;
$content = '';
foreach($this->config as $section => $data) {
foreach($config_array as $section => $data) {
$content .= "[$section]\n";
foreach($data as $item => $value) {
if($value != ''){
if($item != ''){
$content .= "$item=$value\n";
}
}
$content .= "\n";
}
return $content;
}
}
?>
\ No newline at end of file
......@@ -97,7 +97,7 @@ class listform_actions {
foreach($app->listform->listDef['item'] as $field) {
$key = $field['field'];
if(isset($field['formtype']) && $field['formtype'] == 'SELECT') {
$rec[$key] = $field['value'][$rec[$key]];
$rec[$key] = @$field['value'][$rec[$key]];
}
}
......
......@@ -98,7 +98,7 @@ class tform_actions {
global $app, $conf;
$this->onBeforeUpdate();
$ext_where = '';
$sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'UPDATE',$this->id,$ext_where);
if($app->tform->errorMessage == '') {
......@@ -106,11 +106,9 @@ class tform_actions {
if($app->tform->formDef['db_history'] == 'yes') {
$old_data_record = $app->tform->getDataRecord($this->id);
}
if(!empty($sql)) {
$app->db->query($sql);
if($app->db->errorMessage != '') die($app->db->errorMessage);
}
// Save record in database
$this->onUpdateSave($sql);
// loading plugins
$next_tab = $app->tform->getCurrentTab();
......@@ -160,6 +158,19 @@ class tform_actions {
$this->onError();
}
}
/*
Save record in database
*/
function onUpdateSave($sql) {
global $app;
if(!empty($sql)) {
$app->db->query($sql);
if($app->db->errorMessage != '') die($app->db->errorMessage);
}
}
/**
* Function called on data insert
......@@ -173,9 +184,8 @@ class tform_actions {
$ext_where = '';
$sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'INSERT',$this->id,$ext_where);
if($app->tform->errorMessage == '') {
$app->db->query($sql);
if($app->db->errorMessage != '') die($app->db->errorMessage);
$this->id = $app->db->insertID();
$this->id = $this->onInsertSave($sql);
// loading plugins
$next_tab = $app->tform->getCurrentTab();
......@@ -221,6 +231,17 @@ class tform_actions {
$this->onError();
}
}
/*
Save record in database
*/
function onInsertSave($sql) {
global $app, $conf;
$app->db->query($sql);
if($app->db->errorMessage != '') die($app->db->errorMessage);
return $app->db->insertID();
}
function onBeforeUpdate() {
global $app, $conf;
......
......@@ -65,6 +65,7 @@ $form["name"] = "groups";
$form["action"] = "groups_edit.php";
$form["db_table"] = "sys_group";
$form["db_table_idx"] = "groupid";
$form["db_history"] = "no";
$form["tab_default"] = "groups";
$form["list_default"] = "groups_list.php";
$form["auth"] = 'no';
......
......@@ -66,6 +66,7 @@ $form['name'] = 'users';
$form['action'] = 'users_edit.php';
$form['db_table'] = 'sys_user';
$form['db_table_idx'] = 'userid';
$form["db_history"] = "no";
$form['tab_default'] = 'users';
$form['list_default'] = 'users_list.php';
$form['auth'] = 'yes';
......
<?php
/*
Form Definition
Tabledefinition
Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)
Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE
VALUE:
- Wert oder Array
Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).
*/
$form["title"] = "Spamfilter Config";
$form["description"] = "";
$form["name"] = "spamfilter_config";
$form["action"] = "spamfilter_config_edit.php";
$form["db_table"] = "server";
$form["db_table_idx"] = "server_id";
$form["db_history"] = "yes";
$form["tab_default"] = "mail";
$form["list_default"] = "spamfilter_config_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['mail'] = array (
'title' => "Mailserver",
'width' => 100,
'template' => "templates/spamfilter_config_mail_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'module' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '',
'value' => array('postfix_mysql' => 'postfix_mysql')
),
'maildir_path' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '/home/vmail/[domain]/[localpart]/',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'maildir_path_error_empty'),
),
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'homedir_path' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '/home/vmail/',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'homedir_path_error_empty'),
),
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'mailuser_uid' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '5000',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'mailuser_uid_error_empty'),
),
'value' => '',
'width' => '10',
'maxlength' => '255'
),
'mailuser_gid' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '5000',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'mailuser_gid_error_empty'),
),
'value' => '',
'width' => '10',
'maxlength' => '255'
),
'mailuser_name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => 'vmail',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'mailuser_name_error_empty'),
),
'value' => '',
'width' => '10',
'maxlength' => '255'
),
'mailuser_group' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => 'vmail',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'mailuser_group_error_empty'),
),
'value' => '',
'width' => '10',
'maxlength' => '255'
),
'relayhost' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'relayhost_user' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'relayhost_password' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'mailbox_size_limit' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '0',
'value' => '',
'width' => '10',
'maxlength' => '15'
),
'message_size_limit' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '0',
'value' => '',
'width' => '10',
'maxlength' => '15'
),
##################################
# ENDE Datatable fields
##################################
)
);
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Spamfilter';
$wb["active_txt"] = 'Active';
$wb["server_id_txt"] = 'Server';
$wb["email_txt"] = 'Email';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new Spamfilter record';
<?php
$wb["list_head_txt"] = 'Spamfilter';
$wb["active_txt"] = 'Active';
$wb["server_id_txt"] = 'Server';
$wb["server_name_txt"] = 'server_name';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["email_txt"] = 'Email';
$wb["add_new_record_txt"] = 'Add new Spamfilter record';
?>
\ No newline at end of file
<?php
$wb["module_txt"] = 'Server Module';
$wb["maildir_path_txt"] = 'Maildir Path';
$wb["homedir_path_txt"] = 'Homedir Path';
$wb["mailuser_uid_txt"] = 'Mailuser UID';
$wb["mailuser_gid_txt"] = 'Mailuser GID';
$wb["mailuser_name_txt"] = 'Mailuser Name';
$wb["mailuser_group_txt"] = 'Mailuser Group';
$wb["relayhost_txt"] = 'Relayhost';
$wb["relayhost_user_txt"] = 'Relayhost User';
$wb["relayhost_password_txt"] = 'Relayhost Password';
$wb["mailbox_size_limit_txt"] = 'Mailbox Size Limit';
$wb["message_size_limit_txt"] = 'Message Size Limit';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Server Configuration';
$wb["server_name_txt"] = 'Server';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["server_id_txt"] = 'server_id';
?>
\ No newline at end of file
......@@ -58,6 +58,10 @@ if($_SESSION['s']['user']['typ'] == 'admin') {
$items[] = array( 'title' => 'Policy',
'target' => 'content',
'link' => 'mail/spamfilter_policy_list.php');
$items[] = array( 'title' => 'Server Settings',
'target' => 'content',
'link' => 'mail/spamfilter_config_list.php');
}
$module['nav'][] = array( 'title' => 'Spamfilter',
......
......@@ -16,10 +16,10 @@
$liste["name"] = "mail_spamfilter";
// Database table
$liste["table"] = "mail_spamfilter";
$liste["table"] = "server";
// Index index field of the database table
$liste["table_idx"] = "spamfilter_id";
$liste["table_idx"] = "server_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
......@@ -54,7 +54,7 @@ $liste["item"][] = array( 'field' => "active",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('y' => "Yes",'n' => "No"));
'value' => array('1' => "Yes",'0' => "No"));
$liste["item"][] = array( 'field' => "server_id",
......@@ -71,7 +71,7 @@ $liste["item"][] = array( 'field' => "server_id",
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "email",
$liste["item"][] = array( 'field' => "server_name",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
......
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste["name"] = "spamfilter_config";
// Database table
$liste["table"] = "server";
// Index index field of the database table
$liste["table_idx"] = "server_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = 15;
// Script File of the list
$liste["file"] = "spamfilter_config_list.php";
// Script file of the edit form
$liste["edit_file"] = "spamfilter_config_edit.php";
// Script File of the delete script
$liste["delete_file"] = "spamfilter_config_del.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"] = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "server_name",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/spamfilter_config.list.php";
$tform_def_file = "form/spamfilter_config.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checke Berechtigungen für Modul
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
header("Location: ../index.php");
exit;
}
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/spamfilter_config.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {