3 // default framework settings for release
5 class Pman_Core_Config {
10 var $defaults = array( ); // override...
13 // note if other extended 'config's require more, then you porbably need to include these first.
14 var $required_extensions = array(
22 function init($ff, $cfg)
27 $cfg = $this->overlayDefaults($cfg);
29 if (!empty($this->memory_limit)) {
30 $mem = ini_get('memory_limit');
31 if (php_sapi_name() != 'cli' && $this->to_bytes($mem) < $this->to_bytes($this->memory_limit)) {
32 trigger_error("increase the memory limit settings to 2048M or more", E_USER_ERROR);
37 $this->verifyExtensions();
40 if (!isset($cfg['Pman']['timezone'])) {
41 trigger_error("timezone needs setting in Pman[timezone]", E_USER_ERROR);
43 if ($cfg['Pman']['timezone'] != ini_get('date.timezone')) {
44 trigger_error("timezone needs setting in php.ini date.timezone = " . $cfg['Pman']['timezone'], E_USER_ERROR);
51 function to_bytes($val) {
53 $last = strtolower($val[strlen($val)-1]);
55 // The 'G' modifier is available since PHP 5.1.0
57 $val = substr($val, 0, -1);
60 $val = substr($val, 0, -1);
62 $val = substr($val, 0, -1);
69 function overlayDefaults($cfg)
71 if (isset($this->defaults['disable']) && is_array($this->defaults['disable']) ) {
72 $this->defaults['disable'] = implode(',', $this->defaults['disable']);
74 foreach($this->defaults as $k=>$v) {
77 if (!isset($cfg[$k])) {
82 foreach($v as $kk=>$vv) {
83 if (isset($cfg[$k][$kk])) {
91 if (!isset($cfg[$k])) {
98 function verifyExtensions()
102 foreach ($this->required_extensions as $e){
104 if(empty($e) || extension_loaded($e)) {
108 $error[] = "Error: Please install php extension: {$e}";
114 trigger_error("Missing Extensions: \n" . implode('\n', $error), E_USER_ERROR);