Esempio n. 1
0
 /**
  * Write or create new cache file
  *
  * @param string
  * @param string | html
  * @return void
  */
 function write($filename, $content)
 {
     if (!Config::read('App.Base.enable_cache')) {
         return;
     }
     $expire = time() + $this->getConfig('cache_expiration') * 60;
     $filename = md5($filename);
     $filepath = $this->getConfig('cache_path') . $filename . '.tmp';
     if (!($fp = @fopen($filepath, 'w'))) {
         Loader::getClass('Sky.core.Log')->write(400, 'Unable to write cache file: ' . $filepath);
         Exceptions::showError('error', "Unable to write cache file: " . $filepath);
     }
     if (flock($fp, LOCK_EX)) {
         fwrite($fp, $expire . 'T_SKY-->' . $content);
         flock($fp, LOCK_UN);
     } else {
         Loader::getClass('Sky.core.Log')->write(300, 'Unable to secure a file lock for file at: ' . $filepath);
         return;
     }
     fclose($fp);
     @chmod($filepath, 0755);
 }
Esempio n. 2
0
 /**
  * Filter segments for malicious characters
  *
  * @access	private
  * @param	string
  * @return	string
  */
 private function _filter_uri($str)
 {
     if ($str != '' && $this->getConfig('permitted_uri_chars') != '' && $this->getConfig('enable_query_strings') == FALSE) {
         // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
         // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
         if (!preg_match("|^[" . str_replace(array('\\-', '\\-'), '-', preg_quote($this->getConfig('permitted_uri_chars'), '-')) . "]+\$|i", $str)) {
             Exceptions::showError('Server Error', 'The URI you submitted has disallowed characters.');
         }
     }
     // Convert programatic characters to entities
     $bad = array('$', '(', ')', '%28', '%29');
     $good = array('$', '(', ')', '(', ')');
     return str_replace($bad, $good, $str);
 }