JanoF
 Správca fóra
 Založený: 01.05.2005 Príspevky: 8736 Bydlisko: Bratislava Vek: 27
 | Zaslal: So 14.10.06 15:11 |   |
| kód: | ###############################################
## Hack Title: Restrict images in signatures
## Hack Version: 0.1.1
## Author: Freakin' Booty ;-P
## Description: Restrict the width, the height and the number of images in signatures. Everything
## is configurable from the Administration Control Panel.
## Compatibility: 2.0.4
##
## Installation Level: Easy
## Installation Time: 5 - 10 minutes
## Files To Edit: 6
## admin/admin_board.php
## admin/admin_users.php
## includes/usercp_register.php
## language/lang_english/lang_admin.php
## language/lang_english/lang_main.php
## templates/subSilver/admin/board_config_body.tpl
##
## Included Files: 1
## db_update.php
##
## History:
## 0.1.0: Initial release
## 0.1.1: Fixed a few mistakes in the admin board configuration file.
##
## Author Notes:
## None
##
## Support: http://www.phpbbhacks.com/forums
## Copyright: ©2003 Restrict images in signatures 0.1.1 - Freakin' Booty ;-P
##
###############################################
## You downloaded this hack from phpBBHacks.com, the #1 source for phpBB related downloads.
## Please visit http://www.phpbbhacks.com/forums for support.
###############################################
##
###############################################
## This hack is released under the GPL License.
## This hack can be freely used, but not distributed, without permission.
## Intellectual Property is retained by the hack author(s) listed above.
###############################################
#
#-----[ COPY ]--------------------------------------------
#
# Run this file once (access it with your browser) and then delete it!
#
db_update.php => db_update.php
#
#-----[ OPEN ]--------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]--------------------------------------------
#
"L_MAX_SIG_LENGTH" => $lang['Max_sig_length'],
"L_MAX_SIG_LENGTH_EXPLAIN" => $lang['Max_sig_length_explain'],
#
#-----[ AFTER, ADD ]--------------------------------------
#
"L_MAX_SIG_IMAGES_LIMIT" => $lang['Max_sig_images_limit'],
"L_MAX_SIG_IMAGES_SIZE" => $lang['Max_sig_images_size'],
"L_MAX_SIG_IMAGES_SIZE_EXPLAIN" => $lang['Max_sig_images_explain'],
#
#-----[ FIND ]--------------------------------------------
#
"SIG_SIZE" => $new['max_sig_chars'],
#
#-----[ AFTER, ADD ]--------------------------------------
#sig_images_max_width
"SIG_IMAGES_MAX_LIMIT" => $new['sig_images_max_limit'],
"SIG_IMAGES_MAX_HEIGHT" => $new['sig_images_max_height'],
"SIG_IMAGES_MAX_WIDTH" => $new['sig_images_max_width'],
#
#-----[ OPEN ]--------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]--------------------------------------------
#
if ( strlen($sig_length_check) > $board_config['max_sig_chars'] )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Signature_too_long'];
}
#
#-----[ AFTER, ADD ]--------------------------------------
#
else
{
if( preg_match_all("#\[img(:$signature_bbcode_uid)?\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img(:$signature_bbcode_uid)?\]#sie", $signature, $matches) )
{
if( count($matches[0]) > $board_config['sig_images_max_limit'] )
{
$error = TRUE;
$l_too_many_images = ( $board_config['sig_images_max_limit'] == 1 ) ? sprintf($lang['Too_many_sig_image'], $board_config['sig_images_max_limit']) : sprintf($lang['Too_many_sig_images'], $board_config['sig_images_max_limit']);
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $l_too_many_images;
}
else
{
for( $i = 0; $i < count($matches[0]); $i++ )
{
$image = preg_replace("#\[img(:$signature_bbcode_uid)?\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img(:$signature_bbcode_uid)?\]#si", "\\2\\4", $matches[0][$i]);
list($width, $height) = @getimagesize($image);
if( $width > $board_config['sig_images_max_width'] || $height > $board_config['sig_images_max_height'] )
{
$error = TRUE;
$l_image_too_large = sprintf($lang['Sig_image_too_large'], $board_config['sig_images_max_width'], $board_config['sig_images_max_height']);
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $l_image_too_large;
break;
}
}
}
}
}
#
#-----[ OPEN ]--------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]--------------------------------------------
#
if ( strlen($signature) > $board_config['max_sig_chars'] )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Signature_too_long'];
}
#
#-----[ AFTER, ADD ]--------------------------------------
#
else
{
if( preg_match_all("#\[img\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img\]#sie", $signature, $matches) )
{
if( count($matches[0]) > $board_config['sig_images_max_limit'] )
{
$error = TRUE;
$l_too_many_images = ( $board_config['images_max_limit'] == 1 ) ? sprintf($lang['Too_many_sig_image'], $board_config['sig_images_max_limit']) : sprintf($lang['Too_many_sig_images'], $board_config['sig_images_max_limit']);
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $l_too_many_images;
}
else
{
for( $i = 0; $i < count($matches[0]); $i++ )
{
$image = preg_replace("#\[img\](.*)\[/img\]#si", "\\1", $matches[0][$i]);
list($width, $height) = @getimagesize($image);
if( $width > $board_config['sig_images_max_width'] || $height > $board_config['sig_images_max_height'] )
{
$error = TRUE;
$l_image_too_large = sprintf($lang['Sig_image_too_large'], $board_config['sig_images_max_width'], $board_config['sig_images_max_height']);
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $l_image_too_large;
break;
}
}
}
}
}
#
#-----[ OPEN ]--------------------------------------------
#
# Make sure to edit this file for every language installed
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]--------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]-------------------------------------
#
//
// Restrict images in signatures
//
$lang['Max_sig_images_limit'] = 'Maximum Images Per Signatures';
$lang['Max_sig_images_size'] = 'Maximum Image Dimensions In Signatures';
$lang['Max_sig_images_size_explain'] = '(Height x Width in pixels)';
#
#-----[ OPEN ]--------------------------------------------
#
# Make sure to edit this file for every language installed
#
language/lang_english/lang_main.php
#
#-----[ FIND ]--------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]-------------------------------------
#
//
// Restrict images in signatures
//
$lang['Too_many_sig_image'] = 'You have added too many images in your signature. You can only add %d image in your signature.';
$lang['Too_many_sig_images'] = 'You have added too many images in your signature. You can only add %d images in your signature.';
$lang['Sig_image_too_large'] = 'You have added an image that is too large. Images can only be %d pixels wide and %d pixels high.';
#
#-----[ OPEN ]--------------------------------------------
#
# Make sure to edit this file for every template installed
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]--------------------------------------------
#
<tr>
<td class="row1">{L_MAX_SIG_LENGTH}<br /><span class="gensmall">{L_MAX_SIG_LENGTH_EXPLAIN}</span></td>
<td class="row2"><input class="post" type="text" size="5" maxlength="4" name="max_sig_chars" value="{SIG_SIZE}" /></td>
</tr>
#
#-----[ AFTER, ADD ]--------------------------------------
#
<tr>
<td class="row1">{L_MAX_SIG_IMAGES_LIMIT} <br />
<span class="gensmall">{L_MAX_SIG_IMAGES_LIMIT_EXPLAIN}</span>
</td>
<td class="row2"><input class="post" type="text" size="3" maxlength="4" name="sig_images_max_limit" value="{SIG_IMAGES_MAX_LIMIT}" /></td>
</tr>
<tr>
<td class="row1">{L_MAX_SIG_IMAGES_SIZE} <br />
<span class="gensmall">{L_MAX_SIG_IMAGES_SIZE_EXPLAIN}</span>
</td>
<td class="row2"><input class="post" type="text" size="3" maxlength="4" name="sig_images_max_height" value="{SIG_IMAGES_MAX_HEIGHT}" /> x <input class="post" type="text" size="3" maxlength="4" name="sig_images_max_width" value="{SIG_IMAGES_MAX_WIDTH}" /></td>
</tr>
#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
# |
db_update.php
| kód: | <?php
/***************************************************************************
* db_update.php
* -------------------
* copyright : ?2003 Freakin' Booty ;-P
* built for : Restrict images in signatures 0.1.1
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if( !$userdata['session_logged_in'] )
{
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . append_sid('login.'.$phpEx.'?redirect=db_update.'.$phpEx, true));
exit;
}
if( $userdata['user_level'] != ADMIN )
{
message_die(GENERAL_MESSAGE, 'You are not authorised to access this page');
}
$page_title = 'Updating the database';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">';
$sql = array();
$sql[] = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('sig_images_max_width', 400), ('sig_images_max_height', 300), ('sig_images_max_limit', 1)";
for( $i = 0; $i < count($sql); $i++ )
{
if( !$result = $db->sql_query ($sql[$i]) )
{
$error = $db->sql_error();
echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />';
}
else
{
echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successfull</b></font></li><br />';
}
}
echo '</ul></span></td></tr><tr><td class="catBottom" height="28"> </td></tr>';
echo '<tr><th>End</th></tr><tr><td><span class="genmed">Installation is now finished. Please be sure to delete this file now.<br />If you have run into any errors, please visit the <a href="http://www.phpbbhacks.com/forums" target="_phpbbhacks">phpBBHacks.com support forums</a> and ask someone for help.</span></td></tr>';
echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Have a nice day</a></span></td></table>';
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> |
|
_________________ Skrinka: Nexus Morpho & Enermax UCTB12P | Zdroj: Enermax EMG800AWT 800W | Základná doska: Asus Rampage III Gene | Procesor: Intel Core i7 990X Extreme Edition 3.46 GHz & Scythe Susanoo SCSO-1000 | Pamäť: Kingston HyperX XMP 24 GB DDR3 1600 MHz | Grafická karta: Asus GeForce GT 440 1 GB DDR3 & Thermalright HR-03 | Pevný disk: Intel SSD 510 Series 250 GB & Hitachi Deskstar 5K4000 4000 GB | Optická mechanika: Plextor PX-820SA | Čítačka kariet: Akasa AK-ICR-11 | Klávesnica: Logitech G19 | Myš: Logitech G9x & Razer Kabuto | Monitor: 24" LCD Eizo FlexScan S2431WE | Reproduktory: Logitech Z-2300 | Operačný systém: Microsoft Windows 7 & FreeBSD 9 | Záložný zdroj: APC Back-UPS ES 700 | Spotreba: Idle - 200W / Burn - 400W | Mobil: Nokia N9 64 GB | |