News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Maximum Images Per Post

Started by B Patterson, March 10, 2007, 04:41:47 PM

Previous topic - Next topic

B Patterson

Link to Mod

This will limit the maximum number of images per post you can have.  This is good for graphic intensive boards, or for catering to those who are bandwidth challenged.

Currently supports only the POSTING of messages.  So they can post up to whatever they want, then edit it.  When I get more time, I'll add support for editing posts as well.

[ FUTURE PLANS ]
I plan on making this look at posts and edits.  Currently, it only looks at the initial post.  If it sees more than your defined image limit, it will prohibit them from posting.  The catch is that if they go in to edit their post, they can add images over the limit.  I know this is a huge limitation, so I guess now that it's "approved" I'll go ahead and start working on making it work with edits as well.

[ GOOD NEWS! ]
I know for a fact that 2.0 actually has a maximum images per signature mod; however, not one for the posting yet.  When 2.0 comes out, I'll see about porting this over (if it doesn't make it in).

B Patterson

Updated the source to limit the number of images per post in both quick-edits (with the Javascript), normal modifications, and posting.

littleone

It would be awesome to get this to work with Signatures (as in the ability to limit the number of [img] tags in the signature area.

B Patterson


LunarOrbit

I like the idea of this script, but would it be possible to make it configurable separately for each different member group? For example, new users can post 0 images, regular members can post 3, and long time members can post 6. I don't want new members joining just to post pornographic images.

B Patterson

Lunar:  Yes, it's possible, but it's something that will have to wait for 2.0 as I probably won't have time to devote to it until 2.0 is released.

Da Gamer

Willl be able to make a version that wroks with 1.1.3

B Patterson

Probably still works with 1.1.3.  There wasn't a major change between 1.1.1 and 1.1.3.

michelangelo

Could you update it for smf 1.4 ?

B Patterson

Once again, probably still works.  I'll see what I can do though.

funkyspider

Hi, has there been any further progress with this mod?

It's just what i need for my photography forum, but I have a problem when using it with 1.1.4, tinyportal 0.98 and the dilbermc theme.

If i create a post with more than 5 images in, it warns me about it.... all ok.... however when i go back and edit the message and try posting it again it says the post has already been made and won't let me complete the posts.

Any ideas?

Sorry to drag this thread up again but it seemed the only place.

B Patterson

No, I haven't worked on it in a while.  SMF 2 is due out soon, would you be upset if I waited for SMF 3 to update this mod?  I'll be semi-redoing it (although I think it's already supported in SMF 2).  I'll look into the insertion issue at the same time.

funkyspider

it would be nice to get it working in 1.1.4, but that's entirely up to you :)
I will be upgrading to 2 when it's out and stable so should be able to manage until then.

Cheers

saosangmo

This mod doesn't work on 1.1.5 and I get this many errors from Error Log System of SMF
2: preg_match_all() expects at least 3 parameters, 2 given
File: /home/xxx/yyy/Sources/Post.php
Lines: 1361

My 1361 line:
   if($modSettings['max_images_per_post'] != '-1' && preg_match_all('/\[img\]/i', $_POST['message'], $matches) > $modSettings['max_images_per_post'])

does anyone make it work on 1.1.5?

B Patterson

The line you posted would seem to say there's nothing wrong.  There are three parameters given in the preg_match_all() function call.  Can you post from lines 1300 to line 1362 in Sources/Post.php for me?

saosangmo

thank bpat,
the below code is from lines 1300 to 1365, and I use PHP 5. please help me!

      elseif ($row['ID_MEMBER_POSTER'] == $ID_MEMBER && !allowedTo('modify_any'))
      {
         isAllowedTo('modify_replies');

         // If you're modifying a reply, I say it better be logged...
         $moderationAction = true;
      }
      else
      {
         isAllowedTo('modify_any');

         // Log it, assuming you're not modifying your own post.
         if ($row['ID_MEMBER'] != $ID_MEMBER)
            $moderationAction = true;
      }

      $posterIsGuest = empty($row['ID_MEMBER']);

      if (!allowedTo('moderate_forum') || !$posterIsGuest)
      {
         $_POST['guestname'] = addslashes($row['posterName']);
         $_POST['email'] = addslashes($row['posterEmail']);
      }
   }

   // If the poster is a guest evaluate the legality of name and email.
   if ($posterIsGuest)
   {
      $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
      $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);

      if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
         $post_errors[] = 'no_name';
      if ($func['strlen']($_POST['guestname']) > 25)
         $post_errors[] = 'long_name';

      if (empty($modSettings['guest_post_no_email']))
      {
         // Only check if they changed it!
         if (!isset($row) || $row['posterEmail'] != $_POST['email'])
         {
            if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
               $post_errors[] = 'no_email';
            if (!allowedTo('moderate_forum') && preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', stripslashes($_POST['email'])) == 0)
               $post_errors[] = 'bad_email';
         }

         // Now make sure this email address is not banned from posting.
         isBannedEmail($_POST['email'], 'cannot_post', sprintf($txt['you_are_post_banned'], $txt[28]));
      }
   }
   // Check the subject and message.

   if (!isset($_POST['subject']) || $func['htmltrim']($_POST['subject']) === '')
      $post_errors[] = 'no_subject';
   if (!isset($_POST['message']) || $func['htmltrim']($_POST['message']) === '')
      $post_errors[] = 'no_message';
   elseif (!empty($modSettings['max_messageLength']) && $func['strlen']($_POST['message']) > $modSettings['max_messageLength'])
      $post_errors[] = 'long_message';
   else
   {
      if($modSettings['max_images_per_post'] != '-1' && preg_match_all('/\[img\]/i', $_POST['message']) > $modSettings['max_images_per_post']) {
         $post_errors[] = 'too_many_images';
      }
      // Prepare the message a bit for some additional testing.
      $_POST['message'] = $func['htmlspecialchars']($_POST['message'], ENT_QUOTES);

B Patterson

Change this section:
else
  {
     if(
$modSettings['max_images_per_post'] != '-1' && preg_match_all('/\[img\]/i', $_POST['message']) > $modSettings['max_images_per_post']) {
       
$post_errors[] = 'too_many_images';
     }

to be:
else
  {
     if(
$modSettings['max_images_per_post'] != '-1' && preg_match_all('/\[img\]/i', $_POST['message'], $matches) > $modSettings['max_images_per_post']) {
       
$post_errors[] = 'too_many_images';
     }

InternetMafia

Any chance on this mod becoming 1.1.6 compatible
Its better to be dead and cool than alive and uncool.

B Patterson

I haven't really had the time, but I can take a look this weekend either before or after the OU/Texas game....

R.Bourne

#19
I posted on support section by mistake!

I managed to install the package on 1.1.8. However, as soon as I click start a new post, this message shows up on top the page as well as middle!

$txt['too_many_images'] = 'Sorry, but you have posted too many images at one time.  Please remove some and try again.';

It's very strange as I haven't even typed or add any image what-so-ever!

Advertisement: