<?php
// ======================================================================== //
//                                                                          //
//   KooBI- Webportalsystem                                                 //
//   SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS                     //
//                                                                          //
//   ====================================================================   //
//                                                                          //   
//   dream4 | webservices - Am Michelsgrund 7 - 69469 Weinheim - Germany    //    
//   tel. +49(0) 6201 - 980442 / fax. +49(0) 6201 - 64809                   //
//                                                                          //
// ======================================================================== //
$inc = substr(dirname(__FILE__),0,-7)."";

include("$inc/inc/config.php");
include("$inc/class/db.php");

$tmax = time()+1800;
$sqlc =& new dbc("SELECT code FROM ".$dbprefix."_securecode WHERE id='".$_REQUEST['pim']."'");
$rcode = $sqlc->fetchrow();
$sqlc->close();
$thescode = $rcode->code;

$dir = dirname(__FILE__)."/fonts/";
$font = substr(dirname(__FILE__),0,-7)."/fonts/ft52.ttf";

header("Content-type: image/x-png");

$imwidth = 162;
$imheight = 49;


$im = imagecreate ($imwidth, $imheight);

$bgcolorim = ImageColorAllocate ($im, 244, 244, 244);
$textcol = ImageColorAllocate ($im, 0, 0, 0);
$dotsincolor = ImageColorAllocate ($im, 100, 100, 100);

$wavenum = 3;
$wavemultiplier = ($wavenum * 360) / $imwidth;

$aktX = 0;
$aktY = $imwidth;
for ($imp = 0; $imp  < $imwidth; $imp++){
	$newX = $aktX + 1;
	$newY = ($imheight/2) + (cos(deg2rad($newX * $wavemultiplier)) * ($imheight/2));
	ImageLine($im, $aktX, $aktY, $newX, $newY, $dotsincolor);
	$aktX = $newX;
	$aktY = $newY;
}

for ($x = 0; $x <= $imwidth; $x += 23){
	imageline($im, $x, 0, $x, $imheight, $dotsincolor);
}
for ($x = 0; $x <= $imheight; $x += 24){
	imageline($im, 0, $x, $imwidth, $x, $dotsincolor);
}

$pix = $imwidth * $imheight / 10;
for ($i = 0; $i < $pix; $i++){
	imagesetpixel($im, rand(0, $imwidth), rand(0, $imheight), $dotsincolor);
}

ImageTTFText ($im, 20, 0, 15, 35, $textcol, $font, $thescode);
imagepng($im);
ImageDestroy ($im);
exit;
?>