public function buildCss()
 {
     App::import('Vendor', 'AssetMinify.JSMinPlus');
     // Ouverture des fichiers de config
     $dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
     if ($dir->path !== null) {
         foreach ($dir->find('config_.*.ini') as $file) {
             preg_match('`^config_(.*)\\.ini$`', $file, $grep);
             $file = new File($dir->pwd() . DS . $file);
             $ini = parse_ini_file($file->path, true);
             $fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
             $fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
             $contentFull = '';
             foreach ($ini as $data) {
                 // On a pas de version minifié
                 if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
                     $this->out("Compression de " . $data['file'] . ' ... ', 0);
                     $fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
                     $this->out('OK');
                 } else {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
                 }
                 $contentFull .= $fileMin->read() . PHP_EOL;
             }
             // version full
             $fileFull->write($contentFull);
             $fileFull->close();
             // compression
             $fileGz->write(gzencode($contentFull, 6));
         }
     }
 }
Пример #2
0
 private function getVideoFile($id)
 {
     if (empty($id)) {
         return false;
     }
     $dir = new Folder('files/Video/' . $id);
     if (isset($dir->find()[0])) {
         return $dir->find()[0];
     } else {
         return false;
     }
 }
Пример #3
0
 function read($dir = null, $recursive = false)
 {
     $notes = array();
     $path = CORE_PATH . APP_PATH . $dir;
     $folder = new Folder(APP_PATH . $dir);
     $fold = $recursive ? $folder->findRecursive('.*\\.php') : $folder->find('.*\\.php');
     foreach ($fold as $file) {
         $file = $recursive ? $file : $path . $file;
         $file_path = r(CORE_PATH . APP_PATH, '', $file);
         $handle = new File($file_path);
         $content = $handle->read();
         $lines = explode(PHP_EOL, $content);
         //$lines = file($file);
         $ln = 1;
         if (!empty($lines)) {
             foreach ($lines as $line) {
                 if ((is_null($this->type) || $this->type == 'TODO') && preg_match("/[#\\*\\/\\/]\\s*TODO\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['TODO'][$ln] = $match[1];
                 }
                 if ((is_null($this->type) || $this->type == 'OPTIMIZE') && preg_match("/[#\\*\\/\\/]\\s*OPTIMIZE|OPTIMISE\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['OPTIMIZE'][$ln] = $match[1];
                 }
                 if ((is_null($this->type) || $this->type == 'FIXME') && preg_match("/[#\\*\\/\\/]\\s*FIXME|BUG\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['FIXME'][$ln] = $match[1];
                 }
                 $ln++;
             }
         }
     }
     return $this->notes;
 }
Пример #4
0
 /**
  * Overwrite shell initialize to dynamically load all queue related tasks.
  *
  * @return void
  */
 public function initialize()
 {
     // Check for tasks inside plugins and application
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     $conf = Configure::read('Queue');
     if (!is_array($conf)) {
         $conf = [];
     }
     // Merge with default configuration vars.
     Configure::write('Queue', array_merge(['workers' => 3, 'sleepTime' => 10, 'gcprop' => 10, 'defaultWorkerTimeout' => 2 * MINUTE, 'defaultWorkerRetries' => 4, 'workerMaxRuntime' => 0, 'cleanupTimeout' => DAY, 'exitWhenNothingToDo' => false], $conf));
     parent::initialize();
 }
Пример #5
0
 public function render($view = null, $layout = null)
 {
     // set vars
     $name = $download = $extension = $id = $modified = $path = $cache = $mimeType = $compress = null;
     extract($this->viewVars, EXTR_OVERWRITE);
     $this->viewVars['thumbName'] = $thumbName = md5(json_encode($this->viewVars['params']));
     $dir = new Folder(CACHE . 'thumbs', true, 0755);
     $files = $dir->find($this->viewVars['thumbName']);
     if (empty($files)) {
         $pos = strpos($this->viewVars['params']['image'], 'http://');
         if ($pos !== FALSE) {
             $this->_loadExternalFile();
             $this->_resizeFile();
             unlink($this->viewVars['params']['image']);
         } else {
             $this->viewVars['params']['image'] = WWW_ROOT . $this->viewVars['params']['image'];
             $this->_resizeFile();
         }
     }
     $modified = @filemtime(CACHE . 'thumbs/' . $thumbName);
     $pos1 = strrpos($params['image'], '.');
     $id = substr($params['image'], $pos1 + 1, 8);
     $this->response->type($id);
     $this->viewVars['path'] = CACHE . 'thumbs' . DS . $thumbName;
     $this->viewVars['download'] = false;
     $this->viewVars['cache'] = '+1 day';
     $this->viewVars['modified'] = '@' . $modified;
     // Must be a string to work. See MediaView->render()
     parent::render();
 }
Пример #6
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     $plugins = CakePlugin::loaded();
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     parent::initialize();
     $this->QueuedTask->initConfig();
 }
 public function view($id = null)
 {
     $this->layout = 'index';
     $this->Anotacion->id = $id;
     $user = $this->User->findByUsername('transparenciapasiva');
     if (!$this->Anotacion->exists() || $this->Anotacion->field('user_id') != $user['User']['id']) {
         $this->Session->setFlash('<h2 class="alert alert-error">La Anotacion no Existe</h2>', 'default', array(), 'buscar');
         $this->redirect(array('controller' => 'home', 'action' => 'index/tab:3'));
     }
     $this->set('anotacion', $this->Anotacion->read(null, $id));
     $folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id);
     $files_url = array();
     foreach ($folder_anot->find('.*') as $file) {
         $files_url[] = basename($folder_anot->pwd()) . DS . $file;
     }
     $this->set('files', $files_url);
     ////////////////////////////////////////////////////////////////////
     $folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id . DS . 'Respuestas');
     $files_url = array();
     $dir = $folder_anot->read(true, false, true);
     foreach ($dir[0] as $key => $value) {
         $folder = new Folder($value);
         foreach ($folder->find('.*') as $file) {
             $files_url[basename($folder->pwd())][] = $file;
         }
     }
     $this->set('files_res', $files_url);
 }
Пример #8
0
 public function admin_reset($user_id)
 {
     if ($this->Auth->user('role') > 1) {
         $dir = new Folder('../webroot/img/avatars/');
         if ($dir->path != null) {
             // On supprime le fichier
             $files = $dir->find($user_id . '.jpg');
             foreach ($files as $file) {
                 $file = new File($dir->pwd() . DS . $file);
                 $file->delete();
                 $file->close();
             }
             // On sauvegarde
             $user = $this->User->find('first', ['conditions' => ['User.id' => $user_id]]);
             $username = $user['User']['username'];
             $avatar = 'http://cravatar.eu/helmavatar/' . $username;
             $this->User->id = $user_id;
             $this->User->saveField('avatar', $avatar);
             // Redirection
             $this->Session->setFlash('L\'avatar de ' . $username . ' a été réinitialisé', 'toastr_success');
             return $this->redirect(['controller' => 'users', 'action' => 'edit', $user_id]);
         }
     } else {
         throw new NotFoundException();
     }
 }
Пример #9
0
 function get()
 {
     $result = array();
     $controllers_folder = new Folder(APP . 'controllers');
     $controllers = $controllers_folder->find('.*_controller\\.php');
     $appmet = get_class_methods("AppController");
     foreach ($controllers as $controller) {
         $views = array();
         $controller_name = substr($controller, 0, strpos($controller, '_controller'));
         if ($controller_name !== 'app') {
             // consulta los metodos de la clase
             require_once APP . 'controllers' . DS . $controller;
             if (strpos($controller_name, '_')) {
                 $arr = split('_', $controller_name);
                 $controller_name = '';
                 foreach ($arr as $i => $a) {
                     if ($i > 0) {
                         $controller_name .= ucfirst($a);
                     } else {
                         $controller_name .= $a;
                     }
                 }
             }
             $methods = get_class_methods(ucfirst($controller_name) . "Controller");
             $x = array();
             foreach ($methods as $m) {
                 if (!in_array($m, $appmet)) {
                     $x[] = $m;
                 }
             }
             $result[$controller_name] = $x;
         }
     }
     return $result;
 }
Пример #10
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $this->_loadModels();
     $x = App::objects('Queue.Task');
     //'Console/Command/Task'
     //$x = App::path('Task', 'Queue');
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
     }
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     //Config can be overwritten via local app config.
     Configure::load('Queue.queue');
     $conf = (array) Configure::read('Queue');
     //merge with default configuration vars.
     Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
 }
Пример #11
0
 /**
  * Constructor. Binds the model's database table to the object.
  *
  * @param bool|int|string|array $id Set this ID for this model on startup,
  * can also be an array of options, see above.
  * @param string $table Name of database table to use.
  * @param string $ds DataSource connection name.
  * @see Model::__construct()
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     $pluginDir = APP . 'Plugin' . DS . $this->plugin . DS . WEBROOT_DIR . DS . 'img' . DS;
     //カテゴリ間の区切り線
     $dir = new Folder($pluginDir . 'line');
     $files = $dir->find('.*\\..*');
     $files = Hash::sort($files, '{n}', 'asc');
     self::$categorySeparators = array(array('key' => null, 'name' => __d('links', '(no line)'), 'style' => null), array('key' => self::CATEGORY_SEPARATOR_DEFAULT, 'name' => '', 'style' => ''));
     foreach ($files as $file) {
         $info = getimagesize($dir->pwd() . DS . $file);
         $img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'line' . DS . $file;
         self::$categorySeparators[] = array('key' => $file, 'name' => '', 'style' => 'background-image: url(' . $img . '); ' . 'border-image: url(' . $img . '); ' . 'height: ' . $info[1] . 'px;');
     }
     unset($dir);
     //線スタイル
     $dir = new Folder($pluginDir . 'mark');
     $files = $dir->find('.*\\..*');
     $files = Hash::sort($files, '{n}', 'asc');
     self::$listStyles = array(array('key' => null, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_NONE . ';'), array('key' => self::LINE_STYLE_DISC, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_DISC . ';'), array('key' => self::LINE_STYLE_CIRCLE, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_CIRCLE . ';'), array('key' => self::LINE_STYLE_LOWER_ALPHA, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_LOWER_ALPHA . ';'), array('key' => self::LINE_STYLE_UPPER_ALPHA, 'name' => '', 'style' => 'list-style-type: ' . self::LINE_STYLE_UPPER_ALPHA . ';'));
     foreach ($files as $file) {
         $info = getimagesize($dir->pwd() . DS . $file);
         $img = '/' . Inflector::underscore($this->plugin) . DS . 'img' . DS . 'mark' . DS . $file;
         self::$listStyles[] = array('key' => $file, 'name' => '', 'style' => 'list-style-type: none; ' . 'list-style-image: url(' . $img . '); ');
     }
     unset($dir);
 }
 function upload()
 {
     $directory = $this->getNextParam(null, 'path');
     $container = $this->getNextParam(null, 'container');
     if (empty($directory) || empty($container)) {
         $this->errorAndExit('Directory and Container required');
     }
     $Folder = new Folder($directory);
     if ($this->params['recursive']) {
         $files = $Folder->findRecursive();
     } else {
         $single_files = $Folder->find();
         $files = array();
         foreach ($single_files as $file) {
             $files[] = $Folder->pwd() . DS . $file;
         }
     }
     $this->ProgressBar->start(count($files));
     foreach ($files as $file) {
         CloudFiles::upload($file, $container);
         $this->ProgressBar->next();
     }
     $this->out();
     $this->out("Finished.");
 }
Пример #13
0
 /**
  *  Get list of processor names
  */
 private function getProcessorNames($replaceString, $dirPath = 'controllers')
 {
     $path = APP . 'plugins' . DS . 'payment' . DS . $dirPath;
     $thtml = new Folder($path);
     $processors = $thtml->find('(.+)\\.php');
     $processors = str_replace($replaceString, '', $processors);
     return $processors;
 }
 public function admin_index()
 {
     App::uses('Folder', 'Utility');
     App::uses('File', 'Utility');
     $folder = new Folder(WWW_ROOT . 'backups/');
     $files = $folder->find('.*\\.sql');
     $this->set(compact('files'));
 }
Пример #15
0
 public function ingest($type = "meta")
 {
     if ($type == "meta") {
         $meta = new Folder('/Users/n00002621/Dropbox/Research - Cheminfo/OSDB/IS-DB/metadata');
         $files = $meta->find('.*\\.xml');
         foreach ($files as $file) {
             $file = new File($meta->pwd() . DS . $file);
             $text = $file->read();
             $xml = simplexml_load_string($text);
             $data = json_decode(json_encode($xml), true);
             $set = $data['data_set'];
             $sam = $data['sample'];
             $set['id'] = $set['DataSetId'];
             unset($set['DataSetId']);
             $set['author_id'] = $set['ContactAuthor'];
             unset($set['ContactAuthor']);
             $set['publication_id'] = $set['PublicationId'];
             unset($set['PublicationId']);
             $set['sample_id'] = $set['SampleId'];
             unset($set['SampleId']);
             $set['datatype'] = $set['DataType'];
             unset($set['DataType']);
             $set['dataformat'] = $set['DataFormat'];
             unset($set['DataFormat']);
             $set['description'] = $set['Description'];
             unset($set['Description']);
             if (isset($set['Instrument'])) {
                 $set['instrument'] = $set['Instrument'];
                 unset($set['Instrument']);
             } else {
                 $set['instrument'] = "";
             }
             if (isset($set['MeasurementTechnique'])) {
                 $set['measurement'] = $set['MeasurementTechnique'];
                 unset($set['MeasurementTechnique']);
             } else {
                 $set['measurement'] = "";
             }
             $set['oldfilename'] = $set['OldFileName'];
             unset($set['OldFileName']);
             $set['newfilename'] = $set['NewFileName'];
             unset($set['NewFileName']);
             $set['mimetype'] = $set['MimeType'];
             unset($set['MimeType']);
             $set['filesize'] = $set['FileSize'];
             unset($set['FileSize']);
             $set['submitted'] = $set['SubmissionDate'];
             unset($set['SubmissionDate']);
             $set['flags'] = $set['DataSetFlags'];
             unset($set['DataSetFlags']);
             debug($set);
             debug($sam);
             exit;
         }
         debug($files);
         exit;
     }
 }
Пример #16
0
 public function displayPhoto($user)
 {
     $folder = new Folder('img/users');
     $photo = $folder->find("\\b{$user}\\b.*");
     if (empty($photo)) {
         return false;
     }
     return $photo[0];
 }
Пример #17
0
 public function questionnaire_setup()
 {
     $this->Session->delete('questionnaire');
     App::uses('Folder', 'Utility');
     $questionnaireViewFolder = new Folder(APP . 'View' . DS . 'Responses');
     $pages = count($questionnaireViewFolder->find('questionnaire_page_.*\\.ctp'));
     $this->Session->write('questionnaire.params.pages', $pages);
     $this->Session->write('questionnaire.params.maxProgress', 0);
     $this->redirect(array('action' => 'questionnaire_page', 1));
 }
 public function folder()
 {
     $folder = Folder::find('_id', $this->getParam('id', ''));
     if ($folder != NULL) {
         $folder->downloadAsZip();
     } else {
         throw new FolderNotFoundException();
         exit;
     }
 }
 public function index()
 {
     $folder_id = NULL;
     if (is_numeric($this->getParam('id', NULL))) {
         $folder_id = $this->getParam('id', NULL);
     }
     try {
         $folder = Folder::find('_id', $folder_id);
     } catch (FolderNotFoundException $e) {
         System::displayError(System::getLanguage()->_('ErrorFolderNotFound'), '404 Not Found');
     }
     $folder->loadFiles();
     $folder->loadFolders();
     $files = $folder->files;
     $breadcrumb = array();
     if (Utils::getPOST('submit', false) !== false) {
         $delete = Utils::getPOST('delete', array());
         $count = count($delete);
         if ($count > 0 && count($files) > 0) {
             foreach ($files as $file) {
                 for ($i = 0; $i < $count; ++$i) {
                     if ($file->id == $delete[$i]) {
                         $file->delete();
                     }
                 }
             }
         }
         if ($folder->id == 0) {
             System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index'));
         } else {
             System::forwardToRoute(Router::getInstance()->build('BrowserController', 'show', array('id' => $folder->id)));
         }
         exit;
     }
     // Breadcrumb
     $f = $folder;
     while ($f != NULL && $f->id != 0) {
         if ($f->name != '') {
             $breadcrumb[] = $f;
         }
         $f = Folder::find('_id', $f->pid);
     }
     $breadcrumb = array_reverse($breadcrumb);
     $smarty = new Template();
     $smarty->assign('files', $folder->files);
     $smarty->assign('folders', $folder->folders);
     $smarty->assign('title', System::getLanguage()->_('Files'));
     $smarty->assign('currentFolder', $folder);
     $smarty->assign('breadcrumb', $breadcrumb);
     $smarty->assign('AvailableFolders', Folder::getAll());
     $smarty->assign('fafileicons', BrowserController::$fontawesomeFileicons);
     $smarty->assign('remoteDownloadSetting', DOWNLOAD_VIA_SERVER);
     $smarty->requireResource('browser');
     $smarty->display('files/index.tpl');
 }
Пример #20
0
 public function addCssFonts()
 {
     if (!is_object(IdmlAssembler::getInstance()->getProcessor())) {
         return;
     }
     $dir = new Folder(APP . "Data/Pxe/Fonts");
     $files = $dir->find();
     foreach ($files as $file) {
         IdmlAssembler::getInstance()->getProcessor()->addFontToBook($dir->pwd() . DS . $file);
     }
 }
 function getFixtures()
 {
     $fixtures = array();
     $folder = new Folder(APP . 'tests' . DS . 'fixtures');
     $files = $folder->find('.*_fixture\\.php$');
     foreach ($files as $file) {
         $fixture = str_replace('_fixture.php', '', $file);
         $fixtures[] = 'app.' . str_replace('._', '', $fixture);
     }
     return $fixtures;
 }
Пример #22
0
function myClearCache($pattern)
{
    App::import('Core', 'Folder');
    $folder = new Folder(CACHE . 'views');
    $files = $folder->find('.*' . $pattern . '.*');
    if (!empty($files)) {
        foreach ($files as $file) {
            $file = r('.php', '', $file);
            clearCache($file);
        }
    }
}
Пример #23
0
 /**
  * tearDown method
  * @return void
  */
 public function tearDown()
 {
     $path = $this->Image->settings['cachePath'];
     $dir = new Folder($path);
     foreach ($dir->find() as $file) {
         unlink($path . $file);
     }
     if (is_dir($path)) {
         rmdir($path);
     }
     unset($this->Image);
     parent::tearDown();
 }
 public function admin_index()
 {
     $logDir = LOGS;
     $Folder = new Folder($logDir, false);
     $logfiles = $Folder->find('.*.log(\\.[0-9])?', true);
     $files = array();
     foreach ($logfiles as $logfile) {
         $F = new File($logDir . $logfile);
         $file = array('name' => $logfile, 'dir' => $logDir, 'size' => $F->size(), 'last_modified' => $F->lastChange(), 'last_access' => $F->lastAccess());
         array_push($files, $file);
     }
     $this->set(compact('files'));
 }
Пример #25
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $Folder = new Folder(TMP);
     $files = $Folder->find('croogo_.*');
     foreach ($files as $file) {
         unlink(TMP . $file);
     }
     $Folder = new Folder(TESTS . 'test_app' . DS . 'Plugin' . DS . 'Example');
     $Folder->delete();
     $Folder = new Folder(TESTS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'Minimal');
     $Folder->delete();
 }
Пример #26
0
 public function getEngineList()
 {
     App::uses('Folder', 'Utility');
     $sourcePath = VENDORS . 'olc_baker' . DS . 'actions' . DS;
     $fh = new Folder($sourcePath);
     $files = $fh->find('.*\\.php$');
     $list = array();
     foreach ($files as $fileName) {
         $pathInfo = pathinfo($fileName);
         $fileContent = (include $sourcePath . $fileName);
         $list[$pathInfo['filename']] = $fileContent['name'];
     }
     return $list;
 }
Пример #27
0
 function cleanOrphans()
 {
     $folder = new Folder(F_DEPLOYLOGDIR);
     $files = $folder->find('.*\\.xml');
     $uuids = $this->find('all', array('conditions' => array('archive' => '0'), 'fields' => 'uuid'));
     $uuids = Set::extract($uuids, '{n}.DeploymentLog.uuid');
     $count = 0;
     foreach ($files as $file) {
         if (!in_array(substr($file, 0, -4), $uuids)) {
             unlink(F_DEPLOYLOGDIR . $file);
             $count++;
         }
     }
     return $count;
 }
Пример #28
0
 /**
  * Get all the logfiles accessible and whitelisted
  *
  * @return array
  */
 public function getLogFiles()
 {
     $dir = new Folder(Configure::read('LogWatcher.logDir'));
     # if a whitelist is set, only show those
     if ($whitelist = Configure::read('LogWatcher.whitelist')) {
         $allowed = implode('|', $whitelist);
     } else {
         $allowed = '.*';
     }
     $logs = $dir->find($allowed . '\\.log');
     foreach ($logs as &$log) {
         $log = substr($log, 0, -4);
     }
     return $logs;
 }
Пример #29
0
 /**
  * Returns an array of files that are due for recompiling. The key of the
  * array represents the current source file and the value is where the
  * source should be compiled to.
  * @return array
  * @access protected
  */
 protected function _getEligibleFiles()
 {
     $return = array();
     foreach ($this->_getMonitorFolders() as $from => $to) {
         $from = new Folder($from);
         foreach ($from->find('.+\\.sass') as $file) {
             $source = $from->path . $file;
             $compiled = $to . substr($file, 0, -4) . 'css';
             if (!file_exists($compiled) or filemtime($source) > filemtime($compiled)) {
                 $return[$source] = $compiled;
             }
         }
     }
     return $return;
 }
Пример #30
0
 /**
  * Clear test files
  */
 protected function _clearFiles()
 {
     $path = App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS . 'Model' . DS;
     $dir = new Folder($path);
     foreach ($dir->find() as $file) {
         unlink($path . $file);
     }
     $path = App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS . 'Controller' . DS;
     $dir = new Folder($path);
     foreach ($dir->find() as $file) {
         if ($file == 'TestsController.php') {
             continue;
         }
         unlink($path . $file);
     }
 }