但以往的方案都未能完滿解決大家的需要, 現在這個應該能解決大家的問題.
我已經成功試裝在2.05 和plus 1.2上, 並通過測試有效 ^_^
MOD說明 : 限制連結頭像的大小長度
版本 : 0.1.1 (適用於phpbb2.03-2.05 , plus 1.2)
代碼: 選擇全部
###############################################
## Hack Title: Restrict remote avatar images
## Hack Version: 0.1.1
## Author: Freakin' Booty ;-P
## Description: Restrict the width and the height of remote avatars.
## Compatibility: 2.0.3 - 2.0.5
##
## Installation Level: Easy
## Installation Time: 2 - 5 minutes
## Files To Edit: 2
## admin/admin_users.php
## includes/usercp_avatar.php
##
## Included Files: 0
##
## History:
## 0.1.0 Initial release
## 0.1.1 Fixed a few bugs; added a filesize check as well.
##
## Author Notes:
## None
##
## Support: http://www.phpbbhacks.com/forums
## Copyright: ?003 Restrict remote avatar images 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.
###############################################
#
#-----[ OPEN ]--------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]--------------------------------------------
#
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . "<br />" . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
}
#
#-----[ AFTER, ADD ]--------------------------------------
#
list($width, $height) = @getimagesize($user_avatar_remoteurl);
if( $width > $board_config['avatar_max_width'] || $height > $board_config['avatar_max_height'] )
{
$l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
$filehandle = @fopen($user_avatar_remoteurl, 'rb');
$filedata = @fread($filehandle, ($board_config['avatar_filesize'] + 1));
@fclose($filehandle);
$avatar_filesize = strlen($filedata);
if( !$error && ($avatar_filesize < 0 || $avatar_filesize > $board_config['avatar_filesize']) )
{
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
#
#-----[ OPEN ]--------------------------------------------
#
includes/usercp_avatar.php
#
#-----[ FIND ]--------------------------------------------
#
function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename)
{
#
#-----[ AFTER, ADD ]--------------------------------------
#
global $board_config, $lang;
#
#-----[ FIND ]--------------------------------------------
#
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
return;
}
#
#-----[ AFTER, ADD ]--------------------------------------
#
list($width, $height) = @getimagesize($avatar_filename);
if( $width > $board_config['avatar_max_width'] || $height > $board_config['avatar_max_height'] )
{
$l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
$filehandle = @fopen($avatar_filename, 'rb');
$filedata = @fread($filehandle, ($board_config['avatar_filesize'] + 1));
@fclose($filehandle);
$avatar_filesize = strlen($filedata);
if( !$error && ($avatar_filesize < 0 || $avatar_filesize > $board_config['avatar_filesize']) )
{
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#