Browse Source

Added function: Option to disable GETs on boards

main
PupperWoff 7 years ago
committed by discomrade
parent
commit
b72b335f3e
  1. 22
      inc/config.php
  2. 58
      inc/functions.php

22
inc/config.php

@ -1983,6 +1983,28 @@
//$config['public_stat']['date'] = '%m/%d/%y (%a) %l %P';
$config['public_stats']['date'] = '<time datetime="%Y-%m-%dT%H:%M:%SZ">%Y-%m-%dT%H:%M:%S</time>';
/*
* ====================
* Deny GET settings
* ====================
*/
// Set to true if you want to disable all GETs globaly (can also be set for each board in it's config)
$config['post_GETs']['disable'] = false;
// Allow MODS to get the GET if they manage to post at the right time
$config['post_GETs']['not_disabled_for_mods'] = false;
// Minimum length of number to be considered a GET number
$config['post_GETs']['minimum_length'] = 5;
// Post ID that ends in a sequense of repeating number that has "repeating_digits_count" of the same number.
$config['post_GETs']['repeating_digits'] = true;
$config['post_GETs']['repeating_digits_count'] = 4;
// Post ID that is made up of consecutive digits starting with 1, e.g. 12345, 123456 ... 1234567890.
$config['post_GETs']['sequential_digits'] = true;
/*
* ====================
* Other/uncategorized

58
inc/functions.php

@ -1267,6 +1267,17 @@ function post(array $post) {
// Save Post ID
$postID = $pdo->lastInsertId();
// Skip GETS
if(postGETCheck($postID)){
// Delete current post entry
$query = prepare(sprintf("DELETE FROM ``posts_%s`` WHERE `id` = :id", $board['uri']));
$query->bindValue(':id', $postID, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
// Create a new post entry and return new ID
return post($post);
}
// Add file-hashes to database
if($post['has_file'])
{
@ -1292,6 +1303,53 @@ function post(array $post) {
return $postID;
}
function postGETCheck($postID)
{
global $config, $mod;
if (!$config['post_GETs']['disable'] || ($config['post_GETs']['not_disabled_for_mods'] && $mod && $mod['type'] >= MOD))
return false;
//
// Post ID that ends in a sequense of repeating number that has "repeating_digits_count" of the same number.
//
// \b[0-9]+([0-9])\1{4,}\b
//
// Explanation:
// ^(?=.{4,}$) # Number must be of five or more digits
// \b # match word boundary
// [1-9]* # match zero or more instances of digit 1-9
// ([0-9]){3,} # match three more instances of same number at the end (four or more total)
// \b # match word boundary
//
if($config['post_GETs']['repeating_digits']) {
// if(preg_match('/^(?=.{4,}$)\b[1-9]*([0-9])\1{3,}\b/', $postID))
if(preg_match('/^(?=.{' . ($config['post_GETs']['minimum_length'] - 1) . ',10}$)\b[0-9]+([0-9])\1{' . ($config['post_GETs']['repeating_digits_count'] - 1) . ',}\b/', $postID))
return true;
}
//
// Post ID that is made up of consecutive digits starting with 1 ex. 12345, 123456 ... 1234567890.
//
// \b(123|1234|12345|123456|123457|12345678|123456789|1234567890)\b
//
// Explanation:
// ^(?=.{5,}$) # Number must be of five or more digits
// \b(123|1234|.. # Match 1234, or, 12345, or ...
//
if($config['post_GETs']['sequential_digits']) {
if(preg_match('/^(?=.{' . ($config['post_GETs']['minimum_length'] - 1) . ',10}$)\b(123|1234|12345|123456|1234567|12345678|123456789|1234567890){1}\b/', $postID))
return true;
}
// If post ID was not a GET number return false
return false;
}
function bumpThread($id) {
global $config, $board, $build_pages;

Loading…
Cancel
Save