diff --git a/base.php b/base.php index 7f02093..6cc85b4 100644 --- a/base.php +++ b/base.php @@ -13,7 +13,7 @@ require("include.constants.php"); -require("cphp/config.php"); +require("include.config.php"); require("include.dependencies.php"); require("include.exceptions.php"); @@ -28,11 +28,6 @@ require("include.csrf.php"); require("class.templater.php"); require("class.localizer.php"); -$locale = new Localizer(); -$locale->Load($cphp_locale_name); - -setlocale(LC_ALL, $locale->locale); - if(empty($not_html)) { header("Content-Type:text/html; charset=UTF-8"); @@ -41,7 +36,7 @@ if(empty($not_html)) require("class.base.php"); require("class.databaserecord.php"); -foreach($cphp_components as $component) +foreach($cphp_config->components as $component) { require("components/component.{$component}.php"); } diff --git a/class.databaserecord.php b/class.databaserecord.php index b76a523..bc77b33 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -31,6 +31,11 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass public function __construct($uDataSource, $defaultable = null) { + if(!isset($cphp_config->class_map)) + { + die("No class map was specified. Refer to the CPHP manual for instructions."); + } + $this->ConstructDataset($uDataSource, $defaultable); $this->EventConstructed(); } @@ -173,7 +178,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass public function BindDataset($type, $dataset, $defaultable) { - global $cphp_class_map; + global $cphp_config; if(is_array($dataset)) { @@ -191,7 +196,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass public function SetField($type, $variable_name, $column_name) { - global $cphp_class_map; + global $cphp_config; if(!isset($this->uData[$column_name])) { @@ -236,7 +241,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass break; default: $found = false; - foreach($cphp_class_map as $class_type => $class_name) + foreach(get_object_vars($cphp_config->class_map) as $class_type => $class_name) { if($type == $class_type) { @@ -477,13 +482,13 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass { // Not done yet! - if(!isset($cphp_class_map[$type])) + if(!isset($cphp_config->class_map->$type)) { $classname = get_class($this); throw new NotFoundException("Non-existent 'type' argument passed on to {$classname}.RetrieveChildren function."); } - $parent_type = get_parent_class($cphp_class_map[$type]); + $parent_type = get_parent_class($cphp_config->class_map->$type); if($parent_type !== "CPHPDatabaseRecordClass") { $parent_type = ($parent_type === false) ? "NONE" : $parent_type; diff --git a/include.config.php b/include.config.php new file mode 100644 index 0000000..bde3ca9 --- /dev/null +++ b/include.config.php @@ -0,0 +1,26 @@ +locale->default_timezone)) +{ + $user_preferences[CPHP_SETTING_TIMEZONE] = $cphp_config->locale->default_timezone; +} +else +{ + die("No default timezone was specified. Refer to the CPHP manual for instructions."); +} + $timezones = array( 'Pacific/Kwajalein' => '(GMT-12:00) International Date Line West', 'Pacific/Midway' => '(GMT-11:00) Midway Island', diff --git a/include.locale.php b/include.locale.php new file mode 100644 index 0000000..fc53d7b --- /dev/null +++ b/include.locale.php @@ -0,0 +1,26 @@ +locale->default_locale)) +{ + $locale = new Localizer(); + $locale->Load($cphp_config->locale->default_locale); + + setlocale(LC_ALL, $locale->locale); +} +else +{ + die("No default locale was specified. Refer to the CPHP manual for instructions."); +} diff --git a/include.memcache.php b/include.memcache.php index 4d5f8b3..a2302ca 100644 --- a/include.memcache.php +++ b/include.memcache.php @@ -13,10 +13,10 @@ if($_CPHP !== true) { die(); } -if($cphp_memcache_enabled) +if(!empty($cphp_config->memcache->enabled)) { $cphp_memcache = new Memcache; - $cphp_memcache_established = $cphp_memcache->connect($cphp_memcache_server, $cphp_memcache_port); + $cphp_memcache_established = $cphp_memcache->connect($cphp_config->memcache->hostname, $cphp_config->memcache->port); if($cphp_memcache_established !== false) { @@ -30,9 +30,9 @@ if($cphp_memcache_enabled) function mc_get($key) { - global $cphp_memcache_enabled, $cphp_memcache_connected, $cphp_memcache; + global $cphp_config, $cphp_memcache_connected, $cphp_memcache; - if($cphp_memcache_enabled === false || $cphp_memcache_connected === false) + if(empty($cphp_config->memcache->enabled) || $cphp_memcache_connected === false) { return false; } @@ -52,15 +52,15 @@ function mc_get($key) function mc_set($key, $value, $expiry) { - global $cphp_memcache_enabled, $cphp_memcache_connected, $cphp_memcache_compressed, $cphp_memcache; + global $cphp_config, $cphp_memcache_connected, $cphp_memcache; - if($cphp_memcache_enabled === false || $cphp_memcache_connected === false) + if(empty($cphp_config->memcache->enabled) || $cphp_memcache_connected === false) { return false; } else { - if($cphp_memcache_compressed === true) + if(!empty($cphp_config->memcache->compressed) === true) { $flag = MEMCACHE_COMPRESSED; } @@ -76,9 +76,9 @@ function mc_set($key, $value, $expiry) function mc_delete($key) { - global $cphp_memcache_enabled, $cphp_memcache_connected, $cphp_memcache; + global $cphp_config, $cphp_memcache_connected, $cphp_memcache; - if($cphp_memcache_enabled === false || $cphp_memcache_connected === false) + if(empty($cphp_config->memcache->enabled) || $cphp_memcache_connected === false) { return false; } diff --git a/include.mysql.php b/include.mysql.php index 71880c0..a45dcac 100644 --- a/include.mysql.php +++ b/include.mysql.php @@ -15,13 +15,26 @@ if($_CPHP !== true) { die(); } $cphp_mysql_connected = false; -if($cphp_mysql_enabled === true) +if(!empty($cphp_config->database->driver)) { - if(mysql_connect($cphp_mysql_host, $cphp_mysql_user, $cphp_mysql_pass)) + if(empty($cphp_config->database->database)) { - if(mysql_select_db($cphp_mysql_db)) + die("No database was configured. Refer to the CPHP manual for instructions."); + } + + if(mysql_connect($cphp_config->database->hostname, $cphp_config->database->username, $cphp_config->database->password)) + { + if(mysql_select_db($cphp_config->database->database)) { $cphp_mysql_connected = true; } + else + { + die("Could not connect to the specified database. Refer to the CPHP manual for instructions."); + } + } + else + { + die("Could not connect to the specified database server. Refer to the CPHP manual for instructions."); } }