Web Editorの説明についてはWebブラウザからサーバ上のテキストファイルを編集可能に - Web Editorを見てください。
<?php /** * File Tree for Web Editor * @version 0.1.0 * @see http://0-oo.net/sbox/web-editor */ function array_get($arr, $key) { return (array_key_exists($key, $arr)) ? $arr[$key] : null; } function h($str) { return htmlspecialchars($str, ENT_QUOTES); } function u($str) { return urlencode($str); } $root = array_get($_REQUEST, 'root'); $newDir = array_get($_POST, 'dirName'); if (is_dir($root) && $newDir) { $path = $root . '/' . $newDir; if (!file_exists($path)){ mkdir($path); } $root = $path; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <title>file tree - <?php echo h($root); ?></title> </head> <body> <form action="tree.php" method="post"> <div> root directory <input type="text" name="root" value="<?php echo h($root); ?>" style="width:20em;" /> </div> </form> <hr /> <ul> <?php if (is_dir($root)) { $dh = opendir($root); while (($file = readdir($dh)) !== false) { $files[] = $file; } closedir($dh); sort($files); foreach ($files as $file) { if ($file == '.') { continue; } else if ($file == '..') { $arr = split('/', $root); if (count($arr) == 1) { continue; } array_pop($arr); $filePath = implode('/', $arr); } else { $filePath = $root . '/' . $file; } echo '<li>'; if (is_dir($filePath)) { $url = '?root=' . u($filePath); echo '<a href="' . $url . '"><strong>' . h($file) . '</strong></a>'; } else { $url = 'editor.php?path=' . u($filePath); echo '<a href="' . $url . '" target="_blank">' . h($file) . '</a>'; } echo "</li>\n"; } ?> <li> <form action="tree.php" method="post"> <div> <input type="text" name="dirName" /> <input type="hidden" name="root" value="<?php echo h($root); ?>" /> <input type="submit" value="create new directory" /> </div> </form> </li> <li><a href="editor.php?path=<?php echo u($root); ?>/" target="_blank">[ create new file ]</a></li> <?php } else { echo "<li>not found!</li>\n"; } ?> </ul> </body> </html>