vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Remove single users signature allowance (https://vborg.vbsupport.ru/showthread.php?t=19842)

c-pr0mpt 06-10-2001 01:17 AM

Hi
I would like to be able to remove someones ability to post an image in their sig, or their sig area all together. I have rules on size limits, content, and so on. If they dont follow the rules I want to remove their ability to even have one, without affecting the members who are not breaking the rules.

Does this hack exist? If so where can I get it? If not, anyone willing to work on one? :)

Thanks in advance for any answers.

c-pr0mpt 06-10-2001 05:46 PM

I take it this hack doesnt exist. lol

chrispadfield 06-10-2001 10:02 PM

it dosen't but is a good idea. Personally i think signature rules need to be looked at. Possible iteams of relevenace include:

1. Signature size global limit (there is a hack for this)
2. Signauture override based on usergroup
3. Signature override based on individual userid

and the same for images in signatures.

c-pr0mpt 06-10-2001 11:58 PM

Where can I get the global limit hack? Does that mean size in mass, or dimension?

And the other stuff you listed, are you saying this is stuff i could do? Or just ways the hack could be made?

Ratorasniki 06-11-2001 12:00 AM

i've done the following for my board:

-maximum image filesize in sig (single image and combined)
-maximum image resolution (width by height)
-per user hardcoded (ie. no cp stuff) sig disabler

its not foolproof (i can think of about 3 ways to get past either the resolution or filesize thangs, since its only checked on user profile edit) but it works for me for the mostpart. i'm working on removing width and height tags from images as well - i've got some idiots on my board taking small images like smilies and making them enormous in size since they cant just use huge images with varying degrees of luck.

i didnt think anyone else'd use this stuff so i just did it really quick and its reaaaaaaally ugly but if anyone is interested i can clean it up and post it.

c-pr0mpt 06-11-2001 12:04 AM

I would love if you could do that bro. :) Ugly is better than non existent. lol

Ratorasniki 06-11-2001 12:18 AM

you havent seen my ugly. ;)

i've been known to compress an entire class to a single line :D

anyway i'll get on that.

Ratorasniki 06-11-2001 12:35 AM

1 Attachment(s)
in member.php:

find:
Code:

<?php
and insert after:
Code:

/************************************************************************
 stuff for img size
************************************************************************/
define(GIF_SIG, "\x47\x49\x46");
define(JPG_SIG, "\xff\xd8\xff");
define(PNG_SIG, "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a");
define(JPG_SOF0, "\xc0");
define(JPG_SOF1, "\xc1");
define(JPG_SOF2, "\xc2");
define(JPG_SOF3, "\xc3");
define(JPG_SOF5, "\xc5");
define(JPG_SOF6, "\xc6");
define(JPG_SOF7, "\xc7");
define(JPG_SOF9, "\xc9");
define(JPG_SOF10, "\xca");
define(JPG_SOF11, "\xcb");
define(JPG_SOF13, "\xcd");
define(JPG_SOF14, "\xce");
define(JPG_SOF15, "\xcf");
define(JPG_EOI, "\xd9");
define(JPG_SOS, "\xda");
define(RD_BUF, 512);
//***********************************************************************

find:
Code:

  // check that nothing illegal is in the signature
  $signature=censortext($signature);

and insert after:
Code:

//************************************************
// rats sig checking shizynit

  $imgcount = substr_count($signature, "<img src=");
  $sigstart = 0;
  $sigend = strlen($signature);
  $tmpsig = $signature;
  $totalsigsize = 0;

//  $signature .= "<!-- imgcount: $imgcount -->";

  for($i = 0; $i < $imgcount; $i++) {

        if(ereg("<img src=\"(.*)\"(.*)>", $tmpsig, $img)) {
          $img[2] = substr($img[2], 0, strlen($img[2]) - 1);
//          $signature .= CheckSigImageSizes($img[2]);
          CheckSigImageSizes($img[2]);
          $sigstart = strpos($tmpsig,"<img src") + strlen($img[2]);
        }

        if(ereg("<img src=(http[s]*:[/]+)([-a-z0-9_\./]*)>", $tmpsig, $img)) {
          if(substr_count($img[2], " ") > 0) {
            $tmp = explode(" ", $img[2]);
//            $signature .= CheckSigImageSizes("http://".$tmp[0]);
            CheckSigImageSizes("http://".$tmp[0]);
            $sigstart = strpos($tmpsig, "<img src") + strlen($tmp[2]) + 7;
          } else {               
//            $signature .= CheckSigImageSizes("http://".$img[2]);
            CheckSigImageSizes("http://".$img[2]);
            $sigstart = strpos($tmpsig,"<img src") + strlen($img[2]) + 7;
          }
        }

        $tmpsig = substr($signature, $sigstart, $sigend - $sigstart);
  }
//************************************************

and if you're feeling adventurous you can try adding
Code:

//************************************************
// remove width and height params
//strip height tags
$signature=ereg_replace("[:space:]?height=\"[0-9]+\"","",$signature);
$signature=ereg_replace("[:space:]?height=[0-9]+","",$signature);
//strip width tags
$signature=ereg_replace("[:space:]?width=\"[0-9]+\"","",$signature);
$signature=ereg_replace("[:space:]?width=[0-9]+","",$signature);
//************************************************

after the above.

then find (should be right at the bottom):
Code:

  // parse this next line with eval:
  $sendtoname=$destuserinfo[username];
  eval("standardredirect(\"".gettemplate("redirect_sentemail")."\",\"usercp.php?s=$session[sessionhash]\");");
}

and under it add:
Code:

// img size stuff
function GetURLImageSize( $urlpic ){
  $fd= @fopen($urlpic,"r");
  if($fd){ 
      #read in 1k, enough for GIF,PNG.
      #continue to read from file, if the JPG chunk exceeds this
      $imgData = fread( $fd,RD_BUF );
   
      if( substr($imgData,0,3)==GIF_SIG ){ 
        $dim =unpack ("v2dim",substr($imgData,6,4) );
        $width=$dim["dim1"]; $height=$dim["dim2"];
        $type = 1;
      } elseif( substr($imgData,0,8)==PNG_SIG ){ 
        $dim =unpack ("N2dim",substr($imgData,16,8) );
        $width=$dim["dim1"]; $height=$dim["dim2"];     
        $type = 3;
      } elseif( substr($imgData,0,3)==JPG_SIG ){           
        ################# JPG CHUNK SCAN ####################
        $imgPos = 2; $type = 2; $buffer = RD_BUF-2;
        while($imgPos < strlen($imgData)) {
            /* synchronize to the marker 0xFF */
            $imgPos=strpos(&$imgData,0xFF,$imgPos)+1;
            $marker = $imgData[$imgPos];
            do { $marker = ord($imgData[$imgPos++]); } while ($marker == 255);
            /* find dimensions of block */
            switch (chr($marker)) {
              /* Grab width/height from SOF segment (these are acceptable chunk types) */
              case JPG_SOF0:  case JPG_SOF1:  case JPG_SOF2:
              case JPG_SOF3:  case JPG_SOF5:  case JPG_SOF6:
              case JPG_SOF7:  case JPG_SOF9:  case JPG_SOF10:
              case JPG_SOF11: case JPG_SOF12: case JPG_SOF13:
              case JPG_SOF14: case JPG_SOF15:     
              $dim =unpack ("n2dim",substr($imgData,$imgPos+3,4) );
              $height=$dim["dim1"]; $width=$dim["dim2"];
              break 2; //found it so exit
            case JPG_EOI:
            case JPG_SOS:
              return FALSE;    /* End loop in case we find one of these markers */
            default:            /* We're not interested in other markers */
              $skiplen = (ord($imgData[$imgPos++])<<8)+ord($imgData[$imgPos++])-2;
              /* if the skip is more than what we've read in, read more */
              $buffer -= $skiplen;
              if( $buffer<512 ){ #if the buffer of data is too low,read more file.
                  $imgData .= fread( $fd,$skiplen+1024 );
                  $buffer += $skiplen+1024;
              };
              $imgPos += $skiplen;
              break;
            }; //endif check marker type
        }; //endif loop through JPG chunks
      }; //endif chk for valid file types
     
      # got the pic dimensions, close the file
      fclose ($fd);

      return array( $width,$height,$type );
    } else {
      return array( '','','' );
    }; //endif valid file pointer chk
}; // end function

function CheckSigImageSizes($imageurl) {
        global $totalsigsize;

        //change this stuff
        $max_singleimgsz = 20000;        //20k
        $max_totalimgsz = 20000;        //20k
        $max_imgwidth = 300;                //300px wide
        $max_imgheight = 200;                //200px tall

        $imginfo = GetURLImageSize( $imageurl );
        $url=parse_url($imageurl);
        $imgPath = $url[path];
        $imgHost = $url[host];
        $fp = fsockopen($imgHost, 80, &$errno, &$errstr, 30);
        if(!$fp) {
//          echo "ERROR: $errno: $errstr";
        } else {
          fputs($fp,"HEAD $imgPath HTTP/1.0\nHost: $imgHost\n\n");
          while(!feof($fp)) {
              $response .= fgets($fp,128);
          }
          fclose($fp);
        }
        $imgSz = ereg_replace("(.*)(Content-Length: )([0-9]*)(.*)","\\3",$response);
        if($imgSz > $max_singleimgsz) //filesize in bytes
        {
          eval("standarderror(\"".gettemplate("error_sigsizetoobig")."\");");
          exit;
        }
        if($imgSz + $totalsigsize > $max_totalimgsz) //filesize in bytes
        {
          $totalsigsize += $imgSz;
          eval("standarderror(\"".gettemplate("error_sigtotalsizetoobig")."\");");
          exit;
        }
        if($imginfo[0] > $max_imgwidth) //width
        {
          eval("standarderror(\"".gettemplate("error_sigdemtoobig")."\");");
          exit;
        }
        if($imginfo[1] > $max_imgheight) //height
        {
          eval("standarderror(\"".gettemplate("error_sigdemtoobig")."\");");
          exit;
        }
        $totalsigsize += $imgSz;
//return "\n<!-- $imageurl ($imgSz) - $imginfo[0] x $imginfo[1] -->";
}

change the vars at the top of the CheckSigImageSizes function to define your max sizes and that takes care of the image res and filesize stuff.

as for single user sig disabling open showthread.php and find:
Code:

    if ($post[showsignature] and $allowsignatures and trim($post[signature])!="" and ($bbuserinfo[userid]==0 or $bbuserinfo[showsignatures])) {
and change it to :
Code:

    if ($post[showsignature] and $allowsignatures and trim($post[signature])!="" and ($bbuserinfo[userid]==0 or $bbuserinfo[showsignatures]) and $post[username]!="Bad Boy One" and $post[username]!="Bad Boy Two") {
as necessary.

attached txt incase this gets formatted weird :P

c-pr0mpt 06-11-2001 12:43 AM

Thank you VERY much. I will get on this right away and let you know how it worked. =)


All times are GMT. The time now is 02:09 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01254 seconds
  • Memory Usage 1,774KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete