PHP DirectoryIterator Code Examples

This page contains top rated real world PHP examples of DirectoryIterator extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: XmlCollection.php Project: eserozvataf/scabbia1
0
 /**
  * @ignore
  */
 public static function fromFileScan($uPattern)
 {
     $tSep = quotemeta(DIRECTORY_SEPARATOR);
     $tPos = strrpos($uPattern, $tSep);
     if ($tSep !== '/' && $tPos === false) {
         $tSep = '/';
         $tPos = strrpos($uPattern, $tSep);
     }
     if ($tPos !== false) {
         $tPattern = substr($uPattern, $tPos + strlen($tSep));
         $tPath = substr($uPattern, 0, $tPos + strlen($tSep));
     } else {
         $tPath = $uPattern;
         $tPattern = "";
     }
     $tTemp = new static();
     $tHandle = new \DirectoryIterator($tPath);
     $tPatExists = strlen($uPattern) > 0;
     for (; $tHandle->valid(); $tHandle->next()) {
         if (!$tHandle->isFile()) {
             continue;
         }
         $tFile = $tHandle->current();
         if ($tPatExists && !fnmatch($tPattern, $tFile)) {
             continue;
         }
         $tTemp->add(simplexml_load_file($tPath . $tFile));
     }
     return $tTemp;
 }
Example #2
Show file File: ImgDir.php Project: laiello/samusframework
0
 /**
  * Obtem um array de ImgObject com todos os arquivos de imagens dos 
  * diretórios especificados
  * 
  * @param int|null $limit
  * @return array
  */
 public function getImgArray($limit = null)
 {
     $imgArray = array();
     foreach ($this->getDir() as $diretorio) {
         $imgArray = array();
         $d = new DirectoryIterator($diretorio);
         while ($d->valid()) {
             if (!$d->isDot()) {
                 $fileName = $d->getFilename();
                 if ($this->validateFormat($fileName)) {
                     $imgObj = new ImgObject($fileName, $diretorio);
                     $imgArray[] = $imgObj;
                     ++$this->imgCount;
                     if ($limit != null) {
                         if ($this->imgCount >= $limit) {
                             break;
                         }
                     }
                 }
             }
             $d->next();
         }
     }
     return $imgArray;
 }
Example #3
Show file File: Filepicker.php Project: johsbk/penguin
0
 public function index($args)
 {
     $t = Registry::getInstance()->twig->loadTemplate('form/filepicker.tpl');
     $c = array();
     $localpath = Functions::nz($args['path'], '');
     $mediapath = SITE_PATH . '/media/';
     $dir = new \DirectoryIterator($mediapath . $localpath);
     $picformats = array('png', 'jpg', 'gif');
     $files = array();
     foreach ($dir as $file) {
         if (!$dir->isDot()) {
             $path = URL_PATH . '/media/' . $localpath . $file;
             $f = new \stdClass();
             if (strlen($file) > 4 && in_array(substr($file, -3), $picformats)) {
                 $picture = $path;
             } elseif ($dir->isDir()) {
                 $picture = TEMPLATE_PATH . 'form/pics/folder.png';
             } else {
                 $picture = TEMPLATE_PATH . 'form/pics/file.png';
             }
             $f->path = $localpath;
             $f->picture = $picture;
             $f->name = (string) $file;
             $f->type = $dir->isDir() ? 'dir' : 'file';
             $files[] = $f;
         }
     }
     $c['files'] = $files;
     $t->display($c);
 }
Example #4
Show file File: DocumentationTest.php Project: BackupTheBerlios/ubook-svn
0
 function executeDir($directory)
 {
     $iterator = new DirectoryIterator($directory);
     while ($iterator->valid()) {
         $entry = $iterator->getFilename();
         $path = $directory . '/' . $entry;
         $iterator->next();
         if ($entry[0] == '.') {
             continue;
         }
         if (is_file($path)) {
             if (substr($entry, -4) != '.php') {
                 continue;
             }
             if (ctype_upper($entry[0])) {
                 $test = new DocTest($path);
                 if ($test->failed()) {
                     echo $test->toString();
                     $this->fail('Doc test failed.');
                 } else {
                     if ($test->numOfPassed()) {
                         echo ',';
                     } else {
                         echo ' ';
                     }
                 }
             }
         } elseif (is_dir($path)) {
             $this->executeDir($path);
         }
     }
 }
Example #5
Show file File: renamer.php Project: rizaramadan/folder-walking
0
 protected function ProcessFile(DirectoryIterator $pParent, DirectoryIterator $pNode)
 {
     $oldname = $pNode->getPathname();
     $newname = $pParent->getPath() . '\\' . $this->GetLastFolderName($pParent->getPath()) . '.dds';
     rename($oldname, $newname);
     echo '<p>rename <b>' . $oldname . '</b> to <b>' . $newname . '<br/></p>';
 }
Example #6
Show file File: HyyanAdminColorSchema.php Project: hyyan/admin-color-schema
0
 /**
  * Collect schema from wordpress active theme
  * 
  * @return boolean true on success false if color schema folder is not exists
  *                 in the active theme folder
  */
 public function collectSchema()
 {
     $options = $this->getOptions();
     $path = get_template_directory() . $options['path'];
     // make sure that the color schema folder exsists
     if (!file_exists($path) || !is_dir($path)) {
         return;
         // just ignore
     }
     // register the new color schema
     $contents = new \DirectoryIterator($path);
     foreach ($contents as $content) {
         if ($contents->isDot()) {
             continue;
         }
         if ($contents->isDir()) {
             $name = $content->getFilename();
             $init = parse_ini_file($content->getPathname() . '/schema.ini');
             if (!is_array($init)) {
                 trigger_error('Unbale Admin Color Schema Config File', E_USER_ERROR);
             }
             $suffix = is_rtl() ? '-rtl' : '';
             $url = get_template_directory_uri() . $options['path'] . '/' . $name . "/colors{$suffix}.css";
             wp_admin_css_color($name, __(isset($init['name']) && !empty($init['name']) ? $init['name'] : $name, isset($init['domain']) && !empty($init['domain']) ? $init['domain'] : 'default'), $url, isset($init['colors']) && is_array($init['colors']) ? $init['colors'] : array(), isset($init['icons']) && is_array($init['icons']) ? $init['icons'] : array());
         }
     }
 }
Example #7
Show file File: Plugins.php Project: vheissu/kohana-plugin-system
0
 /**
  * Find all plugins defined in your Kohana codebase
  */
 public function find_plugins()
 {
     $paths = Kohana::include_paths();
     foreach ($paths as $path) {
         $dir = $path . self::$plugins_dir;
         //if there's no plugin dir skip to the next path
         if (!file_exists($dir)) {
             continue;
         }
         // Instantiate a new directory iterator object
         $directory = new DirectoryIterator($dir);
         if ($directory->isDir()) {
             foreach ($directory as $plugin) {
                 // Is directory?
                 if ($plugin->isDir() && !$plugin->isDot()) {
                     // if there's no plugin.php in this folder, ignore it
                     if (!file_exists($plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename() . DIRECTORY_SEPARATOR . 'plugin.php')) {
                         continue;
                     }
                     // Store plugin in our pool
                     self::$plugins_pool[$plugin->getFilename()]['plugin'] = ucfirst($plugin->getFilename());
                     self::$plugins_pool[$plugin->getFilename()]['path'] = $plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename();
                 }
             }
         }
     }
     return $this;
 }
Example #8
Show file File: DemoController.php Project: ycheukf/report
0
 function exportpluginAction()
 {
     $aExtDir = array('ALYS.Report.Dictionary', 'ALYS.Report.Plugin');
     //		var_dump(LIB_PATH_ALYS);
     //		var_dump(EXT_PATH_ALYS);
     $LIB_PATH_ALYS = "D:\\htdocs\\work\\apps\\code\\l_project_web\\module\\ycheukf\\Report\\src\\Report\\Lib";
     $EXT_PATH_ALYS = "D:\\htdocs\\work\\apps\\code\\l_project_web\\module\\Application\\src\\Application\\YcheukfReportExt";
     foreach ($aExtDir as $sTmp) {
         $path = str_replace(".", '/', $sTmp);
         $sDirPath = $LIB_PATH_ALYS . '/' . $path;
         $sExtDirPath = $EXT_PATH_ALYS . '/' . str_replace("ALYS/", "", (string) $path);
         //扩展目录, 若需要改路径请改此处
         //	var_export($sDirPath);
         $it = new \DirectoryIterator($sDirPath);
         foreach ($it as $file) {
             if (!$it->isDot() && $file != '.svn' && $file != '.git') {
                 $this->recursiveMkdir($sExtDirPath, '0700');
                 copy($sDirPath . '/' . $file, $sExtDirPath . '/' . $file);
                 $sContent = file_get_contents($sExtDirPath . '/' . $file);
                 //					$sContent = preg_replace("/require_once\(\"".str_replace(".", '\/', $sTmp).".php\"\);/s", ' ', $sContent);
                 $sClassName = str_replace(".php", "", (string) $file);
                 preg_match_all('/namespace (.*);/', $sContent, $aMatch);
                 //					var_dump((string)$file);
                 //					var_dump($aMatch[1][0]);
                 $sContent = str_replace("namespace YcheukfReport\\Lib\\ALYS", 'namespace YcheukfReportExt', $sContent);
                 $sContent = preg_replace("/class ([^\\s]+?) extends ([^}]+?)\\{/s", 'class \\1 extends \\2\\' . $sClassName . '{', $sContent);
                 //			echo $sContent;
                 file_put_contents($sExtDirPath . '/' . $file, $sContent);
             }
         }
     }
     echo "\n\n export file to ext   ... DONE\n\n";
     exit;
 }
Example #9
Show file File: large.php Project: WineWorld/joomlatrialcmbg
0
 protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
 {
     $registry = AEFactory::getConfiguration();
     // Initialize variables
     $arr = array();
     $false = false;
     if (!is_dir($folder) && !is_dir($folder . '/')) {
         return $false;
     }
     try {
         $di = new DirectoryIterator($folder);
     } catch (Exception $e) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!$di->valid()) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!empty($position)) {
         $di->seek($position);
         if ($di->key() != $position) {
             $position = null;
             return $arr;
         }
     }
     $counter = 0;
     $maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
     while ($di->valid()) {
         if ($di->isDot()) {
             $di->next();
             continue;
         }
         if ($di->isDir() != $forFolders) {
             $di->next();
             continue;
         }
         $ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
         $dir = $folder . $ds . $di->getFilename();
         $data = _AKEEBA_IS_WINDOWS ? AEUtilFilesystem::TranslateWinPath($dir) : $dir;
         if ($data) {
             $counter++;
             $arr[] = $data;
         }
         if ($counter == $maxCounter) {
             break;
         } else {
             $di->next();
         }
     }
     // Determine the new value for the position
     $di->next();
     if ($di->valid()) {
         $position = $di->key() - 1;
     } else {
         $position = null;
     }
     return $arr;
 }
Example #10
Show file File: sfPhpunitCreateModelsTestTask.class.php Project: harking/sfPhpunitPlugin
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->checkORMType($options['type']);
     parent::execute($arguments, $options);
     $this->_runInitTask();
     $options['application'] = $arguments['application'];
     // still no class_path given? take the default one!
     if (empty($options['class_path'])) {
         $options['class_path'] = $this->modelTypes[$options['type']]['default_model_path'];
     }
     if (!empty($options['skip_methods'])) {
         $methods = explode(',', $options['skip_methods']);
         foreach ($methods as $method) {
             array_push($this->skipMethods, $method);
         }
     }
     // a custom class given?
     if (!empty($options['class'])) {
         if (strpos($options['class_path'], ':') !== false) {
             throw new sfCommandException(': is not supported in class_path when specifying the class name.');
         }
         $options['libpath'] = $options['class_path'];
         $this->createTestClass($options, $options['target']);
         return;
     }
     $paths = explode(':', $options['class_path']);
     $namespaces = array();
     foreach ($paths as $path) {
         $finder = sfFinder::type('directory');
         $ignoredDirs = $this->modelTypes[$options['type']]['ignored_directory'];
         foreach ($ignoredDirs as $ignDir) {
             $finder = $finder->not_name($ignDir);
         }
         $dirs = $finder->in($path);
         foreach ($dirs as $dir) {
             if (is_dir($dir)) {
                 $namespaces[] = $dir;
             }
         }
     }
     $paths = array_merge($paths, $namespaces);
     foreach ($paths as $path) {
         $options['libpath'] = $path;
         $dir = new DirectoryIterator($path);
         $this->logSection('phpunit', sprintf('Searching %s', $path));
         while ($dir->valid()) {
             if (strpos($dir, '.php') !== false) {
                 $subfolder = basename(dirname($path . DIRECTORY_SEPARATOR . $dir));
                 $suffix = !empty($options['file_suffix']) ? $options['file_suffix'] : $this->modelTypes[$options['type']]['classFileSuffix'];
                 $options['class'] = str_replace($suffix, '', $dir);
                 $this->createTestClass($options, $subfolder);
             }
             $dir->next();
         }
     }
     $this->_runInitTask();
 }
Example #11
Show file File: Layouts.php Project: radekstepan/Fireside
0
 /**
  * Overwrite in children to parse files according to our style.
  * @param array $listing
  * @param DirectoryIterator $item
  */
 public function pushItem(&$listing, DirectoryIterator $entry)
 {
     if (substr($filename = $entry->getFilename(), -4) == '.css') {
         // a reset stylesheet, always used
         if (strpos($stylename = $entry->getBasename('.css'), 'tripoli') !== FALSE) {
         } else {
             array_push($listing, $stylename);
         }
     }
 }
Example #12
Show file File: Parser.php Project: vtk13/word-counter
0
 protected function cleanDir($dir)
 {
     $files = new \DirectoryIterator($dir);
     while ($files->valid()) {
         if (in_array(substr($files->current(), -2), ['.0', '.1'])) {
             unlink($dir . '/' . $files->current());
         }
         $files->next();
     }
 }
Example #13
Show file File: RiotCompiler.php Project: josecelano/php-ddd-cargo-sample
0
 private function compileFile(\DirectoryIterator $file)
 {
     $tag = file_get_contents($file->getPathname());
     $tagName = $file->getBasename('.html');
     $jsFunc = $this->extractJsFunction($tag, $tagName);
     $tagHtml = $this->removeJsFromTag($tag, $tagName);
     $tagHtml = str_replace('"', '\\"', $tagHtml);
     $tagHtml = preg_replace("/\r|\n/", "", $tagHtml);
     return 'riot.tag("' . $tagName . '", "' . $tagHtml . '", ' . $jsFunc . ');';
 }
Example #14
Show file File: checkFolder.class.php Project: AzoteStark/php-class-checkFolder
0
 function __construct($link)
 {
     $d = new DirectoryIterator($link);
     while ($d->valid()) {
         $file = $d->current();
         if (!$file->isDot()) {
             $this->files[] = $file->getFilename();
         }
         $d->next();
     }
     $this->path = $d->getPath();
 }
Example #15
Show file File: CustomDictionaryLoader.php Project: baszoetekouw/janus
0
 /**
  * @param DirectoryIterator $file
  */
 private function addFromFile(DirectoryIterator $file)
 {
     $match = preg_match('/([^.]+)-custom.definition.json/', $file->getFilename(), $matches);
     if (!$match) {
         return;
     }
     $dictionaryName = $matches[1];
     $translations = $this->loadTranslations($file->getPathname());
     foreach ($translations as $translationName => $translations) {
         $this->includeTranslation($dictionaryName, $translationName, $translations);
     }
 }
Example #16
Show file File: IncludeLang.class.php Project: liutongju/DreamCMSCN
0
 /**
  * 
  * @param string $Floder
  * @param string $app
  */
 public static function IncFloder($Floder, $app = '')
 {
     $app_name = $app == '' ? APP_NAME : $app;
     $Floderpath = 'Lang' . DS . $app_name . DS . \getlang() . DS . $Floder;
     $it = new \DirectoryIterator($Floderpath);
     foreach ($it as $file) {
         if (!$it->isDot()) {
             $langfile = $Floderpath . DS . $file;
             self::IncFile($langfile);
         }
     }
 }
Example #17
Show file File: ApplicationI18n.php Project: radekstepan/Clubhouse
0
 public function pushItem(&$listing, DirectoryIterator $item)
 {
     // dot would be for morse code locale?
     if (!$item->isDot() && $item->isFile()) {
         // explode and extract name & type
         list($name, $type) = explode('.', $item->getFilename());
         assert('!empty($name) && !empty($type); // invalid locale files');
         // push name to stack
         if ($type == 'yml') {
             array_push($listing, $name);
         }
     }
 }
Example #18
Show file File: TemplateController.php Project: reinfire/arfooo
0
 function indexAction()
 {
     setcookie("previewTemplateName", false, 0, "/");
     $templates = array();
     $dir = new DirectoryIterator(Config::get('TEMPLATES_PATH'));
     while ($dir->valid()) {
         if (!$dir->isDot()) {
             $templates[] = (string) $dir->current();
         }
         $dir->next();
     }
     $this->set("alltemplates", $templates);
 }
Example #19
Show file File: AdminFilesController.php Project: febryantosulistyo/ClassicSocial
0
 public function indexAction()
 {
     // Get path
     $this->view->path = $path = $this->_getPath();
     $this->view->relPath = $relPath = $this->_getRelPath($path);
     // List files
     $files = array();
     $dirs = array();
     $contents = array();
     $it = new DirectoryIterator($path);
     foreach ($it as $key => $file) {
         $filename = $file->getFilename();
         if ($it->isDot() && $this->_basePath == $path || $filename == '.' || $filename != '..' && $filename[0] == '.') {
             continue;
         }
         $relPath = trim(str_replace($this->_basePath, '', realpath($file->getPathname())), '/\\');
         $ext = strtolower(ltrim(strrchr($file->getFilename(), '.'), '.'));
         if ($file->isDir()) {
             $ext = null;
         }
         $type = 'generic';
         switch (true) {
             case in_array($ext, array('jpg', 'png', 'gif', 'jpeg', 'bmp', 'tif', 'svg')):
                 $type = 'image';
                 break;
             case in_array($ext, array('txt', 'log', 'js')):
                 $type = 'text';
                 break;
             case in_array($ext, array('html', 'htm')):
                 $type = 'markup';
                 break;
         }
         $dat = array('name' => $file->getFilename(), 'path' => $file->getPathname(), 'info' => $file->getPathInfo(), 'rel' => $relPath, 'ext' => $ext, 'type' => $type, 'is_dir' => $file->isDir(), 'is_file' => $file->isFile(), 'is_image' => $type == 'image', 'is_text' => $type == 'text', 'is_markup' => $type == 'markup');
         if ($it->isDir()) {
             $dirs[$relPath] = $dat;
         } else {
             if ($it->isFile()) {
                 $files[$relPath] = $dat;
             }
         }
         $contents[$relPath] = $dat;
     }
     ksort($contents);
     $this->view->paginator = $paginator = Zend_Paginator::factory($contents);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     $this->view->files = $files;
     $this->view->dirs = $dirs;
     $this->view->contents = $contents;
 }
Example #20
Show file File: PackFiles.php Project: laiello/samusframework
0
 /**
  * Compacta todos os arquivos .php de um diretório removendo comentários,
  * espaços e quebras de linhas desnecessárias.
  * motivos de desempenho e segurança esse método so interage em um diretório
  * de cada vez.
  *
  * @param string $directoryPath
  * @param string $newFilesDirectory
  * @param string $newFilesPrefix
  * @param string $newFilesSufix
  */
 public static function cleanDir($directoryPath, $newFilesDirectory = "packed", $newFilesPrefix = "", $newFilesSufix = "")
 {
     $dir = new DirectoryIterator($directoryPath);
     mkdir($directoryPath . "/{$newFilesDirectory}/");
     while ($dir->valid()) {
         if (!$dir->isDir() and !$dir->isDot() and substr($dir->getFilename(), -3, 3) == 'php') {
             $str = self::cleanFile($dir->getPathname());
             $fp = fopen($dir->getPath() . "/packed/" . $newFilesPrefix . $dir->getFilename() . $newFilesSufix, "w");
             fwrite($fp, $str);
             fclose($fp);
             echo $dir->getPathname() . ' - Renomeado com sucesso <br />';
         }
         $dir->next();
     }
 }
Example #21
Show file File: CopyLanguageAction.php Project: Biromain/windwalker-joomla-rad
0
 /**
  * doExecute
  *
  * @return  mixed
  */
 public function doExecute()
 {
     try {
         $lanDir = new \DirectoryIterator($this->config['dir.src'] . '/language');
     } catch (\UnexpectedValueException $e) {
         return;
     }
     // Each languages
     foreach ($lanDir as $dir) {
         if ($lanDir->isDot() || $lanDir->isFile()) {
             continue;
         }
         $this->handleINIFile($dir->getBasename());
     }
 }
Example #22
Show file File: Documentation.php Project: robertlemke/flow-development-collection
0
 /**
  * Returns the available documentation formats for this documentation
  *
  * @return array Array of \TYPO3\Flow\Package\DocumentationFormat
  * @api
  */
 public function getDocumentationFormats()
 {
     $documentationFormats = array();
     $documentationFormatsDirectoryIterator = new \DirectoryIterator($this->documentationPath);
     $documentationFormatsDirectoryIterator->rewind();
     while ($documentationFormatsDirectoryIterator->valid()) {
         $filename = $documentationFormatsDirectoryIterator->getFilename();
         if ($filename[0] != '.' && $documentationFormatsDirectoryIterator->isDir()) {
             $documentationFormat = new \TYPO3\Flow\Package\Documentation\Format($filename, $this->documentationPath . $filename . '/');
             $documentationFormats[$filename] = $documentationFormat;
         }
         $documentationFormatsDirectoryIterator->next();
     }
     return $documentationFormats;
 }
Example #23
Show file File: BuildOriginalNameArray.php Project: saiber/www
0
 function __construct()
 {
     $dir = new DirectoryIterator(dirname(__FILE__));
     foreach ($dir as $file) {
         if (!$dir->isFile()) {
             continue;
         }
         list($code, $bs) = explode('.', $file);
         if (strlen($code) != 2) {
             continue;
         }
         include $file;
         $this->names[$code] = $this->codes[$code];
     }
 }
Example #24
Show file File: DirectoryUtil.class.php Project: ZerGabriel/WCF
0
 /**
  * Fills the list of available files, with DirectoryIterator object as value
  */
 protected function scanFileObjects()
 {
     // value is cached
     if (!empty($this->fileObjects)) {
         return;
     }
     if ($this->recursive) {
         $it = new \RecursiveIteratorIterator($this->obj, \RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($it as $filename => $obj) {
             // ignore . and ..
             if ($it->isDot()) {
                 continue;
             }
             $this->fileObjects[FileUtil::unifyDirSeperator($filename)] = $obj;
         }
     } else {
         foreach ($this->obj as $obj) {
             // ignore . and ..
             if ($this->obj->isDot()) {
                 continue;
             }
             $this->fileObjects[FileUtil::unifyDirSeperator($obj->getFilename())] = $obj;
         }
     }
     // add the directory itself
     $this->fileObjects[$this->directory] = new \SPLFileInfo($this->directory);
 }
Example #25
Show file File: ChartsBuilder.php Project: ribrain80/suncharts
0
 /**
  * Clears Up the images folder
  * Old files are unlinked
  */
 public function clearPast()
 {
     // # DirecotryIterator on image folder
     $chartsIterator = new \DirectoryIterator($this->PM->getProperty("basePath") . "/imagedata/");
     $isDirEmpty = !$chartsIterator->valid();
     // # Check if it is already empty
     if (!$isDirEmpty) {
         $this->log->error("Unlinking old files i've found");
         // # Unlink 'em all
         foreach ($chartsIterator as $file) {
             if ($file->isFile()) {
                 @unlink($this->PM->getProperty("basePath") . "/imagedata/" . $file->getFilename());
             }
         }
     }
 }
Example #26
Show file File: Cron.php Project: Br3nda/indefero
0
 /**
  * Remove orphan repositories.
  */
 public static function removeOrphanRepositories()
 {
     $path = Pluf::f('idf_plugin_syncgit_base_repositories', '/home/git/repositories');
     if (!is_dir($path) || is_link($path)) {
         throw new Pluf_Exception_SettingError(sprintf('Directory %s does not exist! Setting "idf_plugin_syncgit_base_repositories not set.', $path));
     }
     if (!is_writable($path)) {
         throw new Exception(sprintf('Repository %s is not writable.', $path));
     }
     $projects = array();
     foreach (Pluf::factory('IDF_Project')->getList() as $project) {
         $projects[] = $project->shortname;
     }
     unset($project);
     $it = new DirectoryIterator($path);
     $orphans = array();
     while ($it->valid()) {
         if (!$it->isDot() && $it->isDir() && !in_array(basename($it->getFileName(), '.git'), $projects)) {
             $orphans[] = $it->getPathName();
         }
         $it->next();
     }
     if (count($orphans)) {
         $cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'rm -rf ' . implode(' ', $orphans);
         exec($cmd);
         clearstatcache();
         while (list(, $project) = each($orphans)) {
             if (is_dir($project)) {
                 throw new Exception(sprintf('Cannot remove %s directory.', $project));
             }
         }
     }
 }
Example #27
Show file File: ClassLoader.php Project: robo47/BlazeFramework
0
 /**
  * This should provide the feature that the lang package can be used from
  * everywhere without to import it. Currently this is not working.
  */
 private function initLang()
 {
     if ($this->initialized) {
         return;
     }
     $dir = new \DirectoryIterator(__DIR__);
     while ($dir->valid()) {
         $file = $dir->getFilename();
         if ($dir->isFile() && ($len = strpos($file, '.php')) === strlen($file) - 4) {
             $name = substr($file, 0, $len);
             $fullName = 'blaze\\lang\\' . $name;
             $this->loadClass($fullName);
             @class_alias($fullName, $name);
         }
         $dir->next();
     }
 }
Example #28
Show file File: pear_package_parse.php Project: raz0rsdge/horde
0
 public function getPackages(array $srcDirs)
 {
     $pkgs = array();
     foreach ($srcDirs as $dir) {
         $di = new DirectoryIterator($dir);
         foreach ($di as $val) {
             $pathname = $val->getPathname();
             if ($val->isDir() && !$di->isDot() && file_exists($pathname . '/package.xml')) {
                 $pkgs[basename($val)] = $pathname;
             } elseif ($val->isFile() && $val == 'package.xml') {
                 $pkgs[basename($val->getPath())] = $val->getPath();
             }
         }
     }
     asort($pkgs);
     return $pkgs;
 }
Example #29
Show file File: Browser.php Project: TheProjecter/skeleton
0
 public function readDir()
 {
     $this->processRequest();
     $path = $this->base_path . $this->rel_area . $this->rel_path;
     if (file_exists($path)) {
         $directory = new DirectoryIterator($path);
     } else {
         $this->errorMsg = "{$path} does not exist<br/>";
         return -1;
     }
     $result = array();
     $this->entry_n = 0;
     $this->dir_n = 0;
     $this->file_n = 0;
     $this->entry_max = 0;
     $this->dir_max = 0;
     $this->file_max = 0;
     $param = array($this->param_area => $this->rel_area, $this->param_path => '');
     while ($directory->valid()) {
         $filename = $directory->getFileName();
         if ($directory->isDir()) {
             if ($filename == '..') {
                 if ($this->rel_path == '') {
                     $filename = '.';
                     // don't show
                 } else {
                     $pos = strrpos(trim($this->rel_path, '/'), '/');
                     if ($pos === false) {
                         $dir = '';
                     } else {
                         $dir = substr($this->rel_path, 0, $pos);
                     }
                 }
             } else {
                 $dir = $this->rel_path . $filename;
             }
             if ($filename != '.') {
                 $param[$this->param_path] = $dir;
                 $this->entries[$this->entry_max++] = array('type' => 'dir', 'param' => $param, 'filename' => $filename);
             }
         } else {
             $param[$this->param_path] = $this->rel_path;
             $this->entries[$this->entry_max++] = array('type' => 'file', 'param' => $param, 'filename' => $filename);
         }
         $directory->next();
     }
     if ($this->sort) {
         usort($this->entries, array($this, '_entrySort'));
     }
     for ($i = 0; $i < $this->entry_max; $i++) {
         if ($this->entries[$i]['type'] == 'dir') {
             $this->dirs[$this->dir_max++] = $i;
         } else {
             $this->files[$this->file_max++] = $i;
         }
     }
     return $this->entry_max;
 }
Example #30
Show file File: IndexController.php Project: netconstructor/Centurion
0
 public function logAction()
 {
     $pageSize = 4096;
     $overlapSize = 128;
     $dir = APPLICATION_PATH . '/../data/logs/';
     $file = $this->_getParam('file', null);
     $this->view->page = $this->_getParam('page', 0);
     if ($file === null) {
         $file = sprintf('%s_application.log', Zend_Date::now()->toString('yyyy.MM.dd'));
     }
     $fp = fopen($dir . $file, 'r');
     fseek($fp, -$pageSize * ($this->view->page + 1) + $overlapSize, SEEK_END);
     $this->view->errorLog = fread($fp, $pageSize + $overlapSize * 2);
     fclose($fp);
     $iterator = new DirectoryIterator($dir);
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if ($iterator->isFile()) {
                 $files[$iterator->getFilename()] = $iterator->getPathName();
             }
         }
         $iterator->next();
     }
     $this->view->itemCountPerPage = $pageSize;
     $this->view->totalItemCount = filesize($dir . $file);
     $this->view->files = $files;
 }