Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [MOD] Define minimum comment size (sNews 1.4)  (Read 2000 times)

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Define minimum comment size (sNews 1.4)
« on: June 05, 2006, 04:03:32 pm »

simple mod to define how many characters user can input in comment form.
can be applied to default snews1.4

1. backup first :D

2. add this in //global settings
Quote
//GLOBAL SETTINGS
...
$s['min_comment_size'] = 5; //minimum number of characters in comment (comment form)
$s['min_name_size'] = 5; //minimum number of characters in name (comment form)

...
3. find this in //comments
Quote
// COMMENTS
function comment($freeze_status) {
    $comments_order = s('comments_order');  
    $category = get_id('category');
    $article = get_id('article');
      $commentspage = get_id('commentspage');
      if (isset($_POST['commentspage'])) { $go_to_page = $_POST['commentspage']; }
      $query = "SELECT * FROM " .s('prefix'). "articles WHERE seftitle = '$article'";
    $result = mysql_query($query);
      while ($r = mysql_fetch_array($result)) {
        $articleid = $r['id'];
        $id = $r['id'];
    }
   
    if ($commentspage == 0) { $commentspage = 1; }
    if (isset($_POST['comment']) AND strlen($_POST['name']) > 2 AND strlen($_POST['comment']) > 5) {
        echo "

". l('comment_sent') ."

";
...
4. replace blue with red chunk of code
Quote
// COMMENTS
function comment($freeze_status) {
    $comments_order = s('comments_order');  
    $category = get_id('category');
    $article = get_id('article');
      $commentspage = get_id('commentspage');
      if (isset($_POST['commentspage'])) { $go_to_page = $_POST['commentspage']; }
      $query = "SELECT * FROM " .s('prefix'). "articles WHERE seftitle = '$article'";
    $result = mysql_query($query);
      while ($r = mysql_fetch_array($result)) {
        $articleid = $r['id'];
        $id = $r['id'];
    }
   
    if ($commentspage == 0) { $commentspage = 1; }
    $min_name_size = s('min_name_size');
    $min_comment_size = s('min_comment_size');
    if (isset($_POST['comment']) AND strlen($_POST['name']) >= $min_name_size AND strlen($_POST['comment']) >= $min_comment_size)
{
        echo "

". l('comment_sent') ."

";
...
****************************************************************
there is also modded version of comments function with antispam capabilities (snews1.4)

code for this version is:

Quote
$min_name_size = s('min_name_size');
$min_comment_size = s('min_comment_size');
if (isset($_POST['comment']) AND audit() AND strlen($_POST['name']) >= $min_name_size AND strlen($_POST['comment']) >= $min_comment_size)
more info on this issue here
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version