Project

General

Profile

« Previous | Next » 

Revision 848

Added by thorn over 16 years ago

fixed issue with captcha (mt_rand() instead of rand()); fixed bug in search (link to http://.../search/index.php performs a search with string 'unset')

View differences:

trunk/CHANGELOG
10 10
# = Bugfix
11 11
! = Update/Change
12 12

  
13
------------------------------------- 2.7.1 -------------------------------------
13
------------------------------------- 2.7.1 -------------------------------------
14
22-Jun-2008 Thomas Hornik
15
# fixed issue with captcha (mt_rand() instead of rand())
16
# fixed bug in search (link to http://.../search/index.php performs a search with string 'unset')
14 17
22-June-2008 Christian Sommer
15 18
!	added output of block number to section admin if no block name is specified
16 19
21-June-2008 Christian Sommer
trunk/wb/include/captcha/captchas/ttf_image.php
43 43
if(!function_exists('randomString')) {
44 44
	function randomString($len) {
45 45
		list($usec, $sec) = explode(' ', microtime());
46
		srand((float)$sec + ((float)$usec * 100000));
46
		mt_srand((float)$sec + ((float)$usec * 100000));
47 47
		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";
48 48
		$possible="abdfhkrsvwxz23456789";
49 49
		$str="";
50 50
		while(strlen($str)<$len) {
51
			$str.=substr($possible,(rand()%(strlen($possible))),1);
51
			$str.=substr($possible,(mt_rand()%(strlen($possible))),1);
52 52
		}
53 53
		return($str);
54 54
	}
......
64 64

  
65 65
// create image
66 66
$image = ImageCreateFromPNG($bg); // background image
67
$grey = rand(0,50);
67
$grey = mt_rand(0,50);
68 68
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
69 69
$ttf = $font;
70 70
$ttfsize = 25; // fontsize
71 71

  
72
if(rand(0,2)==0) { // 1 out of 3
72
if(mt_rand(0,2)==0) { // 1 out of 3
73 73

  
74 74
	// draw each character individualy
75 75
	$count = 0;
76 76
	$image_failed = true;
77
	$angle = rand(-15,15);
78
	$x = rand(10,25);
79
	$y = rand($height-10,$height-2);
77
	$angle = mt_rand(-15,15);
78
	$x = mt_rand(10,25);
79
	$y = mt_rand($height-10,$height-2);
80 80
	do {
81 81
		for($i=0;$i<strlen($text);$i++) {
82 82
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
83
			$angle = rand(-15,15);
84
			$x = rand($res[4],$res[4]+10);
85
			$y = rand($height-15,$height-5);
83
			$angle = mt_rand(-15,15);
84
			$x = mt_rand($res[4],$res[4]+10);
85
			$y = mt_rand($height-15,$height-5);
86 86
		}
87 87
		if($res[4] > $width) {
88 88
			$image_failed = true;
......
100 100
	$count=0;
101 101
	do {
102 102
		$image = ImageCreateFromPNG($bg); // background image
103
		$grey = rand(0,50);
103
		$grey = mt_rand(0,50);
104 104
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
105 105
		$ttf = $font;
106 106
		$ttfsize = 25; // fontsize
107
		$angle = rand(0,5);
108
		$x = rand(5,30);
109
		$y = rand($height-10,$height-2);
107
		$angle = mt_rand(0,5);
108
		$x = mt_rand(5,30);
109
		$y = mt_rand($height-10,$height-2);
110 110
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);
111 111
		// check if text fits into the image
112 112
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
trunk/wb/include/captcha/captchas/calc_ttf_image.php
73 73

  
74 74
// create image
75 75
$image = ImageCreateFromPNG($bg); // background image
76
$grey = rand(0,50);
76
$grey = mt_rand(0,50);
77 77
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
78 78
$ttf = $font;
79 79
$ttfsize = 25; // fontsize
80 80

  
81
if(rand(0,2)==0) { // 1 out of 3
81
if(mt_rand(0,2)==0) { // 1 out of 3
82 82

  
83 83
	// draw each character individualy
84 84
	$count = 0;
85 85
	$image_failed = true;
86
	$angle = rand(-10,10);
87
	$x = rand(20,35);
88
	$y = rand($height-10,$height-2);
86
	$angle = mt_rand(-10,10);
87
	$x = mt_rand(20,35);
88
	$y = mt_rand($height-10,$height-2);
89 89
	do {
90 90
		for($i=0;$i<strlen($text);$i++) {
91 91
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
92
			$angle = rand(-10,10);
93
			$x = rand($res[4],$res[4]+10);
94
			$y = rand($height-12,$height-7);
92
			$angle = mt_rand(-10,10);
93
			$x = mt_rand($res[4],$res[4]+10);
94
			$y = mt_rand($height-12,$height-7);
95 95
		}
96 96
		if($res[4] > $width) {
97 97
			$image_failed = true;
......
109 109
	$count=0;
110 110
	do {
111 111
		$image = ImageCreateFromPNG($bg); // background image
112
		$grey = rand(0,50);
112
		$grey = mt_rand(0,50);
113 113
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
114
		$angle = rand(0,5);
115
		$x = rand(20,35);
116
		$y = rand($height-10,$height-2);
114
		$angle = mt_rand(0,5);
115
		$x = mt_rand(20,35);
116
		$y = mt_rand($height-10,$height-2);
117 117
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);
118 118
		// check if text fits into the image
119 119
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
trunk/wb/include/captcha/captchas/calc_image.php
61 61
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
62 62
$darkgray = imagecolorallocate($image, 0x30, 0x30, 0x30);
63 63

  
64
srand((double)microtime()*1000000);
65

  
66 64
for($i = 0; $i < 30; $i++) {
67
	$x1 = rand(0,100);
68
	$y1 = rand(0,30);
69
	$x2 = rand(0,100);
70
	$y2 = rand(0,30);
65
	$x1 = mt_rand(0,100);
66
	$y1 = mt_rand(0,30);
67
	$x2 = mt_rand(0,100);
68
	$y2 = mt_rand(0,30);
71 69
	imageline($image, $x1, $y1, $x2, $y2 , $gray);  
72 70
}
73 71

  
74 72
$x = 0;
75 73
$l = strlen($cap);
76 74
for($i = 0; $i < $l; $i++) {
77
	$fnt = rand(3,5);
78
	$x = $x + rand(12 , 20);
79
	$y = rand(7 , 12); 
75
	$fnt = mt_rand(3,5);
76
	$x = $x + mt_rand(12 , 20);
77
	$y = mt_rand(7 , 12); 
80 78
	imagestring($image, $fnt, $x, $y, substr($cap, $i, 1), $darkgray); 
81 79
}
82 80

  
trunk/wb/search/search.php
164 164
}
165 165

  
166 166
// Get search string
167
$search_normal_string = 'unset';
168
$search_entities_string = 'unset'; // for SQL's LIKE
167
$search_normal_string = '';
168
$search_entities_string = ''; // for SQL's LIKE
169 169
$search_display_string = ''; // for displaying
170 170
$search_url_string = ''; // for $_GET
171 171
$string = '';

Also available in: Unified diff