mirror of
https://github.com/ithrts/ImoutoIB.git
synced 2025-01-17 00:28:19 +01:00
captcha, filtering
new captcha new zalgo filtering because old one was messing up the format
This commit is contained in:
parent
68ef890f15
commit
f7444e7194
@ -147,10 +147,6 @@ div.post video {
|
||||
max-height: 480px;
|
||||
}
|
||||
|
||||
.post-content, .post-info {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
BIN
assets/fonts/atarist8x16systemfont.ttf
Normal file
BIN
assets/fonts/atarist8x16systemfont.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/sfautomaton-bold.ttf
Normal file
BIN
assets/fonts/sfautomaton-bold.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/sfautomaton-boldoblique.ttf
Normal file
BIN
assets/fonts/sfautomaton-boldoblique.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/sfautomaton-oblique.ttf
Normal file
BIN
assets/fonts/sfautomaton-oblique.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/sfautomaton-regular.ttf
Normal file
BIN
assets/fonts/sfautomaton-regular.ttf
Normal file
Binary file not shown.
1
assets/fonts/sfautomaton.txt
Normal file
1
assets/fonts/sfautomaton.txt
Normal file
@ -0,0 +1 @@
|
||||
no fucking clue what the license is for this font
|
118
captcha.php
118
captcha.php
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
$permitted_chars = '3456ABCDEFGHJKLMNPQRSRUVWXY';
|
||||
|
||||
|
||||
//
|
||||
if (!isset($permitted_chars)) { //allow for changing this in config.php i guess
|
||||
$permitted_chars = '1234567ACDEFGHJKLMNPRSRUVWXY';
|
||||
}
|
||||
|
||||
function generate_string($input, $strength = 10) {
|
||||
$input_length = strlen($input);
|
||||
$random_string = '';
|
||||
@ -13,48 +16,83 @@ function generate_string($input, $strength = 10) {
|
||||
$random_string = strtolower($random_string);
|
||||
return $random_string;
|
||||
}
|
||||
|
||||
$image = imagecreatetruecolor(200, 50);
|
||||
|
||||
imageantialias($image, true);
|
||||
|
||||
$colors = [];
|
||||
|
||||
$red = rand(125, 175);
|
||||
$green = rand(125, 175);
|
||||
$blue = rand(125, 175);
|
||||
|
||||
for($i = 0; $i < 5; $i++) {
|
||||
$colors[] = imagecolorallocate($image, $red - 20*$i, $green - 20*$i, $blue - 20*$i);
|
||||
}
|
||||
|
||||
imagefill($image, 0, 0, $colors[0]);
|
||||
|
||||
for($i = 0; $i < 10; $i++) {
|
||||
imagesetthickness($image, rand(2, 10));
|
||||
$line_color = $colors[rand(1, 4)];
|
||||
imagerectangle($image, rand(-10, 190), rand(-10, 10), rand(-10, 190), rand(40, 60), $line_color);
|
||||
}
|
||||
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$white = imagecolorallocate($image, 255, 255, 255);
|
||||
$textcolors = [$white, $white];
|
||||
|
||||
$fonts = [__dir__ .'/assets/fonts/captcha0.ttf', __dir__ .'/assets/fonts/captcha0.ttf', __dir__ .'/assets/fonts/captcha0.ttf', __dir__ .'/assets/fonts/captcha0.ttf'];
|
||||
|
||||
|
||||
$string_length = 6;
|
||||
$captcha_string = generate_string($permitted_chars, $string_length);
|
||||
|
||||
|
||||
//$fonts = [__dir__ .'/assets/fonts/sfautomaton-regular.ttf', __dir__ .'/assets/fonts/sfautomaton-oblique.ttf', __dir__ .'/assets/fonts/sfautomaton-bold.ttf', __dir__ .'/assets/fonts/sfautomaton-boldoblique.ttf',];
|
||||
$fonts = [__dir__ .'/assets/fonts/atarist8x16systemfont.ttf', __dir__ .'/assets/fonts/atarist8x16systemfont.ttf'];
|
||||
|
||||
$_SESSION['captcha_text'] = $captcha_string;
|
||||
|
||||
|
||||
$captcha_string = strtoupper($captcha_string); //this shit gets converted to lower in the post.php anyways
|
||||
|
||||
|
||||
$captcha_width = 198;
|
||||
$captcha_height = 50;
|
||||
$captcha_image = imagecreatetruecolor($captcha_width, $captcha_height);
|
||||
$captcha_bg_color = imagecolorallocate($captcha_image, 249, 249, 249); //#F9F9F9
|
||||
imagefill($captcha_image, 0, 0, $captcha_bg_color);
|
||||
|
||||
$black = imagecolorallocate($captcha_image, 0, 0, 0);
|
||||
$white = imagecolorallocate($captcha_image, 255, 255, 255);
|
||||
$textcolors = [$black, $black];
|
||||
|
||||
//annoying lines
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
imagesetthickness($captcha_image, rand(1, 2));
|
||||
imagearc(
|
||||
$captcha_image,
|
||||
rand(1, 300), // x-coordinate of the center.
|
||||
rand(1, 300), // y-coordinate of the center.
|
||||
rand(1, 200), // The arc width.
|
||||
rand(1, 200), // The arc height.
|
||||
rand(1, 300), // The arc start angle, in degrees.
|
||||
rand(1, 300), // The arc end angle, in degrees.
|
||||
(rand(0, 1) ? $black : $white) // A color identifier.
|
||||
);
|
||||
}
|
||||
|
||||
//noise background
|
||||
$color1 = imagecolorallocate($captcha_image,0,0,0);
|
||||
$color2 = imagecolorallocate($captcha_image,0,0,0);
|
||||
for($i = 0; $i < $captcha_width; $i++) {
|
||||
if ($i % 2 == 0) {
|
||||
continue;
|
||||
}
|
||||
for($j = 0; $j < $captcha_height; $j++) {
|
||||
if ($j % 3 == 0) {
|
||||
continue;
|
||||
}
|
||||
if (mt_rand(0,1) == 1) imagesetpixel($captcha_image, $i, $j, $color2);
|
||||
}
|
||||
}
|
||||
|
||||
//text
|
||||
for($i = 0; $i < $string_length; $i++) {
|
||||
$letter_space = 170/$string_length;
|
||||
$initial = 15;
|
||||
|
||||
imagettftext($image, 24, rand(-15, 15), $initial + $i*$letter_space, rand(25, 45), $textcolors[rand(0, 1)], $fonts[array_rand($fonts)], $captcha_string[$i]);
|
||||
$initial = 15;
|
||||
imagettftext($captcha_image, 30, rand(-15, 15), $initial + $i*$letter_space, rand(35, 45), $textcolors[rand(0, 1)], $fonts[array_rand($fonts)], $captcha_string[$i]);
|
||||
}
|
||||
|
||||
|
||||
//noise foreground
|
||||
$color1 = imagecolorallocate($captcha_image, 200, 240, 242);
|
||||
$color2 = imagecolorallocate($captcha_image,220,220,220);
|
||||
for($i = 0; $i < $captcha_width; $i++) {
|
||||
if ($i % 2 == 0) {
|
||||
continue;
|
||||
}
|
||||
for($j = 0; $j < $captcha_height; $j++) {
|
||||
if ($j % 3 == 0) {
|
||||
continue;
|
||||
}
|
||||
if (mt_rand(0,1) == 1) imagesetpixel($captcha_image, $i, $j, $color2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
header('Content-type: image/png');
|
||||
imagepng($image);
|
||||
imagedestroy($image);
|
||||
imagepng($captcha_image);
|
||||
imagedestroy($captcha_image);
|
||||
|
||||
?>
|
@ -134,6 +134,7 @@ $config['reply_body_max'] = 4000; //maximum characters
|
||||
$config['max_lines'] = 40;
|
||||
|
||||
$config['linkify_urls'] = true; //converts http/https to links
|
||||
$config['filter_zalgo'] = true; //you want this, trust me
|
||||
$config['wordfilters'][] = array('/little sister/i', 'imouto'); //regex
|
||||
|
||||
|
||||
|
8
post.php
8
post.php
@ -102,6 +102,14 @@ if (($config['mod']['thread_autosage'] <= $mod_level) && isset($_POST['autosage'
|
||||
$post_subject = phpClean($_POST['subject']);
|
||||
$post_body = phpClean($_POST['body']);
|
||||
|
||||
//filter zalgo from all
|
||||
if ($config['filter_zalgo'] == true) {
|
||||
$post_name = preg_replace("~(?:[\p{M}]{1})([\p{M}])~uis","", $post_name);
|
||||
$post_email = preg_replace("~(?:[\p{M}]{1})([\p{M}])~uis","", $post_email);
|
||||
$post_subject = preg_replace("~(?:[\p{M}]{1})([\p{M}])~uis","", $post_subject);
|
||||
$post_body = preg_replace("~(?:[\p{M}]{1})([\p{M}])~uis","", $post_body);
|
||||
}
|
||||
|
||||
|
||||
//CHECK SOME REQS BEFORE BODY EDIT, length. Check newlines after by scanning <br>'s
|
||||
//IF NEW REPLY
|
||||
|
Loading…
x
Reference in New Issue
Block a user