Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 690

Limit Signature Image Size in kilobyte

$
0
0
Create limitsign.php in Notepad ++

and copy (or you can use attached file)

PHP Code:
<?php 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Plugin info
function limitsign_info ()
{
    return array(
        
"name"            => "limitsign",
        
"description"    => "limitsign",
        
"website"        => "limitsign",
        
"author"        => "limitsign",
        
"authorsite"    => "limitsign",
        
"version"        => "limitsign",
        
"guid"             => "limitsign",
        
"compatibility" => "16*"
    
);
}

$plugins->add_hook('usercp_start''signsize');
function 
signsize()
{
    global 
$mybb$error;

    
preg_match_all("/\[img(.*?)\](.*?)\[\/img\]/i"$mybb->input['signature'], $matchesPREG_SET_ORDER);

    
$kbsizetot 0;
    
    foreach (
$matches as $img)
    {
    
$kbsize strlen(@file_get_contents($img[2]));
    
$kbsizetot += $kbsize;
    }
    
    if ((
$kbsizetot 350000) && ($mybb->input['action'] == "do_editsig")) {

    
$error inline_error("The sum of the size of the images exceeds the allowed limit of 350kb.");

    }    
}
?>

Change "350000" with value you want...
350000 is same 350 kb
100000 is same 100 kb.....

Change "The sum of the size of the images exceeds the allowed limit of 350kb." with error message you want.

upload limitsign.php to plugin folder and activate.
it´s all.

.php  limitsign.php (Size: 1.04 KB / Downloads: 4)

Viewing all articles
Browse latest Browse all 690

Trending Articles