Exemplo n.º 1
0
 public static function init()
 {
     static $_initd = false;
     if ($_initd) {
         throw new Exception('Already initialized.');
     }
     spl_autoload_register(array('OBFind', 'autoload'));
     self::$libdir = defined(self::$const_prefix . 'LIBDIR') ? constant(self::$const_prefix . 'LIBDIR') : dirname(__FILE__);
     $dbconfig = array('dbhost', 'dbname', 'dbuser', 'dbpass');
     foreach ($dbconfig as $ci => $config) {
         if (defined('OBF_' . strtoupper($config))) {
             self::${$config} = constant('OBF_' . strtoupper($config));
         }
     }
     $dsn = sprintf('pgsql:host=%s;dbname=%s;user=%s;password=%s', self::$dbhost, self::$dbname, self::$dbuser, self::$dbpass);
     Rudb::connect($dsn);
     $_initd = true;
 }
Exemplo n.º 2
0
 public function init()
 {
     spl_autoload_register(array(__CLASS__, 'autoload'));
     self::$libdir = FILETHIS_LIBDIR;
     self::$datdir = FILETHIS_DATDIR;
     self::$confdir = FILETHIS_CONFDIR;
     self::load_conf('filethis');
     if (self::conf('filethis', 'data_dir')) {
         self::$datdir = self::conf('filethis', 'data_dir');
     }
     self::load_conf('db');
     $dbconf = self::conf('db');
     if (!$dbconf) {
         throw new Exception('DB not configured.');
     }
     $dsn = sprintf('pgsql:host=%s;dbname=%s;user=%s;password=%s', $dbconf->host, $dbconf->name, $dbconf->user, $dbconf->password);
     Rudb::connect($dsn);
     self::load_conf('twilio');
 }