Welcome, Guest. Please Login or Register.
April 27, 2025, 08:38:25 AM
Home Help Search Log in Register
News: If you are still using YaBB SE, please consider upgrading to SMF as soon as possible.

YaBB SE Community  |  Development  |  Completed mods  |  [Done 1.1] Avatar Upload « previous next »
Pages: 1 [2] Reply Ignore Print
Author Topic: [Done 1.1] Avatar Upload  (Read 4531 times)
sh00le
Noobie
*
Posts: 27


I love Counter Strike.

Re:[Done 1.1] Avatar Upload
« Reply #15 on: December 18, 2002, 01:35:16 PM »
Reply with quote

Hehe..

Tnx..
Logged
Peter
Noobie
*
Posts: 10


WWW
Re:[Done 1.1] Avatar Upload
« Reply #16 on: December 25, 2002, 08:23:55 PM »
Reply with quote

Will this mod work in 1.5.0?
If not, is someone going to change it so it works?

Best regards
Peter
Logged
sh00le
Noobie
*
Posts: 27


I love Counter Strike.

Re:[Done 1.1] Avatar Upload
« Reply #17 on: December 26, 2002, 07:14:03 PM »
Reply with quote

Check this
Logged
Thunderace
Full Member
***
Posts: 211


I'm a llama!

Re:[Done 1.1] Avatar Upload
« Reply #18 on: December 27, 2002, 12:37:46 AM »
Reply with quote

Error in first Boardmod string.
Logged
sh00le
Noobie
*
Posts: 27


I love Counter Strike.

Re:[Done 1.1] Avatar Upload
« Reply #19 on: December 27, 2002, 04:22:34 AM »
Reply with quote

Quote from: Thunderace on December 27, 2002, 12:37:46 AMError in first Boardmod string.

This is error in 1.2.1 version of Avatar Upload?

Please, could you be more specific, like, when this error occured, what did you doing etc...

Tnx.. :)
Logged
Chomper
Noobie
*
Posts: 28


AMD rulez!

ICQ - 75713009 WWW
Re:[Done 1.1] Avatar Upload
« Reply #20 on: December 27, 2002, 12:55:35 PM »
Reply with quote

works fine

but i modified this line a little

<td><input type="checkbox" name="userpicuploadcheck"' . $checked2 . ' /> <input type="file" name="userpicupload" size="35" value="' . $tmp2 . '" /><input type="hidden" name="MAX_FILE_SIZE" value="$max_pic_size"></td>
my version, last value edited to new style

<td><input type="checkbox" name="userpicuploadcheck"' . $checked2 . ' /> <input type="file" name="userpicupload" size="35" value="' . $tmp2 . '" /><input type="hidden" name="MAX_FILE_SIZE" value="' . $max_pic_size . '"></td>         
Logged

sh00le
Noobie
*
Posts: 27


I love Counter Strike.

Re:[Done 1.1] Avatar Upload
« Reply #21 on: December 28, 2002, 12:10:35 PM »
Reply with quote

Quote from: Chomper on December 27, 2002, 12:55:35 PMworks fine

but i modified this line a little

<td><input type="checkbox" name="userpicuploadcheck"' . $checked2 . ' /> <input type="file" name="userpicupload" size="35" value="' . $tmp2 . '" /><input type="hidden" name="MAX_FILE_SIZE" value="$max_pic_size"></td>
my version, last value edited to new style

<td><input type="checkbox" name="userpicuploadcheck"' . $checked2 . ' /> <input type="file" name="userpicupload" size="35" value="' . $tmp2 . '" /><input type="hidden" name="MAX_FILE_SIZE" value="' . $max_pic_size . '"></td>         

Ok, I will make that to...

Tnx.. :)
« Last Edit: December 28, 2002, 10:46:12 PM by sh00le » Logged
HighBoy
Jr. Member
**
Posts: 72


I love it !

Re:[Done 1.1] Avatar Upload
« Reply #22 on: December 28, 2002, 10:44:22 PM »
Reply with quote

Works great !
Thanks
Logged
Surfy
Sr. Member
****
Posts: 458


I'm a llama!

Re:[Done 1.1] Avatar Upload
« Reply #23 on: January 06, 2003, 09:13:49 AM »
Reply with quote

for wich YabbSe Version is this Mod??

Does it work with 1.4.1?

How many Pics can a user Upload?

Surfy
Logged
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:[Done 1.1] Avatar Upload
« Reply #24 on: January 06, 2003, 09:16:51 AM »
Reply with quote

Quote from: Peter on December 25, 2002, 08:23:55 PMWill this mod work in 1.5.0?
If not, is someone going to change it so it works?

Best regards
Peter


I would assume from this, yes.  Please, read before posting.... although I can understand your confusion.

-[Unknown]
Logged
sh00le
Noobie
*
Posts: 27


I love Counter Strike.

Re:[Done 1.1] Avatar Upload
« Reply #25 on: January 06, 2003, 12:08:37 PM »
Reply with quote

Quote from: Surfy on January 06, 2003, 09:13:49 AMfor wich YabbSe Version is this Mod??

Does it work with 1.4.1?

How many Pics can a user Upload?

Surfy

This is for 1.4.1 version od forum. But there is also avatar upload for 1.5.0. version of forum..

Sorry, this was my first topic here so... :(
Logged
Wiziwig
Sr. Member
****
Posts: 407


Programmer and Users Liason and Manager

WWW
Re:[Done 1.1] Avatar Upload
« Reply #26 on: May 01, 2003, 04:04:32 AM »
Reply with quote

Wrong type of Avatar image upload error

I been bugged about this one. Gandolph kept telling me he was able to upload his avatars just fine, but yet my Labrat was not able to upload his. I didnt try my regular account name, so I didnt notice this problem's solution right away.

Labrat kept getting these errors when he tried to upload:

An Error Has Occurred!
Wrong type of Avatar image. Please use gif or jpg.

I been using Netscape 7.1 all along to try to upload a avatar with Labrat's account. I use IE for my regular account.

The final solution is I found that the problem with user avatar upload is it's not Netscape compatable!

Now.. what in the heck do i do about this?

Any suggestions?
Logged

Vampy
Noobie
*
Posts: 17


I'm a llama!

Re:[Done 1.1] Avatar Upload
« Reply #27 on: May 01, 2003, 06:35:36 AM »
Reply with quote

Hi! I'm using Netscape 7 as well. I did notice the problem you mentioned but I think that has something to do with the filesize being too large. In my settings, I specify a max filesize of 5kb. If I try to upload a file greater than 5kb, it will give me that error message. However, when I upload a file say of 3KB, it works just fine. Dunno if I'm right about it but I tracked the problem down to the fact that because in the form, the code
<input type="hidden" name"MAX_FILE_SIZE" value="$max_pic_size">
will automatically check prevent a temp file from being created if the upload file size is larger than that you specify. Because of that the variable $_FILES['userpicupload'] has no value and thus $_FILES['userpicupload']['type'] will also have no value.

I read from the php manual that
<input type="hidden" name"MAX_FILE_SIZE" value="$max_pic_size">
is to stop uploading of file if the file is too large to prevent unduly long waiting for the user. This means that so ling the file is larger than that set in the hidden value, the file is not uploaded and no temp file is created. This will cut down the time that a user have to wait to know that his file is too large or something is wrong with his file.

I also made some modifications to the mod. What I have done was to add the ability to create a new directory to store the upload avatar for each user. This is so that other users cannot use his uploaded avatar. In addition, I have limit the number of avatar for each user to 1. Such that if the user already have a avatar uploaded, the next time he tries to upload a new avatar, the script will delete the old one and replace it with the newly uploaded one.

In addition, because each user have it's own avatar direactory, you can also delete that user directory and the avatar file in it without affecting other users. This is always done when the user with the uplaoded avatar reverts back to using the defualt set of avatar. So this helps you to also safe server space.

If anyone one is interested in the modification, I will post it here.
« Last Edit: May 01, 2003, 09:17:18 AM by Vampy » Logged
Vampy
Noobie
*
Posts: 17


I'm a llama!

Re:[Done 1.1] Avatar Upload
« Reply #28 on: May 01, 2003, 04:04:15 PM »
Reply with quote

As requested by Wiziwig, the following are the modifications to the codes of the avatar upload mod. Note that these modifications requires that you have already installed the avatar upload mod and I'm using YabbSE 1.5.1 with the security upgrade to 1.5.2. Oh and you will need to create a temporary folder for the uploaded file if you cannot have access to php.ini. Refer to the end of this post for more details.

Features:

  • Each user will have his/her own avatar directory to hold uploaded avatar.
  • Limit user to a number of uploaded avatar.
  • Inbuilt ability to delete/replace avatar should the max. no. of avatar be exceeded.
  • Inbulit ability to delete all avatars and the user avatar directory if user reverts back to using the default set of avatar.
Find in Profile.php:
<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_pic_size . '">
Add after:
<input type="hidden" name="pic" value="' . $pic . '">
Find:
//-------------- start of avatar mod
     if( isset($member['userpicuploadcheck']) ) {
        $name_of_pic = $_FILES['userpicupload']['name'];
        $user_avatar_dir = $modSettings['avatar_dir'];
        $user_avatar_pic = $modSettings['avatar_url']."/".$name_of_pic;        
        $max_pic_size = $modSettings['avatar_max_size']*1024;

        if (!file_exists("$user_avatar_dir/$name_of_pic")) {
           if (($_FILES['userpicupload']['type'] == "image/gif") OR ($_FILES['userpicupload']['type'] == "image/pjpeg")) {
              $avatar_image_info = getimagesize($_FILES['userpicupload']['tmp_name']);
              $avatar_width = $avatar_image_info[0];
              $avatar_height = $avatar_image_info[1];
              if (is_uploaded_file($_FILES['userpicupload']['tmp_name']) AND ($avatar_width <= $modSettings['avatar_max_width']) AND ($avatar_height <= $modSettings['avatar_max_height']) AND  ($_FILES['userpicupload']['size'] < $max_pic_size)) {
                  copy($_FILES['userpicupload']['tmp_name'], "$user_avatar_dir/$name_of_pic");
                 $member['userpic'] = $user_avatar_pic;              
              } else {
                 unlink ($_FILES['userpicupload']['tmp_name']);
                 fatal_error("$txt[up3] $modSettings[avatar_max_width] x $modSettings[avatar_max_height], $modSettings[avatar_max_size] KB)");              
              }
           } else {
              fatal_error("$txt[up4]");                          
           }
        } else {
           fatal_error("$txt[up5]");              
        }
     }

 
     $sizes = @getimagesize($member['userpic']);
     if ($sizes)
     {
        if (($sizes[0] > $userpic_width && $userpic_width != 0) ||
           ($sizes[1] > $userpic_height && $userpic_height != 0))
       
        fatal_error("$txt[yse227]  $userpic_width x $userpic_height)");
     
     }
//-------------- end of avatar mod

Replace with:
//-------------- start of avatar mod
  $user_avatar_dir = $modSettings['avatar_dir'];
  $abs_avatar_dir = $user_avatar_dir."/useravatars/".$member['user'];

     if( isset($member['userpicuploadcheck']) ) {
       
        $max_pic_size = $modSettings['avatar_max_size']*1024;
        $uploaddir = $user_avatar_dir . "/useravatars/tmp/";
        $name_of_pic = $_FILES['userpicupload']['name'];
        $type = $_FILES['userpicupload']['type'];
        $user_avatar_pic = $modSettings['avatar_url']."/useravatars/".$member['user']."/".$name_of_pic;
       
       
        $full_path_to_pic = $abs_avatar_dir . "/" . $name_of_pic;
        $full_path_to_old_pic = $user_avatar_dir . "/" . $member['pic'];
        $path_parts = pathinfo($full_path_to_pic);
        $ext = $path_parts["extension"];
        if (is_dir($abs_avatar_dir)) {
           $number_of_files = countfiles($abs_avatar_dir);
        }
        //if (!file_exists("$user_avatar_dir/useravatars/$name_of_pic")) {
        if ($_FILES['userpicupload']['tmp_name']) {
           if (($_FILES['userpicupload']['type'] == "image/pjpeg") OR ($_FILES['userpicupload']['type'] == "image/jpeg") OR ($_FILES['userpicupload']['type'] == "image/gif") OR ($ext == ('jpg' || 'gif'))) {
              $avatar_image_info = getimagesize($_FILES['userpicupload']['tmp_name']);
              $avatar_width = $avatar_image_info[0];
              $avatar_height = $avatar_image_info[1];
             
              if (is_uploaded_file($_FILES['userpicupload']['tmp_name']) AND ($avatar_width <= $modSettings['avatar_max_width']) AND ($avatar_height <= $modSettings['avatar_max_height']) AND ($_FILES['userpicupload']['size'] < $max_pic_size AND $_FILES['userpicupload']['size'] > 0)) {
                 if (is_dir($abs_avatar_dir) == false) {
                    $oldumask = umask(0);
                    mkdir("$abs_avatar_dir", 0777);
                    umask($oldumask);
                    chmod($abs_avatar_dir, 0777);
                 }
                 if ($number_of_files >= 1) {
                    $handle = opendir("$abs_avatar_dir");
                    while (false !== ($file = readdir($handle))) {
                       if (is_file($abs_avatar_dir."/".$file)) {
                          unlink ($abs_avatar_dir."/".$file);
                       }
                    }
                    closedir($handle);
                 }
                  copy($_FILES['userpicupload']['tmp_name'], "$abs_avatar_dir/$name_of_pic");
                 $member['userpic'] = "useravatars/" . $member['user'] . "/" . $name_of_pic;
                 chmod($full_path_to_pic, 0777);
              }
              else {
                 unlink ($_FILES['userpicupload']['tmp_name']);
                 fatal_error("$txt[up3] $modSettings[avatar_max_width] x $modSettings[avatar_max_height], $modSettings[avatar_max_size] KB)");      
              }
           }
           else {
              fatal_error("$txt[up4]");                          
           }
        }
        else {
              fatal_error("Either you did not upload a file or the filesize is too large. Max size: $modSettings[avatar_max_size] KB");              
           }
     }
     else {
        if (is_dir($abs_avatar_dir)) {
        $handle = opendir("$abs_avatar_dir");
        while (false !== ($file = readdir($handle))) {
           if (is_file($abs_avatar_dir."/".$file)) {
              unlink ($abs_avatar_dir."/".$file);
           }
        }
        closedir($handle);
        rmdir($abs_avatar_dir);
        }
     }
//-------------- end of avatar mod


Find in Subs.php:
?>
Add Before:
function countfiles($folder) {

$handle = opendir("$folder");
while (false !== ($file = readdir($handle))) {
  if (is_file($folder."/".$file)) {
     $files[] = $folder."/".$file;
  }
}
closedir($handle);
$result = count($files);
return $result;
}


Some additional notes about the modification:
$abs_avatar_dir = $user_avatar_dir."/useravatars/".$member['user'];
"/useravatars/" can be changed to whatever you want.
For users who are hosted on servers who do not allow them access to php.ini, they may find that one of the settings in php.ini may be set to no value which is required for the avatar upload mod to work, they can add this line in Profile.php:
$uploaddir = $user_avatar_dir . "/useravatars/tmp/";
after this line in Profile.php:
$max_pic_size = $modSettings['avatar_max_size']*1024;
Note that the variable name "$uploaddir" MUST not be changed. However, the value of the variable can be changed to wherever you want the temporary folder to be made.

This is my first attempt in doing a modification to a mod. Please forgive me if my codes aren't optimised for speed or size. If you have any problems, please feel free to contact me and I'll try my best to solve it.
« Last Edit: May 01, 2003, 04:07:20 PM by Vampy » Logged
Pages: 1 [2] Reply Ignore Print 
YaBB SE Community  |  Development  |  Completed mods  |  [Done 1.1] Avatar Upload « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.280 seconds with 18 queries.