All pastes #124021 Raw Edit

Miscellany

public php v1 · immutable
·published 2006-08-09 19:37 UTC
rendered paste body
<?php  include('lib.inc.php');  if (LoggedIn())    {    $pages = array('home.php', 'dvds.php', 'links.php', 'contact.php',                    'theme.php', 'admin.php', 'error.php', 'index.php',                    'lib.inc.php', 'loginscript.php', 'mysql.php',                    'bookmarks.php');    if (isset($_POST['edit']) && isset($_POST['filename']))      {      $edit = $_POST['edit'];      $filename = $_POST['filename'];      if (in_array($filename, $pages))        {        $f = fopen($filename, 'w');        $edit = stripslashes($edit);        echo($edit);        fputs($f, $edit);        fclose($f);        }      else        {        die('Invalid filename');        }              }              elseif (isset($_GET['filename']))      {      $filename = $_GET['filename'];      if (in_array($filename, $pages))        {        echo("              <html>                <head>                  <title>Edit pages</title>                </head>                <body>                  <form action='edit.php' method='post'>                    <textarea name='edit' rows='40' cols='80'>"                      . htmlspecialchars(file_get_contents($filename)) .                    "</textarea>                    <input type='hidden' name='filename' value='$filename' />                    <input type='submit' value='Submit' />                  </form>                  </body>              </html>                        ");        }      }    }  else    {    die('Please login');      }?>