Beispiel #1
0
 function readdir($dir)
 {
     if (isset(self::$cache[$dir])) {
         return self::$cache[$dir];
     }
     return self::$cache[$dir] = File_Find::glob(".*", $dir, self::EXT);
 }
Beispiel #2
0
 public static function instance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
    /**
     * Returns an array of available handlers containing
     * handler name -> info pairs.
     * @param $p_path
     * @return array
     */
    public static function availableHandlers($p_path = null)
    {
        if (is_null($p_path)) {
            $path = dirname(__FILE__) . DIR_SEP. 'cache';
        } else {
            $path = $p_path;
        }

        require_once(dirname(dirname(__FILE__)).'/include/pear/File/Find.php');
        $includeFiles = File_Find::search('/^TemplateCacheHandler_[^.]*\.php$/', $path, 'perl', false);
        $handlers = array();
        foreach ($includeFiles as $includeFile) {
            if (preg_match('/TemplateCacheHandler_([^.]+)\.php/', $includeFile, $matches) == 0) {
                continue;
            }
            require_once $includeFile;
            $handlerName = $matches[1];
            $className = "TemplateCacheHandler_$handlerName";
            if (class_exists($className)) {
                $cacheHandler = new $className;
                $handlers[$handlerName] = array(
                    'is_supported'=>$cacheHandler->isSupported(),
                    'file'=>"$path/TemplateCacheHandler_$handlerName.php",
                    'description'=>$cacheHandler->description());
            }
        }
        return $handlers;
    }
function handleDirFiles($dir_name, $save_dir)
{
    list($directories, $files) = File_Find::maptree($dir_name);
    $new_dir = $save_dir . basename($dir_name);
    if (!file_exists($new_dir)) {
        mkdir($new_dir, 0777);
    }
    foreach ($files as $image_file) {
        if (ereg("(.*)jpg\$", $image_file)) {
            $new_filename = $new_dir . "/" . basename($image_file, ".jpg") . "_resize.jpg";
            echo $new_filename . "\n";
            $tn_image = new Thumbnail($image_file, 340);
            $tn_image->save($new_filename);
            $Canvas =& Image_Canvas::factory(isset($_GET['canvas']) ? $_GET['canvas'] : 'jpg', array('width' => 340, 'height' => 340));
            $Canvas->image(array('x' => 340, 'y' => 340, 'filename' => $new_filename, 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom')));
            $Canvas->setFont(array('name' => 'Courier New', 'size' => 16, 'color' => '#FF66FF'));
            //#FF0033
            $Canvas->addText(array('x' => 165, 'y' => 200, 'text' => 'arzen1013', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
            $Canvas->setFont(array('name' => 'Courier New', 'size' => 10, 'color' => '#000000'));
            //#FF0033
            $Canvas->addText(array('x' => 165, 'y' => 320, 'text' => 'http://shop33691629.taobao.com/', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
            $Canvas->save(array('filename' => $new_filename));
        }
    }
}
Beispiel #5
0
 /**
  * Delete cached data of given component/section
  *
  * @access  public
  * @param   string  $component
  * @param   string  $section
  * @param   string  $params
  * @return  bool
  */
 function delete($component = null, $section = null, $params = null)
 {
     if (!is_null($params)) {
         $params = is_array($params) ? implode('_', $params) : $params;
     } else {
         $params = '';
     }
     require_once PEAR_PATH . 'File/Find.php';
     $match = is_null($component) ? '' : $component;
     $match .= '.' . (is_null($section) ? '' : $section);
     $match .= empty($params) ? '' : '.' . $params;
     $files =& File_Find::search('/' . $match . '/i', $this->_path, 'perl', false, 'files');
     foreach ($files as $file) {
         Jaws_Utils::Delete($file);
     }
     return true;
 }
 /**
  * Get file list
  */
 function file_list()
 {
     if (!is_dir($this->directory)) {
         return false;
     }
     $items =& File_Find::glob('#([a-zA-Z0-9])\\.png#', $this->directory, 'perl');
     if (!is_array($items) or sizeof($items) <= 0) {
         return false;
     }
     $list = array();
     while (list($key, $val) = each($items)) {
         if (sizeof($list) >= $this->number - 1) {
             return $list;
         }
         $diff = (time() - filectime($this->directory . $val)) / 60;
         if ($diff > $this->time) {
             $list[] = $val;
         }
     }
     return $list;
 }
Beispiel #7
0
 /**
  * Search the specified directory tree with the specified pattern.  Return
  * an array containing all matching files (no directories included).
  *
  * @param string $pattern the pattern to match every file with.
  *
  * @param string $directory the directory tree to search in.
  *
  * @param string $type the type of regular expression support to use, either
  * 'php' or 'perl'.
  *
  * @param bool $fullpath whether the regex should be matched against the
  * full path or only against the filename
  *
  * @param string $match can be either 'files', 'dirs' or 'both' to specify
  * the kind of list to return
  *
  * @return array a list of files matching the pattern parameter in the the
  * directory path specified by the directory parameter
  *
  * @author Sterling Hughes <*****@*****.**>
  * @access public
  * @static
  */
 function &search($pattern, $directory, $type = 'php', $fullpath = true, $match = 'files')
 {
     $matches = array();
     list($directories, $files) = File_Find::maptree($directory);
     switch ($match) {
         case 'directories':
             $data = $directories;
             break;
         case 'both':
             $data = array_merge($directories, $files);
             break;
         case 'files':
         default:
             $data = $files;
     }
     unset($files, $directories);
     $match_function = File_Find::_determineRegex($pattern, $type);
     reset($data);
     while (list(, $entry) = each($data)) {
         if ($match_function($pattern, $fullpath ? $entry : basename($entry))) {
             $matches[] = $entry;
         }
     }
     return $matches;
 }
Beispiel #8
0
 /**
  * Search the specified directory tree with the specified pattern.  Return
  * an array containing all matching files (no directories included).
  *
  * @param string $pattern the pattern to match every file with.
  *
  * @param string $directory the directory tree to search in.
  *
  * @param string $type the type of regular expression support to use, either
  * 'php', 'perl' or 'shell'.
  *
  * @param bool $fullpath whether the regex should be matched against the
  * full path or only against the filename
  *
  * @param string $match can be either 'files', 'dirs' or 'both' to specify
  * the kind of list to return
  *
  * @return array a list of files matching the pattern parameter in the the
  * directory path specified by the directory parameter
  *
  * @author Sterling Hughes <*****@*****.**>
  * @access public
  * @static
  */
 function &search($pattern, $directory, $type = 'php', $fullpath = true, $match = 'files')
 {
     $matches = array();
     list($directories, $files) = File_Find::maptree($directory);
     switch ($match) {
         case 'directories':
             $data = $directories;
             break;
         case 'both':
             $data = array_merge($directories, $files);
             break;
         case 'files':
         default:
             $data = $files;
     }
     unset($files, $directories);
     $match_function = File_Find::_determineRegex($pattern, $type);
     reset($data);
     // check if empty string given (ok for 'shell' method, but bad for others)
     if ($pattern || $type != 'php' && $type != 'perl') {
         while (list(, $entry) = each($data)) {
             if ($match_function($pattern, $fullpath ? $entry : basename($entry))) {
                 $matches[] = $entry;
             }
         }
     }
     sort($matches);
     return $matches;
 }
 /**
  * Returns list of files parsed
  *
  * Returns list of files parsed, depending of restrictive parser options.
  *
  * @param mixed $dir     The directory name where to look files
  * @param array $options An array of parser options. See parseData() method.
  *
  * @access public
  * @return array   list of files that should be parsed
  * @since  version 1.8.0b2 (2008-06-03)
  */
 function getFilelist($dir, $options)
 {
     $skipped = array();
     $ignored = array();
     $options = array_merge($this->options, $options);
     $options['file_ext'] = array_map('strtolower', $options['file_ext']);
     if ($dir[strlen($dir) - 1] == '/' || $dir[strlen($dir) - 1] == '\\') {
         $dir = substr($dir, 0, -1);
     }
     // use system directory separator rather than forward slash by default
     $ff = new File_Find();
     $ff->dirsep = DIRECTORY_SEPARATOR;
     // get directory list that should be ignored from scope
     $ignore_dirs = array();
     if (count($options['ignore_dirs']) > 0) {
         foreach ($options['ignore_dirs'] as $cond) {
             $cond = str_replace('\\', "\\\\", $cond);
             $dirs = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'directories');
             $ignore_dirs = array_merge($ignore_dirs, $dirs);
         }
     }
     // get file list that should be ignored from scope
     $ignore_files = array();
     if (count($options['ignore_files']) > 0) {
         foreach ($options['ignore_files'] as $cond) {
             $cond = str_replace('\\', "\\\\", $cond);
             $files = $ff->search('`' . $cond . '`', $dir, 'perl', true, 'files');
             $ignore_files = array_merge($ignore_files, $files);
         }
     }
     list($directories, $files) = $ff->maptree($dir);
     foreach ($files as $file) {
         $file_info = pathinfo($file);
         if ($options['recurse_dir'] == false && $file_info['dirname'] != $dir) {
             $skipped[] = $file;
             continue;
         }
         if (in_array($file_info['dirname'], $ignore_dirs)) {
             $ignored[] = $file;
         } elseif (in_array($file, $ignore_files)) {
             $ignored[] = $file;
         } else {
             if (isset($file_info['extension']) && in_array(strtolower($file_info['extension']), $options['file_ext'])) {
                 continue;
             }
             $ignored[] = $file;
         }
     }
     $files = PHP_CompatInfo_Parser::_arrayDiff($files, array_merge($ignored, $skipped));
     $this->directories = PHP_CompatInfo_Parser::_arrayDiff($directories, $ignore_dirs);
     $this->ignored_files = $ignored;
     return $files;
 }
Beispiel #10
0
    /**
     * Searches for classes that process actions. Returns an array of
     * action names.
     *
     * @return array
     */
    public static function ReadAvailableActions()
    {
        if (is_array(MetaAction::$m_availableActions)) {
            return MetaAction::$m_availableActions;
        }

        if (self::FetchActionsFromCache()) {
        	return self::$m_availableActions;
        }

        require_once('File/Find.php');

        $actions = array();

        $basePaths = array('.');
        foreach (CampPlugin::GetEnabled() as $CampPlugin) {
            $basePaths[] = $CampPlugin->getBasePath();  
        }
        foreach ($basePaths as $basePath) {
            $directoryPath = $GLOBALS['g_campsiteDir'].'/'.$basePath.'/template_engine/metaclasses';
            $actionIncludeFiles = File_Find::search('/^MetaAction[^.]*\.php$/',
            $directoryPath, 'perl', false);

            foreach ($actionIncludeFiles as $includeFile) {
                if (preg_match('/MetaAction([^.]+)\.php/', $includeFile, $matches) == 0
                || strtolower($matches[1]) == 'request') {
                    continue;
                }

                require_once($includeFile);
                $actionName = $matches[1];
                if (class_exists('MetaAction'.$actionName)) {
                    $actions[self::TranslateProperty($actionName)] = array('name'=>$actionName,
                    'file'=>"$directoryPath/MetaAction$actionName.php");
                }
            }
        }    
        self::$m_availableActions = $actions;
        self::StoreActionsInCache();
        return self::$m_availableActions;
    }
Beispiel #11
0
 /**
  * Delete language files for the given language.
  * @param string $p_languageCode
  * @return mixed
  * 		Return TRUE on success, PEAR_Error on failure.
  */
 public static function DeleteLanguageFiles($p_languageCode)
 {
     global $g_localizerConfig;
     $langDir = $g_localizerConfig['TRANSLATION_DIR'].'/'.$p_languageCode;
     if (!file_exists($langDir)) {
         return true;
     }
     $files = File_Find::mapTreeMultiple($langDir, 1);
     foreach ($files as $fileName) {
         $pathname = $langDir . DIR_SEP . $fileName;
         if (file_exists($pathname)) {
         	if (is_writable($pathname)) {
             	unlink($pathname);
         	} else {
         		return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $pathname), CAMP_ERROR_DELETE_FILE);
         	}
         }
     }
     @rmdir($langDir);
     return true;
 } // fn DeleteLanguageFiles
Beispiel #12
0
    /**
     * Returns an array of available engines containing
     * engine name -> info pairs.
     * @param $p_path
     * @return array
     */
    public static function AvailableEngines($p_path = null)
    {
        if (is_null($p_path)) {
            $path = dirname(__FILE__);
        } else {
            $path = $p_path;
        }

        require_once(dirname(dirname(dirname(__FILE__))).'/include/pear/File/Find.php');
        $includeFiles = File_Find::search('/^CacheEngine_[^.]*\.php$/', $path, 'perl', false);
        $engines = array();
        foreach ($includeFiles as $includeFile) {
            if (preg_match('/CacheEngine_([^.]+)\.php/', $includeFile, $matches) == 0) {
                continue;
            }

            require_once($includeFile);
            $engineName = $matches[1];
            $className = "CacheEngine_$engineName";
            if (class_exists($className)) {
                $cacheEngine = new $className;
                $engines[$engineName] = array(
                    'is_supported'=>$cacheEngine->isSupported(),
                    'page_caching_supported'=>$cacheEngine->pageCachingSupported(),
                    'file'=>"$path/CacheEngine_$engineName.php",
                    'description'=>$cacheEngine->description());
            }
        }
        return $engines;
    }
Beispiel #13
0
         $error = __("Could not create incoming directory: %s.", $tempdir);
     } else {
         if (!@chdir($tempdir)) {
             $error = __("Could not change directory to %s.", $tempdir);
         } else {
             $tar = new Archive_Tar($_FILES['pfile']['tmp_name']);
             $extract = $tar->extract();
             if (!$extract) {
                 $error = __("Unknown file format for uploaded file.");
             }
         }
     }
 }
 # Find the PKGBUILD
 if (!$error) {
     $pkgbuild = File_Find::search('PKGBUILD', $tempdir);
     if (count($pkgbuild)) {
         $pkgbuild = $pkgbuild[0];
         $pkg_dir = dirname($pkgbuild);
     } else {
         $error = __("Error trying to unpack upload - PKGBUILD does not exist.");
     }
 }
 # if no error, get list of directory contents and process PKGBUILD
 # TODO: This needs to be completely rewritten to support stuff like arrays
 # and variable substitution among other things.
 if (!$error) {
     # process PKGBUILD - remove line concatenation
     #
     $pkgbuild = array();
     $fp = fopen($pkg_dir . "/PKGBUILD", "r");
 * @author     John.meng <*****@*****.**>
 * @author     цот╤РШ
 * @author     QQ:3440895
 * @version    CVS: $Id: ImageMagickTool.php,v 1.4 2006/10/25 14:22:38 arzen Exp $
 */
set_time_limit(0);
define('APF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..'));
require_once APF_ROOT_DIR . DIRECTORY_SEPARATOR . 'init.php';
require_once 'File/Find.php';
require_once $ClassDir . 'ImageMagickUtility.class.php';
//$source_name = 'C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg';
//$string = "testing";
//$save_name = "D:/www/tools/Water lilies.jpg";
//ImageMagickUtility::addText($source_name,$string,$save_name);
//ImageMagickUtility::resize($source_name,0,120);
$dir = 'D:/м╪ф╛/дою╔и╫ф╞аВ2006-8-15/';
list($directories, $files) = File_Find::maptree($dir);
$x = 0;
foreach ($files as $image_file) {
    if (eregi("(.*)jpg|gif\$", $image_file)) {
        $source_name = $image_file;
        $file_arr = pathinfo($source_name);
        $dir_name = $file_arr["dirname"];
        $exten_name = $file_arr["extension"];
        $base_name = basename($file_arr["basename"], "." . $exten_name);
        $save_name = $dir_name . "/resize_" . $base_name . "." . $exten_name;
        ImageMagickUtility::resize($source_name, 0, 120, $save_name);
        echo $x . " {$save_name} [OK] \n";
        $x++;
    }
}
Beispiel #15
0
 /**
  * Search the specified directory tree with the specified pattern.  Return an
  * array containing all matching files (no directories included).
  *
  * @param string $pattern the pattern to match every file with.
  *
  * @param string $directory the directory tree to search in.
  *
  * @param string $type the type of regular expression support to use, either
  * 'php' or 'perl'.
  *
  * @return array a list of files matching the pattern parameter in the the directory
  * path specified by the directory parameter
  *
  * @author Sterling Hughes <*****@*****.**>
  * @access public
  */
 function &search($pattern, $directory, $type = 'php')
 {
     $matches = array();
     list(, $files) = File_Find::maptree($directory);
     $match_function = File_Find::_determineRegex($pattern, $type);
     reset($files);
     while (list(, $entry) = each($files)) {
         if ($match_function($pattern, $entry)) {
             $matches[] = $entry;
         }
     }
     return $matches;
 }
Beispiel #16
0
 /**
  * Search the specified directory tree with the specified pattern.  Return
  * an array containing all matching files (no directories included).
  *
  * @param string $pattern the pattern to match every file with.
  *
  * @param string $directory the directory tree to search in.
  *
  * @param string $type the type of regular expression support to use, either
  * 'php' or 'perl'.
  *
  * @param bool $fullpath whether the regex should be matched against the
  * full path or only against the filename
  *
  * @return array a list of files matching the pattern parameter in the the
  * directory path specified by the directory parameter
  *
  * @author Sterling Hughes <*****@*****.**>
  * @access public
  */
 function &search($pattern, $directory, $type = 'php', $fullpath = true)
 {
     /* if called statically */
     /* TODO: this will fail if File_Find::search() is called inside */
     /* instance of some other object                                */
     if (!isset($this)) {
         $obj =& new File_Find();
         return $obj->search($pattern, $directory, $type, $fullpath);
     } else {
         $matches = array();
         list(, $files) = File_Find::maptree($directory);
         $match_function = File_Find::_determineRegex($pattern, $type);
         reset($files);
         while (list(, $entry) = each($files)) {
             if ($match_function($pattern, $fullpath ? $entry : basename($entry))) {
                 $matches[] = $entry;
             }
         }
     }
     return $matches;
 }