Пример #1
0
 public function getPodcasts()
 {
     $path = $this->Config->get('path_data_podcast');
     $files = array();
     if ($handle = opendir($path)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != ".." && substr($entry, -4) == 'json') {
                 $files[] = $entry;
             }
         }
         closedir($handle);
     }
     foreach ($files as $fileName) {
         $filePath = $path . $fileName;
         $file = file($filePath);
         if (trim($file[0]) != '') {
             $data = json_decode(implode($file), true);
             $data['file_name'] = str_replace('.json', '', $fileName);
             $this->Feed[$data['file_name']] = $data;
         }
     }
     $this->Feed = ksortBy($this->Feed, 'timestamp');
     $this->Feed = kfillBy($this->Feed, 'file_name');
     $this->Feed = array_reverse($this->Feed);
 }
Пример #2
0
    public function searchFiles($dir, $search = false, $recursive = false) {
        if ($dir) {
            $path = ($dir);
        }

        $files = array();

        if (!$recursive) {
            $objects = new DirectoryIterator($path);
        } else {
            $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
        }

        foreach ($objects as $name => $object) {
            $ok = false;
            if ($search != '')
                if (strpos(strtolower($object -> getFilename()), strtolower($search)) != false && !$object -> isDir() && !in_array($object -> getFilename(), $this -> Excludes))
                    $ok = true;

            if ($search == '')
                if (!$object -> isDir() && !in_array($object -> getFilename(), $this -> Excludes))
                    $ok = true;

            if ($ok == true) {
                $name = utf8_encode($object -> getFilename());

                $files[] = array('name' => str_replace($this -> Suffix, '', $name), 'rname' => utf8_encode($object -> getFilename()), 'filename' => utf8_encode($object -> getFilename()), 'path' => $object -> getPath(), 'ts_edit' => 'te' . $object -> getMTime() . microtime(), 'ts_make' => 'tm' . $object -> getCTime() . microtime());
            }
        }

        $files = array_reverse(ksortBy($files, 'ts_make'));
        
        
        
        return $files;
    }