<?php //header('Content-Type: image/jpeg'); mysql_connect('147.32.164.26','alik','*****') or die('Error: '.mysql_error() ); mysql_select_db('alik'); //for calling, the GET request is assumed: $klic = $_GET['k']; if ($klic<1) { $klic=1; } ; echo 'The "k" variable from the $_GET structure:<br>k='.$klic; $cname = 'arii_fs_cvut_pocitadlo_'.$klic; echo "<br><br>List of cookies:"; $inc_cnt=1; foreach($_COOKIE as $n1 => $v1) { echo "<br>$n1 = $v1" ; if ($n1 == $cname ) {$inc_cnt=0; }; }; if ($inc_cnt==1) { setcookie($cname,"www.fs.cvut.cz/prt/web/cv/cv9e.htm",time()+60*60 ); $inc_cnt=1; } ; echo "<br>c=".$cname; //read the previous value from database: $result=mysql_query('select max(cislo) as minuly from pocitadlo3 where klic='.$klic.';'); $cislo=intval(mysql_result($result,0,"minuly")); echo "<br>val=".$cislo; //increment, then write back to database: $cislo+=$inc_cnt; $q= 'insert into pocitadlo3 values ('.$cislo.','.$klic.',"'. $_SERVER["REMOTE_ADDR"].'",now());'; echo "<br>q=".$q; $result=mysql_query($q); mysql_close(); $src = @imagecreatefromjpeg('0123456789.jpg'); $dst = imagecreatetruecolor(25*4, 39); for ($i=3; $i>=0; $i--) { $c = $cislo % 10; // the modulo is missing in the php language $cislo = ($cislo - $c) / 10; imagecopy($dst, $src, $i*25, 0, $c*25, 0, 25, 39); } imagejpeg($dst,'5poc.jpg',77); echo "<br>picture=<img src='5poc.jpg'>"; imagedestroy($dst); imagedestroy($src); ?>