Browse Source

Added multiple dice roll. Automatic feature archive if op uses configured trip. Increaced post char limit

main
PupperWoff 7 years ago
committed by discomrade
parent
commit
c76a1bd3ef
  1. 7
      inc/archive.php
  2. 7
      inc/config.php
  3. 89
      inc/functions.php
  4. 2
      js/charcount.js

7
inc/archive.php

@ -16,7 +16,7 @@ class Archive {
return;
// Check if it is a thread
$thread_query = prepare(sprintf("SELECT `thread`, `subject`, `body_nomarkup` FROM ``posts_%s`` WHERE `id` = :id", $board['uri']));
$thread_query = prepare(sprintf("SELECT `thread`, `subject`, `body_nomarkup`, `trip` FROM ``posts_%s`` WHERE `id` = :id", $board['uri']));
$thread_query->bindValue(':id', $thread_id, PDO::PARAM_INT);
$thread_query->execute() or error(db_error($thread_query));
$thread_data = $thread_query->fetch(PDO::FETCH_ASSOC);
@ -93,6 +93,11 @@ class Archive {
$query->execute() or error(db_error($query));
// Check if Thread should be Auto Featured based on OP Trip
if(in_array($thread_data['trip'], $config['archive']['auto_feature_trips']))
self::featureThread($thread_id);
// Purge Threads that have timed out
if(!$config['archive']['cron_job']['purge'])
self::purgeArchive();

7
inc/config.php

@ -496,7 +496,7 @@
$config['strip_combining_chars'] = true;
// Maximum post body length.
$config['max_body'] = 1800;
$config['max_body'] = 6000;
// Minimum post body length.
$config['min_body'] = 0;
// Minimum post body length for OPs.
@ -1398,6 +1398,11 @@
$config['archive']['cron_job']['purge'] = false;
// Automatically send threads with thiese trips to Featured Archive
// $config['archive']['auto_feature'] = array("!!securetrip", "!trip");
$config['archive']['auto_feature'] = array();
/*
* ====================
* Advanced build

89
inc/functions.php

@ -3101,53 +3101,60 @@ function shell_exec_error($command, $suppress_stdout = false) {
function diceRoller($post) {
global $config;
if(strpos(strtolower($post->email), 'dice%20') === 0) {
$dicestr = str_split(substr($post->email, strlen('dice%20')));
// Get params
$diceX = '';
$diceY = '';
$diceZ = '';
$curd = 'diceX';
for($i = 0; $i < count($dicestr); $i ++) {
if(is_numeric($dicestr[$i])) {
$$curd .= $dicestr[$i];
} else if($dicestr[$i] == 'd') {
$curd = 'diceY';
} else if($dicestr[$i] == '-' || $dicestr[$i] == '+') {
$curd = 'diceZ';
$$curd = $dicestr[$i];
// $dicestr_all = str_split(substr($post->email, strlen('dice%20')));
$dicestr_all = substr($post->email, strlen('dice%20'));
$dicestr_all = explode("%20", $dicestr_all);
foreach($dicestr_all as $dicestr) {
$dicestr = str_split($dicestr);
// Get params
$diceX = '';
$diceY = '';
$diceZ = '';
$curd = 'diceX';
for($i = 0; $i < count($dicestr); $i ++) {
if(is_numeric($dicestr[$i])) {
$$curd .= $dicestr[$i];
} else if($dicestr[$i] == 'd') {
$curd = 'diceY';
} else if($dicestr[$i] == '-' || $dicestr[$i] == '+') {
$curd = 'diceZ';
$$curd = $dicestr[$i];
}
}
}
// Default values for X and Z
if($diceX == '') {
$diceX = '1';
}
// Default values for X and Z
if($diceX == '') {
$diceX = '1';
}
if($diceZ == '') {
$diceZ = '+0';
}
if($diceZ == '') {
$diceZ = '+0';
}
// Intify them
$diceX = intval($diceX);
$diceY = intval($diceY);
$diceZ = intval($diceZ);
// Intify them
$diceX = intval($diceX);
$diceY = intval($diceY);
$diceZ = intval($diceZ);
// Continue only if we have valid values
if($diceX > 0 && $diceY > 0) {
$dicerolls = array();
$dicesum = $diceZ;
for($i = 0; $i < $diceX; $i++) {
$roll = rand(1, $diceY);
$dicerolls[] = $roll;
$dicesum += $roll;
}
// Continue only if we have valid values
if($diceX > 0 && $diceY > 0) {
$dicerolls = array();
$dicesum = $diceZ;
for($i = 0; $i < $diceX; $i++) {
$roll = rand(1, $diceY);
$dicerolls[] = $roll;
$dicesum += $roll;
// Prepend the result to the post body
$modifier = ($diceZ != 0) ? ((($diceZ < 0) ? ' - ' : ' + ') . abs($diceZ)) : '';
$dicesum = ($diceX > 1) ? ' = ' . $dicesum : '';
$post->body = '<table class="diceroll"><tr><td><img src="'.$config['dir']['static'].'d10.svg" alt="Dice roll" width="24"></td><td>Rolled ' . implode(', ', $dicerolls) . $modifier . $dicesum . '</td></tr></table><br/>' . $post->body;
}
// Prepend the result to the post body
$modifier = ($diceZ != 0) ? ((($diceZ < 0) ? ' - ' : ' + ') . abs($diceZ)) : '';
$dicesum = ($diceX > 1) ? ' = ' . $dicesum : '';
$post->body = '<table class="diceroll"><tr><td><img src="'.$config['dir']['static'].'d10.svg" alt="Dice roll" width="24"></td><td>Rolled ' . implode(', ', $dicerolls) . $modifier . $dicesum . '</td></tr></table><br/>' . $post->body;
}
}
}

2
js/charcount.js

@ -14,7 +14,7 @@ $(document).ready(function(){
// every time an event is fired.
var $inputArea = $('#body');
var $coundownField = $('#countchar');
var $maxChars = 3601;
var $maxChars = 6001;
// Preset countdown field to max initial content length
$coundownField.text($maxChars - $inputArea.length);

Loading…
Cancel
Save