当前位置: 首页>>代码示例>>PHP>>正文


PHP Dir类代码示例

本文整理汇总了PHP中Dir的典型用法代码示例。如果您正苦于以下问题:PHP Dir类的具体用法?PHP Dir怎么用?PHP Dir使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Dir类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 function add()
 {
     if (Upload::isUploadSuccessful("my_file")) {
         $peer = new ImmaginiPeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $d = new Dir("/immagini/user/" . Session::get("/session/username") . Params::get("folder"));
         if (!$d->exists()) {
             $d->touch();
         }
         $do->save_folder = $d->getPath();
         $do->real_name = Upload::getRealFilename("my_file");
         $do->folder = Params::get("folder");
         $tokens = explode(".", Upload::getRealFilename("my_file"));
         $extension = $tokens[count($tokens) - 1];
         $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
         Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
         $peer->save($do);
         if (is_html()) {
             Flash::ok("Immagine aggiunta con successo.");
             return Redirect::success();
         } else {
             return ActiveRecordUtils::toArray($do);
         }
     } else {
         Flash::error(Upload::getUploadError("my_file"));
         return Redirect::failure();
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:ImmaginiController.class.php

示例2: getAllExpression

 public function getAllExpression($flush = false)
 {
     $cache_id = '_model_expression';
     if (($res = F($cache_id)) === false || $flush === true) {
         global $ts;
         $pkg = $ts['site']['expression'];
         $filepath = SITE_PATH . '/public/themes/' . $ts['site']['site_theme'] . '/images/expression/' . $pkg;
         require_once ADDON_PATH . '/libs/Io/Dir.class.php';
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         foreach ($expression_pkg as $value) {
             if (!is_utf8($value['filename'])) {
                 $value['filename'] = auto_charset($value['filename'], 'GBK', 'UTF8');
             }
             list($file) = explode(".", $value['filename']);
             $temp['title'] = $file;
             $temp['emotion'] = '[' . $file . ']';
             $temp['filename'] = $value['filename'];
             $temp['type'] = $pkg;
             $res[$temp['emotion']] = $temp;
         }
         F($cache_id, $res);
     }
     return $res;
 }
开发者ID:armebayelm,项目名称:thinksns-vietnam,代码行数:26,代码来源:ExpressionModel.class.php

示例3: templateNames

 /**
  *	Return possible template names that can be used by the nodes
  *	for rendering by listing all files from the node view directory
  *	
  * 	@return array(string)
  */
 public function templateNames()
 {
     $templateNames = new IndexedArray();
     // get correct template directory from appcontroller’s theme
     $r = get_class_vars('AppController');
     if (empty($r['theme'])) {
         $templateDir = VIEW_DIR . 'node/';
     } else {
         $templateDir = VIEW_DIR . 'theme/' . $r['theme'] . '/node/';
     }
     // list files
     $dir = new Dir($templateDir);
     foreach ($dir->read('@\\.php$@') as $file) {
         if (!$file->isFile()) {
             continue;
         }
         // ignore directories
         if (in_array($file->basename(false), array())) {
             continue;
         }
         // ignore files?
         $templateNames[$file->basename(false)] = $file->basename(false);
     }
     return $templateNames->toArray();
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:31,代码来源:AdminNodeForm.php

示例4: add

 function add()
 {
     ini_set('upload_max_filesize', 8388608 * 4);
     if (Upload::isUploadSuccessful("my_file")) {
         $peer = new DocumentiPeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $d = new Dir("/documenti/user/" . Session::get("/session/username") . "/contenuti/");
         if (!$d->exists()) {
             $d->touch();
         }
         $do->save_folder = $d->getPath();
         $do->real_name = Upload::getRealFilename("my_file");
         $do->folder = Params::get("folder");
         $tokens = explode(".", Upload::getRealFilename("my_file"));
         $extension = $tokens[count($tokens) - 1];
         $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
         Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
         $peer->save($do);
         Flash::ok("Documento aggiunto con successo.");
         return Redirect::success();
     } else {
         return Redirect::failure(Upload::getUploadError("my_file"));
     }
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:25,代码来源:DocumentiController.class.php

示例5: randomFromFolder

 static function randomFromFolder($path, $autocache = true, $include_sub_dirs = false)
 {
     $dir = new Dir($path);
     if (!$dir->exists()) {
         Log::error("FileUtils::randomFromFolder", "La cartella {$path} non esiste!!");
     }
     if (!$dir->isDir()) {
         Log::error("FileUtils::randomFromFolder", "Il percorso {$path} non rappresenta una cartella!!");
     }
     $results = $dir->listFiles();
     $valid_results = array();
     foreach ($results as $dir_elem) {
         if ($dir_elem->isDir() && $include_sub_dirs) {
             $valid_results[] = $dir_elem;
         }
         if ($dir_elem->isFile()) {
             $valid_results[] = $dir_elem;
         }
     }
     if (count($valid_results) == 0) {
         Log::error("FileUtils::randomFromFolder", "Non sono stati trovati risultati validi!!");
     }
     $selected = $valid_results[rand(0, count($valid_results) - 1)];
     $final_result = $selected->getPath();
     if ($autocache) {
         $final_result .= "?mtime=" . $selected->getModificationTime();
     }
     return $final_result;
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:29,代码来源:FileUtils.class.php

示例6: testProps

 function testProps()
 {
     $storage_test_root = "/" . FRAMEWORK_CORE_PATH . "tests/io/storage_dir/";
     Storage::set_storage_root($storage_test_root);
     $test_file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/file_props_test.php");
     $this->assertFalse($test_file->hasStoredProps(), "Il file ha delle proprieta' con lo storage vuoto!!");
     $storage = $test_file->getStoredProps();
     $storage->add("test", array("hello" => 1, "world" => "good"));
     $this->assertTrue($test_file->hasStoredProps(), "Il file storage delle proprieta' non e' stato creato!!");
     $file_path = $test_file->getPath();
     $sum = md5($file_path);
     $store_subdir = "_" . substr($sum, 0, 1);
     $storage_test_root_dir = new Dir($storage_test_root);
     $real_store_dir = $storage_test_root_dir->getSingleSubdir();
     $all_dirs = $real_store_dir->listFiles();
     $props_file_dir = $all_dirs[0];
     $this->assertEqual($props_file_dir->getName(), $store_subdir, "La directory creata non corrisponde!!");
     $final_stored_path = new File($real_store_dir->getPath() . $props_file_dir->getName() . DS . $sum . ".ini");
     $this->assertTrue($final_stored_path->exists(), "Il file finale delle props non e' stato trovato!!");
     $test_file->deleteStoredProps();
     $this->assertFalse($test_file->hasStoredProps(), "Il file delle proprieta' non e' stato eliminato!!");
     $all_files = $real_store_dir->listFiles();
     foreach ($all_files as $f) {
         $f->delete(true);
     }
     Storage::set_storage_root(Storage::get_default_storage_root());
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:27,代码来源:file_props_test.php

示例7: cache

 public function cache()
 {
     if (isset($_GET['type'])) {
         $Dir = new \Dir();
         $cache = D('Common/Cache');
         $type = I('get.type');
         switch ($type) {
             case "template":
                 //删除缓存目录下的文件
                 $Dir->del(RUNTIME_PATH);
                 $Dir->delDir(RUNTIME_PATH . "Cache/");
                 $Dir->delDir(RUNTIME_PATH . "Temp/");
                 //更新开启其他方式的缓存
                 \Think\Cache::getInstance()->clear();
                 $this->success("模板缓存清理成功!", U('Index/cache'));
                 break;
             case "logs":
                 $Dir->delDir(RUNTIME_PATH . "Logs/");
                 $this->success("站点日志清理成功!", U('Index/cache'));
                 break;
             default:
                 $this->error("请选择清楚缓存类型!");
                 break;
         }
     } else {
         $this->display();
     }
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:28,代码来源:IndexController.class.php

示例8: add

 public function add()
 {
     $dao = D("App");
     import('ORG.Io.Dir');
     if ($_REQUEST['appname']) {
         // 添加内容的页面
         $strAppname = h($_GET['appname']);
         $result = $dao->where("url='{$strAppname}'")->count();
         if ($result) {
             $this->error('此应用已安装过');
             exit;
         } else {
             $appConfig = (require SITE_PATH . '/apps/' . $strAppname . '/appinfo/config.php');
         }
         $this->assign('appConfig', $appConfig);
         $this->assign('selected', 'true');
     } else {
         $pDir = new Dir(SITE_PATH . '/apps/');
         $arrDirs = $pDir->toArray();
         $applist = $dao->findall();
         foreach ($applist as $value) {
             $apps[] = $value['enname'];
         }
         foreach ($arrDirs as $value) {
             if (!in_array($value['filename'], $apps) && is_file($value['pathname'] . '/appinfo/config.php')) {
                 $config = (include $value['pathname'] . '/appinfo/config.php');
                 $config['icon'] = str_replace('http://{APP_URL}', SITE_URL . '/apps/' . $value['filename'], $config['icon']);
                 $appList[$value['filename']] = $config;
             }
         }
         $this->assign('appList', $appList);
     }
     $this->display();
 }
开发者ID:wangping1987,项目名称:dhfriendluck,代码行数:34,代码来源:AppManageAction.class.php

示例9: getTemplates

 function getTemplates($path = false)
 {
     if (!$path) {
         $path = 'inc/html/' . conf('Server', 'default_template_set');
     }
     $templates = array('' => 'Inherit', 'default' => 'Default');
     loader_import('saf.File.Directory');
     $dir = new Dir();
     if (!$dir->open($path)) {
         return $templates;
     }
     foreach ($dir->read_all() as $file) {
         if (strpos($file, '.') === 0 || @is_dir($path . '/' . $file)) {
             continue;
         }
         if (preg_match('/^html.([^\\.]+)\\.tpl$/', $file, $regs)) {
             if ($regs[1] == 'default') {
                 continue;
             }
             $templates[$regs[1]] = ucfirst($regs[1]);
         }
     }
     asort($templates);
     return $templates;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:25,代码来源:Templates.php

示例10: getAllExpression

 /**
  * 获取当前所有的表情
  * @param boolean $flush 是否更新缓存,默认为false
  * @return array 返回表情数据
  */
 public function getAllExpression($flush = false)
 {
     $cache_id = '_model_expression';
     if (($res = S($cache_id)) === false || $flush === true) {
         global $ts;
         // $pkg = $ts['site']['expression'];
         $pkg = 'miniblog';
         //TODO 临时写死
         $filepath = THEME_PUBLIC_PATH . '/image/expression/' . $pkg;
         require_once ADDON_PATH . '/library/io/Dir.class.php';
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         foreach ($expression_pkg as $value) {
             /*				
                             if(!is_utf8($value['filename'])){
             					$value['filename'] = auto_charset($value['filename'],'GBK','UTF8');
             				}*/
             list($file) = explode(".", $value['filename']);
             $temp['title'] = $file;
             $temp['emotion'] = '[' . $file . ']';
             $temp['filename'] = $value['filename'];
             $temp['type'] = $pkg;
             $res[$temp['emotion']] = $temp;
         }
         S($cache_id, $res);
     }
     return $res;
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:34,代码来源:ExpressionModel.class.php

示例11: index

 public function index()
 {
     $config_file = CONF_PATH . 'index/config.php';
     $config = (include $config_file);
     if ($dirname = $this->_get('dirname', 'trim')) {
         $config['DEFAULT_THEME'] = $dirname;
         file_put_contents($config_file, "<?php \nreturn " . var_export($config, true) . ";", LOCK_EX);
         $obj_dir = new Dir();
         is_dir(CACHE_PATH . 'index/') && $obj_dir->delDir(CACHE_PATH . 'index/');
         @unlink(RUNTIME_FILE);
     }
     $tpl_dir = TMPL_PATH . 'index/';
     $opdir = dir($tpl_dir);
     $template_list = array();
     while (false !== ($entry = $opdir->read())) {
         if ($entry[0] == '.') {
             continue;
         }
         if (!is_file($tpl_dir . $entry . '/info.php')) {
             continue;
         }
         $info = (include_once $tpl_dir . $entry . '/info.php');
         $info['preview'] = TMPL_PATH . 'index/' . $entry . '/preview.gif';
         $info['dirname'] = $entry;
         $template_list[$entry] = $info;
     }
     $this->assign('template_list', $template_list);
     $this->assign('def_tpl', $config['DEFAULT_THEME']);
     $this->display();
 }
开发者ID:leamiko,项目名称:9k9,代码行数:30,代码来源:templateAction.class.php

示例12: show

 public function show()
 {
     $dirpath = $this->dirpath();
     $dirup = $this->dirup();
     import("ORG.Io.Dir");
     $dir = new Dir($dirpath);
     $dirlist = $dir->toArray();
     if (strpos($dirup, 'Template') > 0) {
         $this->assign('dirup', $dirup);
     }
     if (empty($dirlist)) {
         $this->error('该文件夹下面没有任何文件!');
     }
     if ($_GET['mytpl']) {
         foreach ($dirlist as $key => $value) {
             if (strpos($value['filename'], 'my_') === false) {
                 unset($dirlist[$key]);
             }
         }
     }
     $_SESSION['tpl_reurl'] = C('cms_admin') . '?s=Admin/Tpl/Show/id/' . str_replace('/', '*', $dirpath);
     if ($dirup && $dirup != '.') {
         $this->assign('dirup', $dirup);
     }
     $this->assign('mytpl', $_GET['mytpl']);
     $this->assign('dir', list_sort_by($dirlist, 'mtime', 'desc'));
     $this->assign('dirpath', $dirpath);
     $this->display('./views/admin/tpl_show.html');
 }
开发者ID:skygunner,项目名称:ekucms,代码行数:29,代码来源:TplAction.class.php

示例13: help_walker

/**
 * Walks through the boxes or forms folders and recursively builds a $list of found actions.
 *
 * @param string
 * @param string
 * @param string
 * @param array
 * @return boolean
 *
 */
function help_walker($appname, $type = 'boxes', $directory, &$list)
{
    $dir = new Dir($directory);
    if (!$dir->handle) {
        return false;
    }
    foreach ($dir->read_all() as $file) {
        if (strpos($file, '.') === 0 || $file == 'CVS') {
            continue;
        } elseif (@is_dir($directory . '/' . $file)) {
            $name = str_replace(getcwd() . '/inc/app/' . $appname . '/' . $type . '/', '', $directory . '/' . $file);
            $box = array('name' => $name, 'alt' => ucfirst(basename($name)), $type => array(), 'is_dir' => false);
            if (!@file_exists($directory . '/' . $file . '/index.php')) {
                $box['is_dir'] = true;
            } else {
                if ($type == 'boxes' && @file_exists($directory . '/' . $file . '/settings.php')) {
                    $settings = ini_parse($directory . '/' . $file . '/settings.php');
                    $box['alt'] = $settings['Meta']['name'];
                }
            }
            $list[$name] = $box;
            help_walker($appname, $type, $directory . '/' . $file, $list[$name][$type]);
        }
    }
    return true;
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:36,代码来源:functions.php

示例14: testCompressUncompress

 function testCompressUncompress()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $f->delete();
     FFArchive::compress($f, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/data/"));
     $ext_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/");
     $ext_dir->touch();
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $this->assertTrue($f->exists(), "Il file da decomprimere non esiste!!");
     FFArchive::extract($f, $ext_dir);
     $f1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/cartella.png");
     $this->assertTrue($f1->exists(), "Il file cartella.png non e' stato estratto!!");
     $this->assertEqual($f1->getSize(), 441, "La dimensione di cartella.png non corrisponde!!");
     $f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file1.txt");
     $this->assertTrue($f2->exists(), "Il file file1.txt non e' stato estratto!!");
     $f3 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file2.dat");
     $this->assertTrue($f3->exists(), "Il file file2.dat non e' stato estratto!!");
     $d1 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/empty_folder");
     $this->assertTrue($d1->exists(), "La cartella vuota non e' stata estratta!!");
     $d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder");
     $this->assertTrue($d2->exists(), "La cartella folder non e' stata estratta!!");
     $f4 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder/sub/yep.txt");
     $this->assertTrue($f4->exists(), "Il file yep.txt non e' stato estratto!!");
     $this->assertEqual($f4->getSize(), 10, "La dimensione di yep.txt non corrisponde!!");
     $this->assertTrue($ext_dir->delete(true), "La directory coi file estratti non e' stata elimintata!!");
     $this->assertFalse($f1->exists(), "Il file cartella.png esiste ancora!!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:27,代码来源:ffarchive_test.php

示例15: getThemes

 function getThemes($path = false)
 {
     if (!$path) {
         $path = site_docroot() . '/inc/app/sitepresenter/themes';
     }
     $themes = array();
     //'' => 'Default');
     loader_import('saf.File.Directory');
     $dir = new Dir();
     if (!$dir->open($path)) {
         return $themes;
     }
     foreach ($dir->read_all() as $file) {
         if (strpos($file, '.') === 0 || !@is_dir($path . '/' . $file)) {
             continue;
         }
         //if (preg_match ('/^html.([^\.]+)\.tpl$/', $file, $regs)) {
         //if ($regs[1] == 'default') {
         //	continue;
         //}
         $themes[$file] = ucfirst($file);
         //}
     }
     return $themes;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:25,代码来源:Theme.php


注:本文中的Dir类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。