diff --git a/inc/config.php b/inc/config.php
index 2634f719..5e215fca 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -386,6 +386,11 @@
// When true, a blank password will be used for files (not usable for deletion).
$config['field_disable_password'] = 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;
@@ -726,6 +731,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 of post flags:
+ $config['flag_width'] = 16;
+ $config['flag_height'] = 11;
/*
* ====================
diff --git a/inc/display.php b/inc/display.php
index af0ee89f..ee600ed3 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -270,36 +270,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
@@ -367,42 +356,29 @@ 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->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
@@ -462,7 +438,7 @@ class Thread {
$built .= ' ' . $config['mod']['link_sticky'] . '';
if (hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod))
- if ($this->bumplocked)
+ if ($this->sage)
$built .= ' ' . $config['mod']['link_bumpunlock'] . '';
else
$built .= ' ' . $config['mod']['link_bumplock'] . '';
diff --git a/inc/functions.php b/inc/functions.php
index 085d911f..c6751a91 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -149,6 +149,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']);
@@ -1044,11 +1046,7 @@ function index($page, $mod=false) {
if ($query->rowCount() < 1 && $page > 1)
return false;
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'];
@@ -1080,11 +1078,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) {
@@ -1467,6 +1461,18 @@ function unicodify($body) {
return $body;
}
+function extract_modifiers($body) {
+ $modifiers = array();
+
+ if (preg_match_all('@
File: {{ post.file }} ( @@ -87,7 +90,7 @@
- + {% elseif post.file and post.file %}{% trans %}File:{% endtrans %} {{ post.file }} ( @@ -42,7 +42,7 @@ )
-