All pastes #970315 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-03 23:31 UTC
rendered paste body
index.php:


<?php
require ('auth.php');

print "

Modifica il capitolo (da 1 a 10): 

<form method=\"POST\" action=\"editor.php\">

<input type=\"text\" name=\"capitolo\">
<input type=\"submit\" name=\"ok\" value=\"OK\">

</form>

";


?>







editor.php:

<html><body>
<center>
<?php
require_once ("auth.php");

$capitolo = $_POST['capitolo'];

$link = "capitoli/$capitolo.txt";

$testo = file_get_contents($link);

if($capitolo < 0 || $capitolo > 10){die("Errore, capitolo non presente");}

print "Capitolo $capitolo";
print " <a href=\"index.php\">Annulla</a>";


if(!isset($_POST['salvato'])){

print "<form action=\"\" name=\"modify\" method=\"POST\"> <br> <br> <textarea name=\"testo\" style=\"width:800px; height:700px;\">$testo</textarea> <br> <input type=\"submit\" name=\"salvato\" value=\"Salva\"> </form>";

}

else

{
    $contenuto = $_POST['testo'];
    unlink($link);
    $fileX = fopen($link, "w+");
    fwrite($fileX, $contenuto);
    fclose($fileX);
    print " <p><p><p> Il file è stato aggiornato con successo. <a href=\"index.php\">Ritorna</a>";
}
?>


</center>
</body></html>