-
Notifications
You must be signed in to change notification settings - Fork 16
/
antispam.php
110 lines (97 loc) · 3.34 KB
/
antispam.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
ob_start();
// Start session if no headers were sent
if(!headers_sent())
{
@session_start();
# Patch by David Vieira-Kurz of majorsecurity.de
#@session_regenerate_id();
if(!isset($_SESSION['PHPSESSID']) || !isset($_COOKIE['PHPSESSID']))
{
@session_destroy();
@session_start();
# @session_regenerate_id();
$_SESSION['PHPSESSID'] = true;
$_COOKIE['PHPSESSID'] = true;
}
}
## COLORS
$backgroundColor = '#444444';
$textColor = '#000000';
$noiseColor = '#AAAAAA';
$lineColor = '#555555';
## /COLORS
if(function_exists('gd_info'))
{
if(isset($_GET['num']) && !empty($_GET['num']))
{
$num = $_GET['num'];
$x = 100; $y = 30;
$space = 10;
} else {
$num = 2;
$x = 40; $y = 23;
$space = 6;
}
$sizeMin = 13;
$sizeMax = 19;
$rectMin = -20;
$rectMax = 20;
function hex2rgb($color,$type)
{
if($type == 'r') $r = hexdec(substr($color, 1, 2));
elseif($type == 'g') $r = hexdec(substr($color, 3, 2));
elseif($type == 'b') $r = hexdec(substr($color, 5, 2));
return $r;
}
$im = imagecreate($x, $y);
$backgroundColor = imagecolorallocate($im, hex2rgb($backgroundColor,'r') , hex2rgb($backgroundColor,'g') , hex2rgb($backgroundColor,'b'));
imagecolortransparent ($im, $backgroundColor);
$noiseColor = imagecolorallocate($im, hex2rgb($noiseColor,'r'), hex2rgb($noiseColor,'g'), hex2rgb($noiseColor,'b'));
$lineColor = imagecolorallocate($im, hex2rgb($lineColor,'r') , hex2rgb($lineColor,'g') , hex2rgb($lineColor,'b'));
// Pixel einfügen
if(function_exists('imagesetpixel'))
{
$noise = $x * $y / 10;
for($i = 0; $i < $noise; $i++)
imagesetpixel($im, mt_rand(0, $x), mt_rand(0, $y), $noiseColor);
}
// Linien zeichnen
if(function_exists('imagesetpixel')) imagesetthickness($im, 1);
if(function_exists('imageline'))
{
$anz = mt_rand(4, 9);
for($i = 1; $i <= $anz; $i++)
imageline($im, mt_rand(0, $x), mt_rand(0, $y), $x - mt_rand(0, 0), mt_rand(0, $y), $lineColor);
}
// Zahlencode einfuegen
$code = '';
$z = array("1","2","3","4","5","6","7","8","9","0");
for($f=0; $f<$num; $f++)
{
$spamcode = $z[rand(0,8)];
$w = (16 * $f) + $space;
if(function_exists('imagettftext'))
imagettftext($im, rand($sizeMin,$sizeMax), rand($rectMin,$rectMax), $w, 20,
imagecolorallocate ($im,
hex2rgb($textColor,'r'),
hex2rgb($textColor,'g'),
hex2rgb($textColor,'b')), "./inc/images/fonts/verdana.ttf", $spamcode);
$code .= $spamcode;
}
if(!function_exists('imagettftext'))
{
for($i=0;$i<=strlen($code);$i++) $strcode .= $code[$i].' ';
$text_color = imagecolorallocate ($im, hex2rgb($textColor,'r'), hex2rgb($textColor,'g'), hex2rgb($textColor,'b'));
imagestring($im, 12, $x/10, $y/4, $strcode, $text_color);
}
//Bild ausgeben & bildcache zerstoeren
imagegif($im);
imagedestroy($im);
//Code in Session abspeichern
$_SESSION["sec_$_GET[secure]"] = $code;
header ("Content-type: image/gif");
} else echo '<a href="http://www.libgd.org" target="_blank">GDLib</a> is not installed!';
## OUTPUT BUFFER END ##
ob_end_flush();
?>