Example #1
0
 /**
  * @param        $path
  * @param string $filter
  * @param bool   $recurse
  * @param bool   $fullpath
  *
  * @return array
  */
 static function readDirectory($path, $filter = '.', $recurse = FALSE, $fullpath = FALSE)
 {
     $arr = array();
     if (!@is_dir($path)) {
         return $arr;
     }
     $handle = opendir($path);
     while ($file = readdir($handle)) {
         $dir = Bf_Filesystem::pathName($path . '/' . $file, FALSE);
         $isDir = is_dir($dir);
         if ($file != "." && $file != "..") {
             if (preg_match("/{$filter}/", $file)) {
                 if ($fullpath) {
                     $arr[] = trim(Bf_Filesystem::pathName($path . '/' . $file, FALSE));
                 } else {
                     $arr[] = trim($file);
                 }
             }
             if ($recurse && $isDir) {
                 $arr2 = Bf_Filesystem::readDirectory($dir, $filter, $recurse, $fullpath);
                 $arr = array_merge($arr, $arr2);
             }
         }
     }
     closedir($handle);
     asort($arr);
     return $arr;
 }
Example #2
0
    private function clearTmpFiles()
    {
        require 'bfFilesystem.php';
        $filesAndFolders = Bf_Filesystem::readDirectory(JPATH_ROOT . '/tmp', '.', true);
        foreach ($filesAndFolders as $pointer) {
            $pointer = JPATH_ROOT . '/tmp/' . $pointer;
            if (is_dir($pointer)) {
                bfLog::log('Deleting ' . $pointer);
                Bf_Filesystem::deleteRecursive($pointer, TRUE);
            } else {
                bfLog::log('Deleting ' . $pointer);
                unlink($pointer);
            }
        }
        file_put_contents(JPATH_ROOT . '/tmp/index.html', '<html><body bgcolor="#FFFFFF"></body></html> ');
        $sql = 'DELETE FROM bf_files WHERE
		          filewithpath LIKE "/tmp%"
		            AND
				  filewithpath != "/tmp/index.html"';
        $this->_db->setQuery($sql);
        $this->_db->query();
        bfEncrypt::reply('success', array('res' => TRUE));
    }