Compare commits
87 Commits
deploy_spa
...
debug_prof
|
@ -62,7 +62,7 @@ tf/
|
||||||
/random/
|
/random/
|
||||||
|
|
||||||
# Banners
|
# Banners
|
||||||
banners/*
|
# banners/*
|
||||||
!banners/lain-bottom.png
|
!banners/lain-bottom.png
|
||||||
|
|
||||||
#Fonts
|
#Fonts
|
||||||
|
|
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 72 KiB |
|
@ -12,7 +12,12 @@ $logfile = "/tmp/lainchan_err.out";
|
||||||
|
|
||||||
function print_err($s) {
|
function print_err($s) {
|
||||||
global $logfile;
|
global $logfile;
|
||||||
file_put_contents($logfile, $s . "\n", FILE_APPEND);
|
$datetime = new Datetime();
|
||||||
|
file_put_contents(
|
||||||
|
$logfile,
|
||||||
|
$datetime->format(DateTime::ATOM) . " " . $s . "\n",
|
||||||
|
FILE_APPEND
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStackTraceAsString() {
|
function getStackTraceAsString() {
|
||||||
|
@ -217,6 +222,13 @@ class AntiBot {
|
||||||
// Use SHA1 for the hash
|
// Use SHA1 for the hash
|
||||||
return sha1($hash . $this->salt);
|
return sha1($hash . $this->salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function printErrVars() { //DELETE ME
|
||||||
|
$inputs = $this->inputs;
|
||||||
|
ksort($inputs);
|
||||||
|
|
||||||
|
print_err("Antibot " . $this->hash() . " inputs: " . json_encode($inputs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _create_antibot($board, $thread) {
|
function _create_antibot($board, $thread) {
|
||||||
|
@ -246,16 +258,56 @@ function _create_antibot($board, $thread) {
|
||||||
$query->bindValue(':hash', $antibot->hash());
|
$query->bindValue(':hash', $antibot->hash());
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
//$antibot->printErrVars();
|
||||||
|
|
||||||
return $antibot;
|
return $antibot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dumpVars($extra_salt) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$json_repr = json_encode($_POST);
|
||||||
|
print_err("Check Spam POST data: " . $json_repr);
|
||||||
|
|
||||||
|
if ($json_repr === false) {
|
||||||
|
print_err("Could not jsonify POST data: " . json_last_error_message());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
foreach ($_POST as $name => $value) {
|
||||||
|
$is_valid_input = in_array($name, $config['spam']['valid_inputs']) ? "valid" : "invalid";
|
||||||
|
print_err(" $name: $value ($is_valid_input)");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!empty($extra_salt)) {
|
||||||
|
$extra_salt = implode(':', $extra_salt);
|
||||||
|
} else {
|
||||||
|
$extra_salt = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
print_err("extra_salt: $extra_salt");
|
||||||
|
}
|
||||||
|
|
||||||
function checkSpam(array $extra_salt = array()) {
|
function checkSpam(array $extra_salt = array()) {
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
|
|
||||||
if (!isset($_POST['hash']))
|
#print_err("checkSpam start");
|
||||||
return true;
|
$extra_salt_orig = $extra_salt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!isset($_POST['hash'])) {
|
||||||
|
print_err("checkSpam: _POST array doesn't have key 'hash', check failed.");
|
||||||
|
dumpVars($extra_salt_orig);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (isset($_POST['hash'])) {
|
||||||
$hash = $_POST['hash'];
|
$hash = $_POST['hash'];
|
||||||
|
} else {
|
||||||
|
$hash = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($extra_salt)) {
|
if (!empty($extra_salt)) {
|
||||||
// create a salted hash of the "extra salt"
|
// create a salted hash of the "extra salt"
|
||||||
|
@ -290,7 +342,14 @@ function checkSpam(array $extra_salt = array()) {
|
||||||
// Use SHA1 for the hash
|
// Use SHA1 for the hash
|
||||||
$_hash = sha1($_hash . $extra_salt);
|
$_hash = sha1($_hash . $extra_salt);
|
||||||
|
|
||||||
if ($hash != $_hash) {
|
if (empty($hash)) {
|
||||||
|
print_err("checkSpam: hash is either empty or was never present, check failed. Not flagging as spam however.");
|
||||||
|
dumpVars($extra_salt_orig);
|
||||||
|
// Ignore missing hash, because it was missing for some legitimate posters and bots tend to fill in any field.
|
||||||
|
return false;
|
||||||
|
} else if ($hash != $_hash) {
|
||||||
|
print_err("checkSpam: Hash values do not match! submitted hash value from POST data: $hash ; Computed hash value: $_hash");
|
||||||
|
dumpVars($extra_salt_orig);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +358,10 @@ function checkSpam(array $extra_salt = array()) {
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
if ((($passed = $query->fetchColumn(0)) === false) || ($passed > $config['spam']['hidden_inputs_max_pass'])) {
|
if ((($passed = $query->fetchColumn(0)) === false) || ($passed > $config['spam']['hidden_inputs_max_pass'])) {
|
||||||
// there was no database entry for this hash. most likely expired.
|
// there was no database entry for this hash. most likely expired.
|
||||||
return true;
|
print_err("checkSpam: there was no database entry for this hash. most likely expired. $hash");
|
||||||
|
dumpVars($extra_salt_orig);
|
||||||
|
return $hash; // do not consider this a failure case. (I would rather a spam post than a false-positive tbqh)
|
||||||
|
//return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hash;
|
return $hash;
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Api {
|
||||||
|
|
||||||
$this->threadsPageFields = array(
|
$this->threadsPageFields = array(
|
||||||
'id' => 'no',
|
'id' => 'no',
|
||||||
'bump' => 'last_modified',
|
'bump' => 'bump',
|
||||||
'board' => 'board',
|
'board' => 'board',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -197,6 +197,7 @@ class Api {
|
||||||
$ips[] = $p->ip;
|
$ips[] = $p->ip;
|
||||||
}
|
}
|
||||||
$apiPosts['posts'][0]['unique_ips'] = count(array_unique($ips));
|
$apiPosts['posts'][0]['unique_ips'] = count(array_unique($ips));
|
||||||
|
$apiPosts['posts'][0]['last_modified'] = (empty($thread->posts) ? $thread : end($thread->posts))->time;
|
||||||
|
|
||||||
return $apiPosts;
|
return $apiPosts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
// Enables captcha
|
// Enables captcha
|
||||||
$config['securimage'] = false;
|
$config['securimage'] = false;
|
||||||
|
// Limits captcha to TOR users
|
||||||
|
$config['captcha_tor_only'] = false;
|
||||||
|
|
||||||
// Global announcement -- the very simple version.
|
// Global announcement -- the very simple version.
|
||||||
// This used to be wrongly named $config['blotter'] (still exists as an alias).
|
// This used to be wrongly named $config['blotter'] (still exists as an alias).
|
||||||
|
|
|
@ -24,6 +24,46 @@ register_shutdown_function('fatal_error_handler');
|
||||||
|
|
||||||
$error_recursion=false;
|
$error_recursion=false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global anything is always a bad idea, but since all of this website's error handling comes
|
||||||
|
* down to calling this error function and quitting, we have no way of catching exceptions, for example
|
||||||
|
* during thumbnail creation.
|
||||||
|
*
|
||||||
|
* So push things to run in case of a crash into a list, and then run all of them in error.
|
||||||
|
*
|
||||||
|
* This will be exclusive to callbacks for posting a post callflow, not mod actions or anything else.
|
||||||
|
*/
|
||||||
|
function global_post_cleanup() {
|
||||||
|
global $post_cleanup_list;
|
||||||
|
|
||||||
|
if (!isset($post_cleanup_list)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($post_cleanup_list as $f) {
|
||||||
|
$f();
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($post_cleanup_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
function push_global_post_cleanup($f) {
|
||||||
|
global $post_cleanup_list;
|
||||||
|
|
||||||
|
if (!isset($post_cleanup_list)) {
|
||||||
|
$post_cleanup_list = array($f);
|
||||||
|
} else {
|
||||||
|
array_push($post_cleanup_list, $f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_global_post_cleanup() {
|
||||||
|
global $post_cleanup_list;
|
||||||
|
$post_cleanup_list = array();
|
||||||
|
}
|
||||||
|
|
||||||
function error($message, $priority = true, $debug_stuff = false) {
|
function error($message, $priority = true, $debug_stuff = false) {
|
||||||
global $board, $mod, $config, $db_error, $error_recursion;
|
global $board, $mod, $config, $db_error, $error_recursion;
|
||||||
|
|
||||||
|
@ -75,11 +115,14 @@ function error($message, $priority = true, $debug_stuff = false) {
|
||||||
$data['debug']=$debug_stuff;
|
$data['debug']=$debug_stuff;
|
||||||
}
|
}
|
||||||
print json_encode($data);
|
print json_encode($data);
|
||||||
|
global_post_cleanup();
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
|
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
|
||||||
|
|
||||||
|
global_post_cleanup();
|
||||||
|
|
||||||
die(Element('page.html', array(
|
die(Element('page.html', array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'title' => _('Error'),
|
'title' => _('Error'),
|
||||||
|
|
|
@ -2905,3 +2905,34 @@ function strategy_first($fun, $array) {
|
||||||
return array('defer');
|
return array('defer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ipIsLocal($ip) {
|
||||||
|
// Define the local IP ranges commonly used in private networks
|
||||||
|
$localRanges = [
|
||||||
|
'10.0.0.0/8', // Private network range 10.0.0.0 to 10.255.255.255
|
||||||
|
'172.16.0.0/12', // Private network range 172.16.0.0 to 172.31.255.255
|
||||||
|
'192.168.0.0/16', // Private network range 192.168.0.0 to 192.168.255.255
|
||||||
|
'127.0.0.0/8', // Loopback range for localhost
|
||||||
|
'169.254.0.0/16' // Link-local addresses
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($localRanges as $range) {
|
||||||
|
if (ipInRange($ip, $range)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ipInRange($ip, $range) {
|
||||||
|
// Split the range to get the base IP and the netmask
|
||||||
|
list($baseIP, $netmask) = explode('/', $range);
|
||||||
|
// Convert IPs into long format for easy comparison
|
||||||
|
$ipLong = ip2long($ip);
|
||||||
|
$rangeLong = ip2long($baseIP);
|
||||||
|
$maskLong = ~((1 << (32 - $netmask)) - 1);
|
||||||
|
|
||||||
|
// Check if the IP is in the given range
|
||||||
|
return (($ipLong & $maskLong) == ($rangeLong & $maskLong));
|
||||||
|
}
|
||||||
|
|
|
@ -171,12 +171,13 @@ class ImageBase extends ImageGD {
|
||||||
$this->width = $width;
|
$this->width = $width;
|
||||||
$this->height = $height;
|
$this->height = $height;
|
||||||
|
|
||||||
if (method_exists($this, 'resize'))
|
if (method_exists($this, 'resize')) {
|
||||||
$this->resize();
|
$this->resize();
|
||||||
else
|
} else {
|
||||||
// use default GD functions
|
// use default GD functions
|
||||||
$this->GD_resize();
|
$this->GD_resize();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageImagick extends ImageBase {
|
class ImageImagick extends ImageBase {
|
||||||
|
@ -339,6 +340,24 @@ class ImageConvert extends ImageBase {
|
||||||
$this->temp = false;
|
$this->temp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if there is a real error and false if it's just a warning
|
||||||
|
// (appilcable to the return text of the `gm convert` command only)
|
||||||
|
public static function actualErrorOrJustWarning($message_string) {
|
||||||
|
$warnings = array(
|
||||||
|
"known incorrect sRGB profile",
|
||||||
|
"iCCP: Not recognizing known sRGB profile that has been edited",
|
||||||
|
"sRGB: cHRM chunk does not match sRGB"
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($warnings as $w) {
|
||||||
|
if (strpos($message_string, $w) !== False) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
public function resize() {
|
public function resize() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -390,20 +409,25 @@ class ImageConvert extends ImageBase {
|
||||||
$convert_args = str_replace('-auto-orient', '', $config['convert_args']);
|
$convert_args = str_replace('-auto-orient', '', $config['convert_args']);
|
||||||
else
|
else
|
||||||
$convert_args = &$config['convert_args'];
|
$convert_args = &$config['convert_args'];
|
||||||
if (($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
|
||||||
sprintf($convert_args,
|
$full_convert_cmd =
|
||||||
|
($this->gm ? 'gm ' : '') . 'convert ' .
|
||||||
|
sprintf(
|
||||||
|
$convert_args,
|
||||||
$this->width,
|
$this->width,
|
||||||
$this->height,
|
$this->height,
|
||||||
escapeshellarg($this->src . '[0]'),
|
escapeshellarg($this->src . '[0]'),
|
||||||
$this->width,
|
$this->width,
|
||||||
$this->height,
|
$this->height,
|
||||||
escapeshellarg($this->temp)))) || !file_exists($this->temp)) {
|
escapeshellarg($this->temp)
|
||||||
|
);
|
||||||
|
|
||||||
if (strpos($error, "known incorrect sRGB profile") === false &&
|
if (($error = shell_exec_error($full_convert_cmd)) || !file_exists($this->temp)) {
|
||||||
strpos($error, "iCCP: Not recognizing known sRGB profile that has been edited") === false) {
|
if (ImageConvert::actualErrorOrJustWarning($error)) {
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
error(_('Failed to resize image!')." "._('Details: ').nl2br(htmlspecialchars($error)), null, array('convert_error' => $error));
|
error(_('Failed to resize image!')." "._('Details: ').nl2br(htmlspecialchars($error)), null, array('convert_error' => $error));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($this->temp)) {
|
if (!file_exists($this->temp)) {
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
error(_('Failed to resize image!'), null, $error);
|
error(_('Failed to resize image!'), null, $error);
|
||||||
|
|
|
@ -22,6 +22,7 @@ $config['boards'] = array(
|
||||||
'edu',
|
'edu',
|
||||||
'ga',
|
'ga',
|
||||||
'ent',
|
'ent',
|
||||||
|
'music',
|
||||||
'777',
|
'777',
|
||||||
'posad',
|
'posad',
|
||||||
'i',
|
'i',
|
||||||
|
@ -41,7 +42,7 @@ $config['prepended_foreign_boards'] = array(
|
||||||
|
|
||||||
// Board categories. Only used in the "Categories" theme.
|
// Board categories. Only used in the "Categories" theme.
|
||||||
$config['categories'] = array(
|
$config['categories'] = array(
|
||||||
'Leftypol' => array(
|
'Boards' => array(
|
||||||
'leftypol',
|
'leftypol',
|
||||||
'b',
|
'b',
|
||||||
'WRK',
|
'WRK',
|
||||||
|
@ -50,6 +51,7 @@ $config['categories'] = array(
|
||||||
'edu',
|
'edu',
|
||||||
'ga',
|
'ga',
|
||||||
'ent',
|
'ent',
|
||||||
|
'music',
|
||||||
'777',
|
'777',
|
||||||
'posad',
|
'posad',
|
||||||
'i',
|
'i',
|
||||||
|
@ -64,19 +66,19 @@ $config['categories'] = array(
|
||||||
// with non-board links.
|
// with non-board links.
|
||||||
$config['custom_categories'] = array(
|
$config['custom_categories'] = array(
|
||||||
'Links' => array(
|
'Links' => array(
|
||||||
'New Multitude' => 'https://newmultitude.org/',
|
'New Multitude' => 'https://newmultitude.org',
|
||||||
'Booru image repository' => 'https://lefty.booru.org/',
|
'Booru image repository' => 'https://lefty.pictures',
|
||||||
'Leftypedia' => 'https://leftypedia.org/',
|
|
||||||
'Official chat room' => 'https://talk.leftychan.net/#/room/#welcome:matrix.leftychan.net',
|
'Official chat room' => 'https://talk.leftychan.net/#/room/#welcome:matrix.leftychan.net',
|
||||||
'Gitea instance' => 'https://git.leftychan.net',
|
'Nukechan' => 'https://nukechan.net',
|
||||||
|
#'Gitea instance' => 'https://git.leftychan.net',
|
||||||
'Rules' => 'rules.html',
|
'Rules' => 'rules.html',
|
||||||
'Search' => 'search.php',
|
'Search' => 'search.php',
|
||||||
),
|
),
|
||||||
'Learning resources and blogs' => array(
|
'Learning resources and blogs' => array(
|
||||||
'Michael Roberts\' blog' => 'https://thenextrecession.wordpress.com/',
|
'Michael Roberts\' blog' => 'https://thenextrecession.wordpress.com',
|
||||||
'A Critique Of Crisis Theory blog' => 'https://critiqueofcrisistheory.wordpress.com/',
|
'A Critique Of Crisis Theory blog' => 'https://critiqueofcrisistheory.wordpress.com',
|
||||||
'Leftypedia' => 'https://leftypedia.org/',
|
'Leftypedia' => 'https://wiki.leftypol.org',
|
||||||
'Marxist Internet Archive' => 'https://www.marxists.org/'
|
'Marxist Internet Archive' => 'https://www.marxists.org'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -94,6 +96,7 @@ $config['db']['password'] = '';
|
||||||
$config['cookies']['mod'] = 'mod';
|
$config['cookies']['mod'] = 'mod';
|
||||||
$config['cookies']['salt'] = 'MGYwNjhlNjU5Y2QxNWU3YjQ3MzQ1Yj';
|
$config['cookies']['salt'] = 'MGYwNjhlNjU5Y2QxNWU3YjQ3MzQ1Yj';
|
||||||
|
|
||||||
|
$config['dns_system'] = true;
|
||||||
$config['search']['enable'] = true;
|
$config['search']['enable'] = true;
|
||||||
$config['flood_cache'] = 60 * 15; // 15 minutes. The oldest a post can be in the flood table
|
$config['flood_cache'] = 60 * 15; // 15 minutes. The oldest a post can be in the flood table
|
||||||
$config['flood_time_any'] = 120; // time between thread creation
|
$config['flood_time_any'] = 120; // time between thread creation
|
||||||
|
@ -132,7 +135,8 @@ $config['post_date'] = '%F (%a) %T';
|
||||||
|
|
||||||
$config['thread_subject_in_title'] = true;
|
$config['thread_subject_in_title'] = true;
|
||||||
|
|
||||||
$config['spam']['enabled'] = false;
|
$config['spam']['enabled'] = true;
|
||||||
|
$config['spam']['hidden_inputs_expire'] = 60 * 60 * 24 * 120; //keep hashes for 120 days in the database just in case someone posts on a slow board.
|
||||||
$config['spam_noticer']['enabled'] = true;
|
$config['spam_noticer']['enabled'] = true;
|
||||||
$config['spam_noticer']['base_url'] = 'http://localhost:8300';
|
$config['spam_noticer']['base_url'] = 'http://localhost:8300';
|
||||||
$config['spam_noticer']['ui_url'] = 'https://spamnoticer.leftychan.net/static/index.html';
|
$config['spam_noticer']['ui_url'] = 'https://spamnoticer.leftychan.net/static/index.html';
|
||||||
|
@ -142,7 +146,8 @@ $config['spam_noticer']['website_name'] = "leftychan";
|
||||||
/*
|
/*
|
||||||
* Basic captcha. See also: captchaconfig.php
|
* Basic captcha. See also: captchaconfig.php
|
||||||
*/
|
*/
|
||||||
$config['securimage'] = false;
|
$config['securimage'] = true;
|
||||||
|
$config['captcha_tor_only'] = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Permissions
|
* Permissions
|
||||||
|
@ -209,6 +214,7 @@ $config['allowed_ext_files'][] = 'pdf';
|
||||||
$config['allowed_ext_files'][] = 'txt';
|
$config['allowed_ext_files'][] = 'txt';
|
||||||
$config['allowed_ext_files'][] = 'epub';
|
$config['allowed_ext_files'][] = 'epub';
|
||||||
$config['allowed_ext_files'][] = 'djvu';
|
$config['allowed_ext_files'][] = 'djvu';
|
||||||
|
$config['allowed_ext_files'][] = 'opus';
|
||||||
// Compressed files
|
// Compressed files
|
||||||
$config['allowed_ext_files'][] = 'zip';
|
$config['allowed_ext_files'][] = 'zip';
|
||||||
$config['allowed_ext_files'][] = 'gz';
|
$config['allowed_ext_files'][] = 'gz';
|
||||||
|
@ -257,6 +263,7 @@ $config['user_flags'] = array (
|
||||||
'egalitarianism' => 'Egalitarianism',
|
'egalitarianism' => 'Egalitarianism',
|
||||||
'egoism' => 'Egoism',
|
'egoism' => 'Egoism',
|
||||||
'eristocracy' => 'Έριστοκρατία',
|
'eristocracy' => 'Έριστοκρατία',
|
||||||
|
'Eurasianism' => 'Eurasianism',
|
||||||
'eureka' => 'Eureka',
|
'eureka' => 'Eureka',
|
||||||
'eurocommunism' => 'Eurocommunism',
|
'eurocommunism' => 'Eurocommunism',
|
||||||
'farc' => 'Las FARC',
|
'farc' => 'Las FARC',
|
||||||
|
@ -280,9 +287,10 @@ $config['user_flags'] = array (
|
||||||
'luck_o_the_irish' => 'Luck O\' The Irish',
|
'luck_o_the_irish' => 'Luck O\' The Irish',
|
||||||
'luxemburg' => 'Luxemburg',
|
'luxemburg' => 'Luxemburg',
|
||||||
'marx' => 'Marx',
|
'marx' => 'Marx',
|
||||||
|
'marxism_blackpilism' => 'Marxism Blackpillism',
|
||||||
'mutualism' => 'Mutualism',
|
'mutualism' => 'Mutualism',
|
||||||
'naxalite' => 'Naxalite',
|
'naxalite' => 'Naxalite',
|
||||||
'nazbol' => 'Nazbol',
|
'nazbol' => 'National Bolshevik',
|
||||||
'nazi' => 'Nazi',
|
'nazi' => 'Nazi',
|
||||||
'ndfp' => 'NDFP',
|
'ndfp' => 'NDFP',
|
||||||
'palestine' => 'Palestine',
|
'palestine' => 'Palestine',
|
||||||
|
@ -309,13 +317,14 @@ $config['user_flags'] = array (
|
||||||
'syndicalism' => 'Syndicalism',
|
'syndicalism' => 'Syndicalism',
|
||||||
'tankie' => 'Tankie',
|
'tankie' => 'Tankie',
|
||||||
'technocracy' => 'Technocracy',
|
'technocracy' => 'Technocracy',
|
||||||
|
'The_Other_Russia' => 'The Other Russia',
|
||||||
'think' => 'Think',
|
'think' => 'Think',
|
||||||
'transhumanism' => 'Transhumanism',
|
'transhumanism' => 'Transhumanism',
|
||||||
'united_farm_workers' => 'United Farm Workers',
|
'united_farm_workers' => 'United Farm Workers',
|
||||||
'viet_cong' => 'Viet Cong',
|
'viet_cong' => 'Viet Cong',
|
||||||
'ypg' => 'YPG',
|
'ypg' => 'YPG',
|
||||||
'yugoslavia' => 'Yugoslavia',
|
'yugoslavia' => 'Yugoslavia',
|
||||||
'zapatista' => 'Zapatista'
|
'zgang' => 'Z Gang'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -589,5 +598,5 @@ $config['filters'][] = array(
|
||||||
'message' => 'New threads are being created too quickly. Wait [at most] 10 minutes'
|
'message' => 'New threads are being created too quickly. Wait [at most] 10 minutes'
|
||||||
);
|
);
|
||||||
|
|
||||||
$config['global_message'] = '<span><a href="https://talk.leftychan.net/#/room/#welcome:matrix.leftychan.net" class="">Matrix</a></span> <span><a href="ircs://irc.leftychan.net:6697/#leftychan" class="">IRC Chat</a></span> <span><a href="mumble://leftychan.net" class="">Mumble</a></span> <span><a href="https://t.me/+RegtyzzrE0M1NDMx" class="">Telegram</a></span> <span><a href="https://discord.gg/AcZeFKXPmZ" class="">Discord</a></span>';
|
$config['global_message'] = '<span><a href="https://talk.leftychan.net/#/room/#welcome:matrix.leftychan.net">Matrix</a></span> <span><a href="ircs://irc.leftychan.net:6697/#leftychan">IRC Chat</a></span> <span><a href="mumble://leftychan.net">Mumble</a></span> <span><a href="https://discord.gg/AcZeFKXPmZ">Discord</a></span>';
|
||||||
$config['debug'] = false;
|
$config['debug'] = false;
|
||||||
|
|
|
@ -338,6 +338,8 @@ class Securimage
|
||||||
|
|
||||||
/*%*********************************************************************%*/
|
/*%*********************************************************************%*/
|
||||||
// Properties
|
// Properties
|
||||||
|
public $config_file;
|
||||||
|
public $gdnoisecolor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the captcha image
|
* The width of the captcha image
|
||||||
|
@ -2232,9 +2234,9 @@ class Securimage
|
||||||
$py = array(); // y coordinates of poles
|
$py = array(); // y coordinates of poles
|
||||||
$rad = array(); // radius of distortion from pole
|
$rad = array(); // radius of distortion from pole
|
||||||
$amp = array(); // amplitude
|
$amp = array(); // amplitude
|
||||||
$x = ($this->image_width / 4); // lowest x coordinate of a pole
|
$x = round($this->image_width / 4); // lowest x coordinate of a pole
|
||||||
$maxX = $this->image_width - $x; // maximum x coordinate of a pole
|
$maxX = $this->image_width - $x; // maximum x coordinate of a pole
|
||||||
$dx = mt_rand($x / 10, $x); // horizontal distance between poles
|
$dx = mt_rand(intval($x / 10), $x); // horizontal distance between poles
|
||||||
$y = mt_rand(20, $this->image_height - 20); // random y coord
|
$y = mt_rand(20, $this->image_height - 20); // random y coord
|
||||||
$dy = mt_rand(20, $this->image_height * 0.7); // y distance
|
$dy = mt_rand(20, $this->image_height * 0.7); // y distance
|
||||||
$minY = 20; // minimum y coordinate
|
$minY = 20; // minimum y coordinate
|
||||||
|
@ -2277,7 +2279,7 @@ class Securimage
|
||||||
$x *= $this->iscale;
|
$x *= $this->iscale;
|
||||||
$y *= $this->iscale;
|
$y *= $this->iscale;
|
||||||
if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) {
|
if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) {
|
||||||
$c = imagecolorat($this->tmpimg, $x, $y);
|
$c = imagecolorat($this->tmpimg, intval($x), intval($y));
|
||||||
}
|
}
|
||||||
if ($c != $bgCol) { // only copy pixels of letters to preserve any background image
|
if ($c != $bgCol) { // only copy pixels of letters to preserve any background image
|
||||||
imagesetpixel($this->im, $ix, $iy, $c);
|
imagesetpixel($this->im, $ix, $iy, $c);
|
||||||
|
@ -2298,7 +2300,7 @@ class Securimage
|
||||||
|
|
||||||
$theta = ($this->frand() - 0.5) * M_PI * 0.33;
|
$theta = ($this->frand() - 0.5) * M_PI * 0.33;
|
||||||
$w = $this->image_width;
|
$w = $this->image_width;
|
||||||
$len = mt_rand($w * 0.4, $w * 0.7);
|
$len = mt_rand(intval($w * 0.4), intval($w * 0.7));
|
||||||
$lwid = mt_rand(0, 4);
|
$lwid = mt_rand(0, 4);
|
||||||
|
|
||||||
$k = $this->frand() * 0.6 + 0.2;
|
$k = $this->frand() * 0.6 + 0.2;
|
||||||
|
@ -2318,7 +2320,7 @@ class Securimage
|
||||||
for ($i = 0; $i < $n; ++ $i) {
|
for ($i = 0; $i < $n; ++ $i) {
|
||||||
$x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
|
$x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
|
||||||
$y = $y0 + $i * $dy - $amp * $dx * sin($k * $i * $step + $phi);
|
$y = $y0 + $i * $dy - $amp * $dx * sin($k * $i * $step + $phi);
|
||||||
imagefilledrectangle($this->im, $x, $y, $x + $lwid, $y + $lwid, $this->gdlinecolor);
|
imagefilledrectangle($this->im, intval($x), intval($y), intval($x + $lwid), intval($y + $lwid), $this->gdlinecolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
defined('TINYBOARD') or exit;
|
defined('TINYBOARD') or exit;
|
||||||
|
|
||||||
|
require_once 'inc/mod/pages.php';
|
||||||
|
|
||||||
// create a hash/salt pair for validate logins
|
// create a hash/salt pair for validate logins
|
||||||
function mkhash($username, $password, $salt = false) {
|
function mkhash($username, $password, $salt = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
|
@ -1501,6 +1501,7 @@ function mod_move($originBoard, $postID) {
|
||||||
} else {
|
} else {
|
||||||
deletePost($postID);
|
deletePost($postID);
|
||||||
buildIndex();
|
buildIndex();
|
||||||
|
rebuildThemes('post', $originBoard);
|
||||||
|
|
||||||
openBoard($targetBoard);
|
openBoard($targetBoard);
|
||||||
header('Location: ?/' . sprintf($config['board_path'], $newboard['uri']) . $config['dir']['res'] . link_for($op, false, $newboard), true, $config['redirect_http']);
|
header('Location: ?/' . sprintf($config['board_path'], $newboard['uri']) . $config['dir']['res'] . link_for($op, false, $newboard), true, $config['redirect_http']);
|
||||||
|
@ -1562,7 +1563,7 @@ function mod_merge($originBoard, $postID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($targetBoard === $originBoard){
|
if ($targetBoard === $originBoard) {
|
||||||
// Just update the thread id for all posts in the original thread to new op
|
// Just update the thread id for all posts in the original thread to new op
|
||||||
$query = prepare(sprintf('UPDATE ``posts_%s`` SET `thread` = :newthread WHERE `id` = :oldthread OR `thread` = :oldthread', $originBoard));
|
$query = prepare(sprintf('UPDATE ``posts_%s`` SET `thread` = :newthread WHERE `id` = :oldthread OR `thread` = :oldthread', $originBoard));
|
||||||
$query->bindValue(':newthread', $targetOp, PDO::PARAM_INT);
|
$query->bindValue(':newthread', $targetOp, PDO::PARAM_INT);
|
||||||
|
@ -1586,8 +1587,7 @@ function mod_merge($originBoard, $postID) {
|
||||||
|
|
||||||
// redirect
|
// redirect
|
||||||
header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($newpost) . '#' . $targetOp, true, $config['redirect_http']);
|
header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($newpost) . '#' . $targetOp, true, $config['redirect_http']);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Move thread to new board without shadow thread and then update the thread id for all posts in that thread to new op
|
// Move thread to new board without shadow thread and then update the thread id for all posts in that thread to new op
|
||||||
// indicate that the post is a thread
|
// indicate that the post is a thread
|
||||||
if (count($boards) <= 1)
|
if (count($boards) <= 1)
|
||||||
|
@ -1726,6 +1726,7 @@ function mod_merge($originBoard, $postID) {
|
||||||
deletePost($postID);
|
deletePost($postID);
|
||||||
modLog("Deleted post #{$postID}");
|
modLog("Deleted post #{$postID}");
|
||||||
buildIndex();
|
buildIndex();
|
||||||
|
rebuildThemes('post', $originBoard);
|
||||||
|
|
||||||
openBoard($targetBoard);
|
openBoard($targetBoard);
|
||||||
// Just update the thread id for all posts in the original thread to new op
|
// Just update the thread id for all posts in the original thread to new op
|
||||||
|
|
|
@ -296,6 +296,8 @@ function checkWithSpamNoticer($config, $post, $boardname) {
|
||||||
print_err($body);
|
print_err($body);
|
||||||
$reasons_bitmap = json_decode($body)->reason;
|
$reasons_bitmap = json_decode($body)->reason;
|
||||||
$result->reason = renderReasons($reasons_bitmap);
|
$result->reason = renderReasons($reasons_bitmap);
|
||||||
|
} else if ($config['debug']) {
|
||||||
|
print_err((string) $response->getBody());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print_err("spamnoticer status code: " . $status_code);
|
print_err("spamnoticer status code: " . $status_code);
|
||||||
|
|
|
@ -28,14 +28,14 @@ $(document).ready(function(){
|
||||||
context: document.body,
|
context: document.body,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var last_expanded = false;
|
var last_expanded = false;
|
||||||
$(data).find('div.post.reply').each(function() {
|
$(data).find('div.postcontainer').each(function() {
|
||||||
thread.find('div.hidden').remove();
|
thread.find('div.hidden').remove();
|
||||||
var post_in_doc = thread.find('#' + $(this).attr('id'));
|
var post_in_doc = thread.find('#' + $(this).attr('id'));
|
||||||
if(post_in_doc.length == 0) {
|
if(post_in_doc.length == 0) {
|
||||||
if(last_expanded) {
|
if(last_expanded) {
|
||||||
$(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">');
|
$(this).addClass('expanded').insertAfter(last_expanded);
|
||||||
} else {
|
} else {
|
||||||
$(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
|
$(this).addClass('expanded').insertAfter(thread.find('div.post:first'));
|
||||||
}
|
}
|
||||||
last_expanded = $(this);
|
last_expanded = $(this);
|
||||||
$(document).trigger('new_post', this);
|
$(document).trigger('new_post', this);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
globalThis.LCNSite = class LCNSite {
|
globalThis.LCNSite = class LCNSite {
|
||||||
static INSTANCE = null;
|
|
||||||
|
|
||||||
static "createAbortable" () {
|
static "createAbortable" () {
|
||||||
const obj = { "abort": null, "controller": null, "signal": null }
|
const obj = { "abort": null, "controller": null, "signal": null }
|
||||||
|
@ -32,54 +31,64 @@ globalThis.LCNSite = class LCNSite {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor () {
|
||||||
|
this._isModerator = document.body.classList.contains("is-moderator");
|
||||||
|
|
||||||
|
this._isThreadPage = document.body.classList.contains("active-thread");
|
||||||
|
this._isBoardPage = document.body.classList.contains("active-board");
|
||||||
|
this._isCatalogPage = document.body.classList.contains("active-catalog");
|
||||||
|
|
||||||
|
this._isModPage = location.pathname == "/mod.php";
|
||||||
|
this._isModRecentsPage = this._isModPage && (location.search == "?/recent" || location.search.startsWith("?/recent/"));
|
||||||
|
this._isModReportsPage = this._isModPage && (location.search == "?/reports" || location.search.startsWith("?/reports/"));
|
||||||
|
this._isModLogPage = this._isModPage && (location.search == "?/log" || location.search.startsWith("?/log/"));
|
||||||
|
this._unseen = 0;
|
||||||
|
this._pageTitle = document.title;
|
||||||
|
|
||||||
|
this._favicon = document.querySelector("head > link[rel=\"shortcut icon\"]");
|
||||||
|
this._generatedStyle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#isModerator = document.body.classList.contains("is-moderator");
|
"_doTitleUpdate" () {
|
||||||
#isThreadPage = document.body.classList.contains("active-thread");
|
document.title = (this._unseen > 0 ? `(${this._unseen}) ` : "") + this._pageTitle;
|
||||||
#isBoardPage = document.body.classList.contains("active-board");
|
};
|
||||||
#isCatalogPage = document.body.classList.contains("active-catalog");
|
|
||||||
|
|
||||||
#isModPage = location.pathname == "/mod.php";
|
"isModerator" () { return this._isModerator; }
|
||||||
#isModRecentsPage = this.#isModPage && (location.search == "?/recent" || location.search.startsWith("?/recent/"));
|
"isThreadPage" () {
|
||||||
#isModReportsPage = this.#isModPage && (location.search == "?/reports" || location.search.startsWith("?/reports/"));
|
return this._isThreadPage;
|
||||||
#isModLogPage = this.#isModPage && (location.search == "?/log" || location.search.startsWith("?/log/"));
|
}
|
||||||
|
"isBoardPage" () { return this._isBoardPage; }
|
||||||
|
"isCatalogPage" () { return this._isCatalogPage; }
|
||||||
|
|
||||||
"isModerator" () { return this.#isModerator; }
|
"isModPage" () { return this._isModPage; }
|
||||||
"isThreadPage" () { return this.#isThreadPage; }
|
"isModRecentsPage" () { return this._isModRecentsPage; }
|
||||||
"isBoardPage" () { return this.#isBoardPage; }
|
"isModReportsPage" () { return this._isModReportsPage; }
|
||||||
"isCatalogPage" () { return this.#isCatalogPage; }
|
"isModLogPage" () { return this._isModLogPage; }
|
||||||
|
|
||||||
"isModPage" () { return this.#isModPage; }
|
"getUnseen" () { return this._unseen; }
|
||||||
"isModRecentsPage" () { return this.#isModRecentsPage; }
|
"clearUnseen" () { if (this._unseen != 0) { this.setUnseen(0); } }
|
||||||
"isModReportsPage" () { return this.#isModReportsPage; }
|
|
||||||
"isModLogPage" () { return this.#isModLogPage; }
|
|
||||||
|
|
||||||
#unseen = 0;
|
|
||||||
"getUnseen" () { return this.#unseen; }
|
|
||||||
"clearUnseen" () { if (this.#unseen != 0) { this.setUnseen(0); } }
|
|
||||||
"setUnseen" (int) {
|
"setUnseen" (int) {
|
||||||
const bool = !!int
|
const bool = !!int
|
||||||
if (bool != !!this.#unseen) {
|
if (bool != !!this._unseen) {
|
||||||
this.setFaviconType(bool ? "reply" : null)
|
this.setFaviconType(bool ? "reply" : null)
|
||||||
}
|
}
|
||||||
this.#unseen = int
|
this._unseen = int
|
||||||
this.#doTitleUpdate()
|
this._doTitleUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
#pageTitle = document.title;
|
"getTitle" () { return this._pageTitle; }
|
||||||
"getTitle" () { return this.#pageTitle; }
|
"setTitle" (title) { this._pageTitle = title; this._doTitleUpdate(); }
|
||||||
"setTitle" (title) { this.#pageTitle = title; this.#doTitleUpdate(); }
|
|
||||||
#doTitleUpdate () { document.title = (this.#unseen > 0 ? `(${this.#unseen}) ` : "") + this.#pageTitle; }
|
|
||||||
|
|
||||||
#favicon = document.querySelector("head > link[rel=\"shortcut icon\"]");
|
|
||||||
"setFaviconType" (type=null) {
|
"setFaviconType" (type=null) {
|
||||||
if (this.#favicon == null) {
|
if (this._favicon == null) {
|
||||||
this.#favicon = document.createElement("link")
|
this._favicon = document.createElement("link")
|
||||||
this.#favicon.rel = "shortcut icon"
|
this._favicon.rel = "shortcut icon"
|
||||||
document.head.appendChild(this.#favicon)
|
document.head.appendChild(this._favicon)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#favicon.href = `/favicon${type ? "-" + type : ""}.ico`
|
this._favicon.href = `/favicon${type ? "-" + type : ""}.ico`
|
||||||
}
|
}
|
||||||
|
|
||||||
"getFloaterLContainer" () { return document.getElementById("bar-bottom-l"); }
|
"getFloaterLContainer" () { return document.getElementById("bar-bottom-l"); }
|
||||||
|
@ -87,85 +96,93 @@ globalThis.LCNSite = class LCNSite {
|
||||||
"getThreadStatsLContainer" () { return document.getElementById("lcn-threadstats-l"); }
|
"getThreadStatsLContainer" () { return document.getElementById("lcn-threadstats-l"); }
|
||||||
"getThreadStatsRContainer" () { return document.getElementById("lcn-threadstats-r"); }
|
"getThreadStatsRContainer" () { return document.getElementById("lcn-threadstats-r"); }
|
||||||
|
|
||||||
#generatedStyle = null;
|
|
||||||
"writeCSSStyle" (origin, stylesheet) {
|
"writeCSSStyle" (origin, stylesheet) {
|
||||||
if (this.#generatedStyle == null && (this.#generatedStyle = document.querySelector("head > style.generated-css")) == null) {
|
if (this._generatedStyle == null && (this._generatedStyle = document.querySelector("head > style.generated-css")) == null) {
|
||||||
this.#generatedStyle = document.createElement("style")
|
this._generatedStyle = document.createElement("style")
|
||||||
this.#generatedStyle.classList.add("generated-css")
|
this._generatedStyle.classList.add("generated-css")
|
||||||
document.head.appendChild(this.#generatedStyle)
|
document.head.appendChild(this._generatedStyle)
|
||||||
}
|
}
|
||||||
this.#generatedStyle.textContent += `${this.#generatedStyle.textContent.length ? "\n\n" : ""}/*** Generated by ${origin} ***/\n${stylesheet}`
|
this._generatedStyle.textContent += `${this._generatedStyle.textContent.length ? "\n\n" : ""}/*** Generated by ${origin} ***/\n${stylesheet}`
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.LCNSite.INSTANCE = null;
|
||||||
|
|
||||||
globalThis.LCNPostInfo = class LCNPostInfo {
|
globalThis.LCNPostInfo = class LCNPostInfo {
|
||||||
|
|
||||||
static nodeAttrib = "$LCNPostInfo";
|
constructor () {
|
||||||
static selector = ".post:not(.grid-li)";
|
this._boardId = null;
|
||||||
#boardId = null;
|
this._threadId = null;
|
||||||
#threadId = null;
|
this._postId = null;
|
||||||
#postId = null;
|
this._name = null;
|
||||||
#name = null;
|
this._email = null;
|
||||||
#email = null;
|
this._capcode = null;
|
||||||
#capcode = null;
|
this._flag = null;
|
||||||
#flag = null;
|
this._ip = null;
|
||||||
#ip = null;
|
this._subject = null;
|
||||||
#subject = null;
|
this._createdAt = null;
|
||||||
#createdAt = null;
|
this._parent = null;
|
||||||
|
this._isThread = false;
|
||||||
#parent = null;
|
this._isReply = false;
|
||||||
#isThread = false;
|
this._isLocked = false;
|
||||||
#isReply = false;
|
this._isSticky = false;
|
||||||
#isLocked = false;
|
|
||||||
#isSticky = false;
|
|
||||||
|
|
||||||
static "assign" (post) { return post[this.nodeAttrib] ?? (post[this.nodeAttrib] = this.from(post)); }
|
|
||||||
static "from" (post) {
|
|
||||||
assert.ok(post.classList.contains("post"), "Arty must be expected Element.")
|
|
||||||
const inst = new this()
|
|
||||||
const intro = post.querySelector(".intro")
|
|
||||||
const link = intro.querySelector(".post_no:not([id])").href.split("/").reverse()
|
|
||||||
inst.#postId = link[0].slice(link[0].indexOf("#q") + 2)
|
|
||||||
inst.#threadId = link[0].slice(0, link[0].indexOf("."))
|
|
||||||
inst.#boardId = link[2]
|
|
||||||
inst.#isThread = post.classList.contains("op")
|
|
||||||
inst.#isReply = !inst.#isThread
|
|
||||||
|
|
||||||
inst.#subject = intro.querySelector(".subject")?.innerText ?? null
|
|
||||||
inst.#name = intro.querySelector(".name")?.innerText ?? null
|
|
||||||
inst.#email = intro.querySelector(".email")?.href.slice(7) ?? null
|
|
||||||
inst.#flag = intro.querySelector(".flag")?.src.split("/").reverse()[0].slice(0, -4) ?? null
|
|
||||||
|
|
||||||
inst.#capcode = intro.querySelector(".capcode")?.innerText ?? null
|
|
||||||
inst.#ip = intro.querySelector(".ip-link")?.innerText ?? null
|
|
||||||
inst.#createdAt = new Date(intro.querySelector("time[datetime]").dateTime ?? NaN)
|
|
||||||
|
|
||||||
inst.#isSticky = !!intro.querySelector("i.fa-thumb-tack")
|
|
||||||
inst.#isLocked = !!intro.querySelector("i.fa-lock")
|
|
||||||
|
|
||||||
return inst
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getParent" () { return this.#parent; }
|
|
||||||
"__setParent" (inst) { return this.#parent = inst; }
|
|
||||||
|
|
||||||
"getBoardId" () { return this.#boardId; }
|
static "assign" (post) {
|
||||||
"getThreadId" () { return this.#threadId; }
|
if (post[this.nodeAttrib] == null) {
|
||||||
"getPostId" () { return this.#postId; }
|
return post[this.nodeAttrib] = this.from(post);
|
||||||
|
} else {
|
||||||
|
return post[this.nodeAttrib];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static "from" (post) {
|
||||||
|
assert.ok(post.classList.contains("post"), "Arty must be expected Element.");
|
||||||
|
const inst = new this();
|
||||||
|
const intro = post.querySelector(".intro");
|
||||||
|
const link = intro.querySelector(".post_no:not([id])").href.split("/").reverse();
|
||||||
|
inst._postId = link[0].slice(link[0].indexOf("#q") + 2);
|
||||||
|
inst._threadId = link[0].slice(0, link[0].indexOf("."));
|
||||||
|
inst._boardId = link[2];
|
||||||
|
inst._isThread = post.classList.contains("op");
|
||||||
|
inst._isReply = !inst._isThread;
|
||||||
|
|
||||||
|
inst._subject = cont(intro.querySelector(".subject"), x => x.innerText);
|
||||||
|
inst._name = cont(intro.querySelector(".name"), x => x.innerText);
|
||||||
|
inst._email = cont(intro.querySelector(".email"), x => x.href.slice(7));
|
||||||
|
inst._flag = cont(intro.querySelector(".flag"), x => x.src.split("/").reverse()[0].slice(0, -4));
|
||||||
|
|
||||||
|
inst._capcode = cont(intro.querySelector(".capcode"), x => x.innerText);
|
||||||
|
inst._ip = cont(intro.querySelector(".ip-link"), x => x.innerText);
|
||||||
|
inst._createdAt = new Date(intro.querySelector("time[datetime]").dateTime || NaN);
|
||||||
|
|
||||||
|
inst._isSticky = !!intro.querySelector("i.fa-thumb-tack");
|
||||||
|
inst._isLocked = !!intro.querySelector("i.fa-lock");
|
||||||
|
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
"getParent" () { return this._parent; }
|
||||||
|
"__setParent" (inst) { return this._parent = inst; }
|
||||||
|
|
||||||
|
"getBoardId" () { return this._boardId; }
|
||||||
|
"getThreadId" () { return this._threadId; }
|
||||||
|
"getPostId" () { return this._postId; }
|
||||||
"getHref" () { return `/${this.boardId}/res/${this.threadId}.html#q${this.postId}`; }
|
"getHref" () { return `/${this.boardId}/res/${this.threadId}.html#q${this.postId}`; }
|
||||||
|
|
||||||
"getName" () { return this.#name; }
|
"getName" () { return this._name; }
|
||||||
"getEmail" () { return this.#email; }
|
"getEmail" () { return this._email; }
|
||||||
"getIP" () { return this.#ip; }
|
"getIP" () { return this._ip; }
|
||||||
"getCapcode" () { return this.#capcode; }
|
"getCapcode" () { return this._capcode; }
|
||||||
"getSubject" () { return this.#subject; }
|
"getSubject" () { return this._subject; }
|
||||||
"getCreatedAt" () { return this.#createdAt; }
|
"getCreatedAt" () { return this._createdAt; }
|
||||||
|
|
||||||
"isSticky" () { return this.#isSticky; }
|
"isSticky" () { return this._isSticky; }
|
||||||
"isLocked" () { return this.#isLocked; }
|
"isLocked" () { return this._isLocked; }
|
||||||
"isThread" () { return this.#isThread; }
|
"isThread" () { return this._isThread; }
|
||||||
"isReply" () { return this.#isReply; }
|
"isReply" () { return this._isReply; }
|
||||||
|
|
||||||
"is" (info) {
|
"is" (info) {
|
||||||
assert.ok(info, "Must be LCNPost.")
|
assert.ok(info, "Must be LCNPost.")
|
||||||
|
@ -174,45 +191,48 @@ globalThis.LCNPostInfo = class LCNPostInfo {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LCNPostInfo.nodeAttrib = "$LCNPostInfo";
|
||||||
|
LCNPostInfo.selector = ".post:not(.grid-li)";
|
||||||
|
|
||||||
globalThis.LCNPost = class LCNPost {
|
globalThis.LCNPost = class LCNPost {
|
||||||
|
|
||||||
static nodeAttrib = "$LCNPost";
|
static "assign" (post) {
|
||||||
static selector = ".post:not(.grid-li)";
|
return post[this.nodeAttrib] || (post[this.nodeAttrib] = this.from(post));
|
||||||
#parent = null;
|
|
||||||
#post = null;
|
|
||||||
#info = null;
|
|
||||||
#ipLink = null;
|
|
||||||
#controls = null;
|
|
||||||
#customControlsSeperatorNode = null;
|
|
||||||
|
|
||||||
static "assign" (post) { return post[this.nodeAttrib] ?? (post[this.nodeAttrib] = this.from(post)); }
|
|
||||||
static "from" (post) { return new this(post); }
|
|
||||||
|
|
||||||
"constructor" (post) {
|
|
||||||
assert.ok(post.classList.contains("post"), "Arty must be expected Element.")
|
|
||||||
const intro = post.querySelector(".intro")
|
|
||||||
this.#post = post
|
|
||||||
this.#info = LCNPostInfo.assign(post)
|
|
||||||
this.#ipLink = intro.querySelector(".ip-link")
|
|
||||||
this.#controls = Array.prototype.at.apply(post.querySelectorAll(".controls"), [ -1 ])
|
|
||||||
|
|
||||||
assert.equal(this.#info.getParent(), null, "Info should not have parent.")
|
|
||||||
this.#info.__setParent(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"jQuery" () { return $(this.#post); }
|
static "from" (post) { return new this(post); }
|
||||||
"trigger" (event_id, data=null) { $(this.#post).trigger(event_id, [ data ]); }
|
|
||||||
|
|
||||||
"getElement" () { return this.#post; }
|
constructor (post) {
|
||||||
"getInfo" () { return this.#info; }
|
this._parent = null;
|
||||||
|
this._post = null;
|
||||||
|
this._info = null;
|
||||||
|
this._ipLink = null;
|
||||||
|
this._controls = null;
|
||||||
|
this._customControlsSeperatorNode = null;
|
||||||
|
|
||||||
"getIPLink" () { return this.#ipLink; }
|
assert.ok(post.classList.contains("post"), "Arty must be expected Element.");
|
||||||
"setIP" (ip) { this.#ipLink.innerText = ip; }
|
const intro = post.querySelector(".intro");
|
||||||
|
this._post = post;
|
||||||
|
this._info = LCNPostInfo.assign(post);
|
||||||
|
this._ipLink = intro.querySelector(".ip-link");
|
||||||
|
this._controls = Array.prototype.at.apply(post.querySelectorAll(".controls"), [ -1 ]);
|
||||||
|
//assert.equal(this._info.getParent(), null, "Info should not have parent.");
|
||||||
|
this._info.__setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
"getParent" () { return this.#parent; }
|
|
||||||
"__setParent" (inst) { return this.#parent = inst; }
|
|
||||||
|
|
||||||
static #NBSP = String.fromCharCode(160);
|
"jQuery" () { return $(this._post); }
|
||||||
|
"trigger" (event_id, data=null) { $(this._post).trigger(event_id, [ data ]); }
|
||||||
|
|
||||||
|
"getElement" () { return this._post; }
|
||||||
|
"getInfo" () { return this._info; }
|
||||||
|
|
||||||
|
"getIPLink" () { return this._ipLink; }
|
||||||
|
"setIP" (ip) { this._ipLink.innerText = ip; }
|
||||||
|
|
||||||
|
"getParent" () { return this._parent; }
|
||||||
|
"__setParent" (inst) { return this._parent = inst; }
|
||||||
|
|
||||||
"addCustomControl" (obj) {
|
"addCustomControl" (obj) {
|
||||||
if (LCNSite.INSTANCE.isModerator()) {
|
if (LCNSite.INSTANCE.isModerator()) {
|
||||||
const link = document.createElement("a")
|
const link = document.createElement("a")
|
||||||
|
@ -227,115 +247,122 @@ globalThis.LCNPost = class LCNPost {
|
||||||
link.addEventListener("click", e => { e.preventDefault(); obj.onClick(this); })
|
link.addEventListener("click", e => { e.preventDefault(); obj.onClick(this); })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.#customControlsSeperatorNode == null) {
|
if (this._customControlsSeperatorNode == null) {
|
||||||
this.#controls.insertBefore(this.#customControlsSeperatorNode = new Text(`${this.constructor.#NBSP}-${this.constructor.#NBSP}`), this.#controls.firstElementChild)
|
this._controls.insertBefore(this._customControlsSeperatorNode = new Text(`${this.constructor.NBSP}-${this.constructor.NBSP}`), this._controls.firstElementChild)
|
||||||
} else {
|
} else {
|
||||||
this.#controls.insertBefore(new Text(this.constructor.#NBSP), this.#customControlsSeperatorNode)
|
this._controls.insertBefore(new Text(this.constructor.NBSP), this._customControlsSeperatorNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#controls.insertBefore(link, this.#customControlsSeperatorNode)
|
this._controls.insertBefore(link, this._customControlsSeperatorNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.LCNPost.nodeAttrib = "$LCNPost";
|
||||||
|
globalThis.LCNPost.selector = ".post:not(.grid-li)";
|
||||||
|
globalThis.LCNPost. NBSP = String.fromCharCode(160);
|
||||||
|
|
||||||
globalThis.LCNThread = class LCNThread {
|
globalThis.LCNThread = class LCNThread {
|
||||||
|
|
||||||
static nodeAttrib = "$LCNThread";
|
static "assign" (thread) {
|
||||||
static selector = ".thread:not(.grid-li)";
|
return thread[this.nodeAttrib] || (thread[this.nodeAttrib] = this.from(thread));
|
||||||
#element = null;
|
|
||||||
#parent = null;
|
|
||||||
#op = null;
|
|
||||||
|
|
||||||
static "assign" (thread) { return thread[this.nodeAttrib] ?? (thread[this.nodeAttrib] = this.from(thread)); }
|
|
||||||
static "from" (thread) { return new this(thread); }
|
|
||||||
|
|
||||||
"constructor" (thread) {
|
|
||||||
assert.ok(thread.classList.contains("thread"), "Arty must be expected Element.")
|
|
||||||
this.#element = thread
|
|
||||||
this.#op = LCNPost.assign(this.#element.querySelector(".post.op"))
|
|
||||||
|
|
||||||
//assert.equal(this.#op.getParent(), null, "Op should not have parent.")
|
|
||||||
this.#op.__setParent(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"getElement" () { return this.#element; }
|
static "from" (thread) { return new this(thread); }
|
||||||
"getContent" () { return this.#op; }
|
|
||||||
"getPosts" () { return Array.prototype.map.apply(this.#element.querySelectorAll(".post"), [ el => LCNPost.assign(el) ]); }
|
|
||||||
"getReplies" () { return Array.prototype.map.apply(this.#element.querySelectorAll(".post:not(.op)"), [ el => LCNPost.assign(el) ]); }
|
|
||||||
|
|
||||||
"getParent" () { return this.#parent; }
|
constructor (thread) {
|
||||||
"__setParent" (inst) { return this.#parent = inst; }
|
this._element = null;
|
||||||
|
this._parent = null;
|
||||||
|
this._op = null;
|
||||||
|
assert.ok(thread.classList.contains("thread"), "Arty must be expected Element.")
|
||||||
|
this._element = thread
|
||||||
|
this._op = LCNPost.assign(this._element.querySelector(".post.op"))
|
||||||
|
assert.equal(this._op.getParent(), null, "Op should not have parent.")
|
||||||
|
this._op.__setParent(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
"getElement" () { return this._element; }
|
||||||
|
"getContent" () { return this._op; }
|
||||||
|
"getPosts" () { return Array.prototype.map.apply(this._element.querySelectorAll(".post"), [ el => LCNPost.assign(el) ]); }
|
||||||
|
"getReplies" () { return Array.prototype.map.apply(this._element.querySelectorAll(".post:not(.op)"), [ el => LCNPost.assign(el) ]); }
|
||||||
|
|
||||||
|
"getParent" () { return this._parent; }
|
||||||
|
"__setParent" (inst) { return this._parent = inst; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.LCNThread.nodeAttrib = "$LCNThread";
|
||||||
|
globalThis.LCNThread.selector = ".thread:not(.grid-li)";
|
||||||
|
|
||||||
|
|
||||||
globalThis.LCNPostContainer = class LCNPostContainer {
|
globalThis.LCNPostContainer = class LCNPostContainer {
|
||||||
|
|
||||||
static nodeAttrib = "$LCNPostContainer";
|
static "assign" (container) { return container[this.nodeAttrib] || (container[this.nodeAttrib] = this.from(container)); }
|
||||||
static selector = ".postcontainer";
|
|
||||||
#parent = null;
|
|
||||||
#element = null;
|
|
||||||
#content = null;
|
|
||||||
#postId = null;
|
|
||||||
#boardId = null;
|
|
||||||
|
|
||||||
static "assign" (container) { return container[this.nodeAttrib] ?? (container[this.nodeAttrib] = this.from(container)); }
|
|
||||||
static "from" (container) { return new this(container); }
|
static "from" (container) { return new this(container); }
|
||||||
|
|
||||||
"constructor" (container) {
|
constructor (container) {
|
||||||
|
this._parent = null;
|
||||||
|
this._element = null;
|
||||||
|
this._content = null;
|
||||||
|
this._postId = null;
|
||||||
|
this._boardId = null;
|
||||||
|
|
||||||
assert.ok(container.classList.contains("postcontainer"), "Arty must be expected Element.")
|
assert.ok(container.classList.contains("postcontainer"), "Arty must be expected Element.")
|
||||||
const child = container.querySelector(".thread, .post")
|
const child = container.querySelector(".thread, .post")
|
||||||
this.#element = container
|
this._element = container
|
||||||
this.#content = child.classList.contains("thread") ? LCNThread.assign(child) : LCNPost.assign(child)
|
this._content = child.classList.contains("thread") ? LCNThread.assign(child) : LCNPost.assign(child)
|
||||||
this.#boardId = container.dataset.board
|
this._boardId = container.dataset.board
|
||||||
this.#postId = container.id.slice(2)
|
this._postId = container.id.slice(2)
|
||||||
|
|
||||||
assert.equal(this.#content.getParent(), null, "Content should not have parent.")
|
assert.equal(this._content.getParent(), null, "Content should not have parent.")
|
||||||
this.#content.__setParent(this)
|
this._content.__setParent(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
"getElement" () { return this.#element; }
|
"getElement" () { return this._element; }
|
||||||
"getContent" () { return this.#content; }
|
"getContent" () { return this._content; }
|
||||||
"getBoardId" () { return this.#boardId; }
|
"getBoardId" () { return this._boardId; }
|
||||||
"getPostId" () { return this.#postId; }
|
"getPostId" () { return this._postId; }
|
||||||
|
|
||||||
"getParent" () { return this.#parent; }
|
"getParent" () { return this._parent; }
|
||||||
"__setParent" (inst) { return this.#parent = inst; }
|
"__setParent" (inst) { return this._parent = inst; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.LCNPostContainer.nodeAttrib = "$LCNPostContainer";
|
||||||
|
globalThis.LCNPostContainer.selector = ".postcontainer";
|
||||||
|
|
||||||
|
|
||||||
globalThis.LCNPostWrapper = class LCNPostWrapper {
|
globalThis.LCNPostWrapper = class LCNPostWrapper {
|
||||||
|
|
||||||
static nodeAttrib = "$LCNPostWrapper";
|
static "assign" (wrapper) { return wrapper[this.nodeAttrib] || (wrapper[this.nodeAttrib] = this.from(wrapper)); }
|
||||||
static selector = ".post-wrapper";
|
|
||||||
#wrapper = null;
|
|
||||||
#eitaLink = null;
|
|
||||||
#eitaId = null;
|
|
||||||
#eitaHref = null
|
|
||||||
#content = null;
|
|
||||||
|
|
||||||
static "assign" (wrapper) { return wrapper[this.nodeAttrib] ?? (wrapper[this.nodeAttrib] = this.from(wrapper)); }
|
|
||||||
static "from" (wrapper) { return new this(wrapper); }
|
static "from" (wrapper) { return new this(wrapper); }
|
||||||
|
|
||||||
"constructor" (wrapper) {
|
constructor (wrapper) {
|
||||||
|
this._wrapper = null;
|
||||||
|
this._eitaLink = null;
|
||||||
|
this._eitaId = null;
|
||||||
|
this._eitaHref = null
|
||||||
|
this._content = null;
|
||||||
|
|
||||||
assert.ok(wrapper.classList.contains("post-wrapper"), "Arty must be expected Element.")
|
assert.ok(wrapper.classList.contains("post-wrapper"), "Arty must be expected Element.")
|
||||||
this.#wrapper = wrapper
|
this._wrapper = wrapper
|
||||||
this.#eitaLink = wrapper.querySelector(".eita-link")
|
this._eitaLink = wrapper.querySelector(".eita-link")
|
||||||
this.#eitaId = this.#eitaLink.id
|
this._eitaId = this._eitaLink.id
|
||||||
this.#eitaHref = this.#eitaLink.href
|
this._eitaHref = this._eitaLink.href
|
||||||
|
|
||||||
void Array.prototype.find.apply(wrapper.children, [
|
void Array.prototype.find.apply(wrapper.children, [
|
||||||
el => {
|
el => {
|
||||||
if (el.classList.contains("thread")) {
|
if (el.classList.contains("thread")) {
|
||||||
return this.#content = LCNThread.assign(el)
|
return this._content = LCNThread.assign(el)
|
||||||
} else if (el.classList.contains("postcontainer")) {
|
} else if (el.classList.contains("postcontainer")) {
|
||||||
return this.#content = LCNPostContainer.assign(el)
|
return this._content = LCNPostContainer.assign(el)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
assert.ok(this.#content, "Wrapper should contain content.")
|
assert.ok(this._content, "Wrapper should contain content.")
|
||||||
assert.equal(this.#content.getParent(), null, "Content should not have parent.")
|
assert.equal(this._content.getParent(), null, "Content should not have parent.")
|
||||||
this.#content.__setParent(this)
|
this._content.__setParent(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
"getPost" () {
|
"getPost" () {
|
||||||
|
@ -344,60 +371,62 @@ globalThis.LCNPostWrapper = class LCNPostWrapper {
|
||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
"getElement" () { return this.#wrapper; }
|
"getElement" () { return this._wrapper; }
|
||||||
"getContent" () { return this.#content; }
|
"getContent" () { return this._content; }
|
||||||
"getEitaId" () { return this.#eitaId; }
|
"getEitaId" () { return this._eitaId; }
|
||||||
"getEitaHref" () { return this.#eitaHref; }
|
"getEitaHref" () { return this._eitaHref; }
|
||||||
"getEitaLink" () { return this.#eitaLink; }
|
"getEitaLink" () { return this._eitaLink; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.LCNSetting = class LCNSetting {
|
globalThis.LCNPostWrapper.nodeAttrib = "$LCNPostWrapper";
|
||||||
#id = null;
|
globalThis.LCNPostWrapper.selector = ".post-wrapper";
|
||||||
#eventId = null;
|
|
||||||
#label = null;
|
|
||||||
#hidden = false;
|
|
||||||
#value = null;
|
|
||||||
#valueDefault = null;
|
|
||||||
|
|
||||||
|
|
||||||
|
globalThis.LCNSetting = class LCNSetting {
|
||||||
static "build" (id) { return new this(id); }
|
static "build" (id) { return new this(id); }
|
||||||
|
|
||||||
"constructor" (id) {
|
constructor (id) {
|
||||||
this.#id = id;
|
this._id = null;
|
||||||
this.#eventId = `lcnsetting::${this.#id}`
|
this._eventId = null;
|
||||||
|
this._label = null;
|
||||||
|
this._hidden = false;
|
||||||
|
this._value = null;
|
||||||
|
this._valueDefault = null;
|
||||||
|
|
||||||
|
this._id = id;
|
||||||
|
this._eventId = `lcnsetting::${this._id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
#getValue () {
|
"_getValue" () {
|
||||||
const v = localStorage.getItem(this.#id)
|
const v = localStorage.getItem(this._id)
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return this.__builtinValueImporter(v)
|
return this.__builtinValueImporter(v)
|
||||||
} else {
|
} else {
|
||||||
return this.#valueDefault
|
return this._valueDefault
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"isHidden" () { return this.#hidden; }
|
"isHidden" () { return this._hidden; }
|
||||||
"setHidden" (v) { this.#hidden = v; return this; }
|
"setHidden" (v) { this._hidden = v; return this; }
|
||||||
|
"getValue" () { return this._value || (this._value = this._getValue()); }
|
||||||
"getValue" () { return this.#value ?? (this.#value = this.#getValue()); }
|
|
||||||
"setValue" (v) {
|
"setValue" (v) {
|
||||||
if (this.#value !== v) {
|
if (this._value !== v) {
|
||||||
this.#value = v
|
this._value = v
|
||||||
localStorage.setItem(this.#id, this.__builtinValueExporter(this.#value))
|
localStorage.setItem(this._id, this.__builtinValueExporter(this._value))
|
||||||
setTimeout(() => $(document).trigger(`${this.#eventId}::change`, [ v, this ]), 1)
|
setTimeout(() => $(document).trigger(`${this._eventId}::change`, [ v, this ]), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"getLabel" () { return this.#label; }
|
"getLabel" () { return this._label; }
|
||||||
"setLabel" (label) { this.#label = label; return this; }
|
"setLabel" (label) { this._label = label; return this; }
|
||||||
|
|
||||||
"getDefaultValue" () { return this.#valueDefault; }
|
"getDefaultValue" () { return this._valueDefault; }
|
||||||
"setDefaultValue" (vd) { this.#valueDefault = vd; return this; }
|
"setDefaultValue" (vd) { this._valueDefault = vd; return this; }
|
||||||
|
|
||||||
"onChange" (fn) { $(document).on(`${this.#eventId}::change`, (_,v,i) => fn(v, i)); }
|
"onChange" (fn) { $(document).on(`${this._eventId}::change`, (_,v,i) => fn(v, i)); }
|
||||||
__setIdPrefix (prefix) {
|
__setIdPrefix (prefix) {
|
||||||
this.#id = `${prefix}_${this.#id}`
|
this._id = `${prefix}_${this._id}`
|
||||||
this.#eventId = `lcnsetting::${this.#id}`
|
this._eventId = `lcnsetting::${this._id}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,10 +436,10 @@ globalThis.LCNToggleSetting = class LCNToggleSetting extends LCNSetting {
|
||||||
__builtinDOMConstructor () {
|
__builtinDOMConstructor () {
|
||||||
const div = document.createElement("div")
|
const div = document.createElement("div")
|
||||||
const chk = document.createElement("input")
|
const chk = document.createElement("input")
|
||||||
const txt = document.createElement("label")
|
const lbl = document.createElement("label")
|
||||||
const id = `lcnts::${this.id}`
|
const id = `lcnts::${this.id}`
|
||||||
txt.id = id
|
lbl.htmlFor = id
|
||||||
txt.innerText = this.getLabel()
|
lbl.innerText = this.getLabel()
|
||||||
chk.id = id
|
chk.id = id
|
||||||
chk.type = "checkbox"
|
chk.type = "checkbox"
|
||||||
chk.checked = this.getValue()
|
chk.checked = this.getValue()
|
||||||
|
@ -421,23 +450,17 @@ globalThis.LCNToggleSetting = class LCNToggleSetting extends LCNSetting {
|
||||||
this.onChange(v => chk.checked = v)
|
this.onChange(v => chk.checked = v)
|
||||||
|
|
||||||
div.appendChild(chk)
|
div.appendChild(chk)
|
||||||
div.appendChild(txt)
|
div.appendChild(lbl)
|
||||||
return div
|
return div
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
|
globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
|
||||||
|
|
||||||
#tab_id = null;
|
|
||||||
#id = null;
|
|
||||||
|
|
||||||
#fieldset = null;
|
|
||||||
#legend = null;
|
|
||||||
#label = null;
|
|
||||||
|
|
||||||
static "for" (tab_id, id) {
|
static "for" (tab_id, id) {
|
||||||
const domid = `lcnssc_${tab_id}_${id}`
|
const domid = `lcnssc_${tab_id}_${id}`
|
||||||
const inst = document.getElementById(domid)?.$LCNSettingsSubcategory
|
const inst = cont(document.getElementById(domid), x => x.$LCNSettingsSubcategory)
|
||||||
|
|
||||||
if (inst == null) {
|
if (inst == null) {
|
||||||
const fieldset = document.createElement("fieldset")
|
const fieldset = document.createElement("fieldset")
|
||||||
const legend = document.createElement("legend")
|
const legend = document.createElement("legend")
|
||||||
|
@ -446,7 +469,7 @@ globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
|
||||||
|
|
||||||
// XXX: extend_tab only takes a string so this hacky workaround is used to let us use the regular dom api
|
// XXX: extend_tab only takes a string so this hacky workaround is used to let us use the regular dom api
|
||||||
Options.extend_tab(tab_id, `<div id="__${domid}" hidden></div>`)
|
Options.extend_tab(tab_id, `<div id="__${domid}" hidden></div>`)
|
||||||
const div = document.getElementById(`__${domid}`)?.parentElement
|
const div = cont(document.getElementById(`__${domid}`), x => x.parentElement)
|
||||||
assert.ok(div)
|
assert.ok(div)
|
||||||
|
|
||||||
div.replaceChildren(fieldset)
|
div.replaceChildren(fieldset)
|
||||||
|
@ -456,23 +479,23 @@ globalThis.LCNSettingsSubcategory = class LCNSettingsSubcategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"constructor" (tab_id, id, fieldset) {
|
constructor (tab_id, id, fieldset) {
|
||||||
this.#tab_id = tab_id
|
this._tab_id = tab_id
|
||||||
this.#id = id
|
this._id = id
|
||||||
this.#fieldset = fieldset
|
this._fieldset = fieldset
|
||||||
this.#legend = this.#fieldset.querySelector("legend")
|
this._legend = this._fieldset.querySelector("legend")
|
||||||
this.#fieldset.$LCNSettingsSubcategory = this
|
this._fieldset.$LCNSettingsSubcategory = this
|
||||||
}
|
}
|
||||||
|
|
||||||
"getLabel" () { return this.#label; }
|
"getLabel" () { return this._label; }
|
||||||
"setLabel" (label) { this.#legend.innerText = this.#label = label; return this; }
|
"setLabel" (label) { this._legend.innerText = this._label = label; return this; }
|
||||||
"addSetting" (setting) {
|
"addSetting" (setting) {
|
||||||
assert.ok(setting instanceof LCNSetting)
|
assert.ok(setting instanceof LCNSetting)
|
||||||
setting.__setIdPrefix(`lcnsetting_${this.#tab_id}_${this.#id}`)
|
setting.__setIdPrefix(`lcnsetting_${this._tab_id}_${this._id}`)
|
||||||
if (!setting.isHidden() && setting.__builtinDOMConstructor != null) {
|
if (!setting.isHidden() && setting.__builtinDOMConstructor != null) {
|
||||||
const div = setting.__builtinDOMConstructor()
|
const div = setting.__builtinDOMConstructor()
|
||||||
div.classList.add("lcn-setting-entry")
|
div.classList.add("lcn-setting-entry")
|
||||||
this.#fieldset.appendChild(div)
|
this._fieldset.appendChild(div)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -490,7 +513,7 @@ $().ready(() => {
|
||||||
clazz.forEach = (fn, node=document) => clazz.allNodes(node).forEach(elem => fn(clazz.assign(elem)))
|
clazz.forEach = (fn, node=document) => clazz.allNodes(node).forEach(elem => fn(clazz.assign(elem)))
|
||||||
clazz.filter = (fn, node=document) => clazz.all(node).filter(fn)
|
clazz.filter = (fn, node=document) => clazz.all(node).filter(fn)
|
||||||
clazz.find = fn => clazz.all().find(fn)
|
clazz.find = fn => clazz.all().find(fn)
|
||||||
clazz.first = (node=document) => clazz.assign(node.querySelector(clazz.selector))
|
clazz.first = (node=document) => { return clazz.assign(node.querySelector(clazz.selector)); }
|
||||||
clazz.last = (node=document) => clazz.assign(Array.prototype.at.apply(clazz.allNodes(node), [ -1 ]))
|
clazz.last = (node=document) => clazz.assign(Array.prototype.at.apply(clazz.allNodes(node), [ -1 ]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$().ready(() => {
|
$().ready(() => {
|
||||||
|
|
||||||
const kIsEnabled = LCNToggleSetting.build("enabled")
|
const kIsEnabled = LCNToggleSetting.build("enabled")
|
||||||
const kUpdateOnReplyEnabled = LCNToggleSetting.build("updateOnReplyEnabled")
|
const kUpdateOnReplyEnabled = LCNToggleSetting.build("updateOnReplyEnabled")
|
||||||
//const kIsBellEnabled = LCNToggleSetting.build("bellEnabled")
|
//const kIsBellEnabled = LCNToggleSetting.build("bellEnabled")
|
||||||
|
@ -35,7 +34,7 @@ $().ready(() => {
|
||||||
const abortable = LCNSite.createAbortable()
|
const abortable = LCNSite.createAbortable()
|
||||||
const threadStatsItems = []
|
const threadStatsItems = []
|
||||||
const updateDOMStatus = () => {
|
const updateDOMStatus = () => {
|
||||||
const text = threadState ?? (secondsCounter >= 0 ? `${secondsCounter}s` : "…")
|
const text = threadState || (secondsCounter >= 0 ? `${secondsCounter}s` : "…")
|
||||||
threadUpdateStatus.innerText = text
|
threadUpdateStatus.innerText = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ $().ready(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const findMissingReplies = (thread_op, thread_dom, thread_latest) => {
|
const findMissingReplies = (thread_op, thread_dom, thread_latest) => {
|
||||||
const lastPostTs = (thread_dom.at(-1)?.getInfo() ?? thread_op.getInfo()).getCreatedAt().getTime()
|
const lastPostTs = (cont(thread_dom.at(-1), x => x.getInfo()) || thread_op.getInfo()).getCreatedAt().getTime()
|
||||||
const missing = []
|
const missing = []
|
||||||
|
|
||||||
for (const pc of thread_latest.reverse()) {
|
for (const pc of thread_latest.reverse()) {
|
||||||
|
@ -135,6 +134,7 @@ $().ready(() => {
|
||||||
if (threadState == null) {
|
if (threadState == null) {
|
||||||
if (secondsCounter < 0) {
|
if (secondsCounter < 0) {
|
||||||
const thread = LCNThread.first()
|
const thread = LCNThread.first()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await updateStatsFn(thread)
|
await updateStatsFn(thread)
|
||||||
if (threadState == null && threadStats.last_modified > (thread.getPosts().at(-1).getInfo().getCreatedAt().getTime() / 1000)) {
|
if (threadState == null && threadStats.last_modified > (thread.getPosts().at(-1).getInfo().getCreatedAt().getTime() / 1000)) {
|
||||||
|
@ -154,6 +154,7 @@ $().ready(() => {
|
||||||
|
|
||||||
onTickId = setTimeout(onTickFn, 1000)
|
onTickId = setTimeout(onTickFn, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const refreshFn = () => {
|
const refreshFn = () => {
|
||||||
|
@ -244,7 +245,7 @@ $().ready(() => {
|
||||||
|
|
||||||
$(document).trigger("thread_manual_refresh")
|
$(document).trigger("thread_manual_refresh")
|
||||||
} else {
|
} else {
|
||||||
floaterLinkBox?.remove()
|
cont(floaterLinkBox, x => x.remove())
|
||||||
floaterLinkBox = null
|
floaterLinkBox = null
|
||||||
statReplies = null
|
statReplies = null
|
||||||
statFiles = null
|
statFiles = null
|
||||||
|
|
|
@ -3,39 +3,71 @@
|
||||||
* @author jonsmy
|
* @author jonsmy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function cont(value_to_test, fn) {
|
||||||
|
if (value_to_test != null) {
|
||||||
|
return fn(value_to_test);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const assert = {
|
const assert = {
|
||||||
"equal": (actual, expected, message="No message set") => {
|
"equal": (actual, expected, message="No message set") => {
|
||||||
if (actual !== expected) {
|
if (actual !== expected) {
|
||||||
const err = new Error(`Assertion Failed. ${message}`)
|
const err = new Error(`Assertion Failed. ${message}`);
|
||||||
err.data = { actual, expected}
|
err.data = { actual, expected}
|
||||||
Error.captureStackTrace?.(err, assert.equal)
|
//Error.captureStackTrace?.(err, assert.equal);
|
||||||
debugger
|
debugger;
|
||||||
throw err
|
throw err;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ok": (actual, message="No message set") => {
|
"ok": (actual, message="No message set") => {
|
||||||
if (!actual) {
|
if (!actual) {
|
||||||
const err = new Error(`Assertion Failed. ${message}`)
|
const err = new Error(`Assertion Failed. ${message}`);
|
||||||
err.data = { actual }
|
err.data = { actual }
|
||||||
Error.captureStackTrace?.(err, assert.ok)
|
//Error.captureStackTrace?.(err, assert.ok);
|
||||||
debugger
|
debugger;
|
||||||
throw err
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
AbortSignal.any ??= function (signals) {
|
if (AbortSignal.any == null) {
|
||||||
const controller = new AbortController()
|
AbortSignal.any = (signals) => {
|
||||||
|
const controller = new AbortController();
|
||||||
const abortFn = () => {
|
const abortFn = () => {
|
||||||
for (const signal of signals) {
|
for (const signal of signals) {
|
||||||
signal.removeEventListener("abort", abortFn)
|
signal.removeEventListener("abort", abortFn);
|
||||||
}
|
}
|
||||||
controller.abort()
|
controller.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const signal of signals) {
|
for (const signal of signals) {
|
||||||
signal.addEventListener("abort", abortFn)
|
signal.addEventListener("abort", abortFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return controller.signal
|
return controller.signal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// polyfill for replaceChildren
|
||||||
|
if( Node.prototype.replaceChildren === undefined) {
|
||||||
|
Node.prototype.replaceChildren = function(addNodes) {
|
||||||
|
while(this.lastChild) {
|
||||||
|
this.removeChild(this.lastChild);
|
||||||
|
}
|
||||||
|
if (addNodes !== undefined) {
|
||||||
|
this.append(addNodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.prototype.at === undefined) {
|
||||||
|
Array.prototype.at = function(index) {
|
||||||
|
if (index >= 0) {
|
||||||
|
return this[index];
|
||||||
|
} else {
|
||||||
|
return this[this.length + index];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ $(document).ready(function(){
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$post = $('#reply_' + id);
|
$post = $('#reply_' + id + ', #op_' + id);
|
||||||
if($post.length == 0)
|
if($post.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$('div.post.reply').each(showBackLinks);
|
$('div.post').each(showBackLinks);
|
||||||
|
|
||||||
$(document).on('new_post', function(e, post) {
|
$(document).on('new_post', function(e, post) {
|
||||||
if ($(post).hasClass("reply")) {
|
if ($(post).hasClass("reply")) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ $(document).ready(function(){
|
||||||
$('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
|
$('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
|
||||||
$('.compact-boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
|
$('.compact-boardlist').append('<span>[ <a class="watchlist-toggle" href="#">'+_('watchlist')+'</a> ]</span>');
|
||||||
//Append a watch thread button after every OP.
|
//Append a watch thread button after every OP.
|
||||||
$('.op>.intro').append('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>');
|
$('.op>.intro>a:last').after('<a class="watchThread" href="#">['+_('Watch Thread')+']</a>');
|
||||||
|
|
||||||
//Draw the watchlist, hidden.
|
//Draw the watchlist, hidden.
|
||||||
watchlist.render();
|
watchlist.render();
|
||||||
|
|
4
log.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
include 'inc/functions.php';
|
require_once 'inc/functions.php';
|
||||||
include 'inc/mod/pages.php';
|
require_once 'inc/mod/pages.php';
|
||||||
|
|
||||||
if (!isset($_GET['board']) || !preg_match("/{$config['board_regex']}/u", $_GET['board'])) {
|
if (!isset($_GET['board']) || !preg_match("/{$config['board_regex']}/u", $_GET['board'])) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
|
|
67
post.php
|
@ -455,7 +455,11 @@ function validate_images(array $post_array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_post(){
|
function handle_post(){
|
||||||
global $config,$dropped_post,$board, $mod,$pdo;
|
global $config, $dropped_post, $board, $mod, $pdo, $debug;
|
||||||
|
|
||||||
|
$time_1 = microtime(true);
|
||||||
|
|
||||||
|
init_global_post_cleanup();
|
||||||
|
|
||||||
if (!isset($_POST['body'], $_POST['board']) && !$dropped_post) {
|
if (!isset($_POST['body'], $_POST['board']) && !$dropped_post) {
|
||||||
error($config['error']['bot']);
|
error($config['error']['bot']);
|
||||||
|
@ -467,6 +471,8 @@ function handle_post(){
|
||||||
if (!openBoard($post['board']))
|
if (!openBoard($post['board']))
|
||||||
error($config['error']['noboard']);
|
error($config['error']['noboard']);
|
||||||
|
|
||||||
|
$debug['time']['post'] = array();
|
||||||
|
|
||||||
$board_locked_check = (!isset($_POST['mod']) || !$_POST['mod'])
|
$board_locked_check = (!isset($_POST['mod']) || !$_POST['mod'])
|
||||||
&& ($config['board_locked']===true
|
&& ($config['board_locked']===true
|
||||||
|| (is_array($config['board_locked']) && in_array(strtolower($_POST['board']), $config['board_locked'])));
|
|| (is_array($config['board_locked']) && in_array(strtolower($_POST['board']), $config['board_locked'])));
|
||||||
|
@ -511,7 +517,11 @@ function handle_post(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($config['securimage']) && $config['securimage']){
|
if((isset($config['securimage']) && $config['securimage'])
|
||||||
|
&& (
|
||||||
|
!(isset($config['captcha_tor_only']) && $config['captcha_tor_only'])
|
||||||
|
|| ipIsLocal($_SERVER['REMOTE_ADDR'])
|
||||||
|
)){
|
||||||
|
|
||||||
if(!isset($_POST['captcha'])){
|
if(!isset($_POST['captcha'])){
|
||||||
error($config['error']['securimage']['missing']);
|
error($config['error']['securimage']['missing']);
|
||||||
|
@ -544,10 +554,14 @@ function handle_post(){
|
||||||
error($config['error']['referer']);
|
error($config['error']['referer']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_dnsbl = microtime(true);
|
||||||
checkDNSBL();
|
checkDNSBL();
|
||||||
|
$debug['time']['post']['dnsbl'] = round((microtime(true) - $time_dnsbl) * 1000, 2) . 'ms';
|
||||||
|
|
||||||
|
$time_ban = microtime(true);
|
||||||
// Check if banned
|
// Check if banned
|
||||||
checkBan($board['uri']);
|
checkBan($board['uri']);
|
||||||
|
$debug['time']['post']['check_ban'] = round((microtime(true) - $time_ban) * 1000, 2) . 'ms';
|
||||||
|
|
||||||
if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) {
|
if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) {
|
||||||
check_login(false);
|
check_login(false);
|
||||||
|
@ -588,6 +602,10 @@ function handle_post(){
|
||||||
$mod = $post['mod'] = false;
|
$mod = $post['mod'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer1'] = round(($time_rolling2 - $time_1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
//Check if thread exists
|
//Check if thread exists
|
||||||
if (!$post['op']) {
|
if (!$post['op']) {
|
||||||
$query = prepare(sprintf("SELECT `sticky`,`locked`,`cycle`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri']));
|
$query = prepare(sprintf("SELECT `sticky`,`locked`,`cycle`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri']));
|
||||||
|
@ -603,6 +621,9 @@ function handle_post(){
|
||||||
$thread = false;
|
$thread = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer2'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
// Check for an embed field
|
// Check for an embed field
|
||||||
if ($config['enable_embedding'] && isset($_POST['embed']) && !empty($_POST['embed'])) {
|
if ($config['enable_embedding'] && isset($_POST['embed']) && !empty($_POST['embed'])) {
|
||||||
|
@ -703,6 +724,10 @@ function handle_post(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer3'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
$post['name'] = $_POST['name'] != '' ? $_POST['name'] : $config['anonymous'];
|
$post['name'] = $_POST['name'] != '' ? $_POST['name'] : $config['anonymous'];
|
||||||
$post['subject'] = $_POST['subject'];
|
$post['subject'] = $_POST['subject'];
|
||||||
$post['email'] = str_replace(' ', '%20', htmlspecialchars($_POST['email']));
|
$post['email'] = str_replace(' ', '%20', htmlspecialchars($_POST['email']));
|
||||||
|
@ -746,6 +771,10 @@ function handle_post(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer4'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
// Determine size sanity
|
// Determine size sanity
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -781,6 +810,10 @@ function handle_post(){
|
||||||
$post['filesize'] = $size;
|
$post['filesize'] = $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer5'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
$post['capcode'] = false;
|
$post['capcode'] = false;
|
||||||
|
|
||||||
if ($mod && preg_match('/^((.+) )?## (.+)$/', $post['name'], $matches)) {
|
if ($mod && preg_match('/^((.+) )?## (.+)$/', $post['name'], $matches)) {
|
||||||
|
@ -864,6 +897,10 @@ function handle_post(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer6'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
if ($config['strip_combining_chars']) {
|
if ($config['strip_combining_chars']) {
|
||||||
$post['name'] = strip_combining_chars($post['name']);
|
$post['name'] = strip_combining_chars($post['name']);
|
||||||
$post['email'] = strip_combining_chars($post['email']);
|
$post['email'] = strip_combining_chars($post['email']);
|
||||||
|
@ -1023,6 +1060,13 @@ function handle_post(){
|
||||||
|
|
||||||
validate_images($post);
|
validate_images($post);
|
||||||
|
|
||||||
|
$time_rolling2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer7'] = round(($time_rolling2 - $time_rolling1) * 1000, 2) . 'ms';
|
||||||
|
$time_rolling1 = $time_rolling2;
|
||||||
|
|
||||||
|
$time_2 = microtime(true);
|
||||||
|
$debug['time']['post']['pre_noticer_total'] = round(($time_2 - $time_1) * 1000, 2) . 'ms';
|
||||||
|
|
||||||
if ($config['spam_noticer']['enabled']) {
|
if ($config['spam_noticer']['enabled']) {
|
||||||
require_once 'inc/spamnoticer.php';
|
require_once 'inc/spamnoticer.php';
|
||||||
|
|
||||||
|
@ -1035,8 +1079,23 @@ function handle_post(){
|
||||||
if ($spam_noticer_result->succeeded && $spam_noticer_result->noticed) {
|
if ($spam_noticer_result->succeeded && $spam_noticer_result->noticed) {
|
||||||
error($config['error']['spam_noticer'] . $spam_noticer_result->reason);
|
error($config['error']['spam_noticer'] . $spam_noticer_result->reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have an error with posting this later, send back the
|
||||||
|
* delete token to spamnoticer to remove the post from the recent
|
||||||
|
* posts table. (see error.php for the error cleanup function)
|
||||||
|
*/
|
||||||
|
$f_spamnoticer_cleanup_on_err = function() use ($config, $delete_token) {
|
||||||
|
removeRecentPostFromSpamnoticer($config, array($delete_token));
|
||||||
|
};
|
||||||
|
|
||||||
|
push_global_post_cleanup($f_spamnoticer_cleanup_on_err);
|
||||||
|
|
||||||
|
$debug['time']['post']['spam_noticer'] = round((microtime(true) - $time_2) * 1000, 2) . 'ms';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$time_3 = microtime(true);
|
||||||
|
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
foreach ($post['files'] as $key => &$file) {
|
foreach ($post['files'] as $key => &$file) {
|
||||||
if ($file['is_an_image']) {
|
if ($file['is_an_image']) {
|
||||||
|
@ -1477,6 +1536,10 @@ function handle_post(){
|
||||||
|
|
||||||
$thread_id = $post['op'] ? $id : $post['thread'];
|
$thread_id = $post['op'] ? $id : $post['thread'];
|
||||||
|
|
||||||
|
$time_end = microtime(true);
|
||||||
|
$debug['time']['post']['post_noticer'] = round(($time_end - $time_3) * 1000, 2) . 'ms';
|
||||||
|
$debug['time']['post']['total'] = round(($time_end - $time_1) * 1000, 2) . 'ms';
|
||||||
|
|
||||||
$rendered_thread = buildThread($thread_id);
|
$rendered_thread = buildThread($thread_id);
|
||||||
|
|
||||||
if ($config['syslog'])
|
if ($config['syslog'])
|
||||||
|
|
After Width: | Height: | Size: 669 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 975 B |
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 327 B |
|
@ -6,7 +6,11 @@ body {
|
||||||
background: #1D1F21;
|
background: #1D1F21;
|
||||||
color: #ACACAC;
|
color: #ACACAC;
|
||||||
font-family: Courier, monospace;
|
font-family: Courier, monospace;
|
||||||
font-size: 13px;
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.heading {
|
||||||
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LINKS */
|
/* LINKS */
|
||||||
|
@ -14,26 +18,29 @@ a, a:link, a:visited, .intro a.email span.name {
|
||||||
color: #FFB300;
|
color: #FFB300;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:link:hover, a:visited:hover {
|
a:link:hover, a:visited:hover {
|
||||||
color: #FFB300;
|
color: #FFB300;
|
||||||
text-shadow: 0px 0px 5px #117743;
|
text-shadow: 0px 0px 5px #117743;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.pages a.selected {
|
div.pages a.selected {
|
||||||
color: #FFB300;
|
color: #FFB300;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* INTRO */
|
/* INTRO */
|
||||||
h1, div.title, header div.subtitle {
|
h1, div.title, header div.subtitle {
|
||||||
color: #663E11;
|
color: #FFB300;
|
||||||
font-family: Courier, monospace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 24pt;
|
font-size: 18pt;
|
||||||
font-weight: normal;
|
font-weight: bold;
|
||||||
letter-spacing: 0px;
|
letter-spacing: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
header div.subtitle {
|
header div.subtitle {
|
||||||
font-size: 12pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FORMS AND BUTTONS */
|
/* FORMS AND BUTTONS */
|
||||||
|
@ -44,34 +51,51 @@ div.banner {
|
||||||
form table {
|
form table {
|
||||||
border: 1px dashed #117743;
|
border: 1px dashed #117743;
|
||||||
padding-right: 1px;
|
padding-right: 1px;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
form table tr th {
|
form table tr th {
|
||||||
background: #282A2E;
|
background: #282A2E;
|
||||||
border: 1px solid #117743;
|
border: 1px solid #117743;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"], input[type="password"], textarea, select {
|
input[type="text"], input[type="password"], textarea, select {
|
||||||
border: 1px double #07371F;
|
border: 1px double #07371F;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
background: #282A2E;
|
background: #282A2E;
|
||||||
color: #ACACAC;
|
color: #ACACAC;
|
||||||
font-family: Courier, monospace;
|
font-family: Courier, monospace;
|
||||||
|
margin: 0 1px;
|
||||||
|
padding: 3px !important;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
|
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
|
||||||
box-shadow: 0px 0px 5px 2px #117743;
|
box-shadow: 0px 0px 5px 2px #117743;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
border: 3px double #07371F;
|
border: 3px double #07371F;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
background: #16171A;
|
background-color: #07371F;
|
||||||
color: #ACACAC;
|
color: #ACACAC;
|
||||||
font-family: Courier, monospace;
|
font-family: Courier, monospace;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type="submit"]:hover {
|
||||||
|
border-color: #117743;
|
||||||
|
background-color: #117743;
|
||||||
|
}
|
||||||
|
|
||||||
.dropzone {
|
.dropzone {
|
||||||
background: #16171A;
|
background: #16171A;
|
||||||
border: 3px double #07371F;
|
border: 1px solid #07371F;
|
||||||
color: #ACACAC;
|
color: #ACACAC;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin: 0 2px;
|
||||||
}
|
}
|
||||||
.dropzone .file-hint {
|
.dropzone .file-hint {
|
||||||
color: #ACACAC;
|
color: #ACACAC;
|
||||||
|
@ -113,12 +137,12 @@ fieldset {
|
||||||
div.post.reply {
|
div.post.reply {
|
||||||
background: #282A2E;
|
background: #282A2E;
|
||||||
border: 1px solid #117743;
|
border: 1px solid #117743;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
div.post.reply.highlighted {
|
div.post.reply.highlighted {
|
||||||
background: rgba(59, 22, 43, 0.4);
|
background: rgba(59, 22, 43, 0.4);
|
||||||
border: 1px solid #117743;
|
border: 1px solid #117743;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* POST CONTENT */
|
/* POST CONTENT */
|
||||||
|
@ -159,8 +183,8 @@ hr {
|
||||||
.theme-catalog div.thread, .theme-catalog div.thread:hover {
|
.theme-catalog div.thread, .theme-catalog div.thread:hover {
|
||||||
background: #282A2E;
|
background: #282A2E;
|
||||||
border: 1px solid #117743;
|
border: 1px solid #117743;
|
||||||
border-radius: 5px;
|
border-radius: 2px;
|
||||||
font-size: 10pt;
|
font-size: 11pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OPTIONS */
|
/* OPTIONS */
|
||||||
|
@ -225,7 +249,7 @@ table thead th {
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-catalog .thread .meta {
|
.theme-catalog .thread .meta {
|
||||||
font-size: 10pt;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-catalog .thread.grid-size-small .replies {
|
.theme-catalog .thread.grid-size-small .replies {
|
||||||
|
|
|
@ -20,7 +20,9 @@ body {
|
||||||
|
|
||||||
.bar.top {
|
.bar.top {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100vw;
|
width: calc(100% + 8px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0 .25em;
|
||||||
left: -4px;
|
left: -4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,10 @@
|
||||||
method="post"
|
method="post"
|
||||||
data-max-images="{{ config.max_images }}"
|
data-max-images="{{ config.max_images }}"
|
||||||
>
|
>
|
||||||
{{ antibot.html() }}
|
|
||||||
{% if id %}<input type="hidden" name="thread" value="{{ id }}">{% endif %}
|
{% if id %}<input type="hidden" name="thread" value="{{ id }}">{% endif %}
|
||||||
{{ antibot.html() }}
|
|
||||||
{% if board.uri not in config.overboards|keys %}
|
{% if board.uri not in config.overboards|keys %}
|
||||||
<input type="hidden" name="board" value="{{ board.uri }}">
|
<input type="hidden" name="board" value="{{ board.uri }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ antibot.html() }}
|
|
||||||
{% if current_page %}
|
{% if current_page %}
|
||||||
<input type="hidden" name="page" value="{{ current_page }}">
|
<input type="hidden" name="page" value="{{ current_page }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -103,15 +100,38 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config.securimage %}
|
{% if config.securimage %}
|
||||||
<tr>
|
<tr class="post_form_captcha_row">
|
||||||
<th>
|
<th>
|
||||||
Captcha
|
Captcha
|
||||||
|
{% if config.captcha_tor_only %}
|
||||||
|
<br/>
|
||||||
|
<small>Tor Only</small>
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<img name="captcha-img" id="captcha-img" src="/captcha.php" onClick="this.src='/captcha.php?'+Date.now();document.getElementById('captcha').value = '';"><br />
|
<img name="captcha-img" id="captcha-img" src="/captcha.php" onClick="this.src='/captcha.php?'+Date.now();document.getElementById('captcha').value = '';"><br />
|
||||||
<input type="text" name="captcha" id="captcha" size="25" maxlength="10" autocomplete="off">
|
<input type="text" name="captcha" id="captcha" size="25" maxlength="10" autocomplete="off">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if config.captcha_tor_only %}
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
function isHiddenService() {
|
||||||
|
const hostname = window.location.hostname;
|
||||||
|
return hostname.endsWith('.onion') || hostname.endsWith('.i2p');
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeCaptchaField() {
|
||||||
|
document.querySelectorAll('.post_form_captcha_row')
|
||||||
|
.forEach(e => e.parentNode.removeChild(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isHiddenService()) {
|
||||||
|
removeCaptchaField();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config.user_flag %}
|
{% if config.user_flag %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -204,7 +224,6 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>{% endif %}
|
</tr>{% endif %}
|
||||||
</table>
|
</table>
|
||||||
{{ antibot.html(true) }}
|
|
||||||
<input type="hidden" name="hash" value="{{ antibot.hash() }}">
|
<input type="hidden" name="hash" value="{{ antibot.hash() }}">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,18 @@
|
||||||
<link rel="stylesheet" media="screen" href="/stylesheets/bunker_like.css">
|
<link rel="stylesheet" media="screen" href="/stylesheets/bunker_like.css">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.sidebar {
|
.sidebar {
|
||||||
grid-column: 1;
|
grid-column: 1 / 3;
|
||||||
grid-row: 1 / 3;
|
grid-row: 1 / 3;
|
||||||
width: 200px;
|
|
||||||
border-right-color: gray;
|
|
||||||
border-right-style: solid;
|
|
||||||
border-width: 2px;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.introduction {
|
.introduction {
|
||||||
grid-column: 2 / 9;
|
grid-column: 3 / 9;
|
||||||
grid-row: 1;
|
grid-row: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
grid-column: 2 / 9;
|
grid-column: 3 / 9;
|
||||||
grid-row: 2;
|
grid-row: 2;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -33,8 +28,8 @@
|
||||||
|
|
||||||
body {
|
body {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill,minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fill,minmax(120px, 20%));
|
||||||
gap: 20px;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modlog {
|
.modlog {
|
||||||
|
@ -71,6 +66,16 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
grid-column: 1 / 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.news.ban {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width:768px) {
|
@media (max-width:768px) {
|
||||||
body{
|
body{
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="ban">
|
<div class="ban news">
|
||||||
{% if not news %}
|
{% if not news %}
|
||||||
<p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p>
|
<p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -98,14 +98,14 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<footer>
|
</div>
|
||||||
|
<footer>
|
||||||
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
|
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
|
||||||
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
|
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
|
||||||
<br>Tinyboard Copyright © 2010-2014 Tinyboard Development Group
|
<br>Tinyboard Copyright © 2010-2014 Tinyboard Development Group
|
||||||
<br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel
|
<br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel
|
||||||
<br><br>
|
<br><br>
|
||||||
<br><b>Leftychan.net is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
|
<br><b>Leftychan.net is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
|
||||||
{% endapply %}
|
{% endapply %}
|
||||||
|
|
||||||
|
|