test.php:
<?
session_start();
include "functions.php";
anticheat($_SESSION['game_secret_string']);
?>
functions.php:
<?
function anticheat($secret_session){
$secret_lenght = "3"; //lenght of secret string
$width = 170; // width of image
$height = 60; // height of image
$fontsize = 3.5; // fontsize
for($i=0 ; $i<$secret_lenght ; $i++){
unset($number);
$number = rand(1,10);
switch ($number) {
case 1: $numberwritten = " one"; break;
case 2: $numberwritten = " two"; break;
case 3: $numberwritten = " three"; break;
case 4: $numberwritten = " four"; break;
case 5: $numberwritten = " five"; break;
case 6: $numberwritten = " six"; break;
case 7: $numberwritten = " seven"; break;
case 8: $numberwritten = " eight"; break;
case 9: $numberwritten = " nine"; break;
case 10: $numberwritten = " ten"; break;
}
$secret_string .= $numberwritten;
}
$fontwidth = ImageFontWidth($fontsize) * strlen($secret_string);
$fontheight = ImageFontHeight($fontsize);
// create handle for image
$img = @imagecreate($width,$height);
// white background
$background_colour = imagecolorallocate($img, 0, 0, 0);
// give the 'random' text a nice colour
$text_colour = imagecolorallocate($img, rand(150,255), rand(150,255), rand(100,255));
// give the border a colour too ;)
imagerectangle($img, 0, 0, $width-1, $height-1, $text_colour);
// draw the string horizontally
imagestring($img, $fontsize, rand(3, $width-$fontwidth-3), rand(2, $height-$fontheight-3), $secret_string, $text_colour);
// lets output!
header("Content-type: image/png");
imagepng($img,'',80);
imagedestroy($img);
}
?>
ik wil mijn afbeelding gewoon kunnen bekijken in plats van met die header("") functie is dit mogelijk???
het is om een anti scripting code te maken trouwens
778 views