Commit 00fad689 authored by tbrehm's avatar tbrehm
Browse files

Added basic module processing to the server part.

parent 45f11e2b
$sql_select_policy =
'SELECT *,spamfilter_users.id'.
' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';
$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
' ORDER BY spamfilter_wblist.priority DESC';
\ 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.
*/
class modules {
var $notification_hooks = array();
/*
This function is called to load the modules from the mods-available folder
*/
function loadModules() {
global $app;
}
/*
This function is called by the modules to register for a specific
table change notification
*/
function registerTableHook($table_name,$module_name,$function_name) {
$this->notification_hooks[$table_name][] = array('module' => $module_name, 'function' => $function_name);
}
/*
This function goes through all new records in the
sys_datalog table and and calls the function in the
modules that hooked on to the table change.
*/
function processDatalog() {
global $app;
// TODO: process only new entries.
$sql = "SELECT * FROM sys_datalog WHERE 1";
$records = $app->db->queryAllRecords($sql);
foreach($records as $rec) {
$data = unserialize(stripslashes($rec["data"]));
$this->raiseTableHook($rec["dbtable"],$rec["action"],$data);
}
}
function raiseTableHook($table_name,$action,$data) {
global $app;
// Get the hooks for this table
$hooks = $this->notification_hooks[$table_name];
if(is_array($hooks)) {
foreach($hooks as $hook) {
$module_name = $hook["module"];
$function_name = $hook["function"];
// Claa the processing function of the module
call_user_method($function_name,$app->$module_name,$table_name,$action,$data);
unset($module_name);
unset($function_name);
}
}
unset($hook);
unset($hooks);
}
}
?>
\ 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.
*/
class mail_module {
var $module_name = 'mail';
var $class_name = 'mail_module';
var $actions_available = array( 'mail_domain_insert',
'mail_domain_update',
'mail_domain_delete',
'mail_user_insert',
'mail_user_update',
'mail_user_delete',
'mail_access_insert',
'mail_access_update',
'mail_access_delete',
'mail_forwarding_insert',
'mail_forwarding_update',
'mail_forwarding_delete',
'mail_transport_insert',
'mail_transport_update',
'mail_transport_delete');
/*
This function is called when the module is loaded
*/
function onLoad() {
/*
Annonce the actions that where provided by this module, so plugins
can register on them.
*/
$app->plugins->registerEvents($this->module_name,$this->actions_available);
/*
As we want to get notified of any changes on several database tables,
we register for them.
The following function registers the function "functionname"
to be executed when a record for the table "dbtable" is
processed in the sys_datalog. "classname" is the name of the
class that contains the function functionname.
*/
$app->modules->registerTableHook('mail_access','mail_module','process');
$app->modules->registerTableHook('mail_domain','mail_module','process');
$app->modules->registerTableHook('mail_forwarding','mail_module','process');
$app->modules->registerTableHook('mail_transport','mail_module','process');
$app->modules->registerTableHook('mail_user','mail_module','process');
}
/*
This function is called when a change in one of the registered tables is detected.
The function then raises the events for the plugins.
*/
function process($tablename,$action,$data) {
global $app;
switch ($tablename) {
case 'mail_access':
if($action == 'i') $app->plugins->raiseEvent('mail_access_insert',$data);
if($action == 'u') $app->plugins->raiseEvent('mail_access_update',$data);
if($action == 'd') $app->plugins->raiseEvent('mail_access_delete',$data);
break;
case 'mail_domain':
if($action == 'i') $app->plugins->raiseEvent('mail_domain_insert',$data);
if($action == 'u') $app->plugins->raiseEvent('mail_domain_update',$data);
if($action == 'd') $app->plugins->raiseEvent('mail_domain_delete',$data);
break;
case 'mail_forwarding':
if($action == 'i') $app->plugins->raiseEvent('mail_forwarding_insert',$data);
if($action == 'u') $app->plugins->raiseEvent('mail_forwarding_update',$data);
if($action == 'd') $app->plugins->raiseEvent('mail_forwarding_delete',$data);
break;
case 'mail_transport':
if($action == 'i') $app->plugins->raiseEvent('mail_transport_insert',$data);
if($action == 'u') $app->plugins->raiseEvent('mail_transport_update',$data);
if($action == 'd') $app->plugins->raiseEvent('mail_transport_delete',$data);
break;
case 'mail_user':
if($action == 'i') $app->plugins->raiseEvent('mail_user_insert',$data);
if($action == 'u') $app->plugins->raiseEvent('mail_user_update',$data);
if($action == 'd') $app->plugins->raiseEvent('mail_user_delete',$data);
break;
} // end switch
} // end function
} // end class
?>
\ No newline at end of file
<?php <?php
/* /*
Copyright (c) 2006, Till Brehm, projektfarm Gmbh Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
...@@ -62,52 +62,30 @@ if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){ ...@@ -62,52 +62,30 @@ if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){
@touch($conf["temppath"].$conf["fs_div"].".ispconfig_lock"); @touch($conf["temppath"].$conf["fs_div"].".ispconfig_lock");
$app->log("Set Lock: ".$conf["temppath"].$conf["fs_div"].".ispconfig_lock"); $app->log("Set Lock: ".$conf["temppath"].$conf["fs_div"].".ispconfig_lock");
// Load required base-classes
$this->uses('ini_parser,modules,plugins');
// Get server configuration // Get server configuration
$this->uses('ini_parser');
$conf["serverconfig"] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record["config"])); $conf["serverconfig"] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record["config"]));
// Run the configuration modules /*
if($server_db_record["mail_server"] == 1) { Load the modules that are im the mods-enabled folder
$app->load('mod_mail_base'); */
$mail_module_name = 'mod_mail_'.$conf["serverconfig"]["mail"]["module"];
$app->uses($mail_module_name);
$app->$mail_module_name->write_config();
}
if($server_db_record["web_server"] == 1) { $this->modules->loadModules();
$app->load('mod_web_base');
$web_module_name = 'mod_web_'.$conf["serverconfig"]["web"]["module"];
$app->uses($web_module_name);
$app->$web_module_name->write_config();
}
if($server_db_record["dns_server"] == 1) {
$app->load('mod_dns_base');
$dns_module_name = 'mod_dns_'.$conf["serverconfig"]["dns"]["module"];
$app->uses($dns_module_name);
$app->$dns_module_name->write_config();
}
if($server_db_record["file_server"] == 1) { /*
$app->load('mod_file_base'); Load the plugins that are in the plugins-enabled folder
$file_module_name = 'mod_file_'.$conf["serverconfig"]["file"]["module"]; */
$app->uses($file_module_name);
$app->$file_module_name->write_config();
}
if($server_db_record["db_server"] == 1) { $this->plugins->loadPlugins();
$app->load('mod_db_base');
$db_module_name = 'mod_db_'.$conf["serverconfig"]["db"]["module"];
$app->uses($db_module_name);
$app->$db_module_name->write_config();
}
if($server_db_record["vserver_server"] == 1) { /*
$app->load('mod_vserver_base'); Go trough the sys_datalog table and call the processing functions
$vserver_module_name = 'mod_vserver_'.$conf["serverconfig"]["vserver"]["module"]; in the modules that are hooked on to the table actions
$app->uses($vserver_module_name); */
$app->$vserver_module_name->write_config(); $this->modules->processDatalog();
}
// Remove lock // Remove lock
@unlink($conf["temppath"].$conf["fs_div"].".ispconfig_lock"); @unlink($conf["temppath"].$conf["fs_div"].".ispconfig_lock");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment