Ver Mensaje Individual
  #5 (permalink)  
Antiguo 29/07/2010, 05:05
Avatar de chulifo
chulifo
 
Fecha de Ingreso: abril-2009
Ubicación: perdido en codigos del PHP, pero aprendo rapido!
Mensajes: 524
Antigüedad: 15 años
Puntos: 18
De acuerdo Respuesta: Script para editar php

editor.php
Código PHP:
Ver original
  1. <?php
  2. $random1 = 'randomly_generated_string';
  3. $random2 = 'another_randomly_generated_string';
  4. $target_file = 'index.html';//el nombre del archivo a editar
  5. $this_file = 'editor.php';//el nombre de este archivo
  6.  
  7.  {
  8.     if (isset($_POST['content']))
  9.         file_put_contents($target_file, 'get_magic_quotes_qpc()' ? stripslashes($_POST['content']) : $_POST['content']);
  10.    
  11.     die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  13.    <head>
  14.        <title>Editing...</title>
  15.    </head>
  16.    <body>
  17.        <form method="post" action="' . $this_file . '" />
  18.        <input type="hidden" name="' . $random1 . '" value="' . $random2 . '" />
  19.        <textarea name="content" rows="50" cols="100">' . file_get_contents($target_file) . '</textarea><br />
  20.        <input type="submit" value="Save Changes" />
  21.        </form>
  22.    </body>
  23. </html>');
  24. }
  25. ?>