<?php
session_start();
$_SESSION['pswd1']=rand(1,9);
$_SESSION['pswd2']=rand(1,9);
$_SESSION['pswd3']=rand(1,9);
$_SESSION['pswd4']=rand(1,9);
$im = ImageCreateFromPNG('kod.png');
if ($_SESSION['pswd1']=='1'){
$pos1 = 1;
$black1 = ImagecolorAllocate($im,0,0,0);}
if ($_SESSION['pswd1']=='2'){
$pos1 = 2;
$black1 = ImagecolorAllocate($im,444,0,0);}
if ($_SESSION['pswd1']=='3'){
$pos1 = 3;
$black1 = ImagecolorAllocate($im,0,444,0);}
if ($_SESSION['pswd1']=='4'){
$pos1 = 4;
$black1 = ImagecolorAllocate($im,999,0,0);}
if ($_SESSION['pswd1']=='5'){
$pos1 = 5;
$black1 = ImagecolorAllocate($im,888,999,0);}
if ($_SESSION['pswd1']=='6'){
$pos1 = 6;
$black1 = ImagecolorAllocate($im,444,0,999);}
if ($_SESSION['pswd1']=='7'){
$pos1 = 7;
$black1 = ImagecolorAllocate($im,0,0,999);}
if ($_SESSION['pswd1']=='8'){
$pos1 = 8;
$black1 = ImagecolorAllocate($im,0,999,0);}
if ($_SESSION['pswd1']=='9'){
$pos1 = 9;
$black1 = ImagecolorAllocate($im,666,0,0);}
if ($_SESSION['pswd1']=='0'){
$pos1 = 0;
$black1 = ImagecolorAllocate($im,0,0,777);}
if ($_SESSION['pswd2']=='1'){
$pos2 = 6;
$black2 = ImagecolorAllocate($im,0,0,0);}
if ($_SESSION['pswd2']=='2'){
$pos2 = 8;
$black2 = ImagecolorAllocate($im,444,0,0);}
if ($_SESSION['pswd2']=='3'){
$pos2 = 7;
$black2 = ImagecolorAllocate($im,0,444,0);}
if ($_SESSION['pswd2']=='4'){
$pos2 = 2;
$black2 = ImagecolorAllocate($im,999,0,0);}
if ($_SESSION['pswd2']=='5'){
$pos2 = 4;
$black2 = ImagecolorAllocate($im,888,999,0);}
if ($_SESSION['pswd2']=='6'){
$pos2 = 0;
$black2 = ImagecolorAllocate($im,444,0,999);}
if ($_SESSION['pswd2']=='7'){
$pos2 = 5;
$black2 = ImagecolorAllocate($im,0,0,999);}
if ($_SESSION['pswd2']=='8'){
$pos2 = 3;
$black2 = ImagecolorAllocate($im,0,999,0);}
if ($_SESSION['pswd2']=='9'){
$pos2 = 9;
$black2 = ImagecolorAllocate($im,888,0,0);}
if ($_SESSION['pswd2']=='0'){
$pos2 = 1;
$black2 = ImagecolorAllocate($im,0,0,777);}
if ($_SESSION['pswd3']=='1'){
$pos3 = 1;
$black3 = ImagecolorAllocate($im,0,0,0);}
if ($_SESSION['pswd3']=='2'){
$pos3 = 2;
$black3 = ImagecolorAllocate($im,444,0,0);}
if ($_SESSION['pswd3']=='3'){
$pos3 = 3;
$black3 = ImagecolorAllocate($im,0,444,0);}
if ($_SESSION['pswd3']=='4'){
$pos3 = 4;
$black3 = ImagecolorAllocate($im,999,0,0);}
if ($_SESSION['pswd3']=='5'){
$pos3 = 5;
$black3 = ImagecolorAllocate($im,888,999,0);}
if ($_SESSION['pswd3']=='6'){
$pos3 = 6;
$black3 = ImagecolorAllocate($im,444,0,999);}
if ($_SESSION['pswd3']=='7'){
$pos3 = 7;
$black3 = ImagecolorAllocate($im,0,0,999);}
if ($_SESSION['pswd3']=='8'){
$pos3 = 8;
$black3 = ImagecolorAllocate($im,0,999,0);}
if ($_SESSION['pswd3']=='9'){
$pos3 = 9;
$black3 = ImagecolorAllocate($im,666,0,0);}
if ($_SESSION['pswd3']=='0'){
$pos3 = 0;
$black3= ImagecolorAllocate($im,0,0,777);}
if ($_SESSION['pswd4']=='1'){
$pos4 = 6;
$black4 = ImagecolorAllocate($im,0,0,0);}
if ($_SESSION['pswd4']=='2'){
$pos4 = 8;
$black4 = ImagecolorAllocate($im,444,0,0);}
if ($_SESSION['pswd4']=='3'){
$pos4 = 7;
$black4 = ImagecolorAllocate($im,0,444,0);}
if ($_SESSION['pswd4']=='4'){
$pos4 = 2;
$black4 = ImagecolorAllocate($im,999,0,0);}
if ($_SESSION['pswd4']=='5'){
$pos4 = 4;
$black4 = ImagecolorAllocate($im,888,999,0);}
if ($_SESSION['pswd4']=='6'){
$pos4 = 0;
$black4 = ImagecolorAllocate($im,444,0,999);}
if ($_SESSION['pswd4']=='7'){
$pos4 = 5;
$black4 = ImagecolorAllocate($im,0,0,999);}
if ($_SESSION['pswd4']=='8'){
$pos4 = 3;
$black4 = ImagecolorAllocate($im,0,999,0);}
if ($_SESSION['pswd4']=='9'){
$pos4 = 9;
$black4 = ImagecolorAllocate($im,888,0,0);}
if ($_SESSION['pswd4']=='0'){
$pos4 = 1;
$black4 = ImagecolorAllocate($im,0,0,777);}
Imagestring($im,10,4,$pos1,"".$_SESSION['pswd1']."",$black1);
Imagestring($im,10,17,$pos2,"".$_SESSION['pswd2']."",$black2);
Imagestring($im,10,31,$pos3,"".$_SESSION['pswd3']."",$black3);
Imagestring($im,10,45,$pos4,"".$_SESSION['pswd4']."",$black4);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: image/png");
ImagePng($im);
?>