-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathran.class.php
executable file
·64 lines (48 loc) · 1.6 KB
/
ran.class.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
57
58
59
60
61
62
63
64
<?php
/***********************************************************************
Caleb Champlin ([email protected])
************************************************************************/
class ran
{
var $text; // the random text used in the image
function ran()
{
srand((double)microtime()*1000000^getmypid());
}
function createImage($width=135,$height=45)
{
// send header for our image
header("Content-type:image/jpeg");
// create an image
$im=imagecreate($width,$height);
// white background
$black=imagecolorallocate($im,0,0,0);
// black text and grid
$white=imagecolorallocate($im,255,255,255);
$other=imagecolorallocate($im,0,0,255);
// get a random number to start drawing out grid from
$num=rand(0,5);
// draw vertical bars
for($i=$num;$i<=$width;$i+=10)
imageline($im,$i,0,$i,45,$other);
// draw horizontal bars
for($i=$num;$i<=$height+10;$i+=10)
imageline($im,0,$i,135,$i,$other);
// generate a random string
$string=substr(strtolower(md5(uniqid(rand(),1))),0,7);
$string=str_replace('2','a',$string);
$string=str_replace('l','p',$string);
$string=str_replace('1','h',$string);
$string=str_replace('0','y',$string);
$string=str_replace('o','y',$string);
// place this string into the image
$font = imageloadfont('anticlimax.gdf');
imagestring($im,$font,10,10,$string, $white);
// create the image and send to browser
imagejpeg($im);
// destroy the image
imagedestroy($im);
// return the random text generated
return $this->text=$string;
}
}