-
Notifications
You must be signed in to change notification settings - Fork 0
/
cap.php
56 lines (45 loc) · 969 Bytes
/
cap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
session_start();
include("phpclasses/coordinate.class.php");
include("phpclasses/color.class.php");
include("phpclasses/drawpad.class.php");
include("setup.php");
$operators[] = "+";
$operators[] = "*";
$operators[] = "-";
shuffle($operators);
$operator = $operators[0];
$result = 0;
switch($operator)
{
case "*":
$first = rand(1,5);
$last = rand(1,5);
$result = $first * $last;
break;
case "+":
$first = rand(1,9);
$last = rand(1,9);
$result = $first + $last;
break;
case "-":
$first = rand(1,5);
$last = rand(1,5);
if(($first-$last) < 0)
{
$t1 = $first;
$t2 = $last;
$last = $t1;
$first = $t2;
}
$result = $first - $last;
break;
}
$c = new Color(255,0,255,0);
$img = new DrawPad(65,25, $c);
$img->setTransparency($c);
$img->write(new Coordinate(5,5),"$first $operator $last =",5);
$img->createImage();
$hashed = hash($setup->hashfunction, $setup->salt.$result);
$_SESSION[$setup->sessionname] = $hashed;
?>