-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaptchaCode.php
45 lines (37 loc) · 1.42 KB
/
captchaCode.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
<?php
class CaptchaCode
{
private $seed;
public $a = '', $b= '', $c= '', $rand = '', $img = '';
public function getCode($choice)
{
if($choice == 'alphabets' or $choice == 'numbers' or $choice == 'alphanum')
{
//ALPHABETS
if($choice == 'alphabets'){
$this->seed = str_split('abcdefghijklmnopqrstuvwxyz'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
}
//NUMBERS
else if($choice == 'numbers'){
$this->seed = str_split('0123456789');
}
//ALPHABETS & NUMBERS
else{
$this->seed = str_split('abcdefghijklmnopqrstuvwxyz'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.'0123456789');
}
$this->x = shuffle($this->seed);
foreach (array_rand($this->seed, 5) as $this->k) $this->rand .= $this->seed[$this->k];
return $this->rand;
}
else
{
$this->a = rand(1,10);
$this->b = rand(1,10);
$this->c = $this->a."a".$this->b;
$this->rand = $this->a + $this->b;
return $this->rand;
}
}
}
$captchaCode = new CaptchaCode();
?>