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( $this->fileFields = array(
'thumbheight' => 'tn_h', 'file_id' => 'id',
'thumbwidth' => 'tn_w', 'type' => 'mime',
'extension' => 'ext',
'height' => 'h', 'height' => 'h',
'width' => 'w', 'width' => 'w',
'size' => 'fsize', 'size' => 'fsize',
@ -90,13 +91,12 @@ class Api {
} }
private function translateFile($file, $post, &$apiPost) { private function translateFile($file, $post, &$apiPost) {
global $config;
$this->translateFields($this->fileFields, $file, $apiPost); $this->translateFields($this->fileFields, $file, $apiPost);
$apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.')); $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) { if (isset ($file->thumb) && $file->thumb) {
$apiPost['spoiler'] = $file->thumb === 'spoiler' ? 1 : 0; $apiPost['spoiler'] = $file->thumb === 'spoiler';
} }
if (isset ($file->hash) && $file->hash) { if (isset ($file->hash) && $file->hash) {
$apiPost['md5'] = base64_encode(hex2bin($file->hash)); $apiPost['md5'] = base64_encode(hex2bin($file->hash));
@ -104,6 +104,25 @@ class Api {
else if (isset ($post->filehash) && $post->filehash) { else if (isset ($post->filehash) && $post->filehash) {
$apiPost['md5'] = base64_encode(hex2bin($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) { 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 (isset($config['poster_ids']) && $config['poster_ids']) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']);
if ($threadsPage) return $apiPost; if ($threadsPage) return $apiPost;
// Load board info
if (isset($post->board)) {
openBoard($post->board);
}
// Handle special fields // Handle special fields
if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) { if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) {
$modifiers = extract_modifiers($post->body_nomarkup); $modifiers = extract_modifiers($post->body_nomarkup);
@ -138,21 +162,13 @@ class Api {
} }
// Handle files // 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) { if (isset($post->files) && $post->files && !$threadsPage) {
$file = $post->files[0]; $apiPost['files'] = [];
$this->translateFile($file, $post, $apiPost); foreach ($post->files as $f) {
if (sizeof($post->files) > 1) { $file = array();
$extra_files = array(); $this->translateFile($f, $post, $file);
foreach ($post->files as $i => $f) {
if ($i == 0) continue;
$extra_file = array(); $apiPost['files'][] = $file;
$this->translateFile($f, $post, $extra_file);
$extra_files[] = $extra_file;
}
$apiPost['extra_files'] = $extra_files;
} }
} }

5
inc/config.php

@ -484,8 +484,11 @@
// Strip superfluous new lines at the end of a post. // Strip superfluous new lines at the end of a post.
$config['strip_superfluous_returns'] = true; $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; $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. // Maximum post body length.
$config['max_body'] = 1800; $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 = 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); $body = str_replace("<code $id>", $code, $body);
} }
} }
@ -2257,19 +2257,11 @@ function ordutf8($string, &$offset) {
return $code; return $code;
} }
// Limit Non_Spacing_Mark and Enclosing_Mark characters
function strip_combining_chars($str) { function strip_combining_chars($str) {
$chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY); global $config;
$str = ''; $limit = strval($config['max_combining_chars']+1);
foreach ($chars as $char) { return preg_replace('/(\p{Me}|\p{Mn}){'.$limit.',}/u','', $str);
$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;
} }
function buildThread($id, $return = false, $mod = false) { function buildThread($id, $return = false, $mod = false) {

7
inc/instance-config.php

@ -106,6 +106,10 @@ $config['threads_preview'] = 5;
$config['root'] = '/'; $config['root'] = '/';
$config['secure_trip_salt'] = 'ODQ2NDM0ODlmMmRhNzk2M2EyNjJlOW'; $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 //Banners
$config['url_banner'] = '/banners.php'; $config['url_banner'] = '/banners.php';
@ -273,6 +277,7 @@ $config['user_flags'] = array (
'ndfp' => 'NDFP', 'ndfp' => 'NDFP',
'palestine' => 'Palestine', 'palestine' => 'Palestine',
'pan-africanism' => 'Pan-Africanism', 'pan-africanism' => 'Pan-Africanism',
'cenzopapa' => 'Papież',
'phrygian_cap' => 'Phrygian Cap', 'phrygian_cap' => 'Phrygian Cap',
'pirate' => 'Pirate', 'pirate' => 'Pirate',
'porky' => 'Porky', 'porky' => 'Porky',
@ -439,6 +444,8 @@ $config['markup'][] = array("/~~(.+?)~~/", "<span class=\"strikethrough\">\$1</s
// $config['wordfilters'][] = array('/nigger/i', 'uyghur', true); // $config['wordfilters'][] = array('/nigger/i', 'uyghur', true);
// $config['wordfilters'][] = array('/nigg/i', 'uygh', true); // $config['wordfilters'][] = array('/nigg/i', 'uygh', true);
$config['wordfilters'][] = array('/chud/i', 'FAGGOT', true);
/* /*
* Traditional word filters. Expires 31-12-2021. * 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('/'); var thread_id = (document.location.pathname + document.location.search).split('/');
thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0];
$('.clear') $('.clear').after('<div id="thread_stats"></div>');
.before('<div id="thread_stats"></div>');
var el = $('#thread_stats'); var el = $('#thread_stats');
el.prepend('Page <span id="thread_stats_page">?</span>'); el.prepend('Page <span id="thread_stats_page">?</span>');
if (IDsupport){ 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'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg'))) {
if (!$config['redraw_image'] && $config['use_exiftool']) { if (!$config['redraw_image'] && $config['use_exiftool']) {
if($error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' . 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); 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 { } else {
$image->to($file['file']); $image->to($file['file']);
$dont_copy_file = true; $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 <?php
require_once 'inc/functions.php'; require_once 'inc/functions.php';
require_once 'templates/themes/overboards/overboards.php';
function endsWith( $haystack, $needle ) {
$length = strlen( $needle );
if( !$length ) {
return true;
}
return substr( $haystack, -$length ) === $needle;
}
// Boards that are nsfw // Boards that are nsfw
$nsfw_boards = ['b', 'overboard']; $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 // 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(); $board_list = listBoards();
// Add objects that are not boards but are treated as such // Add objects that are not boards but are treated as such
$board_list[] = ['uri' => 'overboard', 'title' => 'Overboard']; foreach ($overboards_config as $overboard) {
$board_list[] = ['uri' => 'sfw', 'title' => 'SFW Overboard']; $board_list[] = $overboard;
$board_list[] = ['uri' => 'alt', 'title' => 'Alternate Overboard']; }
/** /**
* Allowed fields for the board object: * Allowed fields for the board object:
* - code<string>: The board code ('b', 'tech', ...) * - code<string>: The board code ('b', 'tech', ...)
* - name<string>: The board user-readable name ('Siberia', ...) * - name<string>: The board user-readable name ('Siberia', ...)
* - description<string>: The board description ('Leftist Politically Incorrect', ...)
* - sfw<boolean>: Is this board sfw? * - 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 = []; $boards = [];
foreach ($board_list as $board) { foreach ($board_list as $board) {
// Skip archives // Skip non-whitelisted boards
if (endsWith($board['uri'], '_archive')) { if (!in_array($board['uri'], $whitelist)) {
continue; continue;
} }
@ -43,7 +45,6 @@ foreach ($board_list as $board) {
'code' => $board['uri'], 'code' => $board['uri'],
'name' => $board['title'], 'name' => $board['title'],
'sfw' => !in_array($board['uri'], $nsfw_boards), 'sfw' => !in_array($board['uri'], $nsfw_boards),
'alternate_spoilers' => in_array($board['uri'], $alunya_spoiler),
'posting_enabled' => !in_array($board['uri'], $readonly_boards), '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*/ /* Work in progress*/
/* General */ /* General */
/* Main page */ /* Main page */
legend { legend {
background: indianred color: indianred
} }
div.module, div.ban { div.module, div.ban {
background: #1d1f21;; background: #1d1f21;;
@ -154,6 +154,7 @@ table.modlog tr th {
/* Red text */ /* Red text */
span.heading { span.heading {
color: indianred; color: indianred;
font-size: 14pt;
} }
/* Buggy shit */ /* Buggy shit */
div.post.reply div.body a { div.post.reply div.body a {
@ -172,10 +173,6 @@ div.post.reply div.body a {
.desktop-style div.boardlist:nth-child(1) { .desktop-style div.boardlist:nth-child(1) {
background-color: #151515; background-color: #151515;
} }
/* Red text */
span.heading {
color: indianred;
}
/* Upper part of a post */ /* Upper part of a post */
div.post p { div.post p {
display: block; display: block;
@ -189,12 +186,28 @@ div.post.reply div.body a {
color: #5f89ac; color: #5f89ac;
text-decoration: none; text-decoration: none;
} }
/* OP */ /* Watchlist options */
/* Subject */ #watchlist-toggle, .watchThread, .watchlist-remove, #clearList, #clearGhosts {
.intro span.subject { color: indianred
color: #b294bb;
} }
/* name */ /* Mod things */
.intro span.name { div.report {
color: #5f89ac; 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 */ /* General */
/* Main page */ /* Main page */
legend { legend {
background: #477085 color: #477085
} }
div.module, div.ban { div.module, div.ban {
background: #e9eced; background: #e9eced;
@ -86,7 +86,7 @@ span.quote {
} }
/* Orangetext */ /* Orangetext */
orangeText { orangeText {
color: #ffb854 color: ##bb8359
} }
* Catalog grids */ * Catalog grids */
/* Background color and green border */ /* Background color and green border */
@ -177,13 +177,14 @@ table.modlog tr th {
/* Red text */ /* Red text */
span.heading { span.heading {
color: #d93f42; color: #d93f42;
font-size: 14pt;
} }
/* OP */ /* OP */
/* Subject */ /* Subject */
.intro span.subject { .intro span.subject {
color: #617d6f; color: #617d6f;
} }
/* name */ /* Name */
.intro span.name { .intro span.name {
color: #4c4c4c; color: #4c4c4c;
} }
@ -205,3 +206,18 @@ div.post.reply div.body a {
color: #477085; color: #477085;
text-decoration: none; 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> </th>
<td> <td>
{% if not hide_ip %} {% 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 %} {% else %}
<em>{% trans 'hidden' %}</em> <em>{% trans 'hidden' %}</em>
{% endif %} {% endif %}
@ -61,7 +61,7 @@
<label for="length">{% trans 'Length' %}</label> <label for="length">{% trans 'Length' %}</label>
</th> </th>
<td> <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> <span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
</tr> </tr>
<tr> <tr>

5
templates/post/fileinfo.html

@ -22,9 +22,9 @@
{% if config.show_filename and file.filename %} {% if config.show_filename and file.filename %}
, ,
{% if file.filename|length > config.max_filename_display %} {% 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 %} {% 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 %}
{% endif %} {% endif %}
) )
@ -36,4 +36,3 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}

Loading…
Cancel
Save