TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,972
  • Latest: Lineo
Stats
  • Total Posts: 196,100
  • Total Topics: 21,345
  • Online today: 930
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 383
  • Total: 384
  • @rjen

Who can help me with this code please - Not TP related, but SMF not responding !

Started by knat, April 25, 2007, 05:47:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knat

Hi guys and girls

I need help really bad and people at SMF are not responding.  :P

I installed a mod that forces a minimum of words or characters for a post to be made. This is to prevent one word spamming on my forum. My members like it but my staff hate that it also applies to them. And it even applies to admins also. so is there any simple IF/ELSE i can insert into this script so it will skip it if the user is in any of the admin/moderator groups ?

Here is what the mod did to my sources/post.php file.. i wouldnt ask this question here but the mod seems to be abandoned and i really need help with this. And i know how helpful people are here at TP.  :coolsmiley:

Please dont close my topic right away, i really need this fixed, any help will be appreciated !  :)


<edit file>
$sourcedir/Post.php
</edit file>

<search for>
// Check the subject and message.
</search for>

<add after>
if (!empty($modSettings['minWordLen']) && ((int)$modSettings['minWordLen'] != 0))
{
    $Temp = trim(preg_replace('~[^a-z0-9 ]~si', '', $_POST['message']));
    $Temp = preg_replace('~(( )+)~si', ' ', $Temp);
    $WordArr = explode(' ', $Temp);
    if (count($WordArr) < (int)$modSettings['minWordLen'])
    $post_errors[] = 'minWordLen';
}

if (!empty($modSettings['minChar']) && ((int)$modSettings['minChar'] != 0))
{
    if (strlen($_POST['message']) < (int)$modSettings['minChar'])
      $post_errors[] = 'minChar';
}
</add after>

G6Cad

Im sorry Tank, but i will have to ask you to wait for an answer on SMF.
We try to limit the SMF and other mods support here to the minimum or non at all.

They will give you a reply as soon as they can give you the answer you need.

Thurnok

Here you go... change the mod XML to use the following instead:

<edit file>
$sourcedir/Post.php
</edit file>

<search for>
// Check the subject and message.
</search for>

<add after>
if (!empty($modSettings['minWordLen']) && ((int)$modSettings['minWordLen'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']))
{
    $Temp = trim(preg_replace('~[^a-z0-9 ]~si', '', $_POST['message']));
    $Temp = preg_replace('~(( )+)~si', ' ', $Temp);
    $WordArr = explode(' ', $Temp);
    if (count($WordArr) < (int)$modSettings['minWordLen'])
    $post_errors[] = 'minWordLen';
}

if (!empty($modSettings['minChar']) && ((int)$modSettings['minChar'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']))
{
    if (strlen($_POST['message']) < (int)$modSettings['minChar'])
      $post_errors[] = 'minChar';
}
</add after>


Or, if you already have it installed, just add the following parts to the Post.php file in bold maroon to the original mod's lines shown:

if (!empty($modSettings['minWordLen']) && ((int)$modSettings['minWordLen'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) )

and

if (!empty($modSettings['minChar']) && ((int)$modSettings['minChar'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) )

Thurnok
The one, the only!

knat

@ G6 - Yeah i know I'm kinda breaking the rules but i really needed this fixed before my mods was having my head. Sorry bout that, it wont happen again any time soon ;)

@ Thurnok - Thanks a million, you saved my head from being chopped off :) any chance to add one more group that is post count based ? If it is not to much trouble ^-^ I want to turn this off for charter members and that is usergroup # 12

Final question: is empty($user_info['is_mod']) = usergroup # 2 ??

BIG THANKS YOU AND TONS OF RESPECT !!  O0

Sarge

Quote from: Tank on April 26, 2007, 05:19:41 AM
I want to turn this off for charter members and that is usergroup # 12

Try changing this:

if (!empty($modSettings['minWordLen']) && ((int)$modSettings['minWordLen'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) )

and

if (!empty($modSettings['minChar']) && ((int)$modSettings['minChar'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) )

to these:

if (!empty($modSettings['minWordLen']) && ((int)$modSettings['minWordLen'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) && !in_array('2', $user_info['groups']) && !in_array('12', $user_info['groups']) )

and

if (!empty($modSettings['minChar']) && ((int)$modSettings['minChar'] != 0) && empty($user_info['is_admin']) && empty($user_info['is_mod']) && !in_array('2', $user_info['groups']) && !in_array('12', $user_info['groups']) )

The code I added is in teal. :)

To answer your other question:
Quote from: Tank on April 26, 2007, 05:19:41 AM
Final question: is empty($user_info['is_mod']) = usergroup # 2 ??

As far as I know, $user_info['is_mod'] means a local (board) moderator, not a global moderator (membergroup #2). Just in case, I added both membergroups #2 and #12 in the code above. ;)

knat

Thanks alot Sarge - Everything is working perfect  ;)

Thanks to both of you helping me out even if it was not TP related. Big thanks  :) :) :)

This website is proudly hosted on Crocweb Cloud Website Hosting.