modified: application/common/behavior/ModuleTest.php

modified:   application/index/config.php
	modified:   application/index/controller/Index.php
	modified:   tree.php
master
fengyuexingzi 8 years ago
parent 27b47652b7
commit 1c3ae151c2

@ -15,7 +15,7 @@ class ModuleTest
{ {
public function run() public function run()
{ {
$arr = Config::get('template'); /* $arr = Config::get('template');
$arr = array_merge($arr, [ $arr = array_merge($arr, [
// 模板引擎类型 支持 php think 支持扩展 // 模板引擎类型 支持 php think 支持扩展
'type' => 'Think', 'type' => 'Think',
@ -35,6 +35,6 @@ class ModuleTest
'taglib_end' => '}', 'taglib_end' => '}',
//'taglib_pre_load' => 'app\common\Tree', //'taglib_pre_load' => 'app\common\Tree',
]); ]);
Config::set(['template' => $arr]); Config::set(['template' => $arr]);*/
} }
} }

@ -10,7 +10,7 @@ return [
// 模板引擎类型 支持 php think 支持扩展 // 模板引擎类型 支持 php think 支持扩展
'type' => 'Think', 'type' => 'Think',
// 模板路径 // 模板路径
'view_path' => __DIR__ . '/../../themes/blue/', 'view_path' => '../themes/blue/',
// 模板后缀 // 模板后缀
'view_suffix' => 'html', 'view_suffix' => 'html',
// 模板文件名分隔符 // 模板文件名分隔符

@ -8,10 +8,26 @@ class Index extends Base
{ {
public function index() 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('__LIST__', [1, 2, 3]);
$this->assign('demo_time', $this->request->time()); $this->assign('demo_time', $this->request->time());
$this->assign('demo_name', 'king'); $this->assign('demo_name', 'king');
$this->assign('key', 'demo'); $this->assign('key', 'demo');
return $this->fetch(); return $this->fetch();
} }
public function tree()
{
}
} }

@ -4,4 +4,78 @@
* User: Wind * User: Wind
* Date: 2017/10/25 * Date: 2017/10/25
* Time: 13:46 * Time: 13:46
*/ */
$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 '<pre>';
print_r(m_tree($test_data));
echo '</pre>';
die;
function tree($directory)
{
$mydir = dir($directory);
echo "<ul>\n";
while ($file = $mydir->read()) {
if ($directory == '/') {
$child = $directory . $file;
} else {
$child = "$directory/$file";
}
if ((is_dir($child)) AND ($file != ".") AND ($file != "..") AND ($file != '$RECYCLE.BIN') AND ($file != 'System Volume Information')) {
var_dump("directory: " . $child);
echo "<li><font color=\"#ff00cc\"><b>$file</b></font></li>\n";
tree($child);
} else
echo "<li>$file</li>\n";
}
echo "</ul>\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();

Loading…
Cancel
Save