Browse Source

WIP

pull/40/head
towards_a_new_leftypol 1 year ago
committed by towards-a-new-leftypol
parent
commit
d34e4f6828
  1. 3
      inc/anti-bot.php
  2. 2
      inc/config.php
  3. 2
      inc/display.php
  4. 192
      inc/instance-config.php
  5. 41
      inc/instance-config.php.snapshot-20-dec-2020
  6. 5
      inc/mod/pages.php
  7. 54
      staffapplication.php
  8. 1
      templates/post_reply.html
  9. 9
      templates/themes/catalog/theme.php
  10. 119
      templates/thread2_old.html

3
inc/anti-bot.php

@ -185,8 +185,6 @@ class AntiBot {
public function hash() {
global $config;
print_err("compute hash for post page");
// This is the tricky part: create a hash to validate it after
// First, sort the keys in alphabetical order (A-Z)
$inputs = $this->inputs;
@ -195,7 +193,6 @@ class AntiBot {
$hash = '';
// Iterate through each input
foreach ($inputs as $name => $value) {
print_err("<- " . $name . ' : ' . $value);
$hash .= $name . '=' . $value;
}
// Add a salt to the hash

2
inc/config.php

@ -244,6 +244,8 @@
*
*/
$config['spam']['enabled'] = true;
// Number of hidden fields to generate.
$config['spam']['hidden_inputs_min'] = 4;
$config['spam']['hidden_inputs_max'] = 12;

2
inc/display.php

@ -416,7 +416,7 @@ class Thread {
$file = ($index && $config['file_board']) ? 'post_thread_fileboard.html' : 'post_thread.html';
$built = Element($file, array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'hasnoko50' => $hasnoko50, 'isnoko50' => $isnoko50, 'mod' => $this->mod));
return $built;
}
};

192
inc/instance-config.php

@ -8,28 +8,6 @@
* You can copy values from config.php (defaults) and paste them here.
*/
$config['boards'] = array(
array('leftypol', 'b'),
array('GET', 'ref'),
array('gulag' => 'http://status.example.org/')
);
// Board categories. Only used in the "Categories" theme.
$config['categories'] = array(
'Leftypol' => array('leftypol', 'b'),
'GET' => array('GET', 'ref'),
'Meta' => array('gulag')
);
// Optional for the Categories theme. This is an array of name => (title, url) groups for categories
// with non-board links.
$config['custom_categories'] = array(
'Links' => array(
'Leftypedia' => 'http://example.org',
'Staff application' => 'staff_applications.html',
'FAQ' => 'faq.html',
'Donate' => 'donate.html'
)
);
$config['db']['server'] = 'localhost';
$config['db']['database'] = 'lainchan';
@ -39,173 +17,25 @@
$config['cookies']['mod'] = 'mod';
$config['cookies']['salt'] = 'ZGZkYWU3NGUwZDNiYjU2MDEwZmRkMW';
$config['cookies']['salt'] = 'MGYwNjhlNjU5Y2QxNWU3YjQ3MzQ1Yj';
$config['flood_time'] = 10;
$config['flood_time_ip'] = 120;
$config['flood_time_same'] = 30;
$config['max_body'] = 1800;
$config['flood_time'] = 0;
$config['flood_time_ip'] = 0;
$config['flood_time_same'] = 0;
$config['max_body'] = 100000;
$config['reply_limit'] = 250;
$config['max_links'] = 20;
$config['max_filesize'] = 10485760;
$config['max_links'] = 40;
$config['max_filesize'] = 52428800;
$config['thumb_width'] = 255;
$config['thumb_height'] = 255;
$config['max_width'] = 10000;
$config['max_height'] = 10000;
$config['max_images'] = 4;
$config['threads_per_page'] = 10;
$config['max_pages'] = 50;
$config['max_pages'] = 36;
$config['threads_preview'] = 5;
$config['root'] = '/';
$config['secure_trip_salt'] = 'MzdhNTJiMjNkMTM5Nzc5NDcwOGViMD';
$config['thumb_method'] = 'gm+gifsicle';
$config['gnu_md5'] = '1';
// < Added by Zero >
// Sun Aug 30 17:44:19 UTC 2020
// Allowed image file extensions.
$config['allowed_ext'][] = 'jpg';
$config['allowed_ext'][] = 'jpeg';
$config['allowed_ext'][] = 'bmp';
$config['allowed_ext'][] = 'gif';
$config['allowed_ext'][] = 'png';
// TODO test section, please remove
$config['allowed_ext'][] = 'mp4';
$config['allowed_ext'][] = 'webm';
$config['allowed_ext_files'][] = 'webm';
$config['webm']['use_ffmpeg'] = true;
$config['additional_javascript'][] = 'js/options.js';
$config['additional_javascript'][] = 'js/webm-settings.js';
$config['additional_javascript'][] = 'js/expand-video.js';
$config['max_filesize'] = 50 * 1024 * 1024; // 50MB
$config['webm']['allow_audio'] = true;
$config['webm']['max_length'] = 1000;
//end test section
$config['allowed_ext_files'][] = 'mp4';
$config['allowed_ext_files'][] = 'pdf';
$config['allowed_ext_files'][] = 'txt';
$config['allowed_ext_files'][] = 'zip';
$config['allowed_ext_files'][] = 'epub';
$config['api']['enabled'] = false;
/*
* From Config:
// Always regenerate markup. This isn't recommended and should only be used for debugging; by default,
// Tinyboard only parses post markup when it needs to, and keeps post-markup HTML in the database. This
// will significantly impact performance when enabled.
*
*/
$config['markup_repair_tidy'] = false;
$config['image_reject_repost'] = false;
$config['flood_time'] = 0;
// Minimum time between between each post with the exact same content AND same IP address.
$config['flood_time_ip'] = 0;
$config['filters'] = array();
$config['always_noko'] = false; // the migration script now relies on this default behavior, we can turn this on later.
// </ Added by Zero >
// Changes made via web editor by "admin" @ Tue, 02 Jun 2020 23:16:58 -0700:
$config['debug'] = true;
// Changes made via web editor by "admin" @ Tue, 02 Jun 2020 23:24:29 -0700:
$config['debug'] = false;
$config['verbose_errors'] = false;
/*
* ====================
* Javascript
* ====================
*/
// Additional Javascript files to include on board index and thread pages. See js/ for available scripts.
$config['additional_javascript'][] = 'js/jquery.min.js';
$config['additional_javascript'][] = 'js/inline-expanding.js';
$config['additional_javascript'][] = 'js/multi-image.js'; // required when using multi file upload
$config['additional_javascript'][] = 'js/local-time.js';
$config['additional_javascript'][] = 'js/auto-reload.js';
$config['additional_javascript'][] = 'js/post-hover.js';
$config['additional_javascript'][] = 'js/style-select.js';
// Some scripts require jQuery. Check the comments in script files to see what's needed. When enabling
// jQuery, you should first empty the array so that "js/query.min.js" can be the first, and then re-add
// "js/inline-expanding.js" or else the inline-expanding script might not interact properly with other
// scripts.
// $config['additional_javascript'] = array();
// $config['additional_javascript'][] = 'js/jquery.min.js';
// $config['additional_javascript'][] = 'js/inline-expanding.js';
// $config['additional_javascript'][] = 'js/auto-reload.js';
// $config['additional_javascript'][] = 'js/post-hover.js';
// $config['additional_javascript'][] = 'js/style-select.js';
// Where these script files are located on the web. Defaults to $config['root'].
// $config['additional_javascript_url'] = 'http://static.example.org/tinyboard-javascript-stuff/';
// Compile all additional scripts into one file ($config['file_script']) instead of including them seperately.
$config['additional_javascript_compile'] = false;
// Minify Javascript using http://code.google.com/p/minify/.
$config['minify_js'] = false;
// Dispatch thumbnail loading and image configuration with JavaScript. It will need a certain javascript
// code to work.
$config['javascript_image_dispatch'] = false;
$config['multiimage_method'] = 'each';
$config['mod']['show_ip'] = DISABLED;
$config['mod']['move'] = MOD;
// Changes made via web editor by "admin" @ Sun, 23 Aug 2020 16:45:14 -0700:
$config['force_image_op'] = false;
// Changes made via web editor by "admin" @ Sun, 23 Aug 2020 16:48:22 -0700:
$config['force_body_op'] = false;
// Changes made via web editor by "admin" @ Sun, 23 Aug 2020 17:38:52 -0700:
$config['flood_time'] = 0;
$config['flood_time_ip'] = 0;
$config['flood_time_same'] = 0;
// Changes made via web editor by "admin" @ Wed, 26 Aug 2020 20:15:11 -0700:
$config['min_body'] = 5;
// Changes made via web editor by "admin" @ Wed, 26 Aug 2020 20:15:44 -0700:
$config['force_image_op'] = true;
$config['min_body'] = 15;
// Changes made via web editor by "admin" @ Sat, 29 Aug 2020 13:26:51 -0700:
$config['force_image_op'] = false;
// Changes made via web editor by "admin" @ Sat, 29 Aug 2020 23:13:46 -0700:
$config['cookies']['salt'] = 'ZGZkYWU3NGUwZDNiYjU2MDEwZmRkMX';
// Changes made via web editor by "admin" @ Sat, 29 Aug 2020 23:21:09 -0700:
$config['cookies']['salt'] = 'ZGZkYWU3NGUwZDNiYjU2MDEwZmRkMA';
// Changes made via web editor by "admin" @ Sun, 30 Aug 2020 10:48:36 -0700:
$config['max_body'] = 100000;
$config['secure_trip_salt'] = 'ODQ2NDM0ODlmMmRhNzk2M2EyNjJlOW';
// Changes made via web editor by "admin" @ Sun, 30 Aug 2020 15:25:41 -0700:
$config['max_links'] = 40;
$config['thumb_method'] = 'gm+gifsicle';
$config['gnu_md5'] = '1';

41
inc/instance-config.php.snapshot-20-dec-2020

@ -0,0 +1,41 @@
<?php
/*
* Instance Configuration
* ----------------------
* Edit this file and not config.php for imageboard configuration.
*
* You can copy values from config.php (defaults) and paste them here.
*/
$config['db']['server'] = 'localhost';
$config['db']['database'] = 'lainchan';
$config['db']['prefix'] = '';
$config['db']['user'] = 'lainchan';
$config['db']['password'] = '';
$config['cookies']['mod'] = 'mod';
$config['cookies']['salt'] = 'MGYwNjhlNjU5Y2QxNWU3YjQ3MzQ1Yj';
$config['flood_time'] = 0;
$config['flood_time_ip'] = 0;
$config['flood_time_same'] = 0;
$config['max_body'] = 100000;
$config['reply_limit'] = 250;
$config['max_links'] = 40;
$config['max_filesize'] = 52428800;
$config['thumb_width'] = 255;
$config['thumb_height'] = 255;
$config['max_width'] = 10000;
$config['max_height'] = 10000;
$config['threads_per_page'] = 10;
$config['max_pages'] = 36;
$config['threads_preview'] = 5;
$config['root'] = '/';
$config['secure_trip_salt'] = 'ODQ2NDM0ODlmMmRhNzk2M2EyNjJlOW';
$config['thumb_method'] = 'gm+gifsicle';
$config['gnu_md5'] = '1';

5
inc/mod/pages.php

@ -6,6 +6,8 @@
defined('TINYBOARD') or exit;
require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only!
function mod_page($title, $template, $args, $subtitle = false) {
global $config, $mod;
@ -2649,6 +2651,7 @@ function mod_new_pm($username) {
function mod_rebuild() {
global $config, $twig;
print_err("mod_rebuild");
if (!hasPermission($config['mod']['rebuild']))
error($config['error']['noaccess']);
@ -2673,7 +2676,9 @@ function mod_rebuild() {
if (isset($_POST['rebuild_themes'])) {
$log[] = 'Regenerating theme files';
print_err("mod_rebuild calling rebuildThemes");
rebuildThemes('all');
print_err("mod_rebuild calling rebuildThemes ok");
}
if (isset($_POST['rebuild_javascript'])) {

54
staffapplication.php

@ -0,0 +1,54 @@
<?php
$name = $contactmethod = $email = $application = $antispam = $displaymessage = "";
require './inc/functions.php';
if (isset ($_POST["antispam"])){
if ($_POST["antispam"] == "DUCK"){
$namecheck = ! empty($_POST["name"]);
$contactmethodcheck = $_POST["contactmethod"] == "email";
$emailcheck = ! empty($_POST["email"]);
$emailischecked = $contactmethodcheck ? $emailcheck : true;
if ($emailischecked && $namecheck){
$name = $_POST["name"];
$contactmethod = $_POST["contactmethod"];
$email = $_POST["email"];
$application = $_POST["application"];
$antispam = $_POST["antispam"];
$to = "[email protected]";
$subject = "Lainchan.org Staff Application for " . $name;
$message = "Name: " . $name . "\r\n";
$message .= "Contact method: " . $contactmethod . "\r\n";
$message .= $application;
$message = wordwrap($message, 70, "\r\n");
$source = $emailcheck ? $email : $to;
$headers = 'From: ' . $source . "\r\n" .
'Reply-To: ' . $source . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$sent = mail($to, $subject, $message, $headers);
$sentmessage = $sent ? "was submitted successfully.</p>\r\n" : "was unable to be submitted.</p>\r\n";
$displaymessage = "<p style=\"text-align:center;\"> Your staff application " . $sentmessage;
}
}
else
{
$displaymessage = "<p style=\"text-align:center;\">ANTISPAM VALUE INCORRECT</p>\r\n";
}
}
else {
$displaymessage = "<p style=\"text-align:center;\">ANTISPAM NOT SET</p>\r\n";
}
$displaymessage .= '<span style="text-align:center; display: block;" >[ <a href="https://lainchan.org/"> Return Home </a> ]</span>';
echo Element('page.html', array(
'index' => $config['root'],
'title' => _('Staff Application'),
'config' => $config,
'boardlist' => createBoardlist(isset($mod) ? $mod : false),
'body' => $displaymessage,
)
);
?>

1
templates/post_reply.html

@ -30,5 +30,4 @@
</div>
</div>
</div>
<br/>
{% endfilter %}

9
templates/themes/catalog/theme.php

@ -25,6 +25,7 @@
file_unlink($config['dir']['home'] . $board . '/index.rss');
}
elseif ($action == 'rebuild') {
print_err("catalog_build calling Catalog.build 1. board: $board");
$b->build($settings, $board);
}
}
@ -38,6 +39,7 @@
file_unlink($config['dir']['home'] . $board . '/index.rss');
}
elseif ($action == 'rebuild') {
print_err("catalog_build calling Catalog.build 2");
$b->build($settings, $board);
}
}
@ -297,21 +299,28 @@
error(sprintf(_("Board %s doesn't exist"), $board_name));
}
}
print_err("Catalog.build 1");
if (array_key_exists($board_name, $this->threadsCache)) {
$threads = $this->threadsCache[$board_name];
} else {
print_err("Catalog.build calling buildThreadsQuery. boardname: $board_name");
$sql = $this->buildThreadsQuery($board_name);
print_err("Catalog.build calling buildThreadsQuery ok");
$query = query($sql . ' ORDER BY `bump` DESC') or error(db_error());
$threads = $query->fetchAll(PDO::FETCH_ASSOC);
print_err("Catalog.build has threads");
// Save for posterity
$this->threadsCache[$board_name] = $threads;
}
print_err("Catalog.build 2");
// Generate data for the template
$recent_posts = $this->generateRecentPosts($threads);
print_err("Catalog.build 3");
$this->saveForBoard($board_name, $recent_posts);
print_err("Catalog.build 4");
}
private function buildThreadsQuery($board) {

119
templates/thread2_old.html

@ -0,0 +1,119 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<script type="text/javascript">
var active_page = "thread"
, board_name = "{{ board.uri }}"
, thread_id = "{{ thread.id }}";
</script>
{% include 'header.html' %}
{% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|remove_modifiers|e }}{% endif %}{% endset %}
<meta name="description" content="{{ board.url }} - {{ board.title|e }} - {{ meta_subject }}" />
<meta name="twitter:card" value="summary">
<meta property="og:title" content="{{ meta_subject }}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ config.domain }}/{{ board.uri }}/{{ config.dir.res }}{{ thread.id }}.html" />
{% if thread.files.0.thumb %}<meta property="og:image" content="{{ config.domain }}/{{ board.uri }}/{{ config.dir.thumb }}{{ thread.files.0.thumb }}" />{% endif %}
<meta property="og:description" content="{{ thread.body_nomarkup|e }}" />
<title>{{ board.url }} - {{ meta_subject }}</title>
</head>
<body id="thread" class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} active-thread" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
<div class="bar top">
{{ boardlist.top }}
</div>
<a name="top"></a>
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
{% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %}
<div id="pagewrap">
<header>
<h1 class="glitch" data-text="{{ board.url }} - {{ board.title|e }}">{{ board.url }} - {{ board.title|e }}</h1>
<div class="subtitle">
{% if board.subtitle %}
{% if config.allow_subtitle_html %}
{{ board.subtitle }}
{% else %}
{{ board.subtitle|e }}
{% endif %}
{% endif %}
{% if mod %}<p><a href="?/">{% trans %}Return to dashboard{% endtrans %}</a></p>{% endif %}
</div>
</header>
{% include 'attention_bar.html' %}
{{ config.ad.top }}
{% include 'post_form.html' %}
{% if config.global_message %}<hr /><div class="blotter">{{ config.global_message }}</div>{% endif %}
<hr />
<div class="threadlinks-noup">
<span class="threadlink">[ <a href="{{ return }}">{% trans %}Return{% endtrans %}</a> /</span>
<span class="threadlink"><a href="#bottom" style="padding-left: 10px"> {% trans %}Go to bottom{% endtrans %}</a> ]</span>
</div>
<hr />
<form name="postcontrols" action="{{ config.post_url }}" method="post">
<input type="hidden" name="board" value="{{ board.uri }}" />
{% if mod %}<input type="hidden" name="mod" value="1" />{% endif %}
{{ body }}
<div id="thread-interactions">
<span id="thread-links">
<a id="thread-return" href="{{ return }}">[{% trans %}Return{% endtrans %}]</a>
<a id="thread-top" href="#top">[{% trans %}Go to top{% endtrans %}]</a>
{% if config.catalog_link %}
<a id="thread-catalog" href="{{ config.root }}{{ board.dir }}{{ config.catalog_link }}">[{% trans %}Catalog{% endtrans %}]</a>
{% endif %}
{% if config.home_link %}
| <a id="thread-home" href="{{ config.root }}">[{% trans %}Home{% endtrans %}]</a>
{% endif %}
</span>
<span id="thread-quick-reply">
<a id="link-quick-reply" href="#">[{% trans %}Post a Reply{% endtrans %}]</a>
</span>
{% include 'report_delete.html' %}
</div>
<div class="clearfix"></div>
</form>
{{ boardlist.bottom }}
{{ config.ad.bottom }}
<footer>
{% include 'badges.html' %}
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> +
<a href='https://github.com/lainchan/lainchan'>lainchan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
</div>
<div class="bar bottom">
<div class="threadlinks">
<span class="threadlink">[ <a href="{{ return }}">{% trans %}Return{% endtrans %}</a> /</span>
<span class="threadlink"><a href="#" style="padding-left: 10px"> {% trans %}Go to top{% endtrans %}</a> /</span>
</div>
<div class=pages></div>
</div>
<script type="text/javascript">{% raw %}
ready();
{% endraw %}</script>
<a href="#" id="bottom"></a>
</body>
</html>
Loading…
Cancel
Save