Conflicts:
	inc/config.php
	inc/display.php
	inc/functions.php
This commit is contained in:
czaks
2013-08-16 10:07:24 -04:00
245 changed files with 112 additions and 159 deletions

View File

@@ -391,6 +391,11 @@
// When true, users are instead presented a selectbox for email. Contains, blank, noko and sage.
$config['field_email_selectbox'] = false;
// Attach country flags to posts. Requires the PHP "geoip" extension to be installed:
// http://www.php.net/manual/en/intro.geoip.php. In the future, maybe I will find and include a proper
// pure-PHP geolocation library.
$config['country_flags'] = false;
// Require users to see the ban page at least once for a ban even if it has since expired.
$config['require_ban_view'] = true;
@@ -760,6 +765,17 @@
// Optional HTML to append to "You are banned" pages. For example, you could include instructions and/or
// a link to an email address or IRC chat room to appeal the ban.
$config['ban_page_extra'] = '';
// Display flags (when available). This config option has no effect unless poster flags are enabled (see
// $config['country_flags']). Disable this if you want all previously-assigned flags to be hidden.
$config['display_flags'] = true;
// Location of post flags/icons (where "%s" is the flag name). Defaults to static/flags/%s.png.
// $config['uri_flags'] = 'http://static.example.org/flags/%s.png';
// Width and height (and more?) of post flags. Can be overridden with the Tinyboard post modifier:
// <tinyboard flag style>.
$config['flag_style'] = 'width:16px;height:11px;';
/*
* ====================
@@ -970,7 +986,7 @@
// $config['url_favicon'] = '/favicon.gif';
// EXPERIMENTAL: Try not to build pages when we shouldn't have to.
$config['try_smarter'] = false;
$config['try_smarter'] = true;
/*
* ====================

View File

@@ -271,36 +271,25 @@ function embed_html($link) {
}
class Post {
public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) {
public function __construct($post, $root=null, $mod=false) {
global $config;
if (!isset($root))
$root = &$config['root'];
$this->id = $id;
$this->thread = $thread;
$this->subject = utf8tohtml($subject);
$this->email = $email;
$this->name = utf8tohtml($name);
$this->trip = $trip;
$this->capcode = $capcode;
$this->body = $body;
$this->time = $time;
$this->thumb = $thumb;
$this->thumbx = $thumbx;
$this->thumby = $thumby;
$this->file = $file;
$this->filex = $filex;
$this->filey = $filey;
$this->filesize = $filesize;
$this->filename = $filename;
$this->ip = $ip;
$this->embed = $embed;
$this->root = $root;
foreach ($post as $key => $value) {
$this->{$key} = $value;
}
$this->subject = utf8tohtml($this->subject);
$this->name = utf8tohtml($this->name);
$this->mod = $mod;
$this->root = $root;
if ($this->embed)
$this->embed = embed_html($this->embed);
$this->modifiers = extract_modifiers($this->body_nomarkup);
if ($this->mod)
// Fix internal links
// Very complicated regex
@@ -373,42 +362,30 @@ class Post {
};
class Thread {
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) {
public function __construct($post, $root = null, $mod = false, $hr = true) {
global $config;
if (!isset($root))
$root = &$config['root'];
$this->id = $id;
$this->subject = utf8tohtml($subject);
$this->email = $email;
$this->name = utf8tohtml($name);
$this->trip = $trip;
$this->capcode = $capcode;
$this->body = $body;
$this->time = $time;
$this->thumb = $thumb;
$this->thumbx = $thumbx;
$this->thumby = $thumby;
$this->file = $file;
$this->filex = $filex;
$this->filey = $filey;
$this->filesize = $filesize;
$this->filename = $filename;
foreach ($post as $key => $value) {
$this->{$key} = $value;
}
$this->subject = utf8tohtml($this->subject);
$this->name = utf8tohtml($this->name);
$this->mod = $mod;
$this->root = $root;
$this->hr = $hr;
$this->posts = array();
$this->omitted = 0;
$this->omitted_images = 0;
$this->posts = array();
$this->ip = $ip;
$this->sticky = $sticky;
$this->locked = $locked;
$this->bumplocked = $bumplocked;
$this->embed = $embed;
$this->root = $root;
$this->mod = $mod;
$this->hr = $hr;
if ($this->embed)
$this->embed = embed_html($this->embed);
$this->modifiers = extract_modifiers($this->body_nomarkup);
if ($this->mod)
// Fix internal links
// Very complicated regex
@@ -471,7 +448,7 @@ class Thread {
$built .= ' <a title="'._('Make thread sticky').'" href="?/' . secure_link($board['dir'] . 'sticky/' . $this->id) . '">' . $config['mod']['link_sticky'] . '</a>';
if (hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod))
if ($this->bumplocked)
if ($this->sage)
$built .= ' <a title="'._('Allow thread to be bumped').'" href="?/' . secure_link($board['dir'] . 'bumpunlock/' . $this->id) . '">' . $config['mod']['link_bumpunlock'] . '</a>';
else
$built .= ' <a title="'._('Prevent thread from being bumped').'" href="?/' . secure_link($board['dir'] . 'bumplock/' . $this->id) . '">' . $config['mod']['link_bumplock'] . '</a>';
@@ -496,10 +473,6 @@ class Thread {
return $built;
}
public function ratio() {
return fraction($this->filex, $this->filey, ':');
}
public function build($index=false, $isnoko50=false) {
global $board, $config, $debug;

View File

@@ -153,6 +153,8 @@ function loadConfig() {
$config['url_javascript'] = $config['root'] . $config['file_script'];
if (!isset($config['additional_javascript_url']))
$config['additional_javascript_url'] = $config['root'];
if (!isset($config['uri_flags']))
$config['uri_flags'] = $config['root'] . 'static/flags/%s.png';
if ($config['root_file']) {
chdir($config['root_file']);
@@ -1052,11 +1054,7 @@ function index($page, $mod=false) {
$threads = array();
while ($th = $query->fetch(PDO::FETCH_ASSOC)) {
$thread = new Thread(
$th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'],
$th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'],
$th['sticky'], $th['locked'], $th['sage'], $th['embed'], $mod ? '?/' : $config['root'], $mod
);
$thread = new Thread($th, $mod ? '?/' : $config['root'], $mod);
if ($config['cache']['enabled'] && $cached = cache::get("thread_index_{$board['uri']}_{$th['id']}")) {
$replies = $cached['replies'];
@@ -1088,11 +1086,7 @@ function index($page, $mod=false) {
if ($po['file'])
$num_images++;
$thread->add(new Post(
$po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['capcode'], $po['body'], $po['time'],
$po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'],
$po['filename'], $po['ip'], $po['embed'], $mod ? '?/' : $config['root'], $mod)
);
$thread->add(new Post($po, $mod ? '?/' : $config['root'], $mod));
}
if ($omitted) {
@@ -1496,55 +1490,33 @@ function unicodify($body) {
return $body;
}
function extract_modifiers($body) {
$modifiers = array();
if (preg_match_all('@<tinyboard ([\w\s]+)>(.+?)</tinyboard>@us', $body, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if (preg_match('/^escape /', $match[1]))
continue;
$modifiers[$match[1]] = html_entity_decode($match[2]);
}
}
return $modifiers;
}
function markup(&$body, $track_cites = false) {
global $board, $config, $markup_urls;
$modifiers = extract_modifiers($body);
$body = preg_replace('@<tinyboard ([\w\s]+)>(.+?)</tinyboard>@us', '', $body);
if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1')
return $body;
$body = str_replace("\r", '', $body);
$body = utf8tohtml($body);
if (preg_match_all('@&lt;tinyboard ([\w\s]+)&gt;(.+?)&lt;/tinyboard&gt;@us', $body, $modifiers, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
$skip_chars = 0;
$body_tmp = $body;
$end_markup = false;
foreach ($modifiers as $modifier) {
// preg_match_all is not multibyte-safe
foreach ($modifier as &$match) {
$match[1] = mb_strlen(substr($body_tmp, 0, $match[1]));
}
$modifier['type'] = $modifier[1][0];
$modifier['content'] = $modifier[2][0];
if ($modifier['type'] == 'ban message') {
// Public ban message
$replacement = sprintf($config['mod']['ban_message'], html_entity_decode($modifier['content']));
if ($end_markup) {
$body .= $replacement;
}
} elseif ($modifier['type'] == 'raw html') {
$body = html_entity_decode($modifier['content']);
$replacement = '';
$end_markup = true;
} elseif (preg_match('/^escape /', $modifier['type'])) {
// Escaped (not a real modifier)
$replacement = '&lt;tinyboard ' . substr($modifier['type'], strlen('escape ')) . '&gt;' . $modifier['content'] . '&lt;/tinyboard&gt;';
} else {
// Unknown
$replacement = '';
}
if (!$end_markup) {
$body = mb_substr_replace($body, $replacement, $modifier[0][1] + $skip_chars, mb_strlen($modifier[0][0]));
$skip_chars += mb_strlen($replacement) - mb_strlen($modifier[0][0]);
}
}
if ($end_markup) {
return array();
}
}
if (mysql_version() < 50503)
$body = mb_encode_numericentity($body, array(0x010000, 0xffffff, 0, 0xffffff), 'UTF-8');
@@ -1759,17 +1731,9 @@ function buildThread($id, $return = false, $mod = false) {
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
if (!isset($thread)) {
$thread = new Thread(
$post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'],
$post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'],
$post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], $mod ? '?/' : $config['root'], $mod
);
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
} else {
$thread->add(new Post(
$post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'],
$post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'],
$post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod)
);
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
}
}

View File

@@ -790,19 +790,9 @@ function mod_page_ip($ip) {
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
if (!$post['thread']) {
// TODO: There is no reason why this should be such a fucking mess.
$po = new Thread(
$post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'],
$post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'],
$post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'],
$post['sage'], $post['embed'], '?/', $mod, false
);
$po = new Thread($post, '?/', $mod, false);
} else {
$po = new Post(
$post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'],
$post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'],
$post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod
);
$po = new Post($post, '?/', $mod);
}
if (!isset($args['posts'][$board['uri']]))
@@ -1398,7 +1388,7 @@ function mod_edit_post($board, $edit_raw_html, $postID) {
$query->bindValue(':subject', $_POST['subject']);
$query->bindValue(':body', $_POST['body']);
if ($edit_raw_html) {
$body_nomarkup = '<tinyboard raw html>' . $_POST['body'] . '</tinyboard>';
$body_nomarkup = $_POST['body'] . '<tinyboard raw html>1</tinyboard>';
$query->bindValue(':body_nomarkup', $body_nomarkup);
}
$query->execute() or error(db_error($query));
@@ -2012,19 +2002,9 @@ function mod_reports() {
if (!$post['thread']) {
// Still need to fix this:
$po = new Thread(
$post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'],
$post['capcode'], $post['body'], $post['time'], $post['thumb'],
$post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'],
$post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'],
$post['locked'], $post['sage'], $post['embed'], '?/', $mod, false
);
$po = new Thread($post, '?/', $mod, false);
} else {
$po = new Post(
$post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'],
$post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'],
$post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod
);
$po = new Post($post, '?/', $mod);
}
// a little messy and inefficient