PHP expert |
|
Ik ben er ondertussen al uit. Omdat het in en functie was en een image overschreef hij zichzelf de hele tijd. Heb het nu als volgt:
inc/code.php
<?php
ob_start();
session_start();
$width = 160;
$height = 16;
$fontsize = 3.5;
for($i = 0; $i < 3; $i++)
{
unset($numer);
$number = rand(1, 9);
switch($number)
{
case 1:
$written = " One";
break;
case 2:
$written = " Two";
break;
case 3:
$written = " Three";
break;
case 4:
$written = " Four";
break;
case 5:
$written = " Five";
break;
case 6:
$written = " Six";
break;
case 7:
$written = " Seven";
break;
case 8:
$written = " Eight";
break;
case 9:
$written = " Nine";
break;
}
$totalnumbers .= $number;
$totalwritten .= $written;
}
$_SESSION['hash'] = md5($totalnumbers);
$fontwidth = ImageFontWidth($fontsize) * strlen($totalwritten);
$fontheight = ImageFontHeight($fontsize);
$img = ImageCreate($width, $height);
$background = ImageColorAllocate($img, 97, 96, 78);
$textcolor = ImageColorAllocate($img, 0, 0, 0);
ImageFill($img, 1, 1, $background);
imagestring($img, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $totalwritten, $textcolor);
header('Content-type: image/png');
ImagePNG($img);
ImageDestroy($img);
?>
<?php $width = 160; $height = 16; $fontsize = 3.5; for($i = 0; $i < 3; $i++) { switch($number) { case 1: $written = " One"; break; case 2: $written = " Two"; break; case 3: $written = " Three"; break; case 4: $written = " Four"; break; case 5: $written = " Five"; break; case 6: $written = " Six"; break; case 7: $written = " Seven"; break; case 8: $written = " Eight"; break; case 9: $written = " Nine"; break; } $totalnumbers .= $number; $totalwritten .= $written; } $_SESSION['hash'] = md5($totalnumbers); $fontwidth = ImageFontWidth ($fontsize) * strlen($totalwritten); $fontheight = ImageFontHeight($fontsize); $img = ImageCreate($width, $height); $background = ImageColorAllocate($img, 97, 96, 78); $textcolor = ImageColorAllocate($img, 0, 0, 0); ImageFill($img, 1, 1, $background); imagestring ($img, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $totalwritten, $textcolor); header('Content-type: image/png'); ImagePNG($img); ImageDestroy($img); ?>
en dan het plaatje maak je zo:
<img src="/inc/code.php" alt="" />
en dan was mijn vraag... is dit veiliger dan normaal omdat je nu dus tekst gebruikt? Of kan dit alsnog gelezen worden?
Dit script heb ik flink onder handen genomen omdat ik sommige dingen niet nodig had ed..
http://www.site...amp;id=628 |