コード例 #1
0
ファイル: QueryLog.php プロジェクト: splitice/radical-db
 function addQuery($sql)
 {
     if (!\Radical\Core\Server::isProduction() && $this->explain) {
         $this->queries[] = $sql;
         $this->backtraces[] = debug_backtrace(false);
     }
 }
コード例 #2
0
 /**
  * Handle GET request
  *
  * @throws \Exception
  */
 function GET()
 {
     $key = static::EXTENSION . '_' . $this->name . '_' . $this->version;
     $files = $this->getFiles();
     $this->sendHeaders($files);
     $cache = PooledCache::Get(get_called_class(), 'Memory');
     $ret = $cache->get($key);
     if (!$ret || !\Radical\Core\Server::isProduction()) {
         $data = array();
         foreach ($files as $f) {
             if (is_file($f)) {
                 //Ignore folders
                 $fn = basename($f);
                 $data[$fn] = Individual::get_file($f);
             }
         }
         $ret = '';
         foreach ($data as $f => $d) {
             if (!\Radical\Core\Server::isProduction()) {
                 $ret .= "\r\n/* Including: " . $f . " */\r\n";
             }
             $ret .= $d;
         }
         if (\Radical\Core\Server::isProduction()) {
             $ret = $this->optimize($ret);
             $cache->set($key, $ret);
         }
     }
     echo $ret;
     $headers = \Radical\Web\Page\Handler::top()->headers;
     $headers->setContentLength(strlen($ret));
     $headers['Vary'] = 'Accept-Encoding';
 }
コード例 #3
0
 static function handler($errno, $msg_text, $errfile, $errline)
 {
     if (!(error_reporting() & $errno)) {
         return true;
     }
     if (!($errno & E_STRICT)) {
         //E_STRICT, well we would like it but not PEAR
         if ($errno & E_WARNING && preg_match('/^Declaration of .+ should be compatible with/', $msg_text)) {
             return true;
         }
         new static($errno, $msg_text, new Structs\LocationReference($errfile, $errline));
         return Server::isProduction();
     }
     return true;
 }
コード例 #4
0
 function __construct(\Exception $ex, $fatal = true)
 {
     $this->ex = $ex;
     //Build Error page
     if (!\Radical\Core\Server::isCLI() && \Radical\Core\Server::isProduction()) {
         $message = 'An exception has occurred in the script.';
         global $_ADMIN_EMAIL;
         if (isset($_ADMIN_EMAIL)) {
             $message .= ' Please report this to an administrator at ' . $_ADMIN_EMAIL . '.';
         }
     } else {
         $message = 'An exception occurred at ' . $ex->getFile() . '@' . $ex->getLine() . ': ' . $ex->getMessage();
     }
     $header = sprintf(static::HEADER, ltrim(get_class($ex), '\\'));
     parent::__construct($message, $header, $fatal, $ex);
 }
コード例 #5
0
ファイル: Sass.php プロジェクト: splitice/radical-web-sass
 static function render($file)
 {
     $ext = pathinfo($file, PATHINFO_EXTENSION);
     $bn = basename($file);
     if ($bn[0] == '_') {
         return '';
     }
     // Importable packages
     global $BASEPATH;
     $sass_path = $BASEPATH . '/static/img/sprites/';
     $options = array('style' => 'nested', 'cache' => false, 'syntax' => $ext, 'debug' => false, 'load_paths' => array($sass_path), 'functions' => self::getFunctions(array('Compass', 'Own')), 'extensions' => array('Compass', 'Own'));
     if (\Radical\Core\Server::isProduction()) {
         $options['style'] = 'compressed';
     }
     // Execute the compiler.
     $parser = new \SassParser($options);
     return $parser->toCss($file);
 }
コード例 #6
0
ファイル: Cache.php プロジェクト: splitice/radical-db
 static function init()
 {
     self::$pool = \Radical\Cache\PooledCache::get('radical_orm', 'Memory');
     global $_SQL;
     $cfile = '/tmp/' . $_SQL->getDb();
     if (file_exists($cfile) && filemtime($cfile) >= time() - 30) {
         self::$key = file_get_contents($cfile);
     } else {
         touch($cfile);
         $sql = 'SELECT MAX(UNIX_TIMESTAMP( CREATE_TIME )) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "' . $_SQL->getDb() . '"';
         self::$key = \Radical\DB::Q($sql)->Fetch(Fetch::FIRST);
         file_put_contents($cfile, self::$key);
     }
     if (Server::isProduction()) {
         self::$data = self::$pool->get($_SQL->getDb() . '_' . self::$key);
         register_shutdown_function(function () {
             Cache::save();
         });
     }
     if (!is_array(self::$data)) {
         self::$data = array();
     }
 }