Welcome, Guest. Please Login or Register.
May 14, 2025, 07:37:57 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  new mod idea about image restriction « previous next »
Pages: [1] Reply Ignore Print
Author Topic: new mod idea about image restriction  (Read 1340 times)
justwondering
Guest
new mod idea about image restriction
« on: August 01, 2003, 12:09:44 PM »
Reply with quote

Can anyone create a mod that would disable users abilities to post images via code in there message, but would keep the ability to post graphic smileys? This would be a very usefull feature for the yabbse community - as I`m sure I`m not the only one who has had a board bomabrded with "inapropriate" images. And although aboviously you can bann users, sometimes the image has been there for a while too long before you catch it. Just a thought. Thanks. ;D
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:new mod idea about image restriction
« Reply #1 on: August 01, 2003, 05:44:01 PM »
Reply with quote

Well, you can edit Subs.php and remove the lines (there are 2) that parse [img]...

-[Unknown]
Logged
justwondering
Guest
Re:new mod idea about image restriction
« Reply #2 on: August 03, 2003, 01:47:43 PM »
Reply with quote

Thank you for responding, I am kind of new at this whole thing, which lines should i remove for this? also, can i disable flash etc via this method, and if so which lines should i remove for that?

Thanks :)
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:new mod idea about image restriction
« Reply #3 on: August 03, 2003, 06:35:29 PM »
Reply with quote

Flash is in the mod settings area... you can turn it off already. (it should be off by default.)

-[Unknown]
Logged
Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:new mod idea about image restriction
« Reply #4 on: August 04, 2003, 07:23:28 AM »
Reply with quote

Quote from: [Unknown] on August 01, 2003, 05:44:01 PM
Well, you can edit Subs.php and remove the lines (there are 2) that parse [img]...

Could you tell me please the name of the function which contains these lines?
Logged

[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:new mod idea about image restriction
« Reply #5 on: August 04, 2003, 07:33:24 AM »
Reply with quote

I forget... I think it's parsecodesmilies or something.  Just serach for a LOT of regular expressions in an array.

-[Unknown]
Logged
Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:new mod idea about image restriction
« Reply #6 on: August 04, 2003, 07:37:05 AM »
Reply with quote

Function fixTags?
« Last Edit: August 04, 2003, 07:50:07 AM by Snoader » Logged

Metho
Sr. Member
****
Posts: 342


I'm a llama!

Re:new mod idea about image restriction
« Reply #7 on: August 04, 2003, 07:43:02 AM »
Reply with quote

No, search for this: function doparsecodesmilies

That's what a lot of regex in an array looks like! :D

Methonis
Logged

Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:new mod idea about image restriction
« Reply #8 on: August 04, 2003, 07:54:14 AM »
Reply with quote

Ok, been there. Here you can remove images when a message is displayed on screen, but the image tags are not removed from the message itself. Imo it's impossible to include a statement which makes it possible only to show the image when the message is posted by an admin/GM.

I'd like to add functionality to remove image-tags (including the http-part) before storing a message into the database when a normal user is posting the message. Any idea where to start?
Logged

Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:new mod idea about image restriction
« Reply #9 on: August 04, 2003, 11:15:16 AM »
Reply with quote

This must be it. Haven't tested it yet. Any comments?


function fixTags($message)
{
   // Adapted for image-removing - SG
   
   $fixArray = array
   (
      array('tag' => 'url', 'protocol' => 'http', 'embeddedUrl' => true, 'hasEqualSign' => false),
      array('tag' => 'url', 'protocol' => 'http', 'embeddedUrl' => true, 'hasEqualSign' => true),
      array('tag' => 'iurl', 'protocol' => 'http', 'embeddedUrl' => true, 'hasEqualSign' => false),
      array('tag' => 'iurl', 'protocol' => 'http', 'embeddedUrl' => true, 'hasEqualSign' => true),
      array('tag' => 'ftp', 'protocol' => 'ftp', 'embeddedUrl' => true, 'hasEqualSign' => false),
      array('tag' => 'ftp', 'protocol' => 'ftp', 'embeddedUrl' => true, 'hasEqualSign' => true),
      array('tag' => 'flash', 'protocol' => 'http', 'embeddedUrl' => false, 'hasEqualSign' => true)
   );

   $message = removeImages($message); // Added by SG

   foreach ($fixArray as $param)
      $message = fixTag($message, $param['tag'], $param['protocol'], $param['embeddedUrl'], $param['hasEqualSign']);


   return $message;
}

function removeImages($message)
{
   // To remove image-tags, obviously

   global $settings;
   
   $myTag = 'img';
   
   // First remove all "[img width=xxx ...]...[/img]"-occurences if poster not Admin of Global Moderator
   if (!($settings[7] == "Administrator" || $settings[7] == "Global Moderator"))
   {
      while (preg_match("/\[($myTag width=[0-9]+ height=[0-9]+\s*)\](.+?)\[\/($myTag)\]/si", $message, $matches))
      {
         $leftTag = $matches[1];
         $searchfor = $matches[2];
         $rightTag = $matches[3];

         $message = str_replace(
            "[$leftTag]{$searchfor}[/$rightTag]",
            "", $message);
      }
   
      while (preg_match("/\[($myTag height=[0-9]+ width=[0-9]+\s*)\](.+?)\[\/($myTag)\]/si", $message, $matches))
      {
         $leftTag = $matches[1];
         $searchfor = $matches[2];
         $rightTag = $matches[3];
   
         $message = str_replace(
            "[$leftTag]{$searchfor}[/$rightTag]",
            "", $message);
      }
   }
   
   // Second, fix tags or remove them
         
   while (preg_match("/\[($myTag)\](.+?)\[\/($myTag)\]/si", $message, $matches))
   {
      $leftTag = $matches[1];
      $searchfor = $matches[2];
      $rightTag = $matches[3];
      
      $replace = $searchfor;
      $replace = trim($replace);   // remove all leading and trailing whitespaces
            
      if ($settings[7] == "Administrator" || $settings[7] == "Global Moderator")
      {
         $message = str_replace(
            "[$leftTag]{$searchfor}[/$rightTag]",
            "\{$myTag\}$replace\{/$myTag\}", $message);
      }
      else
      {
         $message = str_replace(
            "[$leftTag]{$searchfor}[/$rightTag]",
            "", $message);
      }
   }
   
   $message = str_replace(
      array("\{$myTag\}", "\{/$myTag\}"),
      array("[$myTag]", "[/$myTag]"), $message);
   
   return $message;
}

« Last Edit: August 06, 2003, 10:09:59 AM by Snoader » Logged

Snoader
Noobie
*
Posts: 28


No guts, no glory.

WWW
Re:new mod idea about image restriction
« Reply #10 on: August 06, 2003, 10:11:50 AM »
Reply with quote

I've tested the code and changed a few things. The updated (and working) code is displayed above.

Add and replace in Subs.php.
Logged

Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  new mod idea about image restriction « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.104 seconds with 21 queries.