Login form



Operations with file content, PART 1
1 example. Write to file


<?

$failas="f_1.txt";
$vardas="jonas"; $amzius="27"; $ugis="180"; $svoris="65656";
$informacija=$vardas."|".$amzius."|".$ugis."|".$svoris;

$f=fopen($failas, "a"); // r r+ w w+ a a+ x x+
fwrite($f, "{$informacija}\n ");
fclose($f);
echo "<br> <pre> "; include $failas; echo"</pre>";

?>

2 example. File statistics



<hr>Pirmas pvz.: statistika <br>
<?

$failas="f_1.txt";
$f = fopen( $failas, "a+" );
if ($f){
echo "Failas egzistuoja <br>";
$stat=fstat ($f);

?><pre><? print_r ($stat); ?></pre><?

fclose ($f);
}else{
echo "blogai";
exit;
}

?>

3 example. Hack Page


<a href="/f_1.php">Link without variables </a>
<hr>Hack PHP: (after hacking write- delete), orwindow.location=1, or img

<form action="f_1.php" method="get">
<input type="text" name="name1" size="40" maxlength="80" value="&lt;script&gt;document.bgColor=10&lt;/script&gt;">
<input type="submit" value="Press">
</form><br>

<?

$failas="f_1.txt";
$a=$_GET ["name1"];
$f=fopen( $failas, "a+");

if ($a!="delete"){

while (!feof($f)) {
$data=fgets($f,300);
echo " $data <hr>";
}

fwrite($f, $a."\n");

}else{

rewind($f);
ftruncate ($f,0);

?>
<script language="JavaScript" type="text/javascript">
window.location="f_1.php";
</script>
<?

}

fclose($f);

?>
 
[ BBC news ][ Yahoo news ][ Linux guru ][ Webmaster ACE ]