|
Avatar System (Fixed - Fully working and tested)
|
|
Topic Started: Dec 18 2008, 01:28 AM (1,431 Views)
|
|
claudia
|
Dec 20 2008, 10:03 PM
Post #11
|
|
- Posts:
- 17
- Group:
- Members
- Member
- #40
- Joined:
- Dec 12, 2008
|
I think it has something to do with my own code and it's probably not working together with this code.
Edited by claudia, Dec 20 2008, 10:04 PM.
|
|
|
| |
|
bustya
|
Dec 21 2008, 03:00 AM
Post #12
|
|
The Master Bitchslapper
- Posts:
- 135
- Group:
- Admins
- Member
- #2
- Joined:
- Mar 20, 2008
|
Whoever need to convert all usernames to lowercase...
In constants.php
find:
/** * This constant forces all users to have * lowercase usernames, capital letters are * converted automatically. */ define("ALL_LOWERCASE", false);
and change it to "true"
PS: any existing members with uppercase characters will need to be changed via the DB itself. You might want to send them an email telling the as well.
Edited by bustya, Dec 21 2008, 03:02 AM.
|
|
|
| |
|
php-coder
|
Jan 20 2009, 01:01 PM
Post #13
|
|
- Posts:
- 134
- Group:
- Contributor
- Member
- #39
- Joined:
- Dec 8, 2008
|
define("ALL_LOWERCASE", false);
Also needs changing to
define("all_lowercase", true);
Being in caps kinda defeats the object 
~Pc
|
|
|
| |
|
bustya
|
Jan 21 2009, 02:39 AM
Post #14
|
|
The Master Bitchslapper
- Posts:
- 135
- Group:
- Admins
- Member
- #2
- Joined:
- Mar 20, 2008
|
@php coder... Constants should be defined in all caps, regardless of what it's defining.
- Code: HTML
-
<?php define("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. ?>
Edited by bustya, Jan 21 2009, 02:42 AM.
|
|
|
| |
|
php-coder
|
Jan 21 2009, 07:29 AM
Post #15
|
|
- Posts:
- 134
- Group:
- Contributor
- Member
- #39
- Joined:
- Dec 8, 2008
|
Thats not directly true, in some cases using Capitals will stop that specific constant from working, i've seen several people come accross this problem before.
Regards ~Pc
|
|
|
| |
|
php-coder
|
Jan 23 2009, 09:03 AM
Post #16
|
|
- Posts:
- 134
- Group:
- Contributor
- Member
- #39
- Joined:
- Dec 8, 2008
|
Ok so after a long time looking at the change avatar section of code i have come to no avail with getting it to remove the old avatar out of the Users DIR so if bustya or Fear can please take a look and tell me what they think i'd be greatfull.
- Code:
-
/* Avatar checking */ $field = "avatar"; //Use field name for avatar $uploaded_dir = "/var/www/html/test/include/avatar/$this->username/"; $avatar_path = $uploaded_dir . $avatar_name; $query = $database->getUserInfo($_SESSION['username']); $avatar_name = $query['avatar']; $noavatar = "noavatar.png"; $myFile = "/var/www/html/test/include/avatar/$this->username/$avatar_name"; $width = 100; $height = 100; $thumbsize = 100;
if(empty($avatar_name)){ } else { if(!$avatar_tmpname){ $form->setError($field, "* Avatar does not exist"); } else { $num_char=strlen($avatar_name); if($num_char > 20){ $form->setError($field, "* Your Avatar name has $num_char characters, the limit is 20"); } else { if($avatar_size > 102400) { $form->setError($field, "* Your avatar is $avatar_size, the maximum upload size is 100kb"); } else if($avatar_type == "image/jpeg"){ if($avatar_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromjpeg($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/pjpeg"){ if($avatar_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromjpeg($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/png"){ if($avatar_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefrompng($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagepng($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/gif"){ if($avatar_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */ /* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromgif($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagegif($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else { $form->setError($field, "* $avatar_type is wrong extension"); } } } }
~Pc
|
|
|
| |
|
php-coder
|
Jan 23 2009, 09:40 AM
Post #17
|
|
- Posts:
- 134
- Group:
- Contributor
- Member
- #39
- Joined:
- Dec 8, 2008
|
Hello,
Problem Solved, the new code below will now remove your Old avatar's aswell as update the database.
- Code:
-
/* Avatar checking */ $field = "avatar"; //Use field name for avatar $uploaded_dir = "/var/www/html/test/include/avatar/$this->username/"; $avatar_path = $uploaded_dir . $avatar_name; $query = $database->getUserInfo($_SESSION['username']); $ava_name = $query['avatar']; $noavatar="noavatar.png"; $myFile = "/var/www/html/test/include/avatar/$this->username/$ava_name"; $width = 100; $height = 100; $thumbsize = 100;
if(empty($avatar_name)){ } else { if(!$avatar_tmpname){ $form->setError($field, "* Avatar does not exist"); } else { $num_char=strlen($avatar_name); if($num_char > 20){ $form->setError($field, "* Your Avatar name has $num_char characters, the limit is 20"); } else { if($avatar_size > 102400) { $form->setError($field, "* Your avatar is $avatar_size, the maximum upload size is 100kb"); } else if($avatar_type == "image/jpeg"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromjpeg($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/pjpeg"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromjpeg($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/png"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefrompng($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagepng($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else if($avatar_type == "image/gif"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* Resize Image */ list($width_orig, $height_orig) = getimagesize($avatar_tmpname); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } /* Done Resize Image */
/* Resize Image */ $image_p = imagecreatetruecolor($thumbsize, $thumbsize); $image = imagecreatefromgif($avatar_tmpname); imagecopyresampled($image_p, $image, -($width/2) + ($thumbsize/2), -($height/2) + ($thumbsize/2), 0, 0, $width, $height, $width_orig, $height_orig);
imagegif($image_p, $avatar_tmpname, 100); /* Done Resize Image */
move_uploaded_file($avatar_tmpname, "$avatar_path"); } else { $form->setError($field, "* $avatar_type is wrong extension"); } } } }
|
|
|
| |
|
hansmaulwurf
|
Apr 30 2009, 09:49 AM
Post #18
|
|
- Posts:
- 10
- Group:
- Members
- Member
- #54
- Joined:
- Apr 30, 2009
|
Hi,
i'm trying to upload users avatars with this script for weeks.
but it doesn't work.
when im uploading a avatar in the useredit file, it inserts the name of the file in my database but it doesn't upload the file.
where is the problem in my code? :
here is my avatar checking:
- Code:
-
/* Avatar checking */ $field = "avatar"; //Use field name for avatar $uploaded_dir = "/include/avatar/$this->username/"; $avatar_path = $uploaded_dir . $savatar_name; $query = $database->getUserInfo($_SESSION['username']); $ava_name = $query['avatar']; $noavatar="noavatar.png"; $myFile = "/include/avatar/$this->username/$ava_name"; $width = 100; $height = 100; $thumbsize = 100; 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 $avatar_size, the maximum upload size is 100kb"); } else if($savatar_type == "image/jpeg"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); } /* 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 */ /* 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($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* 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 */ /* 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/png"){ if($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); } /* 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 */ /* 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($ava_name == $noavatar){ //Delete nothing } else { //Delete old avatar unlink($myFile); }
/* 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 */ /* 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_name, "$avatar_path"); } else { $form->setError($field, "* $avatar_type is wrong extension"); } } } }
thx hans
|
|
|
| |
|
hansmaulwurf
|
May 4 2009, 09:46 PM
Post #19
|
|
- Posts:
- 10
- Group:
- Members
- Member
- #54
- Joined:
- Apr 30, 2009
|
ok,
i solved my problem.
the folder where the avatars should be uploaded in, had the wrong chmod rights...
i dragged the folder avatar out of include...
|
|
|
| |
|
laurens
|
May 10 2009, 04:11 PM
Post #20
|
|
- Posts:
- 57
- Group:
- Contributor
- Member
- #55
- Joined:
- May 9, 2009
|
I just can't get this in my login system. When I add it other function (as email activation) does't work anymore. Please can someone sent me the AUS? I don't know where to get it..
Edited by laurens, May 10 2009, 04:12 PM.
|
|
|
| |
| 1 user reading this topic (1 Guest and 0 Anonymous)
|