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
2017-04-08 15:06:51
"MicroMonkey, post: 94051":
Check line 30 and 31 (or whatever number it is, but it looks like this) in upavatar.php. I didnt test this, but I will later, but it seems logical to me. The VAR $type had multiple references, and that dont work in flash, so I assume it wouldnt work here. I used shit in case tmp was used somewhere else. I didnt feel like looking for it lol

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





[ATTACH]2477._xfImport[/ATTACH]
Capture.PNG
Capture.PNG
2017-04-08 15:10:02
try this. replace your lines 28 to 34


   if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 100);   // Define width sizes what you want.
       define("MAX_HEIGHT", 100);  // Define height sizes what you want.
       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $tmp = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($tmp));

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2017-04-08 15:17:01
"MicroMonkey, post: 94062":
try this. replace your lines 28 to 34

if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 100);   // Define width sizes what you want.
       define("MAX_HEIGHT", 100);  // Define height sizes what you want.
       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $tmp = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($tmp));




Removes the error but does not replace the image
2017-04-08 15:21:20
hmm. Make sure avatars directory is chmod 777. Here is my entire upavatar.php


<?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 = $site_config['avatar_max_filesize'];

   if ($_FILES[avatar]['size'] > $max_avatar_size)
       show_error_msg("Invalid file size!", "Image must be less than " . mksize($site_config['avatar_max_filesize']),1);


   if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 80);   // Define width sizes what you want.
       define("MAX_HEIGHT", 80);  // Define height sizes what you want.
       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $shit = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($shit));

       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'){
           $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("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("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("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("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>Reinstall 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("Upload Avatar");
begin_frame("" . T_("UP_AVATAR") . "");

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>");
  autolink("account.php?action=edit_settings&do=edit", "" . T_("AVATAR_OK") . "");
}
}



if ($action == "upload") {
   print ("<form method=post action=?action=post enctype=multipart/form-data><table align=center width=550 border=1 cellpadding=5><tr><td align=right>". T_("AVATAR_FILE") ." :</td><td><input type=file name=avatar size=60></td></tr><tr><td align=right>". T_("DISCLAIMER") ." :</td><td>". T_("AVATAR_TXT") ."".mksize($site_config['avatar_max_filesize'])."</td></tr><tr><td colspan=2 align=center><input type=submit name=Submit value='".T_("UP_AVATAR")."' class=btn></td></td></tr></table></form>");
//print ("<form method=post action=?action=post enctype=multipart/form-data><table align=center width=550 border=1 cellpadding=5><tr><td class=table_col1 align=right>". T_("AVATAR_FILE") ." :</td><td class=table_col1><input type=file name=avatar size=60></td></tr><tr><td class=table_col1 align=right>". T_("DISCLAIMER") ." :</td><td class=table_col1>". T_("AVATAR_TXT") ."</td></tr><tr><td class=table_col2 colspan=2 align=center><input type=submit name=Submit value='".T_("UP_AVATAR")."' class=btn></td></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 ("Error", "<p><font color=red>Avatar uploading, disabled bay site admin !</font></p>");
}

end_frame();
stdfoot();
?>

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2017-04-08 15:26:55
"MicroMonkey, post: 94064":
hmm. Make sure avatars directory is chmod 777. Here is my entire upavatar.php

<?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 = $site_config['avatar_max_filesize'];

   if ($_FILES[avatar]['size'] > $max_avatar_size)
       show_error_msg("Invalid file size!", "Image must be less than " . mksize($site_config['avatar_max_filesize']),1);


   if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 80);   // Define width sizes what you want.
       define("MAX_HEIGHT", 80);  // Define height sizes what you want.
       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $shit = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($shit));

       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'){
           $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("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("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("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("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>Reinstall 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("Upload Avatar");
begin_frame("" . T_("UP_AVATAR") . "");

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>");
  autolink("account.php?action=edit_settings&do=edit", "" . T_("AVATAR_OK") . "");
}
}



if ($action == "upload") {
   print ("<form method=post action=?action=post enctype=multipart/form-data><table align=center width=550 border=1 cellpadding=5><tr><td align=right>". T_("AVATAR_FILE") ." :</td><td><input type=file name=avatar size=60></td></tr><tr><td align=right>". T_("DISCLAIMER") ." :</td><td>". T_("AVATAR_TXT") ."".mksize($site_config['avatar_max_filesize'])."</td></tr><tr><td colspan=2 align=center><input type=submit name=Submit value='".T_("UP_AVATAR")."' class=btn></td></td></tr></table></form>");
//print ("<form method=post action=?action=post enctype=multipart/form-data><table align=center width=550 border=1 cellpadding=5><tr><td class=table_col1 align=right>". T_("AVATAR_FILE") ." :</td><td class=table_col1><input type=file name=avatar size=60></td></tr><tr><td class=table_col1 align=right>". T_("DISCLAIMER") ." :</td><td class=table_col1>". T_("AVATAR_TXT") ."</td></tr><tr><td class=table_col2 colspan=2 align=center><input type=submit name=Submit value='".T_("UP_AVATAR")."' class=btn></td></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 ("Error", "<p><font color=red>Avatar uploading, disabled bay site admin !</font></p>");
}

end_frame();
stdfoot();
?>




Remember he gave the error but made the change.

Now I do not make the change but I do not have the error
Unknown User
2017-04-08 15:28:49
It may be localhost the problem I will have to upload to a host, I wanted to finish first
Everything mod before uploading to a host
2017-04-08 15:30:17
I had some trouble with this also, and it was user permissions. www-data has the apache2 permissions while a user not in that group would not be able to write to the file. Its a mess lol. Im still having troubles on my end with group permissions on my ubuntu server
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2017-04-08 15:33:41
one thing I did to fix most of my issues was chown the whole site to www-data by executing the following on ubuntu.

sudo chown -R www-data:www-data /var/www/site folder


the only downside to this is I am not able to FTP files without changing the owner to my FTP user
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2017-04-08 15:33:54
I have windows
Unknown User
2017-04-08 15:35:00
"MicroMonkey, post: 94067":
I had some trouble with this also, and it was user permissions. www-data has the apache2 permissions while a user not in that group would not be able to write to the file. Its a mess lol. Im still having troubles on my end with group permissions on my ubuntu server


still do not understand why it behaves that way, it is supposed to work as a host
Unknown User
2017-04-08 15:42:56
"MicroMonkey, post: 94067":
I had some trouble with this also, and it was user permissions. www-data has the apache2 permissions while a user not in that group would not be able to write to the file. Its a mess lol. Im still having troubles on my end with group permissions on my ubuntu server


And found the problem

if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 100);   // Define width sizes what you want.
       define("MAX_HEIGHT", 100);  // Define height sizes what you want.
       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $tmp = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($tmp));


add:

if (preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[avatar]['name'])){
       define("MAX_WIDTH", 100);   // Define width sizes what you want.
       define("MAX_HEIGHT", 100);  // Define height sizes what you want.

       $avatar_dir = "".str_replace("\\","/",getcwd())."".$site_config['avatar_dir']."";
       $avatar_url = "".$site_config['SITEURL']."".$site_config['avatar_dir']."";
       $tmp = explode('.', $_FILES[avatar]['name']);
       $type = strtolower(end($tmp));


Everything was for a space that did not have lol

But your code was correct
2017-04-08 15:44:11
well . Thats odd lol. I will try that then. Now im completely confused
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2017-04-08 15:58:15
"MicroMonkey, post: 94074":
well . Thats odd lol. I will try that then. Now im completely confused


 
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