Remote Avatar Size Control, Fehlermeldung

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Lucky-13

Remote Avatar Size Control, Fehlermeldung

Beitrag von Lucky-13 »

Moin!
Habe einen neuen MOD zur autom. Grössenanpassung von verlinkten Avataren gefunden, hätte da aber noch ein paar Fragen.
Es handelt sich um diesen MOD:

Code: Alles auswählen

############################################### 
## Mod Title:   Remote Avatar Size Control 
## Mod Version: 1.0.0 
## Author:       Michel Renaud < michelr@metalcrypt.com > 
## Description:  This mod ensures remote avatars do not exceed the maximum size specified in the configuration 
## Web site for updates: http://metalcrypt.bravepages.com 
## 
## This mod is for phpBB2 ver 2.0.1 (should work with 2.0.0 as well) 
## 
## 
## Installation Level:  Easy 
## Files To Edit:    3 
##   phpBB2/viewtopic.php 
##   phpBB2/admin/admin_users.php 
##   phpBB2/includes/usercp_avatar.php 
## 
################################################################# 
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites 
################################################################# 
## 
## Installation Notes: 
## 
## 
## if you are using a prefix to you DB tabels then you have to add this to 
## the SQL commands, e.g. "phpbb_users" instead of just "users" - ONLY 
## in the initial SQL commands, not in the php code ! 
## 
## The most important thing to keep in mind is, take your time, make 
## sure you are finding the correct lines to modify, then take care to paste the new code. 
## Please also keep in mind, if you are using more than one language file or theme at your 
## site, you will need to edit the corresponding files for each occurrence.  Good Luck! 
################################################################# 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
## and the Database 
################################################################# 


# 
#-----[ ADD SQL ]------------------------------------------ 
# 

ALTER TABLE phpbb_users ADD user_avatar_width SMALLINT; 
ALTER TABLE phpbb_users ADD user_avatar_height SMALLINT; 
Hat ihn schonmal jemand mit 2.0.6 bzw sogar 2.0.11 getestet?
Verändert er nur Bilder, die zu gross sind, oder auch Avatare, die "zu klein" sind?
Werden die Seitenverhältnisse beibehalten?
Und zu guter letzt die wichtigste Frage: ich habe ein Präfix in der Tabelle, an welcher Stelle muss ich das bei den SQL Befehlen einsetzen?

ALTER TABLE praefix_phpbb_users ADD user_avatar_width SMALLINT

oder

ALTER TABLE phpbb_users ADD praefix_user_avatar_width SMALLINT

vielen Dank
Zuletzt geändert von Lucky-13 am 05.01.2005 17:49, insgesamt 2-mal geändert.
Benutzeravatar
Andy120
Mitglied
Beiträge: 3430
Registriert: 02.01.2004 11:21
Wohnort: Basel (Schweiz)
Kontaktdaten:

Beitrag von Andy120 »

hi...

Bau den MOD doch einfach mal ein...

Dann zur SQL:
ALTER TABLE phpbb_users ADD user_avatar_width SMALLINT
Das rote ist der Praefix ;)

Gruss, Andy
Lucky-13

Beitrag von Lucky-13 »

danke andy!
falls der mod bei mir nicht ganz so will, wie ich's gern hätte, werde ich die zeilen in der datenbank dann mit ALTER TABLE phpbb_users DELETE user_avatar_width SMALLINT wieder los?
Lucky-13

Beitrag von Lucky-13 »

der Mod ist nun eingebaut und das Forum läuft weiterhin. Leider auch noch mit den zu grossen Avataren.
Ich hatte den Verdacht, dass die Resize Funktion evtl nur bei neu verlinkten Avataren klappt und habe gleich mal versucht über's ACP einen der zu grossen Avatare einfach neu einzustellen.
Dabei erhielt ich folgende Fehlermeldungen:
Warning: getimagesize(): URL file-access is disabled in the server configuration in /customers/true-believers.de/true-believers.de/httpd.www/opel/admin/admin_users.php on line 644

Warning: getimagesize(http://home.arcor.de/opelhoelle/bilder/peepee.gif): failed to open stream: no suitable wrapper could be found in /customers/true-believers.de/true-believers.de/httpd.www/opel/admin/admin_users.php on line 644
habe hier mal den kompletten Mod sowie weiter unten die Zeile 644 +/- 10 Zeilen aus meiner admin_users.php (falls es hier zu unübersichtlich ist, alle geänderten Datein sowie den Mod nochmal als Zip-Datei):

Mod

Code: Alles auswählen

############################################### 
## Mod Title:   Remote Avatar Size Control 
## Mod Version: 1.0.0 
## Author:       Michel Renaud < michelr@metalcrypt.com > 
## Description:  This mod ensures remote avatars do not exceed the maximum size specified in the configuration 
## Web site for updates: http://metalcrypt.bravepages.com 
## 
## This mod is for phpBB2 ver 2.0.1 (should work with 2.0.0 as well) 
## 
## 
## Installation Level:  Easy 
## Files To Edit:    3 
##   phpBB2/viewtopic.php 
##   phpBB2/admin/admin_users.php 
##   phpBB2/includes/usercp_avatar.php 
## 
################################################################# 
## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites 
################################################################# 
## 
## Installation Notes: 
## 
## 
## if you are using a prefix to you DB tabels then you have to add this to 
## the SQL commands, e.g. "phpbb_users" instead of just "users" - ONLY 
## in the initial SQL commands, not in the php code ! 
## 
## The most important thing to keep in mind is, take your time, make 
## sure you are finding the correct lines to modify, then take care to paste the new code. 
## Please also keep in mind, if you are using more than one language file or theme at your 
## site, you will need to edit the corresponding files for each occurrence.  Good Luck! 
################################################################# 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
## and the Database 
################################################################# 


# 
#-----[ ADD SQL ]------------------------------------------ 
# 

ALTER TABLE phpbb_users ADD user_avatar_width SMALLINT; 
ALTER TABLE phpbb_users ADD user_avatar_height SMALLINT; 


# 
#-----[ OPEN FILE:  phpBB2/viewtopic.php ]------------------------------------------ 
#  

# 
#-----[ FIND ]------------------------------------------ 
# 

$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid 


# 
#-----[ REPLACE WITH ]------------------------------------------ 
# NOTE!!!! If you have any mod that modifies the user profiles or 
# the individual posts, it is possible that this line has been modified 
# by another mod, so you may have to make changes manually.  This mod 
# requires adding "u.user_avatar_width, u.user_avatar_height" (without the quotes) 
# to the list of fields. 

$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_avatar_width, u.user_avatar_height, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid 

# 
#-----[ FIND ]------------------------------------------ 
# 

            $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : ''; 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

            if ( $board_config['allow_avatar_remote'] ) 
            { 
               if ( ($postrow[$i]['user_avatar_height'] && $postrow[$i]['user_avatar_height'] > 0) && 
                     ($postrow[$i]['user_avatar_width'] && $postrow[$i]['user_avatar_width'] > 0) ) 
               { 
                  $poster_avatar = '<img src="' . $postrow[$i]['user_avatar'] . '" height="' . $postrow[$i]['user_avatar_height'] . '" width="' . $postrow[$i]['user_avatar_width'] . '" alt="" border="0" />'; 
               } 
               else  // No width/height in the user's profile 
               { 
                  $poster_avatar = '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />'; 
               } 
            } 
            else  // remote avatars not allowed 
               $poster_avatar = ''; 
                
                
# 
#-----[ SAVE FILE:  phpBB2/viewtopic.php ]------------------------------------------ 
# 


# 
#-----[ OPEN FILE:  phpBB2/admin/admin_users.php ]------------------------------------------ 
#  

# 
#-----[ FIND ]------------------------------------------ 
# 


      } 
      else if( $user_avatar_local != "" && $avatar_sql == "" && !$error ) 

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# Note: The following block of text goes BEFORE the line with a single '}' above 

         $user_avatar_dimensions = GetImageSize($user_avatar_remoteurl); 
         if ($user_avatar_dimensions == NULL) 
         { 
            $user_avatar_xsize = 0; // Remote avatar not found, zero 
            $user_avatar_ysize = 0; 
         } 
         else 
         {  // Check avatar dimensions, adjust if necessary 
            // Extract the image's width and height 
            $firstquote = strpos($user_avatar_dimensions[3],'"'); 
            $strwidth = substr($user_avatar_dimensions[3],$firstquote+1); 
            $lastquote = strpos($strwidth,'"'); 
            $user_avatar_xsize = substr($strwidth,0,$lastquote); 
       
            $strheight = substr($strwidth,$lastquote+1); 
             
            $firstquote = strpos($strheight,'"'); 
             
            $strheight = substr($strheight,$firstquote+1); 
          
            $lastquote = strpos($strheight,'"'); 
            $user_avatar_ysize = substr($strheight,0,$lastquote); 
             
            if ($user_avatar_xsize > $board_config['avatar_max_width']) // width exceeds max 
            { 
               $user_avatar_ratio = $board_config['avatar_max_width'] / $user_avatar_xsize; 
       
               $user_avatar_xsize = $user_avatar_xsize * $user_avatar_ratio; 
               $user_avatar_ysize = $user_avatar_ysize * $user_avatar_ratio; 
            } 
             
            if ($user_avatar_ysize > $board_config['avatar_max_height']) // height exceeds max 
            { 
               $user_avatar_ratio = $board_config['avatar_max_height'] / $user_avatar_ysize; 
       
               $user_avatar_xsize = $user_avatar_xsize * $user_avatar_ratio; 
               $user_avatar_ysize = $user_avatar_ysize * $user_avatar_ratio; 
            } 
         } 
         $avatar_sql = ", user_avatar = '" . str_replace("\'", "''", $user_avatar_remoteurl) . "', user_avatar_type = " . USER_AVATAR_REMOTE . ", user_avatar_width = " . $user_avatar_xsize . ", user_avatar_height = " . $user_avatar_ysize; 
          
# 
#-----[ SAVE FILE:  phpBB2/admin/admin_users.php ]------------------------------------------ 
# 

# 
#-----[ OPEN FILE:  phpBB2/includes/usercp_avatar.php ]------------------------------------------ 
#  

# 
#-----[ FIND ]------------------------------------------ 
# 


function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename) 
{ 



# 
#-----[ ADD AFTER ]------------------------------------------ 
# Note: This goes after the line with a single '{' above 

   global $board_config; 


# 
#-----[ FIND ]------------------------------------------ 
# 

   return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : ''; 


# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 


   // Ensures the image doesn't exceed the max width and height specified in the board's configuration 
   $user_avatar_dimensions = GetImageSize($avatar_filename); 

   if ($user_avatar_dimensions == NULL) 
   { 
      $user_avatar_xsize = 0; // Remote avatar not found, zero 
      $user_avatar_ysize = 0; 
   } 
   else 
   {  // Check avatar dimensions, adjust if necessary 
       
      // Extract the image's width and height 
      $firstquote = strpos($user_avatar_dimensions[3],'"'); 
      $strwidth = substr($user_avatar_dimensions[3],$firstquote+1); 
      $lastquote = strpos($strwidth,'"'); 
      $user_avatar_xsize = substr($strwidth,0,$lastquote); 

      $strheight = substr($strwidth,$lastquote+1); 
       
      $firstquote = strpos($strheight,'"'); 
       
      $strheight = substr($strheight,$firstquote+1); 
    
      $lastquote = strpos($strheight,'"'); 
      $user_avatar_ysize = substr($strheight,0,$lastquote); 
       
      if ($user_avatar_xsize > $board_config['avatar_max_width']) // width exceeds max 
      { 
         $user_avatar_ratio = $board_config['avatar_max_width'] / $user_avatar_xsize; 

         $user_avatar_xsize = $user_avatar_xsize * $user_avatar_ratio; 
         $user_avatar_ysize = $user_avatar_ysize * $user_avatar_ratio; 
      } 
       
      if ($user_avatar_ysize > $board_config['avatar_max_height']) // height exceeds max 
      { 
         $user_avatar_ratio = $board_config['avatar_max_height'] / $user_avatar_ysize; 

         $user_avatar_xsize = $user_avatar_xsize * $user_avatar_ratio; 
         $user_avatar_ysize = $user_avatar_ysize * $user_avatar_ratio; 
      } 
   } 

   return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE . ", user_avatar_width = " . $user_avatar_xsize . ", user_avatar_height = " . $user_avatar_ysize : ''; 
    
# 
#-----[ SAVE FILE:  phpBB2/includes/usercp_avatar.php ]------------------------------------------ 
# 
admin_users.php
Zeile 644 wäre $user_avatar_dimensions = GetImageSize($user_avatar_remoteurl);

Code: Alles auswählen


			if( preg_match("#^(http:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+\/.*?\.(gif|jpg|png)$)#is", $user_avatar_remoteurl) )
			{
				$avatar_sql = ", user_avatar = '" . str_replace("\'", "''", $user_avatar_remoteurl) . "', user_avatar_type = " . USER_AVATAR_REMOTE;
			}
			else
			{
				$error = true;
				$error_msg = ( !empty($error_msg) ) ? $error_msg . "<br />" . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
			}
         $user_avatar_dimensions = GetImageSize($user_avatar_remoteurl);
         if ($user_avatar_dimensions == NULL)
         {
            $user_avatar_xsize = 0; // Remote avatar not found, zero
            $user_avatar_ysize = 0;
         }
         else
         {  // Check avatar dimensions, adjust if necessary
            // Extract the image's width and height
            $firstquote = strpos($user_avatar_dimensions[3],'"');
            $strwidth = substr($user_avatar_dimensions[3],$firstquote+1);
            $lastquote = strpos($strwidth,'"');
            $user_avatar_xsize = substr($strwidth,0,$lastquote);
Antworten

Zurück zu „phpBB 2.0: Mod Support“