From 994011ddb6cc1097214537160a10bf710aedc553 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 01:15:18 -0700 Subject: [PATCH] load db configs (config,system) for all "executables" --- boot.php | 9 +++++---- include/directory.php | 24 ++++++++++++++---------- include/expire.php | 4 ++++ include/notifier.php | 3 +++ include/poller.php | 3 +++ include/queue.php | 3 +++ index.php | 11 ++--------- 7 files changed, 34 insertions(+), 23 deletions(-) diff --git a/boot.php b/boot.php index f66cf4bc..ff036c3d 100644 --- a/boot.php +++ b/boot.php @@ -498,9 +498,6 @@ function install_plugin($plugin){ if(! function_exists('check_config')) { function check_config(&$a) { - - load_config('system'); - $build = get_config('system','build'); if(! x($build)) $build = set_config('system','build',DB_UPDATE_VERSION); @@ -1218,7 +1215,11 @@ function load_config($family) { if(count($r)) { foreach($r as $rr) { $k = $rr['k']; - $a->config[$family][$k] = $rr['v']; + if ($rr['cat'] === 'config') { + $a->config[$k] = $rr['v']; + } else { + $a->config[$family][$k] = $rr['v']; + } } } }} diff --git a/include/directory.php b/include/directory.php index 2c9daa5e..cae78adb 100644 --- a/include/directory.php +++ b/include/directory.php @@ -2,18 +2,22 @@ require_once("boot.php"); function directory_run($argv, $argc){ - global $a, $db; + global $a, $db; - if(is_null($a)){ - $a = new App; - } + if(is_null($a)) { + $a = new App; + } - if(is_null($db)){ - @include(".htconfig.php"); - require_once("dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; + if(is_null($db)) { + @include(".htconfig.php"); + require_once("dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + }; + + load_config('config'); + load_config('system'); + if($argc != 2) return; diff --git a/include/expire.php b/include/expire.php index cf3b7c8e..64dbe253 100644 --- a/include/expire.php +++ b/include/expire.php @@ -22,6 +22,10 @@ function expire_run($argv, $argc){ require_once('include/items.php'); require_once('include/Contact.php'); + load_config('config'); + load_config('system'); + + $a->set_baseurl(get_config('system','url')); diff --git a/include/notifier.php b/include/notifier.php index d9f90385..4b97311f 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -20,6 +20,9 @@ function notifier_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_config('config'); + load_config('system'); + load_hooks(); if($argc < 3) diff --git a/include/poller.php b/include/poller.php index 99517a7e..4cab5a3b 100644 --- a/include/poller.php +++ b/include/poller.php @@ -24,6 +24,9 @@ function poller_run($argv, $argc){ require_once('include/Contact.php'); require_once('include/email.php'); + load_config('config'); + load_config('system'); + $a->set_baseurl(get_config('system','url')); load_hooks(); diff --git a/include/queue.php b/include/queue.php index cbda196d..fb65d5c2 100644 --- a/include/queue.php +++ b/include/queue.php @@ -22,6 +22,9 @@ function queue_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_config('config'); + load_config('system'); + $a->set_baseurl(get_config('system','url')); load_hooks(); diff --git a/index.php b/index.php index a58e4730..2e24c5b0 100644 --- a/index.php +++ b/index.php @@ -50,15 +50,8 @@ if(! $install) { * Load configs from db. Overwrite configs from .htconfig.php */ - $r = q("SELECT * FROM `config` WHERE `cat` IN ('system', 'config')"); - foreach ($r as $c) { - if ($c['cat']=='config') { - $a->config[$c['k']] = $c['v']; - } else { - $a->config[$c['cat']][$c['k']] = $c['v']; - } - } - unset($r); + load_config('config'); + load_config('system'); require_once("session.php"); load_hooks();