mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-06 04:30:21 +00:00
REVERT Regex Patch for Word Boundaries
This commit is contained in:
parent
3fa05a4f22
commit
b3763b26f5
1 changed files with 19 additions and 26 deletions
|
@ -1,11 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
/* Regex Formatting Generator Script for the Nginx Ultimate Bad Bot Blocker
|
||||||
/* Regex Formatting Generator Script for the Nginx Ultimate Bad Bot Blocker
|
|
||||||
* Adapted from Script Copyright (c) 2017 Stevie-Ray - https://github.com/Stevie-Ray
|
* Adapted from Script Copyright (c) 2017 Stevie-Ray - https://github.com/Stevie-Ray
|
||||||
* Adapted by: Mitchell Krog (mitchellkrog@gmail.com) - https://github.com/mitchellkrogza
|
* Adapted by: Mitchell Krog (mitchellkrog@gmail.com) - https://github.com/mitchellkrogza
|
||||||
* Repo Url: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker
|
* Repo Url: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace mitchellkrogza;
|
namespace mitchellkrogza;
|
||||||
|
|
||||||
use Mso\IdnaConvert\IdnaConvert;
|
use Mso\IdnaConvert\IdnaConvert;
|
||||||
|
@ -14,7 +12,6 @@ class Generator
|
||||||
{
|
{
|
||||||
|
|
||||||
private $projectUrl = "https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker";
|
private $projectUrl = "https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker";
|
||||||
|
|
||||||
public function generateFiles()
|
public function generateFiles()
|
||||||
{
|
{
|
||||||
date_default_timezone_set('Africa/Johannesburg');
|
date_default_timezone_set('Africa/Johannesburg');
|
||||||
|
@ -23,6 +20,7 @@ class Generator
|
||||||
$this->createNginx($lines);
|
$this->createNginx($lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +42,7 @@ class Generator
|
||||||
$IDN = new IdnaConvert();
|
$IDN = new IdnaConvert();
|
||||||
|
|
||||||
$line = $IDN->encode($line);
|
$line = $IDN->encode($line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($line)) {
|
if (empty($line)) {
|
||||||
|
@ -51,12 +50,9 @@ class Generator
|
||||||
}
|
}
|
||||||
$lines[] = $line;
|
$lines[] = $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
$uniqueLines = array_unique($lines, SORT_STRING);
|
$uniqueLines = array_unique($lines, SORT_STRING);
|
||||||
sort($uniqueLines, SORT_STRING);
|
sort($uniqueLines, SORT_STRING);
|
||||||
|
|
||||||
|
|
||||||
if (is_writable($domainsFile)) {
|
if (is_writable($domainsFile)) {
|
||||||
file_put_contents($domainsFile, implode("\n", $uniqueLines));
|
file_put_contents($domainsFile, implode("\n", $uniqueLines));
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,7 +70,7 @@ class Generator
|
||||||
protected function writeToFile($filename, $data)
|
protected function writeToFile($filename, $data)
|
||||||
{
|
{
|
||||||
$file = "/home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/referrers-regex-format.txt";
|
$file = "/home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/referrers-regex-format.txt";
|
||||||
$handle = fopen($file, 'w') or die('Cannot open file: ' . $file);
|
$handle = fopen($file, 'w') or die('Cannot open file: '.$file);
|
||||||
fwrite($handle, $data);
|
fwrite($handle, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,17 +82,14 @@ class Generator
|
||||||
{
|
{
|
||||||
$file = "/home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/referrers-regex-format.txt";
|
$file = "/home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/referrers-regex-format.txt";
|
||||||
$data = "";
|
$data = "";
|
||||||
|
{
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
//$data .= "\"~*" "\\" "b" . preg_quote($line) . "\\" "b" "\" \t1;\n";
|
//$data .= "\"~*\b" . preg_quote($line) . "\"\b" "\t1;\n";
|
||||||
//$data .= "\" . "~*\\" . 'b' . preg_quote($line) . "\" . '\\' . 'b' "\" "\t1;\n";
|
$data .= "\"~*" . preg_quote($line) . "\" \t1;\n";
|
||||||
//$data .= "\" . "~\\" . '\b' . preg_quote($line) . "\" . '\' . '\b' "\t1\n";
|
|
||||||
$data .= '\\' . '~\\' . "\\" . "b" . preg_quote($line) . "\\" . "b \t1\n";
|
|
||||||
}
|
}
|
||||||
$this->writeToFile($file, $data);
|
$this->writeToFile($file, $data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$generator = new Generator();
|
$generator = new Generator();
|
||||||
$generator->generateFiles();
|
$generator->generateFiles();
|
||||||
|
|
Loading…
Add table
Reference in a new issue