From 1c3ae151c254579f9f638c83b625b0154ced5f2f Mon Sep 17 00:00:00 2001 From: fengyuexingzi Date: Wed, 25 Oct 2017 17:43:44 +0800 Subject: [PATCH] modified: application/common/behavior/ModuleTest.php modified: application/index/config.php modified: application/index/controller/Index.php modified: tree.php --- application/common/behavior/ModuleTest.php | 4 +- application/index/config.php | 2 +- application/index/controller/Index.php | 16 +++++ tree.php | 76 +++++++++++++++++++++- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/application/common/behavior/ModuleTest.php b/application/common/behavior/ModuleTest.php index d35ddba..aadff58 100644 --- a/application/common/behavior/ModuleTest.php +++ b/application/common/behavior/ModuleTest.php @@ -15,7 +15,7 @@ class ModuleTest { public function run() { - $arr = Config::get('template'); + /* $arr = Config::get('template'); $arr = array_merge($arr, [ // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', @@ -35,6 +35,6 @@ class ModuleTest 'taglib_end' => '}', //'taglib_pre_load' => 'app\common\Tree', ]); - Config::set(['template' => $arr]); + Config::set(['template' => $arr]);*/ } } \ No newline at end of file diff --git a/application/index/config.php b/application/index/config.php index 3e67685..3d5ebf0 100644 --- a/application/index/config.php +++ b/application/index/config.php @@ -10,7 +10,7 @@ return [ // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', // 模板路径 - 'view_path' => __DIR__ . '/../../themes/blue/', + 'view_path' => '../themes/blue/', // 模板后缀 'view_suffix' => 'html', // 模板文件名分隔符 diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 5cab541..f4722e8 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -8,10 +8,26 @@ class Index extends Base { public function index() { + /** + * getcwd() + * + */ + + var_dump(getcwd()); + var_dump($_SERVER['PHP_SELF']); + var_dump($_SERVER['DOCUMENT_ROOT']); + var_dump(__DIR__); + + $this->assign('__LIST__', [1, 2, 3]); $this->assign('demo_time', $this->request->time()); $this->assign('demo_name', 'king'); $this->assign('key', 'demo'); return $this->fetch(); } + + public function tree() + { + + } } diff --git a/tree.php b/tree.php index 630797b..78803aa 100644 --- a/tree.php +++ b/tree.php @@ -4,4 +4,78 @@ * User: Wind * Date: 2017/10/25 * Time: 13:46 - */ \ No newline at end of file + */ + + +$test_data = [ + ['id' => 0, 'name' => 'A'], + ['id' => 1, 'name' => 'a', 'pid' => 0], + ['id' => 2, 'name' => 'b', 'pid' => 1], + ['id' => 3, 'name' => 'c', 'pid' => 1], + ['id' => 4, 'name' => 'd', 'pid' => 0], + ['id' => 5, 'name' => 'e', 'pid' => 4], +]; +function m_tree($arr, $pid = 0) +{ + $tree = []; + foreach ($arr as $tmp) { + if (!isset($tmp['pid'])) { + $tree[] = $tmp; + } elseif($tmp['pid'] == $pid){ + $tree[$pid][$tmp['id']] = $tmp; + } /*else { + if ($tmp['pid'] > $pid) + $tree[$pid][] = m_tree($arr, $tmp['pid']); + }*/ + } + return $tree; +} + +echo '
';
+print_r(m_tree($test_data));
+echo '
'; +die; + +function tree($directory) +{ + $mydir = dir($directory); + echo "\n"; + $mydir->close(); +} + +function getChmod($filepath) +{ + return substr(base_convert(@fileperms($filepath), 10, 8), -4); +} + +$dirs = tree('/'); + +var_dump($dirs); + +var_dump(is_writable('/test')); + +$perms = getChmod('/test/'); +var_dump(fileperms('/test')); + +var_dump(scandir('/')); +var_dump($_SERVER['DOCUMENT_ROOT']); +chdir('d:/www'); +var_dump(scandir('/')); +echo getcwd(); + + +