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] User Upload BitBucket
Controls ·  Search New posts · Mark unread

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

Unknown User
2009-02-13 16:07:51
create a page called bitbucket-upload.php

<?

require_once("backend/functions.php");

dbconn(false);

loggedinonly();

$maxfilesize = 256 * 1024;

$imgtypes = array (null,'gif','jpg','png');

$scaleh = 250; // set our height size desired

$scalew = 250; // set our width size desired

if ($_SERVER["REQUEST_METHOD"] == "POST")

{

$file = $_FILES["file"];

if (!isset($file) || $file["size"] < 1)

show_error_msg("Upload failed", "Nothing received!");

if ($file["size"] > $maxfilesize)

show_error_msg("Upload failed", "Sorry, that file is too large for the bit-bucket.");

$pp=pathinfo($filename = $file["name"]);

if($pp['basename'] != $filename)

show_error_msg("Upload failed", "Bad file name.");

$tgtfile = "bitbucket/$filename";

if (file_exists($tgtfile))

show_error_msg("Upload failed", "Sorry, a file with the name <b>" . htmlspecialchars($filename) . "</b> already exists in the bit-bucket.");

$size = getimagesize($file["tmp_name"]);

$height = $size[1];

$width = $size[0];

$it = $size[2];

if($imgtypes[$it] == null || $imgtypes[$it] != $pp['extension'])

show_error_msg("Error", "Invalid extension: <b>GIF, JPG or PNG only!</b>");

// Scale image to appropriate avatar dimensions

$hscale=$height/$scaleh;

$wscale=$width/$scalew;

$scale=($hscale < 1 && $wscale < 1) ? 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)

show_error_msg("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, $orig, 0, 0, 0, 0, $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"));

show_error_msg("Success", "Use the following URL to access the file: <b><a href=\"$url\">$url</a></b><p><a href=bitbucket-upload.php>Upload another file</a>.<br>Image ". ($width=$newwidth && $height==$newheight ? "doesn't require rescaling":"Image rescaled from $height x $width to $newheight x $newwidth") .'.');

}

stdhead("Bit-bucket upload");

begin_frame("Bit-bucket upload");

?>

<h1>Bit-bucket upload</h1>

<form method=post enctype="multipart/form-data">

<p><b>Maximum file size: <?=number_format($maxfilesize); ?> bytes.</b></p>

<table border=1 cellspacing=0 cellpadding=5>

<tr><td class=rowhead>Upload file</td><td><input type=file name=file size=60></td></tr>

<tr><td colspan=2 align=center><input type=submit value="Upload" class=btn></td></tr>

</table>

</form>

<p>

<table class=main width=410 border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>

<font class=small><b>Disclaimer:</b> 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 ?></font>

</td></tr></table>

<?

end_frame();

stdfoot();

?>

if any problems please let me know

P.S create a folder in your sites root dir and call it bitbucket and chmod to 0777
Unknown User
2009-02-13 19:09:33
this was done already. i dont know if it is anyway different from this mod dj done but it works jst the same i think

[url="http://www.torrenttrader.org/index.php?showtopic=9798&hl=image+storage"]http://www.torrenttrader.org/index.php?sho...l=image+storage[/url]
Unknown User
2009-02-13 19:15:12
this one doesn't require a database so its lighter on the mysql

thats probs the only difference
Unknown User
2009-02-13 19:17:53
"klonoa2, post: 53758":
create a page called bitbucket-upload.php


<?

require_once("backend/functions.php");

dbconn(false);

loggedinonly();

$maxfilesize = 256 * 1024;

$imgtypes = array (null,'gif','jpg','png');

$scaleh = 250; // set our height size desired

$scalew = 250; // set our width size desired

if ($_SERVER["REQUEST_METHOD"] == "POST")

{

$file = $_FILES["file"];

if (!isset($file) || $file["size"] < 1)

show_error_msg("Upload failed", "Nothing received!");

if ($file["size"] > $maxfilesize)

show_error_msg("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))

show_error_msg("Upload failed", "Sorry, a file with the name <b>" . htmlspecialchars($filename) . "</b> already exists in the bit-bucket.");

$size = getimagesize($file["tmp_name"]);

$height = $size[1];

$width = $size[0];

$it = $size[2];

if($imgtypes[$it] == null || $imgtypes[$it] != $pp['extension'])

show_error_msg("Error", "Invalid extension: <b>GIF, JPG or PNG only!</b>");

// Scale image to appropriate avatar dimensions

$hscale=$height/$scaleh;

$wscale=$width/$scalew;

$scale=($hscale < 1 && $wscale < 1) ? 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, $orig, 0, 0, 0, 0, $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"));

show_error_msg("Success", "Use the following URL to access the file: <b><a href=\"$url\">$url</a></b><p><a href=bitbucket-upload.php>Upload another file</a>.<br>Image ". ($width=$newwidth && $height==$newheight ? "doesn't require rescaling":"Image rescaled from $height x $width to $newheight x $newwidth") .'.');

}

stdhead("Bit-bucket upload");

begin_frame("Bit-bucket upload");

?>

<h1>Bit-bucket upload</h1>

<form method=post enctype="multipart/form-data">

<p><b>Maximum file size: <?=number_format($maxfilesize); ?> bytes.</b></p>

<table border=1 cellspacing=0 cellpadding=5>

<tr><td class=rowhead>Upload file</td><td><input type=file name=file size=60></td></tr>

<tr><td colspan=2 align=center><input type=submit value="Upload" class=btn></td></tr>

</table>

</form>

<p>

<table class=main width=410 border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>

<font class=small><b>Disclaimer:</b> 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 ?></font>

</td></tr></table>

<?

end_frame();

stdfoot();

?>

if any problems please let me know

P.S create a folder in your sites root dir and call it bitbucket and chmod to 0777


Fatal error: Call to undefined function stderr() in /home/admin/domains/place2bscene.co.uk/public_html/bitbucket-upload.php on line 42
Unknown User
2009-02-13 19:48:06
stderr("Upload failed", "Bad file name.");

just change to

show_error_msg("Upload failed", "Bad file name.");

it worked fine on mine so thought i would post but thought there whould be one bug or 2

also do same with

stderr("Image processing failed","Sorry, the uploaded $imgtypes[$it] failed processing. Try resaving the image in a graphic editor. Thanx");

to

show_error_msg("Image processing failed","Sorry, the uploaded $imgtypes[$it] failed processing. Try resaving the image in a graphic editor. Thanx");

and i will change them in first post

thanks daffy
Unknown User
2009-02-13 20:33:11
it must be

show_error_mess("....",".....",1)
Unknown User
2009-02-13 21:09:29
iv changed show_erre_msg to show_error_mess  tried 4 diff gifs and its sayign not supported please try lol gif.png or jpg i prefer dj's version to be honest you get to view what you have uploaded and also see what you have uploaded too. thanks anyway.
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