diff --git a/.gitignore b/.gitignore index 76331ad1..55c31d79 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,7 @@ tf/ /random/ # Banners -banners/* +# banners/* !banners/lain-bottom.png #Fonts diff --git a/banners/BANNER _d.png b/banners/BANNER _d.png new file mode 100644 index 00000000..7cc50bc2 Binary files /dev/null and b/banners/BANNER _d.png differ diff --git a/banners/BANNER_58.png b/banners/BANNER_58.png new file mode 100644 index 00000000..3231106a Binary files /dev/null and b/banners/BANNER_58.png differ diff --git a/banners/banner_Christopher_Dorner.png b/banners/banner_Christopher_Dorner.png new file mode 100644 index 00000000..b321c185 Binary files /dev/null and b/banners/banner_Christopher_Dorner.png differ diff --git a/banners/banner_count_civ_war.png b/banners/banner_count_civ_war.png new file mode 100644 index 00000000..014a5aee Binary files /dev/null and b/banners/banner_count_civ_war.png differ diff --git a/banners/banner_dasha_ussr.png b/banners/banner_dasha_ussr.png new file mode 100644 index 00000000..bfcff674 Binary files /dev/null and b/banners/banner_dasha_ussr.png differ diff --git a/banners/banner_dasha_victory_parade.png b/banners/banner_dasha_victory_parade.png new file mode 100644 index 00000000..3b73547d Binary files /dev/null and b/banners/banner_dasha_victory_parade.png differ diff --git a/banners/banner_east_west_germ.png b/banners/banner_east_west_germ.png new file mode 100644 index 00000000..bd8a71cb Binary files /dev/null and b/banners/banner_east_west_germ.png differ diff --git a/banners/banner_north_korea_venti_rb.jpg b/banners/banner_north_korea_venti_rb.jpg new file mode 100644 index 00000000..078e9d1d Binary files /dev/null and b/banners/banner_north_korea_venti_rb.jpg differ diff --git a/banners/banner_nuke_waifu.png b/banners/banner_nuke_waifu.png new file mode 100644 index 00000000..7fcc9ebd Binary files /dev/null and b/banners/banner_nuke_waifu.png differ diff --git a/banners/banner_pepe_che.png b/banners/banner_pepe_che.png new file mode 100644 index 00000000..0959bc1f Binary files /dev/null and b/banners/banner_pepe_che.png differ diff --git a/banners/banner_powder_gangers_.png b/banners/banner_powder_gangers_.png new file mode 100644 index 00000000..17518479 Binary files /dev/null and b/banners/banner_powder_gangers_.png differ diff --git a/banners/banner_putin_computer.png b/banners/banner_putin_computer.png new file mode 100644 index 00000000..9605716b Binary files /dev/null and b/banners/banner_putin_computer.png differ diff --git a/banners/banner_soviet_1.png b/banners/banner_soviet_1.png new file mode 100644 index 00000000..c3b62fd0 Binary files /dev/null and b/banners/banner_soviet_1.png differ diff --git a/banners/banner_soviet_2.png b/banners/banner_soviet_2.png new file mode 100644 index 00000000..622cca3a Binary files /dev/null and b/banners/banner_soviet_2.png differ diff --git a/banners/banner_soviet_3.png b/banners/banner_soviet_3.png new file mode 100644 index 00000000..e4f15123 Binary files /dev/null and b/banners/banner_soviet_3.png differ diff --git a/banners/banner_soviet_4.png b/banners/banner_soviet_4.png new file mode 100644 index 00000000..74934ac7 Binary files /dev/null and b/banners/banner_soviet_4.png differ diff --git a/banners/banner_space_monkey_3b.png b/banners/banner_space_monkey_3b.png new file mode 100644 index 00000000..008f2147 Binary files /dev/null and b/banners/banner_space_monkey_3b.png differ diff --git a/banners/banner_zero_. hour.png b/banners/banner_zero_. hour.png new file mode 100644 index 00000000..c39287ba Binary files /dev/null and b/banners/banner_zero_. hour.png differ diff --git a/banners/ronald_cross.png b/banners/ronald_cross.png new file mode 100644 index 00000000..b18928ff Binary files /dev/null and b/banners/ronald_cross.png differ diff --git a/banners/ronald_guillotine.png b/banners/ronald_guillotine.png new file mode 100644 index 00000000..69797d12 Binary files /dev/null and b/banners/ronald_guillotine.png differ diff --git a/inc/anti-bot.php b/inc/anti-bot.php index ac61fe54..278a07a3 100644 --- a/inc/anti-bot.php +++ b/inc/anti-bot.php @@ -11,302 +11,364 @@ $hidden_inputs_twig = array(); $logfile = "/tmp/lainchan_err.out"; function print_err($s) { - global $logfile; - file_put_contents($logfile, $s . "\n", FILE_APPEND); + global $logfile; + $datetime = new Datetime(); + file_put_contents( + $logfile, + $datetime->format(DateTime::ATOM) . " " . $s . "\n", + FILE_APPEND + ); } function getStackTraceAsString() { - $stackTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + $stackTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - $traceString = ''; - foreach ($stackTrace as $index => $entry) { - if ($index > 0) { - $traceString .= sprintf( - "#%d %s(%d): %s%s", - $index - 1, - isset($entry['file']) ? $entry['file'] : 'unknown', - isset($entry['line']) ? $entry['line'] : 0, - isset($entry['class']) ? $entry['class'] . $entry['type'] . $entry['function'] : $entry['function'], - PHP_EOL - ); - } + $traceString = ''; + foreach ($stackTrace as $index => $entry) { + if ($index > 0) { + $traceString .= sprintf( + "#%d %s(%d): %s%s", + $index - 1, + isset($entry['file']) ? $entry['file'] : 'unknown', + isset($entry['line']) ? $entry['line'] : 0, + isset($entry['class']) ? $entry['class'] . $entry['type'] . $entry['function'] : $entry['function'], + PHP_EOL + ); } + } - return $traceString; + return $traceString; } // print_err("\n\nSTART\n\n"); class AntiBot { - public $salt, $inputs = array(), $index = 0; - - public static function randomString($length, $uppercase = false, $special_chars = false, $unicode_chars = false) { - $chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; - if ($uppercase) - $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - if ($special_chars) - $chars .= ' ~!@#$%^&*()_+,./;\'[]\\{}|:<>?=-` '; - if ($unicode_chars) { - $len = strlen($chars) / 10; - for ($n = 0; $n < $len; $n++) - $chars .= mb_convert_encoding('&#' . mt_rand(0x2600, 0x26FF) . ';', 'UTF-8', 'HTML-ENTITIES'); - } - - $chars = preg_split('//u', $chars, -1, PREG_SPLIT_NO_EMPTY); - - $ch = array(); - - // fill up $ch until we reach $length - while (count($ch) < $length) { - $n = $length - count($ch); - $keys = array_rand($chars, $n > count($chars) ? count($chars) : $n); - if ($n == 1) { - $ch[] = $chars[$keys]; - break; - } - shuffle($keys); - foreach ($keys as $key) - $ch[] = $chars[$key]; - } - - $chars = $ch; - - return implode('', $chars); - } - - public static function make_confusing($string) { - $chars = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY); - - foreach ($chars as &$c) { - if (mt_rand(0, 3) != 0) - $c = utf8tohtml($c); - else - $c = mb_encode_numericentity($c, array(0, 0xffff, 0, 0xffff), 'UTF-8'); - } - - return implode('', $chars); - } - - public function __construct(array $salt = array()) { - global $config; - - if (!empty($salt)) { - // create a salted hash of the "extra salt" - $this->salt = implode(':', $salt); - } else { - $this->salt = ''; - } - - shuffle($config['spam']['hidden_input_names']); - - $input_count = mt_rand($config['spam']['hidden_inputs_min'], $config['spam']['hidden_inputs_max']); - $hidden_input_names_x = 0; - - for ($x = 0; $x < $input_count ; $x++) { - if ($hidden_input_names_x === false || mt_rand(0, 2) == 0) { - // Use an obscure name - $name = $this->randomString(mt_rand(10, 40), false, false, $config['spam']['unicode']); - } else { - // Use a pre-defined confusing name - $name = $config['spam']['hidden_input_names'][$hidden_input_names_x++]; - if ($hidden_input_names_x >= count($config['spam']['hidden_input_names'])) - $hidden_input_names_x = false; - } - - if (mt_rand(0, 2) == 0) { - // Value must be null - $this->inputs[$name] = ''; - } elseif (mt_rand(0, 4) == 0) { - // Numeric value - $this->inputs[$name] = (string)mt_rand(0, 100000); - } else { - // Obscure value - $this->inputs[$name] = $this->randomString(mt_rand(5, 100), true, true, $config['spam']['unicode']); - } - } - } - - public static function space() { - if (mt_rand(0, 3) != 0) - return ' '; - return str_repeat(' ', mt_rand(1, 3)); - } - - public function html($count = false) { - global $config; - - $elements = array( - '', - '', - '', - '', - '', - '', - '', - '
', - '
', - '', - '' - ); - - $html = ''; - - if ($count === false) { - $count = mt_rand(1, round(abs(count($this->inputs) / 15)) + 1); - } - - if ($count === true) { - // all elements - $inputs = array_slice($this->inputs, $this->index); - } else { - $inputs = array_slice($this->inputs, $this->index, $count); - } - $this->index += count($inputs); - - foreach ($inputs as $name => $value) { - $element = false; - while (!$element) { - $element = $elements[array_rand($elements)]; - $element = str_replace(' ', self::space(), $element); - if (mt_rand(0, 5) == 0) - $element = str_replace('>', self::space() . '>', $element); - if (strpos($element, 'textarea') !== false && $value == '') { - // There have been some issues with mobile web browsers and empty ', + '' + ); + + $html = ''; + + if ($count === false) { + $count = mt_rand(1, round(abs(count($this->inputs) / 15)) + 1); + } + + if ($count === true) { + // all elements + $inputs = array_slice($this->inputs, $this->index); + } else { + $inputs = array_slice($this->inputs, $this->index, $count); + } + $this->index += count($inputs); + + foreach ($inputs as $name => $value) { + $element = false; + while (!$element) { + $element = $elements[array_rand($elements)]; + $element = str_replace(' ', self::space(), $element); + if (mt_rand(0, 5) == 0) + $element = str_replace('>', self::space() . '>', $element); + if (strpos($element, 'textarea') !== false && $value == '') { + // There have been some issues with mobile web browsers and empty