From 7d52e00a51450bc4a080d4e21b7dda02c0a65191 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 14 Nov 2013 05:42:06 -0500
Subject: [PATCH] Fixed list sorting
---
server/server.php | 87 ++++++++++++++++++++++---------------------
1 files changed, 45 insertions(+), 42 deletions(-)
diff --git a/server/server.php b/server/server.php
index 967d13a..3415f6e 100644
--- a/server/server.php
+++ b/server/server.php
@@ -27,11 +27,9 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// $script_path allows development work of using a symbolic link farm
-// to use along side git or svn
-$script_path = dirname($_SERVER["SCRIPT_FILENAME"]);
-require("$script_path/lib/config.inc.php");
-require("$script_path/lib/app.inc.php");
+define('SCRIPT_PATH', dirname($_SERVER["SCRIPT_FILENAME"]));
+require(SCRIPT_PATH."/lib/config.inc.php");
+require(SCRIPT_PATH."/lib/app.inc.php");
set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE);
@@ -40,25 +38,20 @@
$conf['server_id'] = intval($conf['server_id']);
/*
- // Get server record, if updates where available for this server
- $server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE update = 1 AND server_id = ".$conf['server_id']);
- if($server_db_record == false) {
- $app->log('Nothing to update for server_id '.$conf['server_id']);
- die();
- } else {
- // Set update status to 0, so we dont start the update process twice
- $app->db->query("UPDATE server SET update = 0 WHERE server_id = ".$conf['server_id']);
- $app->log('Begin update.');
- }
- */
-
-/*
* Try to Load the server configuration from the master-db
*/
-if ($app->dbmaster->connect()) {
+if ($app->dbmaster->connect_error == NULL) {
$server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']);
-
- $conf['last_datalog_id'] = (int) $server_db_record['updated'];
+
+ if(!is_array($server_db_record)) die('Unable to load the server configuration from database.');
+
+ //* Get the number of the last processed datalog_id, if the id of the local server
+ //* is > then the one of the remote system, then use the local ID as we might not have
+ //* reached the remote server during the last run then.
+ $local_server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']);
+ $conf['last_datalog_id'] = (int) max($server_db_record['updated'],$local_server_db_record['updated']);
+ unset($local_server_db_record);
+
$conf['mirror_server_id'] = (int) $server_db_record['mirror_server_id'];
// Load the ini_parser
@@ -69,9 +62,20 @@
// Set the loglevel
$conf['log_priority'] = intval($conf['serverconfig']['server']['loglevel']);
+
+ // Set level from which admin should be notified by email
+ if(!isset($conf['serverconfig']['server']['admin_notify_events']) || $conf['serverconfig']['server']['admin_notify_events'] == '') $conf['serverconfig']['server']['admin_notify_events'] = 3;
+ $conf['admin_notify_priority'] = intval($conf['serverconfig']['server']['admin_notify_events']);
// we do not need this variable anymore
unset($server_db_record);
+
+ // retrieve admin email address for notifications
+ //$sys_ini = $app->dbmaster->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1");
+ $sys_ini = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1");
+ $conf['sys_ini'] = $app->ini_parser->parse_ini_string(stripslashes($sys_ini['config']));
+ $conf['admin_mail'] = $conf['sys_ini']['mail']['admin_mail'];
+ unset($sys_ini);
/*
* Save the rescue-config, maybe we need it (because the database is down)
@@ -148,7 +152,7 @@
/*
* Next we try to process the datalog
*/
-if ($app->db->connect() && $app->dbmaster->connect()) {
+if ($app->db->connect_error == NULL && $app->dbmaster->connect_error == NULL) {
// Check if there is anything to update
if ($conf['mirror_server_id'] > 0) {
@@ -159,29 +163,28 @@
$tmp_num_records = $tmp_rec['number'];
unset($tmp_rec);
-
+
+ //** Load required base-classes
+ $app->uses('modules,plugins,file,services,system');
+ //** Load the modules that are in the mods-enabled folder
+ $app->modules->loadModules('all');
+ //** Load the plugins that are in the plugins-enabled folder
+ $app->plugins->loadPlugins('all');
if ($tmp_num_records > 0) {
- /*
- There is something to do, triggert by the database -> do it!
- */
- // Write the Log
$app->log("Found $tmp_num_records changes, starting update process.", LOGLEVEL_DEBUG);
- // Load required base-classes
- $app->uses('modules,plugins,file,services');
- // Load the modules that are in the mods-enabled folder
- $app->modules->loadModules('all');
- // Load the plugins that are in the plugins-enabled folder
- $app->plugins->loadPlugins('all');
- // Go through the sys_datalog table and call the processing functions
- // from the modules that are hooked on to the table actions
+ //** Go through the sys_datalog table and call the processing functions
+ //** from the modules that are hooked on to the table actions
$app->modules->processDatalog();
- // Restart services that need to after configuration
- $app->services->processDelayedActions();
- // All modules are already loaded and processed, so there is NO NEED to load the core once again...
- $needStartCore = false;
}
+ //** Process actions from sys_remoteaction table
+ $app->modules->processActions();
+ //** Restart services that need to after configuration
+ $app->services->processDelayedActions();
+ //** All modules are already loaded and processed, so there is NO NEED to load the core once again...
+ $needStartCore = false;
+
} else {
- if (!$app->db->connect()) {
+ if ($app->db->connect->connect_error == NULL) {
$app->log('Unable to connect to local server.' . $app->db->errorMessage, LOGLEVEL_WARN);
} else {
$app->log('Unable to connect to master server.' . $app->dbmaster->errorMessage, LOGLEVEL_WARN);
@@ -201,8 +204,8 @@
$app->uses('modules,plugins,file,services');
// Load the modules that are im the mods-core folder
$app->modules->loadModules('core');
- // Load the plugins that are in the plugins-core folder
- $app->plugins->loadPlugins('core');
+ // Load the plugins that are in the f folder
+ //$app->plugins->loadPlugins('core');
}
--
Gitblit v1.9.1