Browse code

remove ini and error reporting entries as the issues in this file were fixed

Clarissa Walker authored on 2026/09/09 21:47:10
Showing 1 changed files
... ...
@@ -1,7 +1,4 @@
1 1
 <?php
2
-ini_set('display_errors', 0);
3
-ini_set('display_startup_errors', 0);
4
-error_reporting(-1);
5 2
 
6 3
 session_start();
7 4
 define("_BASEDIR", "../");
Browse code

Resolve forgotten PHP deprecation: imagedestroy -> unset

Clarissa Walker authored on 2026/09/04 17:52:09
Showing 1 changed files
... ...
@@ -85,7 +85,7 @@ header("Cache-Control: post-check=0, pre-check=0", false);
85 85
 header("Pragma: no-cache");
86 86
 header('Content-type: image/png');
87 87
 imagepng($image);
88
-imagedestroy($image);
88
+unset($image);
89 89
 
90 90
 exit( );
91 91
 ?> 
Browse code

Resize GD captcha for today's resolutions - and add forgotten set font directory

Clarissa Walker authored on 2026/09/04 14:38:39
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ define("_BASEDIR", "../");
8 8
 include("../config.php");
9 9
 unset($_SESSION[$sitekey.'_digit']);
10 10
 
11
-$image = imagecreate(140, 40);
11
+$image = imagecreate(280, 80);
12 12
 
13 13
 $white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
14 14
 $gray    = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
... ...
@@ -31,6 +31,8 @@ return $color;
31 31
 
32 32
 putenv('GDFONTPATH=' . realpath('.'));
33 33
 
34
+$folder=dir("cFonts/"); //The directory where your fonts reside
35
+
34 36
 while($font=$folder->read()) {
35 37
 if(stristr($font,'.ttf')) {
36 38
   // Check GD Version 2.4.0 or later
... ...
@@ -48,27 +50,27 @@ $rC = rgb_rand(0, 175);
48 50
 $rColors[$i] = imagecolorallocate($image, $rC['r'], $rC['g'], $rC['b']);
49 51
 
50 52
 for ($x = 0; $x < 2; $x++) {
51
-  $x1 = rand(0,140);
52
-  $y1 = rand(0,40);
53
-  $x2 = rand(0,140);
54
-  $y2 = rand(0,40);
53
+  $x1 = rand(0,280);
54
+  $y1 = rand(0,80);
55
+  $x2 = rand(0,280);
56
+  $y2 = rand(0,80);
55 57
   imageline($image, $x1, $y1, $x2, $y2 , $rColors[$i]);  
56 58
 }
57 59
 
58 60
 }
59 61
 
60 62
 /* generate random dots in background */
61
-for( $i=0; $i<(140*40)/3; $i++ ) {
62
-  imagefilledellipse($image, mt_rand(0,140), mt_rand(0,40), 1, 1, $gray);
63
+for( $i=0; $i<(280*80)/3; $i++ ) {
64
+  imagefilledellipse($image, mt_rand(0,280), mt_rand(0,80), 1, 1, $gray);
63 65
 }
64 66
 
65 67
 for ($i = 0; $i < 5; $i++) {
66
- $x = $x + mt_rand(16, 24);
67
- $y = mt_rand(26, 32); 
68
- $angle = mt_rand(-15, 15);
68
+ $x = $x + mt_rand(32, 48);
69
+ $y = mt_rand(52, 64);
70
+ $angle = mt_rand(-30, 30);
69 71
  $fnt = mt_rand(0, sizeof($fontList) - 1);
70 72
  $colori = $rColors[$i];
71
- imagettftext($image, mt_rand(20, 24), $angle,  $x, $y, $colori, $fontList[$fnt], $cnum[$i]); 
73
+ imagettftext($image, mt_rand(40, 48), $angle, $x, $y, $colori, $fontList[$fnt], $cnum[$i]);
72 74
 
73 75
 }
74 76
  
Browse code

Fix GD captcha fonts path for PHP 8.6 and GD 2.4.0 library users

Clarissa Walker authored on 2026/09/04 13:58:06
Showing 1 changed files
... ...
@@ -31,14 +31,17 @@ return $color;
31 31
 
32 32
 putenv('GDFONTPATH=' . realpath('.'));
33 33
 
34
-$folder=dir("cFonts/"); //The directory where your fonts reside
35
-
36 34
 while($font=$folder->read()) {
37
-  if(stristr($font,'.ttf')) $fontList[] = "cFonts/".$font;
35
+if(stristr($font,'.ttf')) {
36
+  // Check GD Version 2.4.0 or later
37
+  if (version_compare(GD_VERSION, '2.4.0', '>=')) {
38
+    $fontList[] = "cFonts/".str_replace(".ttf", "", $font);
39
+    } else {
40
+    $fontList[] = "cFonts/".$font;
41
+    }
42
+  }
38 43
 }
39 44
 
40
-$folder->close();
41
-
42 45
 for ($i = 0; $i < 5; $i++) {
43 46
 $cnum[$i] = rand(0,9);
44 47
 $rC = rgb_rand(0, 175);
... ...
@@ -63,7 +66,6 @@ for ($i = 0; $i < 5; $i++) {
63 66
  $x = $x + mt_rand(16, 24);
64 67
  $y = mt_rand(26, 32); 
65 68
  $angle = mt_rand(-15, 15);
66
- $c = $color[$i];
67 69
  $fnt = mt_rand(0, sizeof($fontList) - 1);
68 70
  $colori = $rColors[$i];
69 71
  imagettftext($image, mt_rand(20, 24), $angle,  $x, $y, $colori, $fontList[$fnt], $cnum[$i]); 
... ...
@@ -85,4 +87,3 @@ imagedestroy($image);
85 87
 
86 88
 exit( );
87 89
 ?> 
88
-
Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,88 @@
1
+<?php
2
+ini_set('display_errors', 0);
3
+ini_set('display_startup_errors', 0);
4
+error_reporting(-1);
5
+
6
+session_start();
7
+define("_BASEDIR", "../");
8
+include("../config.php");
9
+unset($_SESSION[$sitekey.'_digit']);
10
+
11
+$image = imagecreate(140, 40);
12
+
13
+$white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
14
+$gray    = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
15
+$darkgray = imagecolorallocate($image, 0x50, 0x50, 0x50);
16
+$black = imagecolorallocate($image, 0x00, 0x00, 0x00);
17
+
18
+
19
+srand((double)microtime()*1000000);
20
+unset($digit, $cnum);
21
+
22
+
23
+function rgb_rand($min=0,$max=255) {
24
+$color['r'] = mt_rand($min,$max);
25
+$color['g'] = mt_rand($min,$max);
26
+$color['b'] = mt_rand($min,$max);
27
+return $color;
28
+}
29
+
30
+/* Build the list of fonts */
31
+
32
+putenv('GDFONTPATH=' . realpath('.'));
33
+
34
+$folder=dir("cFonts/"); //The directory where your fonts reside
35
+
36
+while($font=$folder->read()) {
37
+  if(stristr($font,'.ttf')) $fontList[] = "cFonts/".$font;
38
+}
39
+
40
+$folder->close();
41
+
42
+for ($i = 0; $i < 5; $i++) {
43
+$cnum[$i] = rand(0,9);
44
+$rC = rgb_rand(0, 175);
45
+$rColors[$i] = imagecolorallocate($image, $rC['r'], $rC['g'], $rC['b']);
46
+
47
+for ($x = 0; $x < 2; $x++) {
48
+  $x1 = rand(0,140);
49
+  $y1 = rand(0,40);
50
+  $x2 = rand(0,140);
51
+  $y2 = rand(0,40);
52
+  imageline($image, $x1, $y1, $x2, $y2 , $rColors[$i]);  
53
+}
54
+
55
+}
56
+
57
+/* generate random dots in background */
58
+for( $i=0; $i<(140*40)/3; $i++ ) {
59
+  imagefilledellipse($image, mt_rand(0,140), mt_rand(0,40), 1, 1, $gray);
60
+}
61
+
62
+for ($i = 0; $i < 5; $i++) {
63
+ $x = $x + mt_rand(16, 24);
64
+ $y = mt_rand(26, 32); 
65
+ $angle = mt_rand(-15, 15);
66
+ $c = $color[$i];
67
+ $fnt = mt_rand(0, sizeof($fontList) - 1);
68
+ $colori = $rColors[$i];
69
+ imagettftext($image, mt_rand(20, 24), $angle,  $x, $y, $colori, $fontList[$fnt], $cnum[$i]); 
70
+
71
+}
72
+ 
73
+$digit = "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";
74
+
75
+$_SESSION[$sitekey.'_digit'] = md5($sitekey.$digit);
76
+ 
77
+header("Expires: Tue, 11 Jun 1985 05:00:00 GMT");  
78
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
79
+header("Cache-Control: no-store, no-cache, must-revalidate");  
80
+header("Cache-Control: post-check=0, pre-check=0", false);
81
+header("Pragma: no-cache");
82
+header('Content-type: image/png');
83
+imagepng($image);
84
+imagedestroy($image);
85
+
86
+exit( );
87
+?> 
88
+