Exemplo n.º 1
0
$__FROG_CONN__ = $__CMS_CONN__;
Record::connection($__CMS_CONN__);
Record::getConnection()->exec("set names 'utf8'");
Setting::init();
use_helper('I18n');
AuthUser::load();
if (AuthUser::isLoggedIn()) {
    I18n::setLocale(AuthUser::getRecord()->language);
} else {
    I18n::setLocale(Setting::get('language'));
}
// Only add the cron web bug when necessary
if (defined('USE_POORMANSCRON') && USE_POORMANSCRON && defined('POORMANSCRON_INTERVAL')) {
    Observer::observe('page_before_execute_layout', 'run_cron');
    function run_cron()
    {
        $cron = Cron::findByIdFrom('Cron', '1');
        $now = time();
        $last = $cron->getLastRunTime();
        if ($now - $last > POORMANSCRON_INTERVAL) {
            echo $cron->generateWebBug();
        }
    }
}
Plugin::init();
Flash::init();
// Setup admin routes
$admin_routes = array('/' . ADMIN_DIR => Setting::get('default_tab'), '/' . ADMIN_DIR . '/' => Setting::get('default_tab'), '/' . ADMIN_DIR . '/:all' => '$1');
Dispatcher::addRoute($admin_routes);
// run everything!
require APP_PATH . DS . 'main.php';
Exemplo n.º 2
0
 public static function dispatch($requested_url = null, $default = null)
 {
     Flash::init();
     // If no url passed, we will get the first key from the _GET array
     // that way, index.php?/controller/action/var1&email=example@example.com
     // requested_url will be equal to: /controller/action/var1
     if ($requested_url === null) {
         $pos = strpos($_SERVER['QUERY_STRING'], '&');
         if ($pos !== false) {
             $requested_url = substr($_SERVER['QUERY_STRING'], 0, $pos);
         } else {
             $requested_url = $_SERVER['QUERY_STRING'];
         }
     }
     // If no URL is requested (due to someone accessing admin section for the first time)
     // AND $default is setAllow for a default tab
     if ($requested_url == null && $default != null) {
         $requested_url = $default;
     }
     // Requested url MUST start with a slash (for route convention)
     if (strpos($requested_url, '/') !== 0) {
         $requested_url = '/' . $requested_url;
     }
     self::$requested_url = $requested_url;
     // This is only trace for debugging
     self::$status['requested_url'] = $requested_url;
     // Make the first split of the current requested_url
     self::$params = self::splitUrl($requested_url);
     // Do we even have any custom routing to deal with?
     if (count(self::$routes) === 0) {
         return self::executeAction(self::getController(), self::getAction(), self::getParams());
     }
     // Is there a literal match? If so we're done
     if (isset(self::$routes[$requested_url])) {
         self::$params = self::splitUrl(self::$routes[$requested_url]);
         return self::executeAction(self::getController(), self::getAction(), self::getParams());
     }
     // Loop through the route array looking for wildcards
     foreach (self::$routes as $route => $uri) {
         // Convert wildcards to regex
         if (strpos($route, ':') !== false) {
             $route = str_replace(':any', '(.+)', str_replace(':num', '([0-9]+)', $route));
         }
         // Does the regex match?
         if (preg_match('#^' . $route . '$#', $requested_url)) {
             // Do we have a back-reference?
             if (strpos($uri, '$') !== false && strpos($route, '(') !== false) {
                 $uri = preg_replace('#^' . $route . '$#', $uri, $requested_url);
             }
             self::$params = self::splitUrl($uri);
             // We found it, so we can break the loop now!
             break;
         }
     }
     return self::executeAction(self::getController(), self::getAction(), self::getParams());
 }
 /**
  * Initialize application resources
  *
  * @param void
  * @return null
  */
 function initialize_resources()
 {
     if (defined('USE_COOKIES') && USE_COOKIES) {
         Cookies::init(COOKIE_PREFIX, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
     }
     // if
     if (defined('USE_FLASH') && USE_FLASH) {
         Flash::init();
     }
     // if
     if (defined('USE_CACHE') && USE_CACHE) {
         cache_use_backend(CACHE_BACKEND, array('lifetime' => CACHE_LIFETIME));
     }
     // if
 }
Exemplo n.º 4
0
function assets_check_gd_support()
{
    $needed = array('GIF Read Support', 'JPEG Support', 'PNG Support');
    $provided = gd_info();
    foreach ($needed as $item) {
        if (!$provided[$item]) {
            Flash::set('error', __('Your system does not have :item. Assets manager will not work properly.', array(':item' => $item)));
            Flash::init();
        }
    }
}
 /**
  * Simple function that checks if the posted data is valid.
  * As side effet, the 'flash' values are set.
  *
  * @param data the post data from the user
  * @return data is valid
  */
 private function check_constraints($data)
 {
     if (!isset($data["name"]) || empty($data["name"])) {
         Flash::set('error', __('You have to specify a name!'));
         Flash::init();
         // XXX: force flash values availability
         return false;
     }
     return true;
 }