aboutsummaryrefslogtreecommitdiffstats
path: root/captcha.php
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-05-27 21:30:45 -0700
committerPinapelz <yukais@pinapelz.com>2026-05-27 21:46:34 -0700
commitaf79a76c78d7886a365784ac6d1895f65c1c381e (patch)
treea7f70fca59cda25a97bcfdf932eea643231161d9 /captcha.php
parent1da02013c535c85b39417ba5f17f23a8b4ad6782 (diff)
update IQ test text and font
Diffstat (limited to 'captcha.php')
-rwxr-xr-xcaptcha.php60
1 files changed, 30 insertions, 30 deletions
diff --git a/captcha.php b/captcha.php
index 286a277..49e6c5b 100755
--- a/captcha.php
+++ b/captcha.php
@@ -8,7 +8,7 @@ if(
$_GET["v"]
) === 0
){
-
+
http_response_code(401);
header("Content-Type: text/plain");
echo "Fuck my feathered cloaca";
@@ -19,7 +19,7 @@ if(
include "data/config.php";
if(config::BOT_PROTECTION !== 1){
-
+
header("Content-Type: text/plain");
echo "The IQ test is disabled";
die();
@@ -28,7 +28,7 @@ if(config::BOT_PROTECTION !== 1){
$grid = apcu_fetch($_GET["v"]);
if($grid !== false){
-
+
// captcha already generated
http_response_code(304); // not modified
die();
@@ -48,7 +48,7 @@ array_splice($range, 0, 1);
$picks = random_int(3, 6);
for($i=0; $i<$picks; $i++){
-
+
$answer_pos_tmp =
array_splice(
$range,
@@ -58,7 +58,7 @@ for($i=0; $i<$picks; $i++){
),
1
);
-
+
$answer_pos[] = $answer_pos_tmp[0];
}
@@ -68,12 +68,12 @@ $choosen = config::CAPTCHA_DATASET[random_int(0, $c - 1)];
$choices = [];
for($i=0; $i<$c; $i++){
-
+
if(config::CAPTCHA_DATASET[$i][0] == $choosen[0]){
-
+
continue;
}
-
+
$choices[] = config::CAPTCHA_DATASET[$i];
}
@@ -81,12 +81,12 @@ for($i=0; $i<$c; $i++){
$grid = [];
for($i=0; $i<16; $i++){
-
+
if(in_array($i, $answer_pos)){
-
+
$grid[] = $choosen;
}else{
-
+
$grid[] = $choices[random_int(0, count($choices) - 1)];
}
}
@@ -100,13 +100,13 @@ apcu_store(
// generate image
if(random_int(0,1) === 0){
-
+
$theme = [
"bg" => "#ebdbb2",
"fg" => "#1d2021"
];
}else{
-
+
$theme = [
"bg" => "#1d2021",
"fg" => "#ebdbb2"
@@ -130,52 +130,52 @@ $distort = [
$i = 0;
for($y=0; $y<4; $y++){
-
+
for($x=0; $x<4; $x++){
-
+
$tmp = new Imagick("./data/captcha/" . $grid[$i][0] . "/" . random_int(1, $grid[$i][1]) . ".png");
-
+
// convert transparency correctly
$tmp->setImageBackgroundColor("black");
$tmp->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
-
+
// randomly mirror
if(random_int(0,1) === 1){
-
+
$tmp->flopImage();
}
-
+
// distort $tmp
$tmp->distortImage(
$distort[random_int(0,1)],
[
0, 0,
random_int(-15, 15), random_int(-15, 15),
-
+
100, 0,
random_int(80, 120), random_int(-15, 15),
-
+
100, 100,
random_int(80, 120), random_int(80, 120),
-
+
0, 100,
random_int(-15, 15), random_int(80, 120)
],
false
);
-
+
$tmp->addNoiseImage($noise[random_int(0, 1)]);
-
+
// append image
$im->compositeImage($tmp->getImage(), Imagick::COMPOSITE_DEFAULT, $x * 100, ($y * 100) + 27);
-
+
$i++;
}
}
// add text
$draw = new ImagickDraw();
-$draw->setFontSize(20);
+$draw->setFontSize(24);
$draw->setFillColor($theme["fg"]);
//$draw->setTextAntialias(false);
$draw->setFont("./data/fonts/captcha.ttf");
@@ -185,17 +185,17 @@ $text = "Pick " . $picks . " images of " . str_replace("_", " ", $choosen[0]);
$pos = 200 - ($im->queryFontMetrics($draw, $text)["textWidth"] / 2);
for($i=0; $i<strlen($text); $i++){
-
+
$im->annotateImage(
$draw,
$pos,
- 20,
+ 22,
random_int(-15, 15),
$text[$i]
);
-
+
$pos += $im->queryFontMetrics($draw, $text[$i])["textWidth"];
-
+
}
$im->setFormat("jpeg");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage