Bas wrote:
> I have my second program:
>
> Filemanager!!!
>
> It contains 2 files(this files are in the admin directory of
> the folder meant in the showindex.php file($dir)):
>
> showindex.php
> ---
> <?php
> $dir = "/pub/publicfiles/"; // Change this to your situation
>
> $dp = opendir($dir);
>
> $filenames = array();
>
> while($file = readdir($dp))
> {
> array_push($filenames, $file);
> }
>
> // Compile an array of the files
> for($i = 0; $i < count($filenames); $i ++)
> {
> if(!(is_dir("$dir/$filenames[$i]")))
> {
> //echo $filenames[$i]."<br>";
> echo "<A
> HREF=\"filemanager.php?pid=open&file=".$filenames[$i]."\">".$f
> ilenames[$i]." </a><br>";
> }
> }
>>
> ---
>
> filemanager.php
>
> ---
> <?php
> /*
> Filemanager v1.0
> v1.0 First Release
> */
> $filename = $_GET['file']; // Read filename from url
> if ($_GET['pid'] == 'open') {
> echo "<HTML><HEAD><TITLE>".$filename."</title></head>"; // echo
> HTML-code echo "<body><h1>Contents of $filename</h1><br>"; /
more
> code $filecontents = nl2br(file_get_contents('../'.$filename));
> // Read contents of file echo $filecontents; echo "<br><a
> href=\"filemanager.php?pid=edit&file=$filename\">Edit</a>"; }
> if ($_GET['pid'] == 'edit') {
> echo "<HTML><HEAD><TITLE>Edit ".$filename."</title></head>";
> $filecontents = file_get_contents('../'.$filename);
> echo "<body><h1>Edit $filename</h1><br>";
> echo "<form name=form
> action=\"filemanager.php?pid=edit2&file=$filename\" method=post>";
> echo "<textarea name=file cols=60
> rows=30>$filecontents</textarea>";
> echo "<input type=submit value=Submit>";
> echo "</form>";
> }
> if ($_GET['pid'] == 'edit2') {
> $newcontent = $_POST['file'];
> echo "<HTML><HEAD><TITLE>$filename</title></head>";
> $file = fopen("../".$filename, "w+");
> $result = fwrite($file, $newcontent);
> echo "<body>Resultaat".$result;
> echo "<br><a
> href=\"filemanager.php?pid=open&file=$filename\">Open</a>";
> fclose($file); }
> echo "<br><br><br><small>Copyright Bas</small></body></html>"; ?>
---
> Change $dir to your dir
> / is the root dir of your harddisk
>
> If you have any improvements(not deleting files, i have
> planned that already), Post or mail me!!!
>
> You can run it with showindex.php and from there it runs
> filemanager.php.
>
> I would like it if you make a p[osibbility to add files(with the
same
> structure)
>
> Regards,
>
> Bas
Just my experience... I had a very nice program like this.. Had it
protected with htaccess... Someone got into it somehow.. I don't know
if it was on the inside or outside, but they really messed up my
machine.. Had to reload Redhat.... :-(
Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php