1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-03-02 00:30:29 +01:00
Conflicts:
	inc/mod/pages.php
This commit is contained in:
8chan 2014-12-24 14:19:35 +00:00
commit 8ac83fbba6
9 changed files with 103 additions and 8 deletions

@ -1,13 +1,13 @@
8chan - The infinitely expanding imageboard. infinity
======================================================== ========================================================
About About
------------ ------------
8chan is a fork of vichan, with the difference that 8chan is geared towards allowing users to create their own boards. infinity is a fork of vichan, with the difference that 8chan is geared towards allowing users to create their own boards. A running instance is at https://8chan.co.
Most things (other than installation) that apply to upstream vichan also apply to 8chan. See their readme for a detailed FAQ: https://github.com/vichan-devel/vichan/blob/master/README.md Most things (other than installation) that apply to upstream vichan also apply to infinity. See their readme for a detailed FAQ: https://github.com/vichan-devel/vichan/blob/master/README.md
If you are not interested in letting your users make their own boards, install vichan instead of 8chan. If you are not interested in letting your users make their own boards, install vichan instead of infinity.
Because I cannot be bothered to maintain `install.php`, the install process is as such: Because I cannot be bothered to maintain `install.php`, the install process is as such:

@ -322,6 +322,17 @@ class Bans {
if ($post) { if ($post) {
$post['board'] = $board['uri']; $post['board'] = $board['uri'];
$match_urls = '(?xi)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))';
$matched = array();
preg_match_all("#$match_urls#im", $post['body_nomarkup'], $matched);
if (isset($matched[0]) && $matched[0]) {
$post['body'] = str_replace($matched[0], '###Link-Removed###', $post['body']);
$post['body_nomarkup'] = str_replace($matched[0], '###Link-Removed###', $post['body_nomarkup']);
}
$query->bindValue(':post', json_encode($post)); $query->bindValue(':post', json_encode($post));
} else } else
$query->bindValue(':post', null, PDO::PARAM_NULL); $query->bindValue(':post', null, PDO::PARAM_NULL);

@ -357,9 +357,14 @@ class Post {
if (isset($this->files) && $this->files) { if (isset($this->files) && $this->files) {
$this->files = json_decode($this->files); $this->files = json_decode($this->files);
// Compatibility for posts before individual file hashing // Compatibility for posts before individual file hashing
foreach ($this->files as &$file) foreach ($this->files as $i => &$file) {
if (empty($file)) {
unset($this->files[$i]);
continue;
}
if (!isset($file->hash)) if (!isset($file->hash))
$file->hash = $this->filehash; $file->hash = $this->filehash;
}
} }
$this->subject = utf8tohtml($this->subject); $this->subject = utf8tohtml($this->subject);

@ -1707,6 +1707,10 @@ function extract_modifiers($body) {
return $modifiers; return $modifiers;
} }
function remove_modifiers($body) {
return preg_replace('@<tinyboard ([\w\s]+)>(.+?)</tinyboard>@usm', '', $body);
}
function markup(&$body, $track_cites = false, $op = false) { function markup(&$body, $track_cites = false, $op = false) {
global $board, $config, $markup_urls; global $board, $config, $markup_urls;

@ -141,6 +141,7 @@
$config['additional_javascript'][] = 'js/thread-stats.js'; $config['additional_javascript'][] = 'js/thread-stats.js';
$config['additional_javascript'][] = 'js/quote-selection.js'; $config['additional_javascript'][] = 'js/quote-selection.js';
$config['additional_javascript'][] = 'js/twemoji/twemoji.js'; $config['additional_javascript'][] = 'js/twemoji/twemoji.js';
$config['additional_javascript'][] = 'js/flag-previews.js';
//$config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; //$config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css';

@ -1600,6 +1600,16 @@ function mod_edit_post($board, $edit_raw_html, $postID) {
if (isset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['body'])) { if (isset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['body'])) {
$trip = isset($_POST['remove_trip']) ? ' `trip` = NULL,' : ''; $trip = isset($_POST['remove_trip']) ? ' `trip` = NULL,' : '';
// Remove any modifiers they may have put in
$_POST['body'] = remove_modifiers($_POST['body']);
// Add back modifiers in the original post
$modifiers = extract_modifiers($post['body_nomarkup']);
foreach ($modifiers as $key => $value) {
$_POST['body'] .= "<tinyboard $key>$value</tinyboard>";
}
if ($edit_raw_html) if ($edit_raw_html)
$query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body` = :body, `body_nomarkup` = :body_nomarkup, `edited_at` = NOW() WHERE `id` = :id', $board)); $query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body` = :body, `body_nomarkup` = :body_nomarkup, `edited_at` = NOW() WHERE `id` = :id', $board));
else else
@ -1657,9 +1667,14 @@ function mod_edit_post($board, $edit_raw_html, $postID) {
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']);
} else { } else {
// Remove modifiers
$post['body_nomarkup'] = remove_modifiers($post['body_nomarkup']);
$post['body_nomarkup'] = utf8tohtml($post['body_nomarkup']);
$post['body'] = utf8tohtml($post['body']);
if ($config['minify_html']) { if ($config['minify_html']) {
$post['body_nomarkup'] = str_replace("\n", '&#010;', utf8tohtml($post['body_nomarkup'])); $post['body_nomarkup'] = str_replace("\n", '&#010;', $post['body_nomarkup']);
$post['body'] = str_replace("\n", '&#010;', utf8tohtml($post['body'])); $post['body'] = str_replace("\n", '&#010;', $post['body']);
$post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']); $post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']);
$post['body'] = str_replace("\r", '', $post['body']); $post['body'] = str_replace("\r", '', $post['body']);
$post['body_nomarkup'] = str_replace("\t", '&#09;', $post['body_nomarkup']); $post['body_nomarkup'] = str_replace("\t", '&#09;', $post['body_nomarkup']);

@ -23,6 +23,14 @@ onready(function(){
.text(_('Expand all images')) .text(_('Expand all images'))
.click(function() { .click(function() {
$('a img.post-image').each(function() { $('a img.post-image').each(function() {
// Don't expand YouTube embeds
if ($(this).parent().parent().hasClass('video-container'))
return;
// or WEBM
if (/^\/player\.php\?/.test($(this).parent().attr('href')))
return;
if (!$(this).parent()[0].dataset.expanded) if (!$(this).parent()[0].dataset.expanded)
$(this).parent().click(); $(this).parent().click();
}); });

17
js/flag-previews.js Normal file

@ -0,0 +1,17 @@
/*
* flag-previews.js - Preview board flags
*
* Copyright (c) 2014 Fredrick Brennan <admin@8chan.co>
*
*/
$(document).on('ready', function() {
var flag_previews = function() {
if (!$('.flag_preview').length) $('[name=user_flag]').after('<img class="flag_preview">');
$('.flag_preview').attr('src', "/static/custom-flags/" + board_name + "/" + $(this).val() + '.png');
}
$('[name=user_flag]').on('change', flag_previews);
$(window).on('quick-reply', function(){$('[name=user_flag]').on('change', flag_previews)});
});

34
tools/hide_bans_links.php Normal file

@ -0,0 +1,34 @@
<?php
require dirname(__FILE__) . '/inc/cli.php';
$query = prepare('SELECT * FROM bans');
$query->execute() or error(db_error($query));
$num_bans = $query->rowCount();
$iter = 0;
while ($ban = $query->fetch(PDO::FETCH_ASSOC)) {
$iter++;
if (!$ban['post'])
continue;
$match_urls = '(?xi)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))';
$matched = array();
$post = json_decode($ban['post']);
preg_match_all("#$match_urls#im", $post->body_nomarkup, $matched);
if (!isset($matched[0]) || !$matched[0])
continue;
$post->body = str_replace($matched[0], '###Link-Removed###', $post->body);
$post->body_nomarkup = str_replace($matched[0], '###Link-Removed###', $post->body_nomarkup);
$update = prepare('UPDATE ``bans`` SET `post` = :post WHERE `id` = :id');
$update->bindValue(':post', json_encode($post));
$update->bindValue(':id', $ban['id']);
$update->execute() or error(db_error($update));
echo "Processed $iter/$num_bans\n";
}