Exemplo n.º 1
0
 protected function __construct($appname)
 {
     self::$appname = $appname;
     //定义系统常量
     define('APP_NAME', self::$appname);
     define('ROOT_PATH', dirname(dirname(__FILE__)));
     define('APP_PATH', ROOT_PATH . '/app');
     define('TPL', ROOT_PATH . '/templates');
     define('COOKIE_EXPIRE', time() + 3600 * 24 * 30);
     define('COOKIE_DOMAIN', '.test.com');
     //应用程序自动加载方法
     spl_autoload_register(array('self', 'sysAutoload'));
 }
Exemplo n.º 2
0
 public function test_config()
 {
     $this->test(1, core_config::set_config('test$only', 'test', 'only'));
     $this->test(2, core_config::get_config('test$only', 'test'));
     $this->test(3, core_config::get_config('test$only', 'none'));
     $this->test(5, core_config::has_config('test$only', 'test'));
     $this->test(4, core_config::get_config(null, 'test'));
     $this->test(6, core_config::get_config(null, 'none'));
     $this->test(7, core_config::get_config(null, 'none', 'default value'));
     $this->set_prefix('helper');
     $this->test(1, config('test'));
     $this->test(2, config('none'));
     $this->test(3, config('none', 'default value'));
 }
Exemplo n.º 3
0
function config($key, $default_value = null)
{
    return core_config::get_config(null, $key, $default_value);
}
Exemplo n.º 4
0
 public static function _create_controller($modular_path_data, $cancel_print = false, $auto_execute = true, $can_detect_caller_path = false)
 {
     // Armazena o método padrão, ele será usado em vários momentos
     $default_method = core_config::get_config(null, 'route_default_method');
     // Define algumas informações principais
     $modular_path = new stdclass();
     $modular_path->url = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . "://{$_SERVER['SERVER_NAME']}" . dirname($_SERVER['SCRIPT_NAME']) . '/';
     // Se o path modular for false, então usa totalmente o padrão
     // Ex: http://127.0.0.1/
     if ($modular_path_data === null || $modular_path_data === false) {
         $modular_path->modular = (array) core_config::get_config(null, 'route_default_modular');
         $modular_path->path = (array) core_config::get_config(null, 'route_default_controller');
         $modular_path->method = $default_method;
         $modular_path->class = core::get_joined_class($modular_path, 'controller');
     } else {
         // Se puder detectar o path do caller (somente execute())
         if ($can_detect_caller_path === true && isset($modular_path_data[0]) === true) {
             // Se o primeiro caractere for um $, indica rota estrita inline
             if ($modular_path_data[0] === '$') {
                 $strict_route = true;
                 $modular_path_data = substr($modular_path_data, 1);
             }
             // Se o modular começar por / apenas remove a informação
             // Caso contrário, deverá preencher com o path do módulo de chamada
             if ($modular_path_data[0] === '/') {
                 $modular_path_data = substr($modular_path_data, 1);
             } else {
                 $modular_path_data = join('/', core::get_caller_module_path()) . '/' . $modular_path_data;
             }
         }
         // Se não definir o modo estrito de rota, obtém a informação
         if (!isset($strict_route)) {
             $strict_route = config('route_strict_mode');
         }
         // Extende a informação da URL
         $modular_path->url .= $modular_path_data;
         // Se houver uma definição de path, é necessário fazer uma busca por arquivos
         // Primeiramente, é necessário separar a chamada
         $modular_path_data = explode('/', $modular_path_data);
         // Depois é necessário buscar pelo modular do endereço solicitado
         // Ex: http://127.0.0.1/site
         $modular_path_data = core::get_modular_parts($modular_path_data, array('search_paths' => false, 'path_clip_empty' => true, 'make_fullpath' => true));
         // Se a modular não for definida, retorna um controller neutro
         if (isset($modular_path_data->modular) === false) {
             if ($strict_route === true) {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_MODULAR_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             } else {
                 $modular_path_data->modular = (array) core_config::get_config(null, 'route_default_modular');
             }
         }
         // Senão, armazena a informação
         $modular_path->modular = $modular_path_data->modular;
         // Depois é necessário buscar pelo controller do endereço solicitado
         // Ex: http://127.0.0.1/site/master ou simplesmente http://127.0.0.1/master
         $modular_path_data = core::get_modular_parts(@$modular_path_data->remains, array('start_dir' => $modular_path_data->fullpath . '/controllers', 'search_modules' => false));
         // Se o controller não for definido, define com o valor padrão
         if (!empty($modular_path_data->path)) {
             $modular_path->path = $modular_path_data->path;
         } else {
             if ($strict_route === false) {
                 $modular_path->path = (array) core_config::get_config(null, 'route_default_controller');
             } else {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_PATH_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
         }
         // Gera o nome completo da chamada
         $modular_path->class = core::get_joined_class($modular_path, 'controller');
         // Se não existir mais informações para o method, usa o valor padrão
         if (empty($modular_path_data->remains) === false) {
             $modular_path->method = array_shift($modular_path_data->remains);
         } else {
             if ($strict_route === false) {
                 $modular_path->method = $default_method;
             } else {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_METHOD_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
         }
     }
     // Gera o caminho completo do arquivo
     $modular_path->fullpath = core::get_path_fixed(CORE_MODULES . '/' . join('/_', $modular_path->modular) . '/controllers/' . join('/', $modular_path->path) . '.php');
     // Se o arquivo de controller não existir, usará o controler neutro
     if (is_file($modular_path->fullpath) === false) {
         return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_CONTROLLER_NOT_FOUND, self::RETURN_TYPE_DEFAULT, false);
     }
     // Senão, faz um require da classe solicitada
     if (class_exists($modular_path->class, false) === false) {
         core::do_require($modular_path->fullpath);
     }
     // Se for chamado um método diferente do padrão, mas este não existir, usa o método padrão
     try {
         if ($modular_path->method !== $default_method && method_exists($modular_path->class, $modular_path->method) === false) {
             if ($strict_route === true) {
                 return new self($modular_path, null, $cancel_print, self::STATUS_CONTROLLER_INVALID | self::STATUS_METHOD_REQUIRED, self::RETURN_TYPE_DEFAULT, false);
             }
             array_unshift($modular_path_data->remains, $modular_path->method);
             $modular_path->method = $default_method;
         }
     } catch (core_exception $e) {
         $modular_path->method = $default_method;
     }
     // Por fim, cria o controller com as definições passadas
     return new $modular_path->class($modular_path, @$modular_path_data->remains, $cancel_print, self::STATUS_SUCCESS, self::RETURN_TYPE_DEFAULT, $auto_execute);
 }
Exemplo n.º 5
0
<?php

error_reporting(E_ALL);
include './core/config.php';
core_config::appInit('remind');
core_config::appRun();
Exemplo n.º 6
0
<?php

$___config = new core_config();
$___config->setData(array('design' => array('skin' => 'default', 'core' => array('skin' => array('path' => 'app' . DS . 'core' . DS . 'design' . DS . '%skin%' . DS)), 'mod' => array('skin' => array('path' => 'app' . DS . 'mod' . DS . '%mod%' . DS . 'design' . DS . '%skin%' . DS))), 'pdo' => array('adapter' => 'mysql', 'config' => array('dsn' => 'mysql:host=localhost;dbname=gis_trade', 'username' => 'root', 'password' => '', 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION))), 'url' => array('base' => 'http://gis.local/'), 'dir' => array('base' => __DIR__, 'sd' => __DIR__ . DS . 'sd' . DS, 'log' => __DIR__ . DS . 'sd' . DS . 'log' . DS)));
Exemplo n.º 7
0
 public static function _get_connection($conn_path = null, $index_name = null)
 {
     return core_config::get_config($conn_path, "database_connection[{$index_name}]");
 }
Exemplo n.º 8
0
//NOTE: altere a informação para false para desabilitar a função
$config->language_session_key = 'language-id';
// string, false
// Alterar sessão automaticamente quando usar a request key
//NOTE: altere a informação para false para desabilitar a função
$config->language_session_autosync = true;
/** CONFIGURAÇÕES DE BANCO DE DADOS */
// Permitir conexão preguiçosa: conectar somente quando for necessário.
$config->database_lazy_mode = true;
// boolean
// Usar conexões persistentes por padrão
$config->database_persistent_mode = true;
// boolean
// Charset padrão para ser utilizado
$config->database_default_charset = 'utf8';
// string
/** CONFIGURAÇÕES DE SESSÃO */
// Prefixar sessões (isto evita conflito de sessões)
//NOTE: altere a informação para true para prefixar automaticamente
//NOTE: altere a informação para false para desabilitar a função
$config->session_prefix = true;
// Ao prefixar automaticamente, também incluir a modular
$config->session_prefix_modular = false;
/** CONFIGURAÇÕES DE SEGURANÇA */
// Chave de segurança para SHA256
//NOTE: prefira utilizar um dos itens em: http://bit.ly/aHeU8I
$config->security_key = 'default';
// Salva as configurações na raiz
core_config::save_configs('', $config);
// Carrega as configurações modular
core::do_require(CORE_MODULES . '/configs.php');
Exemplo n.º 9
0
 public static function do_require($__required_file)
 {
     // As configurações deverão ser salvas nesta variável
     $config = new stdclass();
     // Armazena a informação se o arquivo existe
     $__is_file = false;
     // Inclui o arquivo especificado
     $__required_file = realpath($__required_file);
     if (is_file($__required_file)) {
         $__is_file = true;
         require $__required_file;
     }
     // Salva as configurações, se necessário
     core_config::save_configs(self::get_path_clipped($__required_file), (array) $config);
     return $__is_file;
 }