Beispiel #1
0
 function __construct($db_index = NULL, $installation_data = NULL)
 {
     $this->_core =& Vevui::get();
     if ($installation_data && array_key_exists('missing', $installation_data)) {
         $this->_core->missing_component(get_class($this), $installation_data['missing']);
     }
     $config = $this->_core->e->db;
     if (NULL === $db_index) {
         $db_config_key = $config->default_schema;
         $db_config_value = $config->databases->{$db_config_key};
     } else {
         $db_config_key = $db_index;
         $db_config_value = $config->databases->{$db_index};
     }
     if (array_key_exists($db_config_key, self::$_drivers)) {
         $this->_drv =& self::$_drivers[$db_config_key]['drv'];
     } else {
         $drv = $db_config_value->drv;
         if (!self::$_sqldrv_loaded) {
             require SYS_PATH . '/core/sqldrv.php';
             self::$_sqldrv_loaded = TRUE;
         }
         $drv_class = 'Drv_' . $drv;
         if (!class_exists($drv_class)) {
             require SYS_PATH . '/core/drvs/' . $drv . '.php';
         }
         $data = Vevui::get_installation_data();
         $data = array_key_exists('drv', $data) && array_key_exists($drv, $data['drv']) ? $data['drv'][$drv] : NULL;
         $this->_drv = new $drv_class($db_config_value, $data);
         self::$_drivers[$db_config_key]['drv'] =& $this->_drv;
         self::$_drivers[$db_config_key]['functions'] = $this->_drv->register_functions();
     }
     $this->_config_key = $db_config_key;
 }
Beispiel #2
0
 function __construct($installation_data = NULL)
 {
     $this->_core =& Vevui::get();
     if ($installation_data && array_key_exists('missing', $installation_data)) {
         $this->_core->missing_component(get_class($this), $installation_data['missing']);
     }
 }
Beispiel #3
0
 function __construct()
 {
     $core =& Vevui::get();
     $loadnosqlmdl = $loadsqlmdl = FALSE;
     foreach ($core->e->db->databases as $db) {
         if (!$loadnosqlmdl) {
             switch ($db->drv) {
                 case 'mongodb':
                 case 'redis':
                     $loadnosqlmdl = TRUE;
             }
         }
         if (!$loadsqlmdl) {
             switch ($db->drv) {
                 case 'mysql':
                 case 'sqlite3':
                     $loadsqlmdl = TRUE;
             }
         }
     }
     if ($loadnosqlmdl) {
         require SYS_PATH . '/core/mdl.php';
     }
     if ($loadsqlmdl) {
         require SYS_PATH . '/core/sqlmdl.php';
     }
 }
Beispiel #4
0
 function __construct()
 {
     $config_file_path = CACHE_PATH . '/config.php';
     $core =& Vevui::get();
     $core->disable_errors();
     if (file_exists($config_file_path)) {
         @(include $config_file_path);
     }
     $core->enable_errors();
     if (isset($config) && self::VERSION === $config->_vevui->version && ENVIRONMENT === $config->_vevui->environment) {
         $config_ok = TRUE;
     } else {
         $config_ok = FALSE;
         $config = new stdClass();
     }
     // Skip checking for modifications.
     if (!$config_ok || $config->app->config_ttl && $config->_vevui->timestamp + $config->app->config_ttl < time()) {
         $config_mtime = $config_ok ? $config->_vevui->timestamp : FALSE;
         $files = @scandir(APP_CONFIG_PATH);
         $modified = FALSE;
         $yaml_files = array();
         foreach ($files as $file) {
             if (0 !== strcasecmp(substr($file, -5), '.yaml')) {
                 continue;
             }
             $name = strtolower(substr($file, 0, -5));
             $yaml_files[$name] = TRUE;
             if (FALSE === $config_mtime || $config_mtime < @filemtime(APP_CONFIG_PATH . '/' . $file) || !property_exists($config, $name)) {
                 $config->{$name} = $core->l->yaml->load(APP_CONFIG_PATH . '/' . $file, 'haanga' != $name);
             }
         }
         // Delete old entries that no longer exist as files.
         foreach ($config as $key => $value) {
             if ('_vevui' != $key && !array_key_exists($key, $yaml_files)) {
                 unset($config->{$key});
             }
         }
         $this->_merge_config($config, $core->l->yaml->load(APP_CONFIG_PATH . '/envs/' . ENVIRONMENT . '.yaml'));
         if ($config->app->cache) {
             $config->_vevui = new stdClass();
             $config->_vevui->version = self::VERSION;
             $config->_vevui->timestamp = time();
             $config->_vevui->environment = ENVIRONMENT;
             // Save config atomically. If not possible, we still work but very slow!
             $tempname = tempnam(CACHE_PATH, '_config.php.' . microtime(TRUE));
             $content = '<?php $config = unserialize(\'' . str_replace('\'', '\\\'', serialize($config)) . "');\n" . '// Generated by Vevui ' . VEVUI_VERSION . ' on ' . date('c');
             $core->disable_errors();
             @file_put_contents($tempname, $content);
             @rename($tempname, $config_file_path);
             $core->enable_errors();
         }
     }
     unset($config->_vevui);
     // Assign config to local fields.
     foreach ($config as $key => $value) {
         $this->{$key} = $value;
     }
 }
Beispiel #5
0
 function __construct($installation_data = NULL)
 {
     $this->_core =& Vevui::get();
     if ($installation_data && array_key_exists('missing', $installation_data)) {
         $this->_core->missing_component(get_class($this), $installation_data['missing']);
     }
     $config = $this->e->app;
     $this->_debug = $config->debug;
     $this->_profiling = $config->profiling;
     if (lcg_value() < $this->_profiling) {
     }
 }
Beispiel #6
0
 function __construct($db_index = NULL)
 {
     parent::__construct();
     $this->_core =& Vevui::get();
     $config = $this->_core->e->db;
     if (NULL === $db_index) {
         $db_config_value = $config->databases->{$config->default_schema};
     } else {
         $db_config_value = $config->databases->{$db_index};
     }
     // Only MySQL at the moment. mysql:dbname=testdb;host=127.0.0.1
     $dsn = $db_config_value->drv . ':dbname=' . $db_config_value->db . ';host=' . $db_config_value->host;
     self::$_pdo = new PDO($dsn, $db_config_value->user, $db_config_value->pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
     $this->_conn = $this->createDefaultDBConnection(self::$_pdo, $db_config_value->db);
 }
Beispiel #7
0
 function __construct($db_config, $installation_data = NULL)
 {
     parent::__construct($db_config, $installation_data);
     try {
         $this->_connection = new Mongo('mongodb://' . $db_config->host);
         $this->_db_name = $db_config->db;
         $this->_db = $this->_connection->{$this->_db_name};
         $this->_collections = array($this->_db_name => array());
         if (property_exists($db_config, 'user')) {
             $this->_db->authenticate($db_config->user, $db_config->pass);
         }
     } catch (MongoException $e) {
         $this->_raise_error($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
         return;
     }
     $core =& Vevui::get();
     $this->_in_debug = $core->e->app->debug;
 }
Beispiel #8
0
 function __construct()
 {
     parent::__construct();
     $this->_core =& Vevui::get();
 }
Beispiel #9
0
 limitations under the License.
*************************************************************************/
/***********************************************************
  Vevui configuration options
 **********************************************************/
/* Path where the sys folder is located. */
$sys_path = '../sys';
/* Path where the app folder is located. */
$app_path = '../app';
/* Environment to use. */
$environment = 'dev';
/***********************************************************
  DON'T EDIT BELOW THIS LINE (UNLESS YOU ARE A DEVELOPER ;)
 **********************************************************/
define('ROOT_PATH', __DIR__ . '/..');
define('SYS_PATH', __DIR__ . '/' . $sys_path);
define('APP_PATH', __DIR__ . '/' . $app_path);
define('CACHE_PATH', __DIR__ . '/../cache');
define('APP_CONTROLLERS_PATH', APP_PATH . '/c');
define('APP_CONFIG_PATH', APP_PATH . '/e');
define('APP_HELPERS_PATH', APP_PATH . '/h');
define('APP_LIBRARIES_PATH', APP_PATH . '/l');
define('APP_MODELS_PATH', APP_PATH . '/m');
define('APP_ERROR_TEMPLATES_PATH', APP_PATH . '/o');
define('APP_VIEWS_PATH', APP_PATH . '/v');
define('APP_EXTENSIONS_PATH', APP_PATH . '/x');
define('ENVIRONMENT', $environment);
require SYS_PATH . '/core/coreloader.php';
$core =& Vevui::get();
$core->route();
/* End of file pub/index.php */