Browse Source

Merge branch 'config' into defer-javascript

pull/40/head
nonmakina 3 years ago
committed by GitHub
parent
commit
fe280cdc12
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. BIN
      banners/1619614700009.png
  2. BIN
      banners/flagsroom2.png
  3. BIN
      banners/pencilbanner.png
  4. BIN
      banners/pencilbanner2.png
  5. 54
      inc/api.php
  6. 5
      inc/config.php
  7. 20
      inc/functions.php
  8. 7
      inc/instance-config.php
  9. 4
      js/thread-stats.js
  10. 7
      post.php
  11. 0
      static/flags/antifa.png
  12. BIN
      static/flags/atheism.png
  13. BIN
      static/flags/cenzopapa.png
  14. 0
      static/flags/council_communism.png
  15. 39
      status.php
  16. 39
      stylesheets/demain_dark.css
  17. 22
      stylesheets/demain_light.css
  18. 4
      templates/mod/ban_form.html
  19. 5
      templates/post/fileinfo.html

BIN
banners/1619614700009.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
banners/flagsroom2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
banners/pencilbanner.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
banners/pencilbanner2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

54
inc/api.php

@ -45,8 +45,9 @@ class Api {
);
$this->fileFields = array(
'thumbheight' => 'tn_h',
'thumbwidth' => 'tn_w',
'file_id' => 'id',
'type' => 'mime',
'extension' => 'ext',
'height' => 'h',
'width' => 'w',
'size' => 'fsize',
@ -90,13 +91,12 @@ class Api {
}
private function translateFile($file, $post, &$apiPost) {
global $config;
$this->translateFields($this->fileFields, $file, $apiPost);
$apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.'));
$dotPos = strrpos($file->file, '.');
$apiPost['ext'] = substr($file->file, $dotPos);
$apiPost['tim'] = substr($file->file, 0, $dotPos);
if (isset ($file->thumb) && $file->thumb) {
$apiPost['spoiler'] = $file->thumb === 'spoiler' ? 1 : 0;
$apiPost['spoiler'] = $file->thumb === 'spoiler';
}
if (isset ($file->hash) && $file->hash) {
$apiPost['md5'] = base64_encode(hex2bin($file->hash));
@ -104,6 +104,25 @@ class Api {
else if (isset ($post->filehash) && $post->filehash) {
$apiPost['md5'] = base64_encode(hex2bin($post->filehash));
}
$apiPost['file_path'] = $config['uri_img'] . $file->file;
// Pick the correct thumbnail
if (isset($file->thumb) && $file->thumb === 'spoiler') {
// Spoiler
$apiPost['thumb_path'] = $config['root'] . $config['spoiler_image'];
} else if (!isset($file->thumb) || $file->thumb === 'file') {
// Default file format image
$thumbFile = $config['file_icons']['default'];
if (isset($file->extension) && isset($config['file_icons'][$file->extension])) {
$thumbFile = $config['file_icons'][$file->extension];
}
$apiPost['thumb_path'] = $config['root'] . sprintf($config['file_thumb'], $thumbFile);
} else {
// The file's own thumbnail
$apiPost['thumb_path'] = $config['uri_thumb'] . $file->thumb;
}
}
private function translatePost($post, $threadsPage = false) {
@ -115,6 +134,11 @@ class Api {
if (isset($config['poster_ids']) && $config['poster_ids']) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']);
if ($threadsPage) return $apiPost;
// Load board info
if (isset($post->board)) {
openBoard($post->board);
}
// Handle special fields
if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) {
$modifiers = extract_modifiers($post->body_nomarkup);
@ -138,21 +162,13 @@ class Api {
}
// Handle files
// Note: 4chan only supports one file, so only the first file is taken into account for 4chan-compatible API.
if (isset($post->files) && $post->files && !$threadsPage) {
$file = $post->files[0];
$this->translateFile($file, $post, $apiPost);
if (sizeof($post->files) > 1) {
$extra_files = array();
foreach ($post->files as $i => $f) {
if ($i == 0) continue;
$apiPost['files'] = [];
foreach ($post->files as $f) {
$file = array();
$this->translateFile($f, $post, $file);
$extra_file = array();
$this->translateFile($f, $post, $extra_file);
$extra_files[] = $extra_file;
}
$apiPost['extra_files'] = $extra_files;
$apiPost['files'][] = $file;
}
}

5
inc/config.php

@ -484,8 +484,11 @@
// Strip superfluous new lines at the end of a post.
$config['strip_superfluous_returns'] = true;
// Strip combining characters from Unicode strings (eg. "Zalgo").
// Strip combining characters from Unicode strings (eg. "Zalgo"). This will impact some non-English languages.
$config['strip_combining_chars'] = true;
// Maximum number of combining characters in a row allowed in Unicode strings so that they can still be used in moderation.
// Requires $config['strip_combining_chars'] = true;
$config['max_combining_chars'] = 0;
// Maximum post body length.
$config['max_body'] = 1800;

20
inc/functions.php

@ -2196,8 +2196,8 @@ function markup(&$body, $track_cites = false, $op = false) {
$code = rtrim(ltrim($code, "\r\n"));
$code = "<pre class='code lang-$code_lang'>".str_replace(array("\n","\t"), array("&#10;","&#9;"), htmlspecialchars($code))."</pre>";
$code = "<pre class='code lang-$code_lang'>".str_replace(array("\n","\t"), array("&#10;","&#9;"), htmlspecialchars($code, ENT_COMPAT, "UTF-8", false))."</pre>";
$body = str_replace("<code $id>", $code, $body);
}
}
@ -2257,19 +2257,11 @@ function ordutf8($string, &$offset) {
return $code;
}
// Limit Non_Spacing_Mark and Enclosing_Mark characters
function strip_combining_chars($str) {
$chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
$str = '';
foreach ($chars as $char) {
$o = 0;
$ord = ordutf8($char, $o);
if ( ($ord >= 768 && $ord <= 879) || ($ord >= 1536 && $ord <= 1791) || ($ord >= 3655 && $ord <= 3659) || ($ord >= 7616 && $ord <= 7679) || ($ord >= 8400 && $ord <= 8447) || ($ord >= 65056 && $ord <= 65071))
continue;
$str .= $char;
}
return $str;
global $config;
$limit = strval($config['max_combining_chars']+1);
return preg_replace('/(\p{Me}|\p{Mn}){'.$limit.',}/u','', $str);
}
function buildThread($id, $return = false, $mod = false) {

7
inc/instance-config.php

@ -106,6 +106,10 @@ $config['threads_preview'] = 5;
$config['root'] = '/';
$config['secure_trip_salt'] = 'ODQ2NDM0ODlmMmRhNzk2M2EyNjJlOW';
$config['strip_combining_chars'] = true;
// Maximum number of combining characters in a row allowed so that they can still be used in moderation.
$config['max_combining_chars'] = 3;
//Banners
$config['url_banner'] = '/banners.php';
@ -273,6 +277,7 @@ $config['user_flags'] = array (
'ndfp' => 'NDFP',
'palestine' => 'Palestine',
'pan-africanism' => 'Pan-Africanism',
'cenzopapa' => 'Papież',
'phrygian_cap' => 'Phrygian Cap',
'pirate' => 'Pirate',
'porky' => 'Porky',
@ -439,6 +444,8 @@ $config['markup'][] = array("/~~(.+?)~~/", "<span class=\"strikethrough\">\$1</s
// $config['wordfilters'][] = array('/nigger/i', 'uyghur', true);
// $config['wordfilters'][] = array('/nigg/i', 'uygh', true);
$config['wordfilters'][] = array('/chud/i', 'FAGGOT', true);
/*
* Traditional word filters. Expires 31-12-2021.
*

4
js/thread-stats.js

@ -14,8 +14,8 @@ $(document).ready(function(){
var thread_id = (document.location.pathname + document.location.search).split('/');
thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0];
$('.clear')
.before('<div id="thread_stats"></div>');
$('.clear').after('<div id="thread_stats"></div>');
var el = $('#thread_stats');
el.prepend('Page <span id="thread_stats_page">?</span>');
if (IDsupport){

7
post.php

@ -1092,8 +1092,13 @@ function handle_post(){
if ($config['redraw_image'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg'))) {
if (!$config['redraw_image'] && $config['use_exiftool']) {
if($error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' .
escapeshellarg($file['tmp_name'])))
escapeshellarg($file['tmp_name']))) {
error(_('Could not strip EXIF metadata!'), null, $error);
} else {
clearstatcache(true, $file['tmp_name']);
if (($newfilesize = filesize($file['tmp_name'])) !== false)
$file['size'] = $newfilesize;
}
} else {
$image->to($file['file']);
$dont_copy_file = true;

0
static/flags/antifa.png

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 656 B

BIN
static/flags/atheism.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/flags/cenzopapa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

0
static/flags/council_communism.png

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

39
status.php

@ -1,41 +1,43 @@
<?php
require_once 'inc/functions.php';
function endsWith( $haystack, $needle ) {
$length = strlen( $needle );
if( !$length ) {
return true;
}
return substr( $haystack, -$length ) === $needle;
}
require_once 'templates/themes/overboards/overboards.php';
// Boards that are nsfw
$nsfw_boards = ['b', 'overboard'];
// Boards that use spoiler_alunya.png as their spoiler
$alunya_spoiler = ['leftypol', 'anime'];
// Boards where posts are not allowed to be created
$readonly_boards = ['overboard', 'sfw', 'alt'];
$readonly_boards = [];
// Allowed boards
$whitelist = [];
foreach ($config['boards'] as $boards) {
foreach ($boards as $board) {
$whitelist[] = $board;
}
}
foreach ($overboards_config as $board) {
$whitelist[] = $board['uri'];
$readonly_boards[] = $board['uri'];
}
$board_list = listBoards();
// Add objects that are not boards but are treated as such
$board_list[] = ['uri' => 'overboard', 'title' => 'Overboard'];
$board_list[] = ['uri' => 'sfw', 'title' => 'SFW Overboard'];
$board_list[] = ['uri' => 'alt', 'title' => 'Alternate Overboard'];
foreach ($overboards_config as $overboard) {
$board_list[] = $overboard;
}
/**
* Allowed fields for the board object:
* - code<string>: The board code ('b', 'tech', ...)
* - name<string>: The board user-readable name ('Siberia', ...)
* - description<string>: The board description ('Leftist Politically Incorrect', ...)
* - sfw<boolean>: Is this board sfw?
* - alternate_spoilers<boolean>: Does this board use the alunya spoiler?
* - posting_enabled<boolean>: Can new posts be created belonging to this board?
*/
$boards = [];
foreach ($board_list as $board) {
// Skip archives
if (endsWith($board['uri'], '_archive')) {
// Skip non-whitelisted boards
if (!in_array($board['uri'], $whitelist)) {
continue;
}
@ -43,7 +45,6 @@ foreach ($board_list as $board) {
'code' => $board['uri'],
'name' => $board['title'],
'sfw' => !in_array($board['uri'], $nsfw_boards),
'alternate_spoilers' => in_array($board['uri'], $alunya_spoiler),
'posting_enabled' => !in_array($board['uri'], $readonly_boards),
];
}

39
stylesheets/demain_dark.css

@ -1,9 +1,9 @@
/* Demain_light theme for leftypol.org adapted from Seaweed theme for 4chan*/
/* Demain_light theme for leftypol.org adapted from "Tomorrow" theme for 4chan*/
/* Work in progress*/
/* General */
/* Main page */
legend {
background: indianred
color: indianred
}
div.module, div.ban {
background: #1d1f21;;
@ -154,6 +154,7 @@ table.modlog tr th {
/* Red text */
span.heading {
color: indianred;
font-size: 14pt;
}
/* Buggy shit */
div.post.reply div.body a {
@ -172,10 +173,6 @@ div.post.reply div.body a {
.desktop-style div.boardlist:nth-child(1) {
background-color: #151515;
}
/* Red text */
span.heading {
color: indianred;
}
/* Upper part of a post */
div.post p {
display: block;
@ -189,12 +186,28 @@ div.post.reply div.body a {
color: #5f89ac;
text-decoration: none;
}
/* OP */
/* Subject */
.intro span.subject {
color: #b294bb;
/* Watchlist options */
#watchlist-toggle, .watchThread, .watchlist-remove, #clearList, #clearGhosts {
color: indianred
}
/* name */
.intro span.name {
color: #5f89ac;
/* Mod things */
div.report {
color: grey;
}
.banlist-opts .checkboxes label {
display: block;
color: grey;
}
tr.tblhead > th {
color: grey;
}
.desktop-style div.boardlist:not(.bottom) {
background-color: #151515;
}
.banlist-opts .checkboxes label {
display: block;
color: grey;
}
tr.tblhead > th {
color: indianred
}

22
stylesheets/demain_light.css

@ -3,7 +3,7 @@
/* General */
/* Main page */
legend {
background: #477085
color: #477085
}
div.module, div.ban {
background: #e9eced;
@ -86,7 +86,7 @@ span.quote {
}
/* Orangetext */
orangeText {
color: #ffb854
color: ##bb8359
}
* Catalog grids */
/* Background color and green border */
@ -177,13 +177,14 @@ table.modlog tr th {
/* Red text */
span.heading {
color: #d93f42;
font-size: 14pt;
}
/* OP */
/* Subject */
.intro span.subject {
color: #617d6f;
}
/* name */
/* Name */
.intro span.name {
color: #4c4c4c;
}
@ -205,3 +206,18 @@ div.post.reply div.body a {
color: #477085;
text-decoration: none;
}
/* WatchList options */
#watchlist-toggle, .watchThread, .watchlist-remove, #clearList, #clearGhosts {
color: #617d6f
}
/* Mod tools */
div.report {
color: black;
}
.banlist-opts .checkboxes label {
display: block;
color: black;
}
.desktop-style div.boardlist:not(.bottom) {
background-color: #e9eced;
}

4
templates/mod/ban_form.html

@ -24,7 +24,7 @@
</th>
<td>
{% if not hide_ip %}
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip|e }}">
<input type="text" name="ip" id="ip" size="30" maxlength="43" value="{{ ip|e }}">
{% else %}
<em>{% trans 'hidden' %}</em>
{% endif %}
@ -61,7 +61,7 @@
<label for="length">{% trans 'Length' %}</label>
</th>
<td>
<input type="text" name="length" id="length" size="20" maxlength="40">
<input type="text" name="length" id="length" size="20" maxlength="43">
<span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
</tr>
<tr>

5
templates/post/fileinfo.html

@ -22,9 +22,9 @@
{% if config.show_filename and file.filename %}
,
{% if file.filename|length > config.max_filename_display %}
<a href="{{ config.uri_img }}{{ file.file }}" download="{{ file.filename }}" title="Save as original filename">{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }}</a>
<span class="postfilename" title="{{ file.filename|e|bidi_cleanup }}">{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }}</span>
{% else %}
<a href="{{ config.uri_img }}{{ file.file }}" download="{{ file.filename }}" title="Save as original filename">{{ file.filename|e|bidi_cleanup }}</a>
<span class="postfilename">{{ file.filename|e|bidi_cleanup }}</span>
{% endif %}
{% endif %}
)
@ -36,4 +36,3 @@
{% endfor %}
</div>
{% endif %}

Loading…
Cancel
Save