1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-17 19:29:28 +01:00

Make it so board owners can force flags

For country flags, a "?" will now show if the flag is unknown (for example, if the user is using Tor or just has an IP that is not in the GeoIP database)

For board owner-defined flags, "None" option disappears and posting is impossible without choosing a valid flag.

This commit is for /fringe/.
This commit is contained in:
Fredrick Brennan 2015-03-16 16:31:01 +08:00
parent 86d99b332b
commit b85e1f2f0b
15 changed files with 2013 additions and 289 deletions

View File

@ -460,6 +460,7 @@ FLAGS;
$user_flags = isset($_POST['user_flags']) ? "if (file_exists('$b/flags.php')) { include 'flags.php'; }\n" : '';
$captcha = isset($_POST['captcha']) ? 'true' : 'false';
$force_subject_op = isset($_POST['force_subject_op']) ? 'true' : 'false';
$force_flag = isset($_POST['force_flag']) ? 'true' : 'false';
$tor_posting = isset($_POST['tor_posting']) ? 'true' : 'false';
$new_thread_capt = isset($_POST['new_thread_capt']) ? 'true' : 'false';
$oekaki = isset($_POST['oekaki']) ? 'true' : 'false';
@ -569,6 +570,7 @@ FLAGS;
\$config['default_stylesheet'] = array('Custom', \$config['stylesheets']['Custom']);
\$config['captcha']['enabled'] = $captcha;
\$config['force_subject_op'] = $force_subject_op;
\$config['force_flag'] = $force_flag;
\$config['tor_posting'] = $tor_posting;
\$config['new_thread_capt'] = $new_thread_capt;
\$config['hour_max_threads'] = $hour_max_threads;

View File

@ -457,10 +457,14 @@
// Do you need a body for your reply posts?
$config['force_body'] = false;
// Do you need a user or country flag for your posts?
$config['force_flag'] = false;
// Do you need a body for new threads?
$config['force_body_op'] = true;
// Require an image for threads?
$config['force_image_op'] = true;
// Require a subject for threads?
$config['force_subject_op'] = false;
// Strip superfluous new lines at the end of a post.
$config['strip_superfluous_returns'] = true;

View File

@ -12,7 +12,7 @@ $(document).on('ready', function() {
return $('.flag_preview').remove();
}
$('.flag_preview').attr('src', "/static/custom-flags/" + board_name + "/" + $(this).val() + '.png');
$('.flag_preview').attr('src', configRoot + "static/custom-flags/" + board_name + "/" + $(this).val() + '.png');
}
$('[name=user_flag]').on('change', flag_previews);

View File

@ -2,7 +2,6 @@
/*
* Copyright (c) 2010-2014 Tinyboard Development Group
*/
require "./inc/functions.php";
require "./inc/anti-bot.php";
@ -589,7 +588,7 @@ elseif (isset($_POST['post'])) {
$post['body'] .= "\n<tinyboard raw html>1</tinyboard>";
}
if (($config['country_flags'] && !$config['allow_no_country']) || ($config['country_flags'] && $config['allow_no_country'] && !isset($_POST['no_country']))) {
if (($config['country_flags'] && (!$config['allow_no_country'] || $config['force_flag'])) || ($config['country_flags'] && $config['allow_no_country'] && !isset($_POST['no_country']))) {
require 'inc/lib/geoip/geoip.inc';
$gi=geoip\geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
@ -605,25 +604,29 @@ elseif (isset($_POST['post'])) {
return '::ffff:'.$part7.':'.$part8;
}
if ($country_code = geoip\geoip_country_code_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))) {
if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2')))
$post['body'] .= "\n<tinyboard flag>".strtolower($country_code)."</tinyboard>".
"\n<tinyboard flag alt>".geoip\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
}
$country_code = geoip\geoip_country_code_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']));
$country_name = geoip\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']));
if (!$country_code) $country_code = 'A1';
if (!$country_name) $country_name = 'Unknown';
$post['body'] .= "\n<tinyboard flag>".strtolower($country_code)."</tinyboard>".
"\n<tinyboard flag alt>$country_name</tinyboard>";
}
if ($config['user_flag'] && isset($_POST['user_flag']))
if (!empty($_POST['user_flag']) ){
$user_flag = $_POST['user_flag'];
if (!isset($config['user_flags'][$user_flag]))
error(_('Invalid flag selection!'));
if ($config['user_flag'] && isset($_POST['user_flag'])) {
if (!empty($_POST['user_flag']) ){
$user_flag = $_POST['user_flag'];
if (!isset($config['user_flags'][$user_flag]))
error(_('Invalid flag selection!'));
$flag_alt = isset($user_flag_alt) ? $user_flag_alt : $config['user_flags'][$user_flag];
$flag_alt = isset($user_flag_alt) ? $user_flag_alt : $config['user_flags'][$user_flag];
$post['body'] .= "\n<tinyboard flag>" . strtolower($user_flag) . "</tinyboard>" .
"\n<tinyboard flag alt>" . $flag_alt . "</tinyboard>";
$post['body'] .= "\n<tinyboard flag>" . strtolower($user_flag) . "</tinyboard>" .
"\n<tinyboard flag alt>" . $flag_alt . "</tinyboard>";
} else if ($config['force_flag']) {
error(_('You must choose a flag to post on this board!'));
}
}
if (mysql_version() >= 50503) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -21,7 +21,7 @@ body {
}
.post-table th, .post-table-options th {
width: 75px;
width: 85px;
}
.post-table-options {

View File

@ -13,6 +13,7 @@
var inMod = {% if mod %}true{% else %}false{% endif %};
var modRoot="{{ config.root }}"+(inMod ? "mod.php?/" : "");
var max_images={{ config.max_images }};
var board_name="{{ board.uri }}";
{% raw %}
var styles = {
{% endraw %}

View File

@ -114,8 +114,10 @@ function alert(a, do_confirm, confirm_ok_action, confirm_cancel_action) {
var saved = {};
var matches = document.URL.match({% endraw %}/\/([0-9a-zA-Z\+$_\u0080-\uFFFF]{1,58})\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page50|replace({'+': '\\+', '%d': '\\d+', '.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.catalog_link|replace({'.': '\\.'}) }})/{% raw %});
var board_name = (matches ? matches[1] : false);
if (typeof board_name === "undefined") {
var matches = document.URL.match({% endraw %}/\/([0-9a-zA-Z\+$_\u0080-\uFFFF]{1,58})\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page50|replace({'+': '\\+', '%d': '\\d+', '.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.catalog_link|replace({'.': '\\.'}) }})/{% raw %});
var board_name = (matches ? matches[1] : false);
}
function get_cookie(cookie_name) {
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

View File

@ -30,6 +30,7 @@
<tr><th>{% trans %}YouTube/Voocaroo embedding{% endtrans %}</th><td><input type="checkbox" name="enable_embedding" {% if config.enable_embedding %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require image for OP{% endtrans %}</th><td><input type="checkbox" name="force_image_op" {% if config.force_image_op %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require subject for OP{% endtrans %}</th><td><input type="checkbox" name="force_subject_op" {% if config.force_subject_op %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require user/country flag for all posts{% endtrans %}</th><td><input type="checkbox" name="force_flag" {% if config.force_flag %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Disable images{% endtrans %}</th><td><input type="checkbox" name="disable_images" {% if config.disable_images %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Poster ID's{% endtrans %}</th><td><input type="checkbox" name="poster_ids" {% if config.poster_ids %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Display SAGE! after saged posts{% endtrans %}</th><td><input type="checkbox" name="show_sages" {% if config.show_sages %}checked{% endif %}></td></tr>

View File

@ -3,7 +3,7 @@
{% if config.country_flags_condensed %}
class="flag flag-{{ post.modifiers.flag }}" src="{{ config.image_blank }}"
{% else %}
class="flag" src="{{ config.uri_flags|sprintf(post.modifiers.flag) }}"
class="flag" src="{{ config.root }}{{ config.uri_flags|sprintf(post.modifiers.flag) }}"
{% endif %}
style="{% if post.modifiers['flag style'] %}
{{ post.modifiers['flag style'] }}

View File

@ -100,6 +100,24 @@
</td>
</tr>
{% endif %}
{% set flag_tr %}
{% if config.user_flag %}
<tr>
<th>{% trans %}Flag{% endtrans %} {% if config.force_flag %}<span class="required-star">*</span>{% endif %}</th>
<td>
<select name="user_flag" id="user_flag">
{% if not config.force_flag %}<option value="">{% trans %}None{% endtrans %}</option>{% endif %}
{% for flag, text in config.user_flags %}
<option value="{{ flag }}">{{ text }}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
{% endset %}
{% if config.force_flag %}
{{ flag_tr }}
{% endif %}
<tr>
<td class="required-field-cell">
<span class="required-wrap hint">
@ -113,19 +131,10 @@
</tr>
</tbody></table><table class="post-table-options"><tbody>
{% if config.user_flag %}
<tr>
<th>{% trans %}Flag{% endtrans %}</th>
<td>
<select name="user_flag" id="user_flag">
<option value="">{% trans %}None{% endtrans %}</option>
{% for flag, text in config.user_flags %}
<option value="{{ flag }}">{{ text }}</option>
{% endfor %}
</select>
</td>
</tr>
{% if not config.force_flag %}
{{ flag_tr }}
{% endif %}
{% if config.enable_embedding %}
<tr id="upload_embed">
<th>
@ -162,7 +171,7 @@
{% trans %}Spoiler images{% endtrans %} <span class="unimportant hint">{% trans %}(this replaces the thumbnails of your images with question marks){% endtrans %}</label>
</div>{% endif %}
{% if config.allow_no_country and config.country_flags %}<div class="no-country-option">
{% if config.allow_no_country and config.country_flags and not config.force_flag %}<div class="no-country-option">
<label><input title="No country flag" id="no_country" name="no_country" type="checkbox">
{% trans %}Hide country{% endtrans %} <span class="unimportant hint">{% trans %}(this board displays your country when you post if this is unchecked){% endtrans %}</span></label>
</div>{% endif %}

25
tools/flags/config.rb Normal file
View File

@ -0,0 +1,25 @@
require 'compass/import-once/activate'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "../../static/flags/"
sass_dir = "sass"
images_dir = "../../static/flags/"
javascripts_dir = "../../js/"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

View File

@ -0,0 +1,9 @@
/*$disable-magic-sprite-selectors: true;*/
$flags-sprite-dimensions: true;
$flags-layout: smart;
$flags-base-class: '.flags';
@import "compass/utilities/sprites";
@import "../../static/flags/*.png"; /* */
@include all-flags-sprites;