forked from leftypol/leftypol
Print statements everywhere
This commit is contained in:
parent
05a0274f1f
commit
cd9515397c
5 changed files with 245 additions and 25 deletions
|
@ -8,6 +8,15 @@ defined('TINYBOARD') or exit;
|
|||
|
||||
$hidden_inputs_twig = array();
|
||||
|
||||
$logfile = "/tmp/lainchan_err.out";
|
||||
file_put_contents($logfile, "\n\nSTART\n\n", FILE_APPEND);
|
||||
|
||||
function print_err($s) {
|
||||
global $logfile;
|
||||
|
||||
file_put_contents($logfile, $s . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
class AntiBot {
|
||||
public $salt, $inputs = array(), $index = 0;
|
||||
|
||||
|
@ -171,6 +180,8 @@ class AntiBot {
|
|||
|
||||
public function hash() {
|
||||
global $config;
|
||||
|
||||
print_err("compute hash for post page");
|
||||
|
||||
// This is the tricky part: create a hash to validate it after
|
||||
// First, sort the keys in alphabetical order (A-Z)
|
||||
|
@ -180,6 +191,7 @@ class AntiBot {
|
|||
$hash = '';
|
||||
// Iterate through each input
|
||||
foreach ($inputs as $name => $value) {
|
||||
print_err("<- " . $name . ' : ' . $value);
|
||||
$hash .= $name . '=' . $value;
|
||||
}
|
||||
// Add a salt to the hash
|
||||
|
@ -252,6 +264,7 @@ function checkSpam(array $extra_salt = array()) {
|
|||
|
||||
// Iterate through each input
|
||||
foreach ($inputs as $name => $value) {
|
||||
print_err("-> " . $name . ' : ' . $value);
|
||||
$_hash .= $name . '=' . $value;
|
||||
}
|
||||
|
||||
|
@ -261,8 +274,10 @@ function checkSpam(array $extra_salt = array()) {
|
|||
// Use SHA1 for the hash
|
||||
$_hash = sha1($_hash . $extra_salt);
|
||||
|
||||
if ($hash != $_hash)
|
||||
if ($hash != $_hash) {
|
||||
print_err("Hash mismatch");
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = prepare('SELECT `passed` FROM ``antispam`` WHERE `hash` = :hash');
|
||||
$query->bindValue(':hash', $hash);
|
||||
|
|
0
inc/error.php
Normal file → Executable file
0
inc/error.php
Normal file → Executable file
|
@ -6,6 +6,8 @@
|
|||
|
||||
defined('TINYBOARD') or exit;
|
||||
|
||||
require_once 'inc/anti-bot.php';
|
||||
|
||||
class Filter {
|
||||
public $flood_check;
|
||||
private $condition;
|
||||
|
@ -209,6 +211,8 @@ function purge_flood_table() {
|
|||
|
||||
function do_filters(array $post) {
|
||||
global $config;
|
||||
|
||||
print_err("do_filters begin");
|
||||
|
||||
if (!isset($config['filters']) || empty($config['filters']))
|
||||
return;
|
||||
|
|
|
@ -25,6 +25,8 @@ require_once 'inc/queue.php';
|
|||
require_once 'inc/polyfill.php';
|
||||
@include_once 'inc/lib/parsedown/Parsedown.php'; // fail silently, this isn't a critical piece of code
|
||||
|
||||
require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only!
|
||||
|
||||
if (!extension_loaded('gettext')) {
|
||||
require_once 'inc/lib/gettext/gettext.inc';
|
||||
}
|
||||
|
@ -371,6 +373,7 @@ function define_groups() {
|
|||
function create_antibot($board, $thread = null) {
|
||||
require_once dirname(__FILE__) . '/anti-bot.php';
|
||||
|
||||
print_err("Create Antibot.");
|
||||
return _create_antibot($board, $thread);
|
||||
}
|
||||
|
||||
|
@ -995,6 +998,7 @@ function insertFloodPost(array $post) {
|
|||
|
||||
function post(array $post) {
|
||||
global $pdo, $board,$config;
|
||||
print_err("Post function START");
|
||||
$query = prepare(sprintf("INSERT INTO ``posts_%s`` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :body_nomarkup, :time, :time, :files, :num_files, :filehash, :password, :ip, :sticky, :locked, :cycle, 0, :embed, :slug)", $board['uri']));
|
||||
|
||||
// Basic stuff
|
||||
|
@ -1083,10 +1087,13 @@ function post(array $post) {
|
|||
}
|
||||
|
||||
if (!$query->execute()) {
|
||||
print_err("Post DB ERROR " . print_r($query, true));
|
||||
undoImage($post);
|
||||
error(db_error($query));
|
||||
}
|
||||
|
||||
print_err("Post function DONE");
|
||||
|
||||
return $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue