Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[ADDON] Upload Avtar
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2012-08-02 16:28:39
hello,

the uploder does not upload .jpg files to the avatars dir but it does upload .png files.

what can be the problem or am i over looking somthing

my folder are cmod to 777 and everthing is supportd in the GD

gd

GD Support enabled

GD Version 2.0

FreeType Support enabled

FreeType Linkage with freetype

FreeType Version 2.3.11

T1Lib Support enabled

GIF Read Support enabled

GIF Create Support enabled

JPEG Support enabled

libJPEG Version 6b

PNG Support enabled

libPNG Version 1.2.42

WBMP Support enabled

Tanks
Unknown User
2012-08-02 18:42:26
my guess they might be .jpeg and not .jpg i have seen that alot with pictures.

in upavatar.php

change



if (preg_match('/^(.+).(jpg|gif|png)$/si', $_FILES[avatar]['name'])){




to







if (preg_match('/^(.+).(jpg|gif|png|jpeg)$/si', $_FILES[avatar]['name'])){

Unknown User
2012-08-03 05:16:34
ArticWolf

i did change the line but stillno luck

any thing else i can try
Unknown User
2012-08-03 17:37:20
lol suxs to be you i guess... maybe its .JPG rofl case matters on linux.

none ever puts what os, server they trying stuff on so oh well...
Unknown User
2012-08-03 23:54:52
I have the same problem, gifs upload fine as well as png's it just seems to be jpg's

I have tried renaming the extension to  jpg, JPG, jpeg And even JPEG but still not uploading image to server.

Dedicated Server.

TT 2.08

Apache version 2.2.21

linux  2.6.18-238.19.1.el5

PHP version 5.3.8

MySQL version 5.1.63-cll
Unknown User
2012-08-04 00:53:01
my guess your system has an issue with

 $nimage = imagecreatefromjpeg($_FILES[avatar]['tmp_name']);
Unknown User
2012-08-04 02:25:57
ah i see the issue i think:) seems newer os changed the name from JPG to JPEG

this new file attached fixes that issue, I tested on  Debian 6.0.5 (Linux 3.2.13-grsec-xxxx-grs-ipv6-32)

its for  2.08 so people lower versions will have to change the language stuff back...

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=5919"]upavatar.php[/url]
upavatar.php
Download
Unknown User
2012-08-05 01:26:54
Tested and working. Thanks again Arcticwolf  EDIT: hhmm seams i spoke too soon, it uploaded once then i tried another image and still wont work  :(



PHP Warning:  imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: gd-jpeg: JPEG library reports unrecoverable error:  in /var/home/xxxx/public_html/upavatar.php on line 51

[05-Aug-2012 08:50:04] PHP Warning:  imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: '/tmp/phpQJ1uSR' is not a valid JPEG file in /var/home/xxxx/public_html/upavatar.php on line 51

[05-Aug-2012 08:50:04] PHP Warning:  imagecopyresampled() expects parameter 2 to be resource, boolean given in /var/home/xxxx/public_html/upavatar.php on line 52

Unknown User
2012-08-05 10:58:49
It may be this section



if ($type == 'png' OR $type == 'gif' OR $type == 'jpg' OR $type == 'jpeg'){

   $avatar = $CURUSER[id] . "." . $type;

   if (($type == 'jpg' OR $type == 'jpeg') AND ($gdinfo['JPG Support'] OR $gdinfo['JPEG Support']) ){

   $nimage = imagecreatefromjpeg($_FILES[avatar]['tmp_name']);

   imagecopyresampled($tmp_image, $nimage, 0, 0, 0, 0, $n_w, $n_h, $width, $height);

   if (!imagejpeg($tmp_image, $avatar_dir . "/" . $avatar))

   show_error_msg(T_("ERROR"), "Error, uploading JPG files type. <br>Maybe your GD library not support JPG",1);

   }



try removing the gif + png parts from this particular part
Unknown User
2012-08-08 07:46:41
Yeah tried that but then png's and gif's don't work, i just let my users know they can't upload jpg's, they can live with it :lol:
Unknown User
2012-08-08 12:14:54
lol over next couple of days i should have some time spare so i will take a look what i can do.
Unknown User
2012-08-08 21:36:51
only time i ever seen that bug with image upload is when an image is really not an .jpg but an .bmp or .png just renamed to an .jpg that might be your issue.
Unknown User
2012-08-09 08:23:15
"ArcticWolf, post: 84614":
only time i ever seen that bug with image upload is when an image is really not an .jpg but an .bmp or .png just renamed to an .jpg that might be your issue.

yeah could be, who knows whats been done with these images that are on the net these days lol
Unknown User
2012-10-14 16:19:18
ADAPTED TO V2.8

LANGUAGE.PHP

[spoiler]


$LANG["IMAGE_AVATAR"] = "Image";

$LANG["TXT_AVATAR"] = "<b>Do not upload unauthorized or illegal pictures</b>.<br>You avatar will be automatically resized to <b>80x80</b>px.<br>Maximum file size must be <b>500</b>kb.";



/// START UPLOAD AVATAR ///

define("UP_AVATAR", "Upload Avatar");

define("AVATAR_LINC", "Link to your avatar image");

define("NO_AVATAR", "<font color=red><b>Error</b></font><br><br> You have not specified a avatar file! <br><br> Back to ");

define("AVATAR_OK", "You have successfull updated your avatar! <br><br>Back to ");

/// END UPLOAD AVATAR ///



?>

[/spoiler]





ACCOUNT.PHP



[spoiler]


/// START UPLOAD AVATAR ///

if ($site_config['AVATARUPLOAD']){

   $avatar = htmlspecialchars($CURUSER["avatar"]);

   if (!$avatar)

       $avatar = "".$site_config["SITEURL"]."/images/default_avatar.gif";



   print("<tr><td align=right class=table_col2><B>" . AVATAR . ":</b></td><td align=left class=table_col1><table border=0><tr><td rowspan=2 width=90><img src=$avatar></td><td><input name=avatar size=50 value="" . htmlspecialchars($CURUSER["avatar"]) . ""><br />n<i>" . AVATAR_LINC . ": 80x80px</i></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ <a href=upavatar.php?action=upload><b>" . UP_AVATAR . "</b></a> ]</td></tr></table></td></tr>");

}

else{

print("<TR><TD align=right class=table_col2><B>" . AVATAR_URL . ":</b> </td><TD align=left class=table_col2><input name=avatar size=50 value="" . htmlspecialchars($CURUSER["avatar"]) . ""><br />n<i>" . AVATAR_LINC . ": 80x80px</i></td></tr>");

}

/// END UPLOAD AVATAR ///


[/spoiler]





UPAVATAR.PHP



[spoiler]


<?php

////////////////////////////////////////

//  TorrentTrader v2.x

//  http://www.torrenttrader.org

//

//  Upload Avatar

//  Author: Skayver

//

//  Date: 13/11/2007

///////////////////////////////////////



require_once ("backend/functions.php");

dbconn();

loggedinonly();

$action = $_REQUEST["action"];



if ($site_config['AVATARUPLOAD']){



if (!($_FILES[avatar]['name'] == "")) {

   $max_avatar_size = 768000;



   if ($_FILES[avatar]['size'] > $max_avatar_size)

   show_error_msg("Invalid file size!", "Image must be less than " . mksize($max_avatar_size),1);



   if (preg_match('/^(.+).(jpg|gif|png|jpeg)$/si', $_FILES[avatar]['name'])){

   define("MAX_WIDTH", 90);   // Define width sizes what you want.

   define("MAX_HEIGHT", 90);  // Define height sizes what you want.

   $avatar_dir = "".str_replace("","/",getcwd())."".$site_config['avatar_dir']."";

   $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";

   $type = strtolower(end(explode('.', $_FILES[avatar]['name'])));



   if (extension_loaded('gd')){

   $gdinfo = gd_info();

   list($width, $height) = getimagesize($_FILES[avatar]['tmp_name']);

   $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);



   if ($scale < 1) {

   $n_w = floor($scale*$width);

   $n_h = floor($scale*$height);

   }

   else{

   $n_w = $width;

   $n_h = $height;

   }



   $tmp_image = imagecreatetruecolor($n_w, $n_h);



   if ($type == 'png' OR $type == 'gif' OR $type == 'jpg' OR $type == 'jpeg'){

   $avatar = $CURUSER[id] . "." . $type;

   if (($type == 'jpg' OR $type == 'jpeg') AND ($gdinfo['JPG Support'] OR $gdinfo['JPEG Support']) ){

   $nimage = imagecreatefromjpeg($_FILES[avatar]['tmp_name']);

   imagecopyresampled($tmp_image, $nimage, 0, 0, 0, 0, $n_w, $n_h, $width, $height);

   if (!imagejpeg($tmp_image, $avatar_dir . "/" . $avatar))

   show_error_msg(T_("ERROR"), "Error, uploading JPG files type. <br>Maybe your GD library not support JPG",1);

   }



   if ($type == 'gif' and $gdinfo['GIF Create Support']){

   if ($scale < 1) {

   $nimage = imagecreatefromgif($_FILES[avatar]['tmp_name']);

   imagecopyresampled($tmp_image, $nimage, 0, 0, 0, 0, $n_w, $n_h, $width, $height);

   if (!imagegif($tmp_image, $avatar_dir . "/" . $avatar))

   show_error_msg(T_("ERROR"), "Error, uploading GIF files type. <br>Maybe your GD library not support GIF Create",1);

   }

   else{

   if (!move_uploaded_file($_FILES[avatar]['tmp_name'], $avatar_dir . "/" . $avatar))

   show_error_msg(T_("ERROR"), "Error, moving uploaded GIF file.",1);

   }

   }



   if ($type == 'png' and $gdinfo['PNG Support'] == 1 ){

   $nimage = imagecreatefrompng($_FILES[avatar]['tmp_name']);

   imagecopyresampled($tmp_image, $nimage, 0, 0, 0, 0, $n_w, $n_h, $width, $height);

   if (!imagepng($tmp_image, $avatar_dir . "/" . $avatar))

   show_error_msg(T_("ERROR"), "Error, uploading PNG files type. <br>Maybe your GD library not support PNG",1);

   }

   SQL_Query_exec("UPDATE users SET avatar = '$avatar_url/$avatar' WHERE username = '$CURUSER[username]'");

   }

   }

   else { show_error_msg("PHP - Error", "PHP on your server, not support GD library. <br>Reinstal your PHP with support GD",1); }

   }

   else {

   write_log("<b>HACKING ATTEMPT !!! </b>- User <b>" . $CURUSER["username"] . "</b> try to upload avatar file: <b>" . $_FILES[avatar]["name"] . "</b>");

   show_error_msg("Invalid type", "Is not allowed type file: (" . $_FILES[avatar]["name"] .")",1);

   }

}



stdhead(T_("UP_AVATAR"));

begin_frame(T_("UP_AVATAR"), center);



if ($action == "post") {

   if (empty($_FILES[avatar]['tmp_name'])){

   print ("<br><p><center>" . T_("NO_AVATAR") . "<a href=upavatar.php?action=upload><b>".T_("UP_AVATAR")."</b></a></center></p>");

   }

   else{

   print ("<br><p><center>" . T_("AVATAR_OK") . "<a href=account.php?action=edit_settings&do=edit><b>" . T_("ACCOUNT") . "</b></a></center></p>");

   }

}



if ($action == "upload") {

   print ("<form method=post action=?action=post enctype=multipart/form-data><table width=550 border=0><tr><td>". T_("IMAGE_AVATAR") ."</td><td><input type=file name=avatar size=60></td></tr><tr><td>". DISCLAIMER .":</td><td><table width=99%><td>" . T_("TXT_AVATAR") . "</td><td align=right colspan=4><input type=submit class=btn name=Submit value=".UPLOAD." class=btn></td></table></td></tr></table></form>");

}



if (!$action == "post" OR !$action == "upload") {

   write_log("<b>HACKING ATTEMPT !!! </b>- User <b>" . $CURUSER["username"] . "</b> tries to direct access to upavatar.php");

   print ("<br><p><center><b>Direct access not allowed !!!</b></p><p>Go to: <a href=account.php?action=edit_settings&do=edit><b>" . T_("ACCOUNT") . "</b></a></center></p><br>");

}

}

else{

   stdhead("ERROR !");

   write_log("<b>HACKING ATTEMPT !!! </b>- User <b>" . $CURUSER["username"] . "</b> tries to upload avatar !");

   show_error_msg (T_("ERROR"), "<p><font color=red>Avatar uploading, disabled by site admin !</font></p>");

}



end_frame();

stdfoot();

?>

[/spoiler]
2013-04-06 14:29:15
Thanks you!! :)
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728