* merged quickspam plugin with coding-style branch
* other cosmetic changes
This commit is contained in:
parent
5944f87bb8
commit
6b133960ed
@ -24,7 +24,7 @@
|
||||
|
||||
<h2> {$panelstrings.gensetts} </h2>
|
||||
|
||||
<dl>
|
||||
<dl class="option-list">
|
||||
<dt><label for="title"> {$panelstrings.blogtitle} </label></dt>
|
||||
<dd><input type="text" name="title" id="title" class="textinput{$error.title|notempty:' field-error'}"
|
||||
value="{$flatpress.TITLE|escape:"html"}" />
|
||||
@ -84,7 +84,7 @@
|
||||
|
||||
<h2> {$panelstrings.intsetts} </h2>
|
||||
|
||||
<dl>
|
||||
<dl class="option-list">
|
||||
<dt> {$panelstrings.utctime} </dt>
|
||||
{assign var=temp_time value="%b %d %Y %H:%M:%S"}
|
||||
<dd> <code> {"r"|date:$smarty.now} </code> </dd>
|
||||
|
@ -237,7 +237,8 @@ input.maxsize, select.maxsize { width: 100% }
|
||||
}
|
||||
|
||||
|
||||
#plugin-table-body td {
|
||||
.admin-widgets-blockparser td ,
|
||||
.admin-plugin-default td {
|
||||
padding: 1em .6em;
|
||||
}
|
||||
|
||||
@ -468,7 +469,7 @@ li.widget-class {
|
||||
|
||||
/* ===== CONFIG PANEL ===== */
|
||||
|
||||
.option-set dl {
|
||||
.option-set .option-list {
|
||||
margin-bottom: 4em;
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ function do_bbcode_img($action, $attributes, $content, $params, $node_object) {
|
||||
// Plugin hook, here lightbox attachs
|
||||
$popup = apply_filters('bbcode_img_popup', $popup, $absolutepath);
|
||||
$popup_start = $attributes['popup'] == 'true'
|
||||
? '<a title="View image \''. $title .'\'" href="'. /* BLOG_BASEURL . $actualpath.*/
|
||||
? '<a title="'. $title .'" href="'. /* BLOG_BASEURL . $actualpath.*/
|
||||
$absolutepath .'"'. $popup .'>'
|
||||
: '';
|
||||
$popup_end = $attributes['popup'] == 'true'
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{include file=shared:errorlist.tpl}
|
||||
|
||||
{html_form class="config-panel"}
|
||||
{html_form class=option-set}
|
||||
<h2>{$plang.editing}</h2>
|
||||
|
||||
<dl>
|
||||
<dl class="option-list">
|
||||
<dt><label for="bb-escape-html">
|
||||
{$plang.allow_html}
|
||||
</label></dt>
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
<h2>{$plang.other}</h2>
|
||||
|
||||
<dl>
|
||||
<dl class="option-list">
|
||||
<dt><label for="bb-comments">
|
||||
{$plang.comments}
|
||||
</label></dt>
|
||||
|
25
fp-plugins/qspam/lang/lang.en-us.php
Normal file
25
fp-plugins/qspam/lang/lang.en-us.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$lang['plugin']['qspam'] = array(
|
||||
'error' => 'ERROR: The comment contained banned words'
|
||||
);
|
||||
|
||||
$lang['admin']['plugin']['submenu']['qspam'] = 'QuickSpamFilter';
|
||||
$lang['admin']['plugin']['qspam'] = array(
|
||||
'head' => 'QuickSpam Configuration',
|
||||
'desc1' => 'Do not allow comments containing these words (write one per line) :',
|
||||
'desc2' => '<strong>Warning:</strong> A comment will be disallowed even when one word is part of another.
|
||||
|
||||
(e.g. "old" matches "b<em>old</em>" too)',
|
||||
'options' => 'Other options',
|
||||
'desc3' => 'Bad Word Count',
|
||||
'desc3pre' => 'Block comments containing more than ',
|
||||
'desc3post' => ' bad word(s).',
|
||||
'submit' => 'Save configuration',
|
||||
'msgs' => array(
|
||||
1 => 'Bad words successful saved.',
|
||||
-1 => 'Bad words not saved.'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
@ -1,38 +1,121 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: QuickSpamFilter
|
||||
Plugin URI: http://flatpress.nowherland.it/
|
||||
Description: Quick ban words (edit the plugin to add more to the list)
|
||||
Author: NoWhereMan (E.Vacchi)
|
||||
Version: 3.0
|
||||
Author URI: http://www.nowhereland.it
|
||||
*/
|
||||
|
||||
add_action('comment_validate', 'plugin_qspam_validate', 5, 2);
|
||||
|
||||
function plugin_qspam_validate(&$bool, $contents) {
|
||||
|
||||
if (!$bool) return false;
|
||||
|
||||
$BAN_WORDS = array(
|
||||
'href', '[url' // bans links
|
||||
);
|
||||
|
||||
$txt = strtolower(trim($contents['content']));
|
||||
while (($w = array_pop($BAN_WORDS))
|
||||
&&
|
||||
(($r = strpos ($txt, $w)) === false));
|
||||
|
||||
# if( strrchr($txt, ':')==':' ) $r=true;
|
||||
|
||||
if ($r!==false) {
|
||||
global $smarty;
|
||||
$smarty->assign('error', array('ERROR: The comment contained banned words'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: QuickSpamFilter
|
||||
Plugin URI: http://flatpress.nowherland.it/
|
||||
Description: Quick ban words (edit the plugin to add more to the list)
|
||||
Author: NoWhereMan
|
||||
Version: 3.5.1
|
||||
Author URI: http://www.nowhereland.it
|
||||
*/
|
||||
|
||||
/**
|
||||
* This plugin denies comments when they're containing "bad words",
|
||||
* e.g. "href" (which indexes links)., etc.
|
||||
*
|
||||
* @global $smarty
|
||||
* @param boolean $bool
|
||||
* @param string $contents The comment
|
||||
* @return unknown
|
||||
*/
|
||||
function plugin_qspam_validate(&$bool, $contents) {
|
||||
if (!$bool) {
|
||||
return false;
|
||||
}
|
||||
$qscfg = plugin_getoptions('qspam');
|
||||
// We're looking for these words:
|
||||
$BAN_WORDS = '';
|
||||
if (isset($qscfg['wordlist'])) {
|
||||
$BAN_WORDS = $qscfg['wordlist'];
|
||||
} else {
|
||||
// rudimentary ban of links
|
||||
$BAN_WORDS = array('href', '[url');
|
||||
}
|
||||
$qscfg['number'] = isset($qscfg['number'])
|
||||
? $qscfg['number']
|
||||
: 1;
|
||||
$txt = strtolower(trim($contents['content']));
|
||||
$count = 0;
|
||||
while ($w = array_pop($BAN_WORDS)) {
|
||||
$count += substr_count($txt, strtolower($w));
|
||||
}
|
||||
if ($count >= $qscfg['number']) {
|
||||
global $smarty;
|
||||
$lang = lang_load('plugin:qspam');
|
||||
$smarty->assign('error', array($lang['plugin']['qspam']['error']));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
add_action('comment_validate', 'plugin_qspam_validate', 5, 2);
|
||||
|
||||
if (class_exists('AdminPanelAction')){
|
||||
/**
|
||||
* Provides an admin panel entry for QuickSpam setup.
|
||||
*/
|
||||
class admin_plugin_qspam extends AdminPanelAction {
|
||||
var $langres = 'plugin:qspam';
|
||||
|
||||
/**
|
||||
* Initializes this panel.
|
||||
*/
|
||||
function setup() {
|
||||
$this->smarty->assign('admin_resource', "plugin:qspam/admin.plugin.qspam");
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups the default panel.
|
||||
*/
|
||||
function main() {
|
||||
$qscfg = plugin_getoptions('qspam');
|
||||
$qscfg['wordlist'] = isset($qscfg['wordlist']) && is_array($qscfg['wordlist'])
|
||||
? implode("\n", $qscfg['wordlist'])
|
||||
: '';
|
||||
$qscfg['number'] = isset($qscfg['number'])
|
||||
? $qscfg['number']
|
||||
: 1;
|
||||
$this->smarty->assign('qscfg', $qscfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be executed when the QSF configuration is send.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function onsubmit() {
|
||||
if ($_POST['qs-wordlist']){
|
||||
$wordlist = isset($_POST['qs-wordlist'])
|
||||
? stripslashes($_POST['qs-wordlist'])
|
||||
: '';
|
||||
$wordlist = str_replace("\r", "\n", $wordlist);
|
||||
// DMKE: Works neither recursive correct nor in a loop... *grrr*
|
||||
#$wordlist = str_replace("\n\n", "\n", $wordlist);
|
||||
$wordlist = explode("\n", $wordlist);
|
||||
$wordlist = array_filter($wordlist, array($this, '_array_filter'));
|
||||
$number = isset($_POST['qs-number']) && is_numeric($_POST['qs-number'])
|
||||
? (int)$_POST['qs-number']
|
||||
: 1;
|
||||
plugin_addoption('qspam', 'wordlist', $wordlist);
|
||||
plugin_addoption('qspam', 'number', $number);
|
||||
plugin_saveoptions('qspam');
|
||||
$this->smarty->assign('success', 1);
|
||||
} else {
|
||||
$this->smarty->assign('success', -1);
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array filter callback function. Culls empty array values.
|
||||
* Life is hell ._.
|
||||
*
|
||||
* @param string $str
|
||||
* @return boolean
|
||||
*/
|
||||
function _array_filter($str) {
|
||||
return strlen(trim($str)) > 0;
|
||||
}
|
||||
}
|
||||
admin_addpanelaction('plugin', 'qspam', true);
|
||||
}
|
||||
|
||||
?>
|
29
fp-plugins/qspam/tpls/admin.plugin.qspam.tpl
Normal file
29
fp-plugins/qspam/tpls/admin.plugin.qspam.tpl
Normal file
@ -0,0 +1,29 @@
|
||||
<h2>{$plang.head}</h2>
|
||||
|
||||
{include file=shared:errorlist.tpl}
|
||||
|
||||
{html_form class=option-set}
|
||||
|
||||
<div class="option-list">
|
||||
<p>{$plang.desc1|wptexturize}</p>
|
||||
<p>
|
||||
<textarea id="qs-wordlist" name="qs-wordlist" rows="10" cols="20">{$qscfg.wordlist}</textarea>
|
||||
</p>
|
||||
<p>{$plang.desc2}</p>
|
||||
</div>
|
||||
|
||||
<h2>{$plang.options}</h2>
|
||||
<dl class="option-list">
|
||||
<dt><label>{$plang.desc3}</label></dt>
|
||||
<dd>
|
||||
{$plang.desc3pre}
|
||||
<input type="text" class="smalltextinput" id="qs-number" name="qs-number" value="{$qscfg.number}" />
|
||||
{$plang.desc3post}
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<div class="buttonbar">
|
||||
<input type="submit" value="{$plang.submit}"/>
|
||||
</div>
|
||||
{/html_form}
|
Loading…
x
Reference in New Issue
Block a user