예제 #1
0
 public function getRelativePath($forceCreation = false)
 {
     if (null === $this->getFilepath()) {
         return null;
     }
     $fullPath = $this->getFullPath($forceCreation);
     $route = Registry::get('route');
     $baseUrl = $route->getBaseUrl();
     $documentRoot = Library::getDocumentRoot() . $baseUrl . '/public';
     return substr($fullPath, strlen($documentRoot));
 }
예제 #2
0
 public function __construct($iniConfigurationFilepath)
 {
     $config = Library::parse_ini_file_advanced($iniConfigurationFilepath);
     $this->config = $config[APPLICATION_ENV];
     $this->route = new Route();
     $this->request = new Request();
     $this->_loadPHPSettings();
     if (php_sapi_name() !== 'cli') {
         $this->route->setCurrentUrl($_SERVER['REQUEST_URI']);
     }
     $baseUrl = rtrim('/' . trim($this->config['general.baseUrl'], '/'), '/');
     $url = str_replace($baseUrl, '', $this->route->getCurrentUrl());
     Registry::set('config', $this->config);
     Registry::set('route', $this->route);
     Registry::set('request', $this->request);
     $this->route->setDefaultModule($this->config['general.defaultModule'])->setDefaultController($this->config['general.defaultController'])->setDefaultAction($this->config['general.defaultAction'])->setDefaultLayout($this->config['general.defaultLayout'])->setBaseUrl($baseUrl)->dispatchFromURL($url);
 }
예제 #3
0
 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if the filesize of $value is at least min and
  * not bigger than max (when max is not null).
  *
  * @param  string $value Real file to check for size
  * @param  array  $file  File data from Zend_File_Transfer
  * @return boolean
  */
 public function isValid($value, $file = null)
 {
     // Is file readable ?
     if (!Library::isReadable($value)) {
         return $this->_throw($file, self::NOT_FOUND);
     }
     // limited to 4GB files
     $size = sprintf("%u", @filesize($value));
     $this->_size = $size;
     // Check to see if it's smaller than min size
     $min = $this->getMin(true);
     $max = $this->getMax(true);
     if ($min !== null && $size < $min) {
         if ($this->useByteString()) {
             $this->_min = $this->_toByteString($min);
             $this->_size = $this->_toByteString($size);
             $this->_throw($file, self::TOO_SMALL);
             $this->_min = $min;
             $this->_size = $size;
         } else {
             $this->_throw($file, self::TOO_SMALL);
         }
     }
     // Check to see if it's larger than max size
     if ($max !== null && $max < $size) {
         if ($this->useByteString()) {
             $this->_max = $this->_toByteString($max);
             $this->_size = $this->_toByteString($size);
             $this->_throw($file, self::TOO_BIG);
             $this->_max = $max;
             $this->_size = $size;
         } else {
             $this->_throw($file, self::TOO_BIG);
         }
     }
     if (count($this->_messages) > 0) {
         return false;
     }
     return true;
 }