Location: PHPKode > scripts > EditPHP > editphp/editphp.inc
<?php


/*
==============================================================
This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS  FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

This  file and the whole EditPHP distribution is copyright (c)
2000 Pierre Marceau all rights reserved.  You may  freely  use
and  redistribute  under the  terms of the  GNU General Public
License.
--------------------------------------------------------------
        EditPHP - http://www.skynet.ca/~pierre/
==============================================================
*/

class editphp{

// Of course you can change these setting here but it is much
// better to override the settings in the editphp.php3 file
// Even the default username and password can stay, simply
// override them in editphp.php3.
// See readme.htm for details

  var $version="1.0"; //May 16, 2000
  var $infowidth=33;
  var $infoheight=10;
  var $winwidth=740;
  var $winheight=450;
  var $ebwidth=70;
  var $ebheight=18;
  var $winmoveto="120,95";
  var $myfileextensions="(php|php3|htm|html|inc|css|js|txt|sql)\$";
  var $myrestrictedfiles="/|^\\.";
  var $mylinks=array("Home"=>"http://www.skynet.ca/~pierre/", 
                     "PHP"=>"http://www.php.net/"); 
  var $mustauthenticate=0;
  var $editphpusername="ZaoIXSbARx.YUPZSWa/KhFx2"; //pierre (encrypted)
  var $editphppassword="oIyBa5BOTlG1cDI7APAOofvY"; //finland (encrypted)
  var $expertmode=0;


/*Authen*/
  function authenticate(){
    global $PHP_AUTH_USER,
           $PHP_AUTH_PW,
           $PHP_SELF;

    switch (1){
      case (!$this->mustauthenticate)  :
        return;
      case (!function_exists("crypt")) :
        echo "Crypt function not available please set \$mustauthenticate=0";
        exit;
    }

    if (isset($PHP_AUTH_USER)&&$PHP_AUTH_USER!=""){
      $encrypted_username = crypt(substr($PHP_AUTH_USER, 0, 8),"Za");
      $encrypted_username .= substr(crypt(substr($PHP_AUTH_USER, 8, 8),"Za"),2,11);
    }else{
    $encrypted_username = "";
    }
    
    if (isset($PHP_AUTH_PW)&&$PHP_AUTH_PW!=""){
      $encrypted_password = crypt(substr($PHP_AUTH_PW, 0, 8),substr($encrypted_username,2,2));
      $encrypted_password .= substr(crypt(substr($PHP_AUTH_PW, 8, 8),substr($encrypted_username,2,2)),2,11);
    }else{
    $encrypted_password = "";
    }

    switch (true){
      case ($encrypted_username==$this->editphpusername) &&
           ($encrypted_password==$this->editphppassword) : return(true);
      case ($this->mustauthenticate) : break;
      default : return(true);
    }
    header ("WWW-authenticate: basic realm=\"EditPHP\"");
    header ("HTTP/1.0 401 Unauthorised");
    echo
    "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n",
    "<HTML><HEAD>\n",
    "<TITLE>404 Not Found</TITLE>\n",
    "</HEAD><BODY>\n",
    "<H1>Not Found</H1>\n",
    "The requested URL $PHP_SELF was ",
    "not found on this server.<P>\n",
    "</BODY>\n",
    "</HTML>\n";
    exit;
  }


/*Colours*/
  function colours() {
    global $PHP_SELF, $wrap, $cols, $fontsize, $seed;
    $this->myheader();
    echo
    "<title>\n",
    "  EditPHP v$this->version \n",
    "</title>\n",
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\" style=\"{font-family: monospace; font-size: 12pt;}\">\n",
    "<div align=\"center\">\n",
    "<table border=\"1\" width=\"92%\">\n";
    if (!isset($seed)) {
      srand(time());
      $seed=rand(100,900);
      $fontsize=12;
      $cols=2;
      $wrap="nowrap";
    }
    function randomcolor() {
      $myrandomcolor  = "#";
      for ($i=1; $i<=3; $i++) { 
        $x = rand(0,255);
        $x = dechex($x);
        $x = strtoupper($x);
        if (strlen($x) == 1) {
          $x = "0".$x;
        }
        $myrandomcolor  .= $x;
      }
      return $myrandomcolor;
    }
    srand($seed);
    for ($loops=1; $loops<6; $loops++) { 
      echo  "  <tr  style=\"{font-family: monospace; font-size: ${fontsize}pt;}\">\n";
      for ($y=0; $y<$cols; $y++) { 
        $mybgcolor = randomcolor();
        $mycolor = randomcolor();
        echo  "    <td $wrap style=\"{color: $mycolor; background-color: $mybgcolor; text-align: center;}\">\n"; 
        echo  "     <i>txt</i>: $mycolor <i>bkg</i>: $mybgcolor <i>sz</i>:$fontsize\n";
        echo  "    </td>\n\n"; 
      } 
      echo "  </tr>\n\n";
    } 
    $prevpage = $PHP_SELF."?mode=colours&wrap=$wrap&fontsize=$fontsize&cols=$cols&seed=".strval($seed-1); 
    $nextpage = $PHP_SELF."?mode=colours&wrap=$wrap&fontsize=$fontsize&cols=$cols&seed=".strval($seed+1); 
    $smallerfont = $PHP_SELF."?mode=colours&wrap=$wrap&seed=$seed&cols=$cols&fontsize=".strval($fontsize-1);
    $biggerfont = $PHP_SELF."?mode=colours&wrap=$wrap&seed=$seed&cols=$cols&fontsize=".strval($fontsize+1);
    $lesscols = $PHP_SELF."?mode=colours&wrap=$wrap&seed=$seed&fontsize=$fontsize&cols=".strval($cols-1);
    $morecols = $PHP_SELF."?mode=colours&wrap=$wrap&seed=$seed&fontsize=$fontsize&cols=".strval($cols+1);
    $wrapon = $PHP_SELF."?mode=colours&seed=$seed&fontsize=$fontsize&cols=$cols&wrap=nowrap";
    $wrapoff = $PHP_SELF."?mode=colours&seed=$seed&fontsize=$fontsize&cols=$cols";
    echo
    "</table>\n",
    "<table width=\"92%\" border=\"1\">\n",
    "<tr>\n",
    "<th>Colour chart</td>\n",
    "<th>Font size</td>\n",
    "<th>Columns</td>\n",
    "<th>Word wrap</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td align=\"center\">\n",
    "<a href=\"$prevpage\">Prev</a>\n",
    "<a href=\"$nextpage\">Next</a>\n",
    "</td>\n",
    "<td align=\"center\">\n",
    "<a href=\"$smallerfont\">(-)</a><a href=\"$biggerfont\">(+)</a>\n",
    "</td>\n",
    "<td align=\"center\">\n",
    "  <a href=\"$lesscols\">(-)</a><a href=\"$morecols\">(+)</a>\n",
    "</td>\n",
    "<td align=\"center\">\n",
    " <a href=\"$wrapoff\">On</a>\n",
    " <a href=\"$wrapon\">Off</a>\n",
    "</td>\n",
    "</tr>\n",
    "</table>\n",
    "</div>\n",
    "</body>\n",
    "</html>\n";
  }

/*Crypter*/
  function crypter(){
    global $PHP_SELF, $username, $password;
    $disableButton = "";

    $encrypted_username = "########################";
    $encrypted_password = "########################";

    if (isset($username)&&$username!=""){
      $encrypted_username = crypt(substr($username, 0, 8),"Za");
      $encrypted_username .= substr(crypt(substr($username, 8, 8),"Za"),2,11);
    }

    if (isset($password)&&$password!=""){
      $encrypted_password = crypt(substr($password, 0, 8),substr($encrypted_username,2,2));
      $encrypted_password .= substr(crypt(substr($password, 8, 8),substr($encrypted_username,2,2)),2,11);
    }

    $info = "Encrypted username:\n${encrypted_username}\n\n".
            "Encrypted password:\n${encrypted_password}";

    $this->myheader();
    echo
    "<title>\n",
    "  EditPHP v$this->version \n",
    "</title>\n",
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n<ol>\n";
    if (!function_exists("crypt")){
      $disableButton = "disabled";
      echo
      "<li><b>Notice:</b> the <b>crypt()</b> function is not available ",
      "on this PHP server. Passwords will not work! ",
      "This script will continue, so you ",
      "can see what it does, however the ENCRYPT ",
      "button has been disabled.\n";
    }
    echo
    "<li>Enter the new username and password that you would ",
    "like to have encrypted.\n",
    "<li>Press the Encrypt button.\n",
    "<li>Cut the encrypted username and password ",
    "then paste them into their appropriate places in your ",
    "editphp.php3 file.\n</ol>\n", 

    "<form method=\"post\">\n",
    "<table border=\"4\">\n",
    "<tr>\n",
      "<td>Username</td>",
      "<td><input name=\"username\"></td>",
      "<td rowspan=\"3\"><textarea readonly cols=\"35\" rows=\"6\">$info</textarea></td>",
    "</tr>",
    "<tr>",
      "<td>Password</td>",
      "<td><input name=\"password\"></td>",
    "</tr>",
    "<tr>",
      "<td colspan=\"2\" align=\"center\"><input $disableButton type=\"submit\" value=\"Encrypt\"></td>",
    "</tr></table>", 
    "</form>",
    "<p>Your username and password can be any length, however\n",
    "only the first 16 characters of each are used.\n",
    "Six or more alpha and numeric\n",
    "characters is best. If you throw in a couple\n",
    " % ^ & # @ type characters all the better. You can even use\n",
    "unprintable characters such as ß (alt-225) or ± (alt-241)\n",
    "to really thwart the cracker.\n",
    "</body>";
    $this->myfooter();
  }


/*Delete*/
  function delete(){
    global $filename, $mysubmit, $HTTP_HOST, $PHP_SELF;
    if ($this->isillegalfile($filename)){
      $this->showinfo("Illegal filename!");
      return 0;       
    }
    if (file_exists($filename)){
      if (@unlink ($filename)){
        $this->showinfo("Deleted.");
        unset ($filename);
        return 1;
      }else{
        $this->showinfo("Denied!");
        return 0;
      }
    }else{
      $this->showinfo("Not found!");
        return 0;
    }       
  }


/*IsIllegalFile*/
  function isillegalfile($myfilename=""){
    switch (1){
      case $myfilename==""                             : return 1;
      case eregi($this->myrestrictedfiles,$myfilename) : return 1;
      case !eregi($this->myfileextensions,$myfilename) : return 1;
      default : return 0;
    }
  }


/*Main*/
  function main(){
    global $filename, $mysubmit, $mode;
    $this->authenticate();
    switch (true){
      case (isset($mysubmit)) : $this->mysubmit()   ; exit;
      case (isset($mode))     : $this->mode()       ; exit;
      case (isset($filename)) : $this->showdisp()   ; break;
      default                 : $this->openwin()    ; exit;
    }
  }


/*Mode*/
  function mode(){
    global $mode;
    switch ($mode){
      case ("showdisp")   : $this->showdisp()       ; break;
      case ("showinfo")   : $this->showinfo()       ; break;
      case ("init")       : $this->showinfo("init") ; break;
      case ("showlinks")  : $this->showlinks()      ; break;
      case ("openwin")    : $this->myframebody()    ; break;
      case ("upload")     : $this->upload()         ; break;
      case ("about")      : $this->showabout()      ; break;
      case ("php_info")   : $this->showphp_info()   ; break;
      case ("print")      : $this->showprint()      ; break;
      case ("crypter")    : $this->crypter()        ; break;
      case ("colours")    : $this->colours()        ; break;
      case ("image")      : $this->myimage()        ; break;
    }
  }


/*MyFrame*/
  function myframebody(){
    global $PHP_SELF;
    $this->myheader();
    echo
    "<script>\n",
    "<!--\n";
    include ("editphp.js");
    echo
    "//-->\n",
    "</script>\n",
    "<title>\n",
    "  EditPHP v$this->version \n",
    "</title>\n",
    "</head>\n",
    "<frameset rows=\"*,$this->infoheight%\" onload=\"moveTo($this->winmoveto);\">\n",
    "  <frame src=\"$PHP_SELF?mode=showdisp\" name=\"display\" frameborder=\"0\" scrolling=\"no\" noresize>\n",
    "  <frameset cols=\"$this->infowidth%,*\">\n",
    "    <frame src=\"$PHP_SELF?mode=init\" name=\"info\" frameborder=\"0\" scrolling=\"no\" noresize>\n",
    "    <frame src=\"$PHP_SELF?mode=showlinks\" name=\"links\" frameborder=\"0\" scrolling=\"no\" noresize>\n",
    "  </frameset>\n",
    "</frameset>\n";
    $this->myfooter();
  }


/*MyFooter*/
  function myfooter(){
    echo "\n</html>\n";
  }


/*MyHead*/
  function myheader(){
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Pragma: no-cache"); // HTTP/1.0
    header("Cache-Control: no-cache, must-revalidate");
    echo
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n",
    "<!--\n",
    "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Mon, 26 Jul 1997 05:00:00 GMT\">\n",
    "<META HTTP-EQUIV=\"Last-Modified\" CONTENT=\"" . gmdate("D, d M Y H:i:s") . " GMT\">\n",
    "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n",
    "<META HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache, must-revalidate\">\n",
    "-->\n",
    "<!--\n",
    "EditPHP by Pierre Marceau\n",
    "Copyright (c)2000 all rights reserved.\n",
    "-->\n",
    "<html>\n",
    "<head>\n";
  }

/*MyImage (this is the blue lines background graphic BASE64 encoded)*/ 
  function myimage() {
    header("Content-type: image/gif");
    header("Content-length: 862");
    echo base64_decode(
    'R0lGODlhFAAUAPcAAP//////zP//mf//Zv/'.
    '/M///AP/M///MzP/Mmf/MZv/MM//MAP+Z//'.
    '+ZzP+Zmf+ZZv+ZM/+ZAP9m//9mzP9mmf9mZ'.
    'v9mM/9mAP8z//8zzP8zmf8zZv8zM/8zAP8A'.
    '//8AzP8Amf8AZv8AM/8AAMz//8z/zMz/mcz'.
    '/Zsz/M8z/AMzM/8zMzMzMmczMZszMM8zMAM'.
    'yZ/8yZzMyZmcyZZsyZM8yZAMxm/8xmzMxmm'.
    'cxmZsxmM8xmAMwz/8wzzMwzmcwzZswzM8wz'.
    'AMwA/8wAzMwAmcwAZswAM8wAAJn//5n/zJn'.
    '/mZn/Zpn/M5n/AJnM/5nMzJnMmZnMZpnMM5'.
    'nMAJmZ/5mZzJmZmZmZZpmZM5mZAJlm/5lmz'.
    'JlmmZlmZplmM5lmAJkz/5kzzJkzmZkzZpkz'.
    'M5kzAJkA/5kAzJkAmZkAZpkAM5kAAGb//2b'.
    '/zGb/mWb/Zmb/M2b/AGbM/2bMzGbMmWbMZm'.
    'bMM2bMAGaZ/2aZzGaZmWaZZmaZM2aZAGZm/'.
    '2ZmzGZmmWZmZmZmM2ZmAGYz/2YzzGYzmWYz'.
    'ZmYzM2YzAGYA/2YAzGYAmWYAZmYAM2YAADP'.
    '//zP/zDP/mTP/ZjP/MzP/ADPM/zPMzDPMmT'.
    'PMZjPMMzPMADOZ/zOZzDOZmTOZZjOZMzOZA'.
    'DNm/zNmzDNmmTNmZjNmMzNmADMz/zMzzDMz'.
    'mTMzZjMzMzMzADMA/zMAzDMAmTMAZjMAMzM'.
    'AAAD//wD/zAD/mQD/ZgD/MwD/AADM/wDMzA'.
    'DMmQDMZgDMMwDMAACZ/wCZzACZmQCZZgCZM'.
    'wCZAABm/wBmzABmmQBmZgBmMwBmAAAz/wAz'.
    'zAAzmQAzZgAzMwAzAAAA/wAAzAAAmQAAZgA'.
    'AMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'.
    'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'.
    'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'.
    'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'.
    'AAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAFA'.
    'AUAEAIQwBJCBxIsKBBAAgTKlyYUCDDhwsdQ'.
    'pwoceLDihYjksh4cSNHjR9BhmzocSQAjCFR'.
    'flTJkWVGlxZhUiw5UiZEgzhzBgQAOw==');
  }


/*Mysubmit*/
  function mysubmit(){
    global $mysubmit;
    switch ($mysubmit){
      case ("Delete") : $this->delete()      ; break;
      case ("Go")     : $this->save()        ; break;
      case ("Save")   : $this->save()        ; break;
      case ("Load")   : $this->showdisp()    ; break;
      case ("Upload") : $this->saveul()      ; break;
    }
  }


/*OpenWin*/
  function openwin(){
    global $PHP_SELF;
    $this->myheader();
    echo
    "  <script>\n",
    "    <!--\n",
    "    history.back();\n",
    "    window.open(\"$PHP_SELF?mode=openwin\",\"\",\"width=$this->winwidth,height=$this->winheight,status,location\");\n",
    "    //-->\n",
    "  </script>\n",
    "</head>\n",
    "<body>\n",
    "</body>\n",
    "</html>\n";
  }


/*Save*/
  function save(){
    global $filename, $editbuffer, $mysubmit, $HTTP_HOST, $PHP_SELF;
    if ($this->isillegalfile($filename)){
      $this->showinfo("Illegal filename!");
      return 0;       
    }
    if ($myfilehandle=@fopen($filename,'w')){
      if (get_magic_quotes_gpc()){
        $editbuffer = stripslashes($editbuffer);
      }
      fputs($myfilehandle,$editbuffer);
      fclose($myfilehandle);
      $this->showinfo("Saved OK");
    }else{
      $this->showinfo("Denied!");
    }
  }


/*SaveUL*/
  function saveul(){
    global $userfile, $userfile_name;
    if ($userfile=="none"){
       return (0);
    }
    $this->myheader();
    echo
    "<title>\n",
    "EditPHP v$this->version \n",
    "</title>\n";
    include "editphp.css";
    echo
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n",
    "<div align=center>\n";
    if (copy($userfile, $userfile_name)){
      echo "<br><br><br><p><b>$userfile_name</b> has been saved<br>to the current directory.</p>\n";
      if ($this->isillegalfile($userfile_name)){
        echo
        "<P><B>$userfile_name</B> is not an<br>extension in your \$myfileextensions array\n",
        "so it<br>will not show up in the selection list.</p>\n";
      }else{
       echo
        "<p>Remember you must click the Reset link before<br>you will see this new file\n",
        "in the selection list.</p>\n";
      }
    }else{
      echo "<p><b>$userfile_name</b>: Failed!</p>\n";
    }
    echo
    "</div>\n",
    "</body>\n";
    $this->myfooter();
  }


/*ShowAbout*/
  function showabout(){
    global $PHP_SELF;
    $this->myheader();
    echo
    "<title>\n",
    "About EditPHP v$this->version \n",
    "</title>\n";
//    include "editphp.css";
    echo
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n",
    "<div align=center>\n",
    "<h3>EditPHP by Pierre Marceau &#169;2000<h3>\n",
    "</div>",
    "<pre>",
    "Version  : $this->version\n",
    "Homepage : <a href=\"http://www.skynet.ca/~pierre/\">http://www.skynet.ca/~pierre/</a>\n",
    "Email    : <a href=\"mailto:hide@address.com\">mailto:hide@address.com</a>\n",
    "Survey   : <a href=\"http://www.skynet.ca/~pierre/survey.htm\">Take the EditPHP user survey.</a><br>\n";
    if (is_file("readme.htm")){
      include "readme.htm";
    }
    echo
    "</pre>",
    "</body>\n";
    $this->myfooter();
  }


/*ShowDisp*/
  function showdisp(){
    global $PHP_SELF, $filename;
    $newvar="";
    if (isset($filename) && file_exists($filename)){
      $myfile=file($filename);
      $mylines=count($myfile);
      for($index=0;$index<$mylines;$index++){
        $newvar.=$myfile[$index];
      }
      $newvar = htmlspecialchars($newvar);
    }else{
      $filename="untitled";
      $newvar="";
    }
    if ($this->isillegalfile($filename)){
      $filename="untitled";
      $newvar="";
    }
    $this->myheader();
    include ("editphp.css");
    echo
    "\n<title>\n",
    "  EditPHP v$this->version \n",
    "</title>\n",
    "</head>\n\n",
    "<body background=\"$PHP_SELF?mode=image\" onload=\"parent.editbufferonload();\">\n",
    "<div>\n",
    "<form id=\"editform\" method=\"post\" onsubmit=\"return(false);\">\n",
    "<div align=\"center\"><table border=\"0\" width=\"98%\"></div>\n",
    "<tr>\n",
    "  <td>\n",
    "    <input name=\"filename\" value=\"$filename\">\n",
    "    <input type=\"button\" accesskey=\"g\" title=\"Save and Run\" value=\"Go\" onclick=\"parent.submitted(this.value,this.form);\">\n",
    "    <input type=\"button\" title=\"Save to disk\" value=\"Save\" onclick=\"parent.submitted(this.value,this.form);\">\n",
    "    <input type=\"button\" title=\"Delete $filename\" value=\"Delete\" onclick=\"parent.submitted(this.value,this.form);\">\n",
    "    <input name=\"mysubmit\" type=\"hidden\">\n",
    "    <a href=\"$PHP_SELF?mode=print&filetoprint=$filename\" title=\"Print $filename\" target=\"_blank\">Print</a>\n",
    "    <a href=\"$PHP_SELF?mode=openwin\" target=\"_top\" title=\"Reset\">Reset</a>\n",
    "    <a href=\"$PHP_SELF?mode=php_info\" target=\"_blank\" title=\"PHP Info\">Info</a>\n",
    "    <a href=\"$PHP_SELF?mode=crypter\" target=\"_blank\" title=\"Change password\">Password</a>\n",
    "    <a href=\"$PHP_SELF?mode=colours\" target=\"_blank\" title=\"Colour chart\">Colours</a>\n",
    "    <a href=\"$PHP_SELF?mode=upload\" target=\"_blank\" title=\"Upload\">UL</a>\n",
    "  </td>\n",
    "  <td align=\"right\">\n";
    $this->showlist();
    echo
    "  </td>\n",
    "</tr>\n",
    "<tr>\n",
    "  <td align=\"center\" class=\"textarea\" colspan=\"2\">\n",
    "<textarea class=\"textarea\" tabindex=\"1\" wrap=\"off\" cols=\"$this->ebwidth\" rows=\"$this->ebheight\" name=\"editbuffer\">\n",
    "$newvar",
    "</textarea>\n", // Do not indent, must come right after $newvar
    "  </td>\n",
    "</tr>\n",
    "</table>\n",
    "</form>\n",
    "</div>\n",
    "</body>\n";
    $this->myfooter(); 
  }


/*ShowInfo*/
  function showinfo($msg=""){
    global $PHP_SELF, $mysubmit;
    $this->myheader();
    if (!isset($mysubmit)) {$mysubmit="";}
    echo
    "<script>\n",
    "<!--\n";
    switch ($msg){
      case "init":
        break;
	
      case "Redundant":
        echo
        "parent.display.document.forms[0].target=\"display\";\n";
	$msg="No changes to save";
        break;

      case "Denied!":
        echo
        "alert('$mysubmit: access denied by operating system');\n";
        "parent.display.document.forms[0].target=\"display\";\n";
        break;

      case "Deleted.":
        echo
        "parent.display.document.forms[0].filename.value=\"untitled\";\n";
        "parent.display.document.forms[0].target=\"display\";\n";
        break;

      case "Saved OK":
        echo
        "parent.display.document.forms[0].target=\"display\";\n",
        "parent.display.document.forms[0].editbuffer.defaultvalue=parent.display.document.forms[0].editbuffer.value;\n";

      default:
        echo
        "parent.display.document.forms[0].target=\"display\";\n";
    }
    if ($mysubmit=="Go"){
      echo "window.open(parent.display.document.forms[0].filename.value,\"GoWindow\");\n";
    }
    echo
    "//-->\n",
    "</script>\n";
    include ("editphp.css");
    echo
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n",
    "<form>\n",
    "&#160;&#160;<input name=\"info\" value=\"$msg\" size=\"26\">\n",
    "</form>\n",
    "</body>\n";
     $this->myfooter();
  }


/*ShowLinks*/
  function showlinks(){
    global $filename, $PHP_SELF;
    $this->myheader();
    include ("editphp.css");
    echo
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">&#160;\n";
    for(reset($this->mylinks);$mydescription=key($this->mylinks);next($this->mylinks)){
      $url=pos($this->mylinks);
      echo "<a href=\"$url\" tabindex=\"-1\" target=\"_blank\" ";
      if (!$this->expertmode){
        echo "onclick=\"return confirm('EditPHP will remain open\\nin the background.');\" ";
      }
      echo "name=\"$url\">$mydescription</a>\n";
    }
    echo
    "<a href=\"$PHP_SELF?mode=about\" target=\"infowindow\" title=\"Comments welcome!\">About</a>\n",
    "</body>\n";
    $this->myfooter();
  }


/*ShowList*/
  function showlist(){
    $mydirectory=opendir(".");
    while($entryname=readdir($mydirectory)){
      $a = eregi($this->myfileextensions,$entryname);
      $b = !eregi($this->myrestrictedfiles,$entryname);  
      if ( $a && $b ){
        $myfiles["$entryname"]=filemtime($entryname);
      }
    }
    echo "    <select name=\"myopenfile\" onchange=\"parent.submitted('Load',this.form);\">\n";
    echo "      <option>\n";
    if (is_array($myfiles)) {
      arsort($myfiles);
      while (list($name,$value)=each($myfiles)){
        echo "      <option>$name\n";
      }
    }else{
      echo "      <option>No matching file extensions\n";
    }
    echo
    "    </select>\n";
    closedir($mydirectory);
  }


/*ShowPHPinfo*/
  function showphp_info(){
    global $PHP_SELF;
    $this->myheader();
    echo
    "<title>\n",
    "EditPHP v$this->version \n",
    "</title>\n";
    include "editphp.css";
    echo
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n";
    phpinfo();
    echo "</body>\n";
    $this->myfooter();
  }


/*ShowPrint*/
  function showprint(){
    global $PHP_SELF, $filetoprint;

    $myfile        = @file($filetoprint);
    $lines         = count($myfile);
    $time          = date("h:i A");
    $date          = date("l F dS, Y");
    $reportheading = sprintf("File %s with %s lines. Printed %s at %s",$filetoprint,$lines,$date,$time);
    $myline        = "";

    if ($this->isillegalfile($filetoprint)){
      return 0;       
    }

    $this->myheader();
    include ("editphp.css");
    echo
    "<title>",
    "EditPHP v$this->version",
    "</title>",
    "</head>\n",
    "<body background=\"$PHP_SELF?mode=image\">\n",
    "<div>\n",
    "<h4 class=printreport>$reportheading</h4>\n",
    "<pre class=printreport>\n";
    for($index=0;$index<$lines;$index++){
      $myline = htmlentities("$myfile[$index]");
      printf("<br>%3s. %s",$index+1,$myline);
    }
    echo
    "</pre>\n",
    "</div>\n",
    "</body>\n";
    $this->myfooter();
  }


/*Upload*/
  function upload(){
    global $PHP_SELF;
    $this->myheader();
    echo
      "</head>\n",
      "<body background=\"$PHP_SELF?mode=image\">\n",
      "<div align=\"center\">\n",
      "<h2>File Upload</h2><p>\n",
      "<form action=\"$PHP_SELF\" method=\"post\" enctype=\"multipart/form-data\">\n",
      "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"200000\">\n",
      "<input type=\"file\" name=\"userfile\" size=\"70\">\n",
      "<br><input type=\"submit\" name=\"mysubmit\" value=\"Upload\">\n",
      "</form>\n",
      "</div>\n",
      "</body>\n";
    $this->myfooter();
  }
}
?>
Return current item: EditPHP