經我一晚的研究 , 終於解決了!!
![非常生氣 :evil:](./images/smilies/icon_evil.gif)
其實是作者的一個小bugs..........~"~
Hack Title: Rapid offsite avatar check
Hack Version: 1.5.0
Author: Antony Bailey
Description: Checks offsite avatars to make sure they conform to the set params.
Compatibility: 2.0.4
PS:請先移除所有連結頭像限制的MOD!
代碼: 選擇全部
###############################################
## Hack Title: Rapid offsite avatar check
## Hack Version: 1.5.0
## Author: Antony Bailey
## Description: Checks offsite avatars to make sure they conform to the set params.
## Compatibility: 2.0.4
##
## Installation Level: Easy
## Installation Time: 2 minutes
## Files To Edit: 1
## usercp_avatar.php
##
##
## History:
## 1.0.0: Initial test.
## 1.5.0: Typo fixed.
##
## Author Notes:
## Thanks again FB-ke, for saving my typos once again. Just a } that's the bug I had. :roll:
##
## Support: http://www.phpbbhacks.com/forums
## Copyright: ?003 Rapid offsite avatar check 1.0.0 - Antony Bailey
##
###############################################
## 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 ]------------------------------------------
#
includes/usercp_avatar.php
#
#-----[ FIND ]------------------------------------------
#
function check_image_type(&$type, &$error, &$error_msg)
{
global $lang;
switch( $type )
{
case 'jpeg':
case 'pjpeg':
case 'jpg':
return '.jpg';
break;
case 'gif':
return '.gif';
break;
case 'png':
return '.png';
break;
default:
$error = true;
$error_msg = (!empty($error_msg)) ? $error_msg . '<br />' . $lang['Avatar_filetype'] : $lang['Avatar_filetype'];
break;
#
#-----[ BEFORE, ADD, ADD ]------------------------------------------
#
function download_avatar($filename)
{
global $board_config, $userdata;
$retvar="NULL";
clearstatcache();
$localfile = './' . $board_config['avatar_path'].'/'.$userdata['session_user_id'].basename($filename);
$fd = @fopen($filename,"rb");
if ($fd)
{
$imgdata = fread($fd,$board_config['avatar_filesize']+1);
$fl = @fopen($localfile,"wb");
if ($fl)
{
$fp=@fwrite($fl,$imgdata);
@fclose($fl);
if ($fp != -1)
{
if (filesize($localfile) <= $board_config['avatar_filesize'])
{
$retvar = $localfile;
}
else
{
@unlink($localfile);
$retvar = 'SIZE';
}
}
else
{
@unlink($localfile);
message_die(GENERAL_ERROR, 'Could not write avatar file to local storage. Please contact someone who cares with this message', '', __LINE__, __FILE__);
}
}
else
{
@unlink($localfile);
message_die(GENERAL_ERROR, 'Could not write avatar file to local storage. Please contact the someone who cares with this message', '', __LINE__, __FILE__);
}
fclose($fd);
}
return $retvar;
}
#
#-----[ FIND ]------------------------------------------
#
function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename)
{
if ( !preg_match('#^(http)|(ftp):\/\/#i', $avatar_filename) )
{
$avatar_filename = 'http://' . $avatar_filename;
}
if ( !preg_match('#^((http)|(ftp):\/\/[\w\-]+?\.([\w\-]+\.)+[\w]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) )
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
return;
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename)
{
global $board_config, $lang;
if ( !preg_match('#^(http)|(ftp):\/\/#i', $avatar_filename) )
{
$avatar_filename = 'http://' . $avatar_filename;
}
if ( !preg_match('#^((http)|(ftp):\/\/[\w\-]+?\.([\w\-]+\.)+[\w]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) )
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
return;
}
$tmp_filename=download_avatar($avatar_filename);
$width=2*$board_config['avatar_max_width'];
$height=2*$board_config['avatar_max_height'];
switch ($tmp_filename)
{
case 'NULL':
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['No_connection_URL'] : $lang['No_connection_URL'];
return;
break;
case 'SIZE':
$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;
return;
break;
default:
unset ($height);
unset ($width);
list($width, $height) = getimagesize($tmp_filename);
if (!isset($width) or $width<=0) $width=2*$board_config['avatar_max_width'];
if (!isset($height) or $height<=0) $height=2*$board_config['avatar_max_height'];
@unlink($tmp_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;
return;
}
}
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
![ㄏㄏㄏ :mrgreen:](./images/smilies/icon_mrgreen.gif)
找尋 :
代碼: 選擇全部
return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : '';
代碼: 選擇全部
$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;
return;
}
}
![ㄏㄏㄏ :mrgreen:](./images/smilies/icon_mrgreen.gif)
你可以試試 是否真的完美!!
對了 , 最後要把avatars的folder的CHMOD改成777
當然 , 你要到後台把avatars的路徑設定正確^^
來了竹貓這麼久 , 終於有點貢獻了
![害羞 :oops:](./images/smilies/icon_redface.gif)
(希望之前沒有人寫過....~"~)