From 80dc724738310b5c86ff43a7b3c6977ccd74e965 Mon Sep 17 00:00:00 2001 From: towards_a_new_leftypol Date: Mon, 19 Oct 2020 23:01:15 -0400 Subject: [PATCH] lots of print statements --- inc/anti-bot.php | 4 ++++ inc/functions.php | 10 +++++++++- inc/instance-config.php | 6 ++++-- inc/lib/webm/ffmpeg.php | 2 ++ install.php | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/inc/anti-bot.php b/inc/anti-bot.php index 9899e52c..6f9d2a0b 100644 --- a/inc/anti-bot.php +++ b/inc/anti-bot.php @@ -17,6 +17,10 @@ function print_err($s) { file_put_contents($logfile, $s . "\n", FILE_APPEND); } +function print_err2($s) { + print_err($s); +} + class AntiBot { public $salt, $inputs = array(), $index = 0; diff --git a/inc/functions.php b/inc/functions.php index fdb74b12..b77ad54b 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -379,21 +379,26 @@ function create_antibot($board, $thread = null) { function rebuildThemes($action, $boardname = false) { global $config, $board, $current_locale; + print_err("rebuildThemes"); // Save the global variables $_config = $config; $_board = $board; + print_err("list themes"); // List themes if ($themes = Cache::get("themes")) { // OK, we already have themes loaded + print_err("themes loaded from cache"); } else { + print_err("querying db for themes"); $query = query("SELECT `theme` FROM ``theme_settings`` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error()); $themes = array(); while ($theme = $query->fetch(PDO::FETCH_ASSOC)) { + print_err("theme found in db"); $themes[] = $theme; } @@ -449,6 +454,7 @@ function loadThemeConfig($_theme) { function rebuildTheme($theme, $action, $board = false) { global $config, $_theme; $_theme = $theme; + print_err("rebuildTheme with \$theme as " . $theme); $theme = loadThemeConfig($_theme); @@ -2293,9 +2299,11 @@ function strip_combining_chars($str) { function buildThread($id, $return = false, $mod = false) { global $board, $config, $build_pages; $id = round($id); + print_err("buildThread start"); - if (event('build-thread', $id)) + if (event('build-thread', $id)) { return; + } if ($config['cache']['enabled'] && !$mod) { // Clear cache diff --git a/inc/instance-config.php b/inc/instance-config.php index c5e7090c..823fd330 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -35,7 +35,7 @@ $config['db']['database'] = 'lainchan'; $config['db']['prefix'] = ''; $config['db']['user'] = 'lainchan'; - $config['db']['password'] = 'oijrljqqwjr242kjn'; + $config['db']['password'] = ''; $config['cookies']['mod'] = 'mod'; @@ -82,7 +82,7 @@ $config['additional_javascript'][] = 'js/expand-video.js'; $config['max_filesize'] = 50 * 1024 * 1024; // 50MB $config['webm']['allow_audio'] = true; - $config['webm']['max_length'] = 620; + $config['webm']['max_length'] = 1000; //end test section @@ -92,6 +92,8 @@ $config['allowed_ext_files'][] = 'zip'; $config['allowed_ext_files'][] = 'epub'; + $config['api']['enabled'] = false; + /* * From Config: // Always regenerate markup. This isn't recommended and should only be used for debugging; by default, diff --git a/inc/lib/webm/ffmpeg.php b/inc/lib/webm/ffmpeg.php index 91b6af17..f9a50cf7 100644 --- a/inc/lib/webm/ffmpeg.php +++ b/inc/lib/webm/ffmpeg.php @@ -3,12 +3,14 @@ * ffmpeg.php * A barebones ffmpeg based webm implementation for vichan. */ + function get_webm_info($filename) { global $board, $config; $filename = escapeshellarg($filename); $ffprobe = $config['webm']['ffprobe_path']; $ffprobe_out = array(); $webminfo = array(); + exec("$ffprobe -v quiet -print_format json -show_format -show_streams $filename", $ffprobe_out); $ffprobe_out = json_decode(implode("\n", $ffprobe_out), 1); $webminfo['error'] = is_valid_webm($ffprobe_out); diff --git a/install.php b/install.php index ef2d7aa0..a35a3360 100755 --- a/install.php +++ b/install.php @@ -9,6 +9,7 @@ if (fopen('inc/instance-config.php' , 'a') === false) { } require 'inc/functions.php'; +require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only! loadConfig(); @@ -23,6 +24,31 @@ $page = array( // this breaks the display of licenses if enabled $config['minify_html'] = false; +function checkMd5Exec(bool $can_exec) { + print_err2("checkMd5Exec"); + print_err2($can_exec); + $shell_out = shell_exec("pwd"); + print_err2("shell out: " . $shell_out); + $shell_out = shell_exec('echo "vichan" | md5sum'); + print_err2("shell out: " . $shell_out); + $shell_ok = $shell_out == "141225c362da02b5c359c45b665168de -\n"; + print_err2("shell ok: " . strval($shell_ok)); + $result = $can_exec && $shell_ok; + print_err2($result); + return $result; +} + +function checkGifsicle() { + print_err2("checkGifsicle"); + $shell_out = shell_exec('echo $PATH'); + print_err2("shell out: " . $shell_out); + $shell_out = shell_exec('gifsicle --help'); + print_err2("shell out: " . $shell_out); + $shell_out = shell_exec('which gifsicle'); + print_err2("shell out (which gifsicle): " . $shell_out); + return $shell_out; +} + if (file_exists($config['has_installed'])) { // Check the version number @@ -647,6 +673,7 @@ if ($step == 0) { echo Element('page.html', $page); } elseif ($step == 1) { + print_err2("Hello World install.php"); $page['title'] = 'Pre-installation test'; $can_exec = true; @@ -663,6 +690,8 @@ if ($step == 0) { $version = explode('.', PHP_VERSION); define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); } + + print_err2("Can exec: " . strval($can_exec)); // Required extensions $extensions = array( @@ -770,7 +799,7 @@ if ($step == 0) { array( 'category' => 'Image processing', 'name' => '`gifsicle` (command-line animted GIF thumbnailing)', - 'result' => $can_exec && shell_exec('which gifsicle'), + 'result' => $can_exec && checkGifsicle(), 'required' => false, 'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.', 'effect' => function (&$config) { if ($config['thumb_method'] == 'gm') $config['thumb_method'] = 'gm+gifsicle'; @@ -780,7 +809,7 @@ if ($step == 0) { 'category' => 'Image processing', 'name' => '`md5sum` (quick file hashing on GNU/Linux)', 'prereq' => '', - 'result' => $can_exec && shell_exec('echo "vichan" | md5sum') == "141225c362da02b5c359c45b665168de -\n", + 'result' => checkMd5Exec($can_exec), 'required' => false, 'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower. Ignore if not using Linux.', 'effect' => function (&$config) { $config['gnu_md5'] = true; },