Example #1
0
 public function __construct(array $config = Null)
 {
     parent::__construct($config);
     if ($config) {
         $this->config = $config;
     } else {
         $this->config = BaseConfig::$config['runtime'];
     }
     $ebits = ini_get('error_reporting');
     error_reporting(E_ALL ^ E_NOTICE);
     if (function_exists('xdebug_break') && $this->config['xdebug']['enable'] != false) {
         ini_set('html_errors', 'On');
         ini_set('xdebug.auto_trace', 'On');
         ini_set('xdebug.show_exception_trace', 'Off');
         ini_set('xdebug.collect_vars', 'on');
         ini_set('xdebug.var_display_max_depth', '10');
         ini_set('xdebug.show_local_vars', 'Off');
         ini_set('xdebug.dump_globals', 'on');
         ini_set('xdebug.collect_params', '4');
         ini_set('xdebug.collect_assignments', 'On');
         ini_set('xdebug.collect_return', 'On');
         ini_set('xdebug.collect_return', 'On');
         ini_set('xdebug.collect_includes', 'On');
         ini_set('xdebug.profiler_append', 'On');
         ini_set('xdebug.trace_format', 'On');
         ini_set('xdebug.profiler_output_name', 'script');
         ini_set('xdebug.cli_color', 'On');
     } else {
         RuntimeConfig::set('runtime/xdebug/enable', false);
     }
 }
Example #2
0
File: boot.php Project: uwitec/mgoa
 private static function BuildEnvironment($run_mode = 'deploy')
 {
     $base_run_mode = ini('base/RUN_MODE');
     $run_mode = $base_run_mode ? $base_run_mode : $run_mode;
     $run_mode = strtolower($run_mode);
     !defined('RUN_MODE') && define('RUN_MODE', $run_mode);
     import('system/environment/base');
     import(sprintf('system/environment/%s', $run_mode));
     import('system/share/config/runtime');
     RuntimeConfig::__init__($run_mode);
     $run_mode_classname = ucfirst($run_mode) . 'Environment';
     $runtime_environment = new $run_mode_classname();
 }
Example #3
0
        function smarty_function_get_gravatar($params, $tpl_obj)
        {
            RuntimeConfig::load_application_config('gravatar');
            /*
             * the params
             */
            $email = md5($params['email']);
            $size = $params['size'] ? $params['size'] : ini('gravatar_config/size');
            $size = $size ? $size : '80';
            $rating = $params['rating'] ? $params['rating'] : ini('gravatar_config/rating');
            $rating = $rating ? $rating : 'G';
            $default = $params['default'] ? $params['default'] : ini('gravatar_config/default');
            $default = $default ? $default : 'wavatar';
            /*
             * Cache the remote avatar to local server
             */
            $cache_dir = Package::get_folder(ini('gravatar_config/cache_dir'));
            $cache_img = $cache_dir . DS . $email . '_' . $size . '.jpg';
            if (is_file($cache_img) && filemtime($cache_img) + ini('gravatar_config/cache_life') > time()) {
                $link = str_ireplace(BASE_DIR . DS, ini('base/BASE_URL'), $cache_img);
                $link = str_ireplace(DS, '/', $link);
            } else {
                $link = sprintf('http://www.gravatar.com/avatar/%s?rating=%s&size=%s&default=%s', $email, $rating, $size, $default);
                $content = @file_get_contents($link);
                if (!$content) {
                    $link = $params['onerror'] ? $params['onerror'] : ini('gravatar_config/onerror_img');
                } else {
                    if (ini('gravatar_config/caching') && $cache_dir && $params['email']) {
                        if (!is_dir($cache_dir)) {
                            @mkdir($cache_dir, 0777);
                        }
                        @file_put_contents($cache_img, $content);
                    }
                }
            }
            return <<<EOF
                <img src="{$link}" width="{$size}" height="{$size}" />
EOF;
        }
Example #4
0
File: base.php Project: uwitec/mgoa
 public static function dispatch($app, $view_action, array $params = null)
 {
     $view_action = $view_action ? $view_action : 'index';
     import('system/bin/application');
     import('system/bin/cache');
     /*
      * application's url pattern mapping
      */
     $app_map_array = YamlBackend::load('etc/conf.d/urls.yml');
     if ($app_map_array['map'][$app]) {
         $app = $app_map_array['map'][$app];
     } else {
         if (array_keys($app_map_array['map'], $app)) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
     }
     /*
      * Cache all INSTALLED APPS urls pattern
      */
     $cache_id = 'URLS_MAP';
     $url_name_map_cache_id = 'URL_NAME_MAP';
     $app_map_array_flip_cache_id = 'URL_APP_MAP_ARRAY_FLIP';
     $cache_instance = CacheBackend::get_instance();
     if ($cache_instance->is_cached($cache_id) && RUN_MODE == 'deploy' && false) {
         self::$url_patterns = $cache_instance->get($cache_id);
         self::$url_name_map = $cache_instance->get($url_name_map_cache_id);
         $app_map_array_flip = $cache_instance->get($app_map_array_flip_cache_id);
     } else {
         $installed_apps = ini('base/INSTALLED_APPS');
         $app_map_array_flip = array_flip($app_map_array['map']);
         foreach ($installed_apps as $installed_app) {
             $urlpattern = YamlBackend::load(sprintf('applications/%s/urls.yml', $installed_app));
             if ($app_map_array_flip[$installed_app]) {
                 $installed_app = $app_map_array_flip[$installed_app];
             }
             /*
              * The url-name map to view action
              * like: url name='auth_login' => auth.AuthController.login
              */
             if ($urlpattern) {
                 foreach ($urlpattern as $key => $value) {
                     if ($value['name']) {
                         self::$url_name_map[$value['name']] = $installed_app . '/' . $key;
                     }
                 }
             }
             self::$url_patterns[$installed_app] = $urlpattern;
         }
         $cache_instance->set($cache_id, self::$url_patterns);
         if (self::$url_name_map) {
             $cache_instance->set($url_name_map_cache_id, self::$url_name_map);
         }
         $cache_instance->set($app_map_array_flip_cache_id, $app_map_array_flip);
     }
     $app_map_name = array_key_exists($app, $app_map_array_flip) ? $app_map_array_flip[$app] : $app;
     $urlpattern = self::$url_patterns[$app_map_name];
     try {
         /*
          * does not set the action key
          */
         if (!$urlpattern[$view_action]['action']) {
             $_c = ucfirst($app) . 'Controller';
             try {
                 import(Package::get_file(sprintf('applications/%s/%s', $app, $_c)));
                 $urlpattern[$view_action]['action'] = $_c . '.' . $view_action;
             } catch (DoesNotExistsException $e) {
                 throw new DispatchException(1011, $app . '/' . $view_action);
             }
         }
         list($controller, $method) = explode('.', $urlpattern[$view_action]['action']);
         import(sprintf('applications/%s/%s', $app, $controller));
         if (!is_callable(array($controller, $method))) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
         /*
          * Set current application and action
          */
         RuntimeConfig::set('runtime/application', $app);
         RuntimeConfig::set('runtime/action', $view_action);
         RuntimeConfig::set('runtime/view_action', $app . '/' . $view_action);
         BaseConfig::load_application_config($app);
         try {
             $controller = new $controller($params);
             RuntimeConfig::set('runtime/application_instance', $controller);
             /*
              * Re-init the plugins with the application implements
              */
             Pluggable::init($controller);
             /*
              * Trigger the plugins in before_application_run
              */
             Pluggable::trigger('before_application_run');
             /*
              * Call the view-action method
              */
             call_user_func_array(array($controller, $method), (array) $params);
             /*
              * Dependence exception
              */
         } catch (DependenceException $e) {
             //pass
         }
         /*
          * When the DispatchException catched
          * Return the 404
          */
     } catch (DispatchException $e) {
         $app = new BaseApplication();
         Pluggable::init($app);
         Pluggable::trigger('before_application_run');
         $app->load('smarty')->display('404');
     }
 }