Welcome Guest [Log In] [Register]
Add Reply
Avatar System
Topic Started: Aug 14 2008, 10:58 PM (1,635 Views)
claudia

Sorry, fixed it. lol, I will try and find the misspelled code!
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

To be honest, the upload avatar system he implemented i assume is from the net and works, but as i said when he was altering the code to run with the login system i think he may have misspelles something im not to sure till i have a look, but Fear may beat me to it and re-post a fixed version as everyone wants this mod and its in high demand.

We will see what happens but ill check over it tomorrow anyways.


~Pc
Offline Profile Quote Post Goto Top
 
claudia

No worries! I'm just doing this for fun!
Offline Profile Quote Post Goto Top
 
claudia

Hello,

A quick suggestion and if one can give me any ideas on how to go about it or if this logic would work, what if instead of having to add the avatar during registration, one can add it during the user edit section? I tried playing around with the script and changed it , with no avail, owing to being a beginner here.

Here is what I have attempted to do:


1) add a new table called avatar, this would have the username (primary key) and also the avatar witht the default noavatar.png

2) in session.php copy the registration section but keep only what is needed in this case the avatar section...

3) update in database.php with the same function as addNewUser but called addAvatar.

4) in process.php create a function procAvatar

5) create a avatar.php form for the user to upload, or add it in the useredit.php.

6) view it in the userinfo.php

What do you guyz think?

I have another go at it any ways, the issue I think is trying to link the avatar table to the users table, when wanting to update the information on both.

Thanks

Claudia :D
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

Claudia regarding the
Quote:
 
the issue I think is trying to link the avatar table to the users table
issue you can join tables together in a mysql query that may help you out with that part, and also, Fear is re-writing this code at the weekend so you may want to wait untill then to see what he comes up with ? Upto you just a thought as he originally wrote it so he is going to revise it, fix it and release it again.


~Pc
Edited by php-coder, Dec 16 2008, 03:38 AM.
Offline Profile Quote Post Goto Top
 
claudia

Scratch that, it's not logical I think!
Offline Profile Quote Post Goto Top
 
bustya
Member Avatar
The Master Bitchslapper
I use to have my avatar upload in the edituser form, I've since changed it though. Now I have a separate form for upload handling... this is important because for a secure image upload you need to use getimagesize() function to be sure the user isn't uploading a script. I have an entire image handling package I'm going to be uploading here soon. I plan to get back to work on it today, (I've been sick the last few weeks).

It includes: Image uploading (allows a limit per user), sorting images with drag&drop, captioning images, cropping pics (drag box over image and double click), and the part I haven't finished yet... select an uploaded pic to set as avatar, that's the easy part, really, I've just been busy with Xmas and sick as well.

Oh yeah, I also altered my image serving script so that it's idiot proof... if the user breaks the url in anyway a default pic is shown instead of nothing or a PHP error. I'll be back soon to post all of this.
Offline Profile Quote Post Goto Top
 
bustya
Member Avatar
The Master Bitchslapper
Here's a sample of how the cropping script works, this url will only be good for a short time as I'm about to change it so it crops a selected user pic rather than this default (test) pic. Drag the box then double click inside the selected area.

cropping script example
Offline Profile Quote Post Goto Top
 
Admin
Administrator
bustya
Dec 16 2008, 07:12 PM
Here's a sample of how the cropping script works, this url will only be good for a short time as I'm about to change it so it crops a selected user pic rather than this default (test) pic. Drag the box then double click inside the selected area.

cropping script example
looks very nice, hopefully you can post it soon :)
Offline Profile Quote Post Goto Top
 
php-coder
Member Avatar

Hello,

this -> Add below the email checking in editaccount function:

Code:
 

/* Avatar checking */
$field = "avatar"; //Use field name for avatar
$uploaded_dir = "/home/www/iithink.freehostia.com/login/include/avatar/$this->username/";
$avatar_path = $uploaded_dir . $savatar_name;
$query = $database->getUserInfo($_SESSION['username']);
$avatar_name = $query['avatar'];
$noavatar="noavatar.png";
$myFile = "/home/www/iithink.freehostia.com/login/include/avatar/$this->username/$avatar_name";
$width = 100;
$height = 100;
$thumbsize = 100;

/* Resize Image */
list($width_orig, $height_orig) = getimagesize($savatar_tmpname);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
/* Done Resize Image */

if(empty($savatar_name)){
} else {
if(!$savatar_tmpname){
$form->setError($field, "* Avatar does not exist");
} else {
$num_char=strlen($savatar_name);
if($num_char > 20){
$form->setError($field, "* Your Avatar name has $num_char characters, the limit is 20");
} else {
if($savatar_size > 102400) {
$form->setError($field, "* Your avatar is $savatar_size, the maximum upload size is 100kb");
} else if($savatar_type == "image/jpeg"){
if($avatar_name == $noavatar){
//Delete nothing
} else {
//Delete old avatar
unlink($myFile);
}

/* Resize Image */
$image_p = imagecreatetruecolor($thumbsize, $thumbsize);
$image = imagecreatefromjpeg($savatar_tmpname);
imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);

imagejpeg($image_p, $savatar_tmpname, 100);
/* Done Resize Image */

move_uploaded_file($savatar_tmpname, "$avatar_path");
} else if($savatar_type == "image/pjpeg"){
if($avatar_name == $noavatar){
//Delete nothing
} else {
//Delete old avatar
unlink($myFile);
}

/* Resize Image */
$image_p = imagecreatetruecolor($thumbsize, $thumbsize);
$image = imagecreatefromjpeg($savatar_tmpname);
imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);

imagejpeg($image_p, $savatar_tmpname, 100);
/* Done Resize Image */

move_uploaded_file($savatar_tmpname, "$avatar_path");
} else if($avatar_type == "image/png"){
if($avatar_name == $noavatar){
//Delete nothing
} else {
//Delete old avatar
unlink($myFile);
}

/* Resize Image */
$image_p = imagecreatetruecolor($thumbsize, $thumbsize);
$image = imagecreatefrompng($savatar_tmpname);
imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);

imagepng($image_p, $savatar_tmpname, 100);
/* Done Resize Image */

move_uploaded_file($savatar_tmpname, "$avatar_path");
} else if($savatar_type == "image/gif"){
if($avatar_name == $noavatar){
//Delete nothing
} else {
//Delete old avatar
unlink($myFile);
}

/* Resize Image */
$image_p = imagecreatetruecolor($thumbsize, $thumbsize);
$image = imagecreatefromgif($savatar_tmpname);
imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);

imagegif($image_p, $savatar_tmpname, 100);
/* Done Resize Image */

move_uploaded_file($savatar_tmpname, "$avatar_path");
} else {
$form->setError($field, "* $savatar_type is wrong extension");
}
}
}
}


Is what i beleive to be the problem i have made the correct adjustments to the file if it doesnt work then ill have to re-check all the files again.. but try it and let me know.


~Pc
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Other · Next Topic »
Add Reply