Thread: TSSE 1.3.9
View Single Post
  #85  
Old 7th March 2014, 05:38
naotem's Avatar
naotem naotem is offline
Member
 
Join Date: Feb 2009
Brazil
Posts: 11
Default
Thanks for the help but it did not work.
The images in jpg and png work but are not supported in gif, tried several gif of various sizes and always shows the error:
Image processing failed
Sorry, the uploaded gif failed processing. Try resaving the image in a graphic editor. Thanx

This is my bitbucket-upload.php
PHP Code:
<?php
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
maxsysop ();
parked();
$maxfilesize 256 1024;
$imgtypes = array (null,'gif','jpg','png');
$scaleh 150// set our height size desired
$scalew 150// set our width size desired

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$file $_FILES["file"];
if (!isset(
$file) || $file["size"] < 1)
stderr("Upload failed""Nothing received!");
if (
$file["size"] > $maxfilesize)
stderr("Upload failed""Sorry, that file is too large for the bit-bucket.");
$pp=pathinfo($filename $file["name"]);
if(
$pp['basename'] != $filename)
stderr("Upload failed""Bad file name.");
$tgtfile "$bitbucket/$filename";
if (
file_exists($tgtfile))
stderr("Upload failed""Sorry, a file with the name <b>" htmlspecialchars($filename) . "</b> already exists in the bit-bucket.",false);

$size getimagesize($file["tmp_name"]);
$height $size[1];
$width $size[0];
$it $size[2];
if(
$imgtypes[$it] == null || $imgtypes[$it] != $pp['extension'])
stderr("Error""Invalid extension: <b>GIF, JPG ou PNG apenas!</b>",false);

// Scale image to appropriate avatar dimensions
$hscale=$height/$scaleh;
$wscale=$width/$scalew;
$scale=($hscale && $wscale 1) ? : ( $hscale $wscale) ? $hscale $wscale;
$newwidth=floor($width/$scale);
$newheight=floor($height/$scale);
$orig=($it==1)?@imagecreatefromgif($file["tmp_name"]): ($it==2)?@imagecreatefromjpeg($file["tmp_name"]):@imagecreatefrompng($file["tmp_name"]);
if(!
$orig)
stderr("Image processing failed","Sorry, the uploaded $imgtypes[$it] failed processing. Try resaving the image in a graphic editor. Thanx");
$thumb imagecreatetruecolor($newwidth$newheight);
imagecopyresized($thumb$orig0000$newwidth$newheight$width$height);
$ret=($it==1)?imagegif($thumb$tgtfile): ($it==2)?imagejpeg($thumb$tgtfile):imagepng($thumb$tgtfile);

$url str_replace(" ""%20"htmlspecialchars("$BASEURL/bitbucket/$filename"));
$name sqlesc($filename);
$added sqlesc(get_date_time());
if (
$_POST['public'] != 'yes' 
    
$public='"0"';
else 
    
$public='"1"';
sql_query("INSERT INTO bitbucket (owner, name, added, public) VALUES ($CURUSER[id]$name$added$public)") or sqlerr(__FILE____LINE__);
sql_query("UPDATE users SET avatar = ".sqlesc($url)." WHERE id = $CURUSER[id]") or sqlerr(__FILE____LINE__);
stderr("Success""Use the following URL to access the file: <br><b><a href=\"$url\">$url</a></b><p><a href=bitbucket-upload.php>Upload another file</a>.<br><br><img src=\"$url\" border=0><br><br>Image ". ($width=$newwidth && $height==$newheight "doesn't require rescaling":"Image rescaled from $height x $width to $newheight x $newwidth") .'.<br>Note: Your profile has been updated!',false);
}

stdhead("AVATAR Upload");
?>
<h1>AVATAR Upload</h1>
<form method="post" action="<?=$_SERVER[SCRIPT_NAME];?>" enctype="multipart/form-data">
<table border=1 cellspacing=0 cellpadding=5>
<?
$disclaimer 
"
<tr><td colspan=2 align=center><div class=alert align=justify>Disclaimer:
Do not upload unauthorized or illegal pictures. Uploaded pictures should be considered \"public domain\"; do not upload pictures you wouldn't want a stranger to have access to. Uploaded images will be scaled to 
$scaleh x $scalew
<br><br>Maximum file size: "
.number_format($maxfilesize)." bytes.</div>
"
;
if(!
is_writable("$bitbucket"))
    print(
"<tr><td class=rowhead colspan=2><div class=alert>ATTENTION: Upload directory isn't writable. Please contact the administrator about this problem!</div></tr></td>");
print(
"$disclaimer");
?>
<tr><td class=rowhead>File</td><td><input type="file" name="file" size="60"></td></tr>
<tr><td colspan=2 align=center><input type=checkbox name=public value=yes>Other users can use my avatar (It's choosable in the profile). <input type="submit" value="Upload"></td></tr>
</table>
</form>
<?
stdfoot
();
?>
Any other solution?
Reply With Quote