/** * checks a database configuration array, and set its defaults. **/ private static function _checkconfig($dbname, $isdef = false) { // if not database name specified use array's name. if (!isset(self::$_DDB['name']) || !self::$_DDB['name']) { self::$_DDB['name'] = Arrays::key_first(self::$_DBS); } // if not hostname specified use localhost if (!isset(self::$_DDB['hostname']) || !self::$_DDB['hostname']) { self::$_DDB['hostname'] = 'localhost'; } // if not username or password is specified, send error. if (!isset(self::$_DDB['username']) || !self::$_DDB['username']) { Core::error('VARREQ', 'LIBTIT', array(__CLASS__, 'username')); } if (!isset(self::$_DDB['password']) || !self::$_DDB['password']) { Core::error('VARREQ', 'LIBTIT', array(__CLASS__, 'password')); } // self explanatory if (!isset(self::$_DDB['prefix'])) { self::$_DDB['prefix'] = ''; } if (!isset(self::$_DDB['driver']) || !self::$_DDB['driver']) { self::$_DDB['driver'] = 'mysql'; } if (!isset(self::$_DDB['pconnect']) || !is_bool(self::$_DDB['pconnect'])) { self::$_DDB['pconnect'] = true; } if (!isset(self::$_DDB['debug']) || !is_bool(self::$_DDB['debug'])) { self::$_DDB['debug'] = true; } if (!isset(self::$_DDB['cache']) || !is_bool(self::$_DDB['cache'])) { self::$_DDB['cache'] = false; } if (!isset(self::$_DDB['cachedir']) || !self::$_DDB['cachedir']) { self::$_DDB['cachedir'] = CACH; } if (!is_writable(self::$_DDB['cachedir'])) { Core::error('403DIR', 'LIBTIT', array(__CLASS__, 'cachedir')); } // detect charset and collation if necessary if (!isset(self::$_DDB['charset']) || !self::$_DDB['charset']) { self::$_DDB['charset'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][0] : ''; } if (!isset(self::$_DDB['collat']) || !self::$_DDB['collat']) { self::$_DDB['collat'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][1] : ''; } }
/** * checks a database configuration array, and set its defaults. **/ private static function _check() { // if not database name specified use array's name. if (!isset(self::$INFO['name']) || !self::$INFO['name']) { self::$INFO['name'] = Arrays::key_first(self::$_DBS); } // if not hostname specified use localhost if (!isset(self::$INFO['hostname']) || !self::$INFO['hostname']) { self::$INFO['hostname'] = 'localhost'; } // if not username or password is specified, send error. if (!isset(self::$INFO['username']) || !self::$INFO['username']) { self::error('VARREQ', 'LIBTIT', array(__CLASS__, 'username')); } if (!isset(self::$INFO['password']) || !self::$INFO['password']) { self::error('VARREQ', 'LIBTIT', array(__CLASS__, 'password')); } // self explanatory if (!isset(self::$INFO['port']) || !self::$INFO['port']) { self::$INFO['port'] = self::$PORT; } if (!isset(self::$INFO['prefix'])) { self::$INFO['prefix'] = ''; } if (!isset(self::$INFO['driver']) || !self::$INFO['driver']) { self::$INFO['driver'] = Arrays::first(self::$_DRV); } if (!isset(self::$INFO['pconnect']) || !is_bool(self::$INFO['pconnect'])) { self::$INFO['pconnect'] = true; } // persistent connection if (!isset(self::$INFO['debug']) || !is_bool(self::$INFO['debug'])) { self::$INFO['debug'] = true; } if (!isset(self::$INFO['cache']) || !is_bool(self::$INFO['cache'])) { self::$INFO['cache'] = false; } if (!isset(self::$INFO['cachedir']) || !self::$INFO['cachedir']) { self::$INFO['cachedir'] = CACH . 'DB/'; } if (!file_exists(self::$INFO['cachedir'])) { mkdir($INFO['cachedir'], 0777); } // send an error if the directory isn't writable if (!is_writable(self::$INFO['cachedir']) === false) { self::error('403DIR', 'LIBTIT', array(__CLASS__, 'cachedir')); } // detect charset and collation if necessary $chset = Core::config('charset'); if (!isset(self::$INFO['charset']) || !self::$INFO['charset']) { self::$INFO['charset'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][0] : ''; } if (!isset(self::$INFO['collat']) || !self::$INFO['collat']) { self::$INFO['collat'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][1] : ''; } }