Exemplo n.º 1
0
 public function loadFile($file, array $vars = array())
 {
     Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file);
     $file = realpath($file);
     if (!$file || !is_readable($file) || !is_file($file)) {
         throw new FtpException("The file {$file} is not readable.");
     }
     if (!in_array($file, $this->_loadedFiles)) {
         $this->_loadedFiles[] = $file;
         $ext = pathinfo($file, PATHINFO_EXTENSION);
         if ($ext === 'yml' || $ext === 'yaml') {
             $conf = Parsers\Yaml\Factory::factory()->loadFile($file);
         }
         if ($ext === 'ini') {
             $conf = parse_ini_file($file, true);
         } else {
             if ($ext === 'php') {
                 $conf = (include $file);
             }
         }
         $this->_importFiles($conf);
         if ($this->_vars || $vars) {
             $conf = $this->parseConf($conf, $vars ? $vars : $this->_vars);
         }
         if (!empty($this->_config)) {
             $this->_config = Arrays::arrayMergeRec($this->_config, $conf);
         } else {
             $this->_config = $conf;
         }
     }
 }
Exemplo n.º 2
0
Arquivo: Ftp.php Projeto: Nivl/Ninaca
 private static function octetConverter_exec($size, $to = 'o', $si = false)
 {
     $unit = is_numeric($size) ? 'o' : strtolower($size[strlen($size) - 1]);
     $base = $si ? 10 : 2;
     if ($si) {
         $pow = array('o' => 1, 'k' => 3, 'm' => 6, 'g' => 9, 't' => 12);
     } else {
         $pow = array('o' => 1, 'k' => 10, 'm' => 20, 'g' => 30, 't' => 40);
     }
     if ($to === $unit) {
         return $size * 1;
     } else {
         if (Arrays::getKey($to, $units) < Arrays::getKey($unit, $units)) {
             return $size * pow($base, $pow[$unit]);
         } else {
             return $size / pow($base, $pow[$to]);
         }
     }
 }