Webpage Editor VERSION 2 - UPDATED

By F*U*R*B*Y* on Jun 23, 2007

Ok, who here has a host which is gay and makes you go through like 4/5 pages to get to your site to edit? Well this way, you can just visit one page and edit it.

Just upload and visit.

SUGGESTION

Add a encryptor, i use 18 diffrent cookies which is pretty hard to get around.

<?php
echo  "<body align='center'>";
if (isset($_GET[dir])) {
echo "<form name='edit' action='$PHP_SELF?dir='.$_GET[dir].'' method='POST'>";
echo "<input type='hidden' name='dir' value='$_GET[dir]'>";
}else {
echo "<form name='edit' action='$PHP_SELF' method='POST'>";
echo "<input type='hidden' name='dir' value='./'>";
}
echo "<input type='text' value='page' name='page'><br><input type='radio' name='file' value='makepage'>Make a Page<input type='radio' name='file' value='delpage'>Delete a Page<br><input value="submit" type="submit"></form>";
function list_files($dir)
{
  if(is_dir($dir))
  {
    if($handle = opendir($dir))
    {
      while($file = readdir($handle))
      {
        if($file != "." && $file != "..")
        {
          if (!strtolower(strrchr($file,"."))) {
            if (isset($_GET[dir])) {
              echo '<br><a href="edit.php?dir='.$_GET[dir].''.$file.'">'.$file.'</a>';
            }else {
              echo '<br><a href="edit.php?dir='.$_GET[dir].''.$file.'">'.$file.'</a>';
            }
          }else {
            echo '<br><a href="?open='.$file.'">'.$file.'</a>';
          }
        }
      }
      closedir($handle);
    }
  }
}

//Use this to make a page

if (isset($_POST[file])) {
  if ($_POST[file] == makepage) {
    $dir = $_POST[dir];
    $file = $_POST[page];
    if($handle = opendir($dir)) {
      if (file_exists($_GET[dir] . "/$file")) {
        echo "Folder or file '$file' already exists!";
      }elseif(fopen($_GET[dir] . "/$file", 'w')) {
        echo "New file '$file' created";
      }else {
        echo "Error: Can't create new file '$file'!";
      }
    }
    elseif(file_exists($file)) {
      echo "Folder or file '$file' already exists!";
    }elseif(fopen($file,"w")) {
      echo "New file '$file' created";
    }else {
      echo "Error: Can't create new file '$file'!";
    }
  }else {
    $file = $_POST[page];
    if(!file_exists($file)) { echo "Error: File '$file' does not exist!"; }
    else if(unlink($file)) { echo "File: '$file' deleted succesfully"; }
  }
}

if (isset($_POST['save'])) {
  $file = stripslashes($_POST[save]);
  $handle = fopen($_GET['open'],'w');
  fwrite($handle, $file);
  echo "Successfully wrote to $_GET[open]";
}elseif (isset($_GET['open'])) {
  echo "<h3>$_GET[dir] $_GET[open]</h3>";
  echo "<br><br>";
  echo "<form name='save' method='post' action='edit.php?open=$_GET[open]'>";
  echo "<textarea rows=20 cols=100% name='save'>".htmlspecialchars(file_get_contents($_GET['open']))."</textarea>";
  echo "<br><input type='Submit' value='Save'>";
}if (isset($_GET[dir]) && !isset($_GET[open])) {
  list_files("./$_GET[dir]");
}else {
  list_files("./");
}
?>

Comments

Sign in to comment.
skytech   -  Mar 25, 2008

pls can any body here instruct me on how to use this webpage code snippet becoz i install it and it brought back page cannot be found,pls help out and how can i integrate it to each page of my site in order to edit them.

 Respond  
F*U*R*B*Y*   -  Feb 20, 2008

yeah uh working on VERSION 3

 Respond  
Undefined_Variable   -  Feb 20, 2008

You need to add \\'s before the (\")\'s because the code is seeing them as variables and directories because it\'s not commented out or w/e

 Respond  
F*U*R*B*Y*   -  Aug 15, 2007

oh v2.2 then :P i better change the script :P thanks for pointing that out :P, and next version in about under a week :P

 Respond  
F*U*R*B*Y*   -  Aug 14, 2007

i\'m making the next version at the moment, nearly completed

 Respond  
Snipe   -  Aug 13, 2007

Hey Furby did you make a new version that you havnt released yet? And i\'ll send you my copy of mine.

 Respond  
F*U*R*B*Y*   -  Aug 11, 2007

pm me the script and i\'ll try it out, but thanks for the feedback

 Respond  
Snipe   -  Aug 10, 2007

Furby please reply, thanks.

 Respond  
Snipe   -  Aug 10, 2007

Hey I liked this script just I had some problems with it, like when I went to edit a new page inside a folder, it would give me errors...not sure why, but maybe I can fix it, also I started playing around with it, and i think I made it better and easy to use. Tell me if you want a copy of it :)

 Respond  
peterpowell   -  Aug 10, 2007

i would pass everything through htmlentities(); when saving and html_entity_decode(); when loading it into the editor

;)

-PP

 Respond  
tehtacoking   -  Jul 18, 2007

hmm, you haven\'t fixed the bug yet :S
cool.php got saved to the base of drive e:\

 Respond  
sharpknife   -  Jul 17, 2007

great idea.. but I\'d rather not risk it

 Respond  
F*U*R*B*Y*   -  Jul 17, 2007

but none the less fixed :P

 Respond  
F*U*R*B*Y*   -  Jul 17, 2007

hmm when i hit edit and then save it changed all my \\" to \"

 Respond  
Earl   -  Jul 16, 2007

I\'m sorry dude but I believe some of your coding is not 100% correct yet, now you\'re generating tstring errors starting at line three.

 Respond  
F*U*R*B*Y*   -  Jul 16, 2007

Thanks, fixed

 Respond  
Earl   -  Jul 15, 2007

I added a session login system to mine. I found a bug, when you go into another directory that has same file names to the prior folder of where the edit.php file is, it\'ll open the file in the main directory.

 Respond  
Hawkee   -  Jul 07, 2007

This is still a major security risk. Definitely don\'t use this unless you absolutely know what you\'re doing. Furby, I suggest you add a login and password feature that requires the session before any files are created, edited or deleted.

 Respond  
F*U*R*B*Y*   -  Jul 07, 2007

thanks for pointing that out, fixed.

 Respond  
tehtacoking   -  Jul 07, 2007

MAJOR security risk dude,
http://webtastix.co.nz/tehtaco.php
(i didn\'t do anything bad...just proving a point)

 Respond  
F*U*R*B*Y*   -  Jul 03, 2007

Oh ya, i know its not alot on looks, but i\'m making a design for it

So please don\'t criticize me on the design side of it. I\'m more after the coding points and that :D

 Respond  
F*U*R*B*Y*   -  Jul 03, 2007

UPDATED, This is Version 2, i\'m pretty sure it all works, but not a 100% certain on the save, but the rest works, now can go into sub dir/folders, and so on and forth, edit stuff from sub dir(not sure if it saves) so please tell me if it doesn\'t save, it kept saying didn\'t have correct privilege\'s but it did so i dunno

 Respond  
F*U*R*B*Y*   -  Jul 01, 2007

[quote=[M]ike]Pretty nifty, it\'s always nice to have an online control panel, means you can give other users a way to edit/update your site. Maybe add a member system with rites, so that some users can edit more than others etc. etc. Could become a very nice and popular Admin Control Panel script. Good job so far Furby.[/quote]

you can give other users a way to edit/update your site. --- Not reckon mended if some noob gets your site, they could get your account banned.

Maybe add a member system with rites, so that some users can edit more than others etc. etc. --- Reffer to above problem, and also it also varies how people set up a member system, mine uses cookies but others may use sessions which mean you would need to edit script, which is what you would have to do now.....

But besides that, thanks. Version 2 nearly ready for upload, just working on Dir/Folder stuff.

 Respond  
[M]ike   -  Jun 30, 2007

Pretty nifty, it\'s always nice to have an online control panel, means you can give other users a way to edit/update your site. Maybe add a member system with rites, so that some users can edit more than others etc. etc. Could become a very nice and popular Admin Control Panel script. Good job so far Furby.

 Respond  
F*U*R*B*Y*   -  Jun 24, 2007

ya on mine, it has 5 md5\'d encrypted passwords, can not edit this file, can not edit my configuration file, can not edit my index file but everything else. Plus i always pick very carefully who i give access to and who i don\'t give access to

 Respond  
Hawkee   -  Jun 23, 2007

This can be a huge security hazard on any server. If anybody besides the administrator gains access they could potentially gain access to the server and do something malicious.

 Respond  
F*U*R*B*Y*   -  Jun 23, 2007

also you can test it at http://webtastix.co.nz/test/edit.php

 Respond  
F*U*R*B*Y*   -  Jun 23, 2007

Just as a side note it also hides the . and ..

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.