示例#1
0
文件: sqlmdl.php 项目: scalia/Vevui
 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;
 }
示例#2
0
文件: lib.php 项目: scalia/Vevui
 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']);
     }
 }
示例#3
0
 function __get($model_name)
 {
     $data = Vevui::get_installation_data();
     $data = isset($data['m'][$model_name]) ? $data['m'][$model_name] : NULL;
     require APP_MODELS_PATH . '/' . $model_name . '.php';
     return $this->{$model_name} = new $model_name($data);
 }
示例#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;
     }
 }
示例#5
0
文件: ctrl.php 项目: scalia/Vevui
 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) {
     }
 }
示例#6
0
 function __get($library_name)
 {
     $data = Vevui::get_installation_data();
     if ($this->_user_libraries) {
         $folder = APP_LIBRARIES_PATH;
         $data = isset($data['ul'][$library_name]) ? $data['ul'][$library_name] : NULL;
     } else {
         $folder = SYS_PATH . '/libraries';
         $data = isset($data['l'][$library_name]) ? $data['l'][$library_name] : NULL;
     }
     require $folder . '/' . $library_name . '.php';
     return $this->{$library_name} = new $library_name($data);
 }
示例#7
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);
 }
示例#8
0
文件: mongodb.php 项目: scalia/Vevui
 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;
 }
示例#9
0
 function __construct()
 {
     parent::__construct();
     $this->_core =& Vevui::get();
 }
示例#10
0
文件: index.php 项目: scalia/Vevui
 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 */
示例#11
0
文件: core.php 项目: scalia/Vevui
 public function route()
 {
     $app = $this->e->app;
     $this->_uri = urldecode($_SERVER['REQUEST_URI']);
     // Strip /index.php if exists.
     $pos = strpos($this->_uri, '/index.php');
     if (0 === $pos) {
         $this->_uri = substr($this->_uri, strlen('/index.php'));
     }
     // Check if query string is activated
     if ($app->query_string) {
         if (FALSE !== ($query_pos = strpos($this->_uri, '?'))) {
             $query_string = substr($this->_uri, $query_pos + 1);
             $this->_uri = substr($this->_uri, 0, $query_pos);
             // Check if query string character set is valid
             if (!preg_match('/^[=&' . $app->url_chars . ']+$/i', $query_string)) {
                 $this->not_found();
             }
         }
     }
     // Apply URI Routing rules
     if (property_exists($app, 'routes')) {
         foreach ($app->routes as $pattern => $redir) {
             $count = 0;
             $this->_uri = preg_replace('/' . str_replace('/', '\\/', $pattern) . '/', $redir, $this->_uri, 1, $count);
             if ($count) {
                 break;
             }
         }
     }
     // Check if URI character set is valid
     if (!preg_match('/^[\\/' . $app->url_chars . ']+$/i', $this->_uri)) {
         $this->not_found();
     }
     $uri_segs = explode('/', $this->_uri);
     $uri_segs_count = count($uri_segs);
     $this->_request_class = $app->default_controller;
     $this->_request_method = 'index';
     $request_params = array();
     if ('' !== $uri_segs[1]) {
         $this->_request_class = strtolower($uri_segs[1]);
     }
     if (2 < $uri_segs_count) {
         if ('' !== $uri_segs[2]) {
             $this->_request_method = $uri_segs[2];
         }
         $request_params = array_slice($uri_segs, 3);
     }
     // Call controller/method
     $filepath = APP_CONTROLLERS_PATH . '/' . $this->_request_class . '.php';
     require SYS_PATH . '/core/baselog.php';
     require SYS_PATH . '/core/log.php';
     require SYS_PATH . '/core/ctrl.php';
     if (!file_exists($filepath)) {
         $this->not_found();
     }
     require $filepath;
     $data = Vevui::get_installation_data();
     $data = array_key_exists('c', $data) && array_key_exists($this->_request_class, $data['c']) ? $data['c'][$this->_request_class] : NULL;
     $this->_request_ctrl = new $this->_request_class($data);
     if (!is_subclass_of($this->_request_ctrl, 'Ctrl') || !strncmp($this->_request_method, '_', 1)) {
         $this->not_found();
     }
     ob_start();
     call_user_func_array(array($this->_request_ctrl, $this->_request_method), $request_params);
     ob_flush();
 }