forked from emcs/TradingEye-V7.1.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_auth.php
executable file
·92 lines (90 loc) · 2.09 KB
/
image_auth.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
=======================================================================================
Copyright: TradingEye
Version: 7.1.1
=======================================================================================
*/
class captcha
{
var $inNumChar = 6;
var $numChars = 3;
var $w;
var $h = 80;
var $colBG = "255 220 131";
var $colTxt = "153 0 0";
var $colBorder = "0 128 192";
var $charx = 30;
var $numCirculos = 10;
var $texto;
function __construct()
{
}
function m_GenImage($num){
if (($num != '')&&($num > $this->numChars)) $this->numChars = $num;
$this->texto = $this->m_GenString();
$_SESSION['image_auth_string'] = $this->texto;
}
function m_GenString()
{
rand(0,time());
//$possible="ahlftdsknprvy24579";
$possible="abcdefghijklmnopqrstuvwxyz";
// $possible="AHLFTDSKNPRVY24579";
$str="";
while(strlen($str)<$this->numChars)
{
$str.=substr($possible,(rand()%(strlen($possible))),1);
}
$txt = $str;
return $txt;
}
function m_GetImage()
{
global $_CONF;
$this->im=imagecreatefromjpeg(LIB_IMAGES_PATH."captcha_image.jpg");
$ident = 15;
$black = imagecolorallocate($this->im, 0, 0, 0);
for ($i=0;$i<$this->numChars;$i++){
$char = substr($this->texto, $i, 1);
$font = LIB_IMAGES_PATH."fonts/verdana.ttf";
$y = round(($this->h-10)/2);
$t = rand(2,20);
$size=rand(15,20);
$col = $this->m_GetColor($this->colTxt);
if (($i%2) == 0)
{
imagettftext($this->im, $size, 0, $ident, $y+$t, $black, $font, $char);
}
else
{
imagettftext($this->im, $size, 10, $ident, $y+$t, $black, $font, $char);
}
$ident = $ident+(rand (25, 30));
}
}
function m_GetColor($var){
$rgb = explode(" ",$var);
$col = imagecolorallocate ($this->im, $rgb[0], $rgb[1], $rgb[2]);
return $col;
}
function m_ShowImage()
{
header("Content-type: image/jpeg");
ImageJpeg($this->im);
//Imagegif($this->im);
}
function m_CheckCode($stEnteredCode)
{
//if (isset($this->postCode)) $this->loadCodes();
if ($stEnteredCode == $_SESSION['image_auth_string'])
{
return true;
}
else
{
return false;
}
}
}
?>