SRL Archive - News and General

Release of File Uploader


Harry

2008-09-26 12:41:47

Try it out :D
http://www.hy71194.mgatesphoto.com/files/index.php
Have fun! :D

~ Hy71194

Sause/"Source" : http://www.srl-forums.com/forum/showpost.php?p=503145&postcount=33

MylesMadness

2008-09-26 13:12:37

Mines better :p
http://www.pspsquare.com/upload/

Buckleyindahouse

2008-09-26 16:16:18

From: Mylesmadness
Mines better :p
http://www.pspsquare.com/upload/

You have smaller upload limits.

MylesMadness

2008-09-26 16:27:09

From: Buckleyindahouse
You have smaller upload limits.
We have the same. But, just to be better I will increase it by one. Count it! One kb

PvH

2008-09-26 16:30:51

Timer made one too..
Why is everyone making themm *sigh*
Anyways.. looks nice.. but 1mb upload is.. kinda small:p

PvH

MylesMadness

2008-09-26 16:34:00

What do you think is a good size

Infantry001

2008-09-26 16:38:22

1 gig or two :/

mixster

2008-09-26 16:45:53

From: Mylesmadness
What do you think is a good size

6~7 inches.

Someone upload loads of illegal images to it and get Hy's site removed pl0x :)

Markus

2008-09-26 16:50:32

Someone who can make a 15gb upload? :D

MylesMadness

2008-09-26 17:09:01

From: Markus
Someone who can make a 15gb upload? :D
15 gigs, that would fill my server in less then one upload.

Heavenzeyez1

2008-09-26 17:12:33

Nice job!
I need this thing really often.
~Eerik~

MylesMadness

2008-09-26 17:41:11

My uploader increased to 50 mb per upload

Heavenzeyez1

2008-09-26 17:44:34

From: Mylesmadness
My uploader increased to 50 mb per upload


Ouch, it's really good!
Don't you think that your server might crash now? :rolleyes:
~Eerik~

MylesMadness

2008-09-26 19:07:30

From: heavenzeyez1
Ouch, it's really good!
Don't you think that your server might crash now? :rolleyes:
~Eerik~
As long as you don't use it like crazy like game client hosting it should be fine.

MylesMadness

2008-09-26 19:09:48

From: heavenzeyez1
Ouch, it's really good!
Don't you think that your server might crash now? :rolleyes:
~Eerik~
As long at its not like posted everywhere it should be fine

Edit: Decreased to 8 mb because the setting in my server were a max of 8 mb anyway

Harry

2008-10-07 19:11:22

/me uploads a lot of spammy images to Myles's.. just kidding :p, but seriously Myles, made/put in a CAPTCHA please? ;)

And PvH, Timers was a rip form copyrighted work; he just removed the copyright and claimed as his own. Mine is hard work ;O

And sowwy for semi-gravedig, my PC is a bit 'grounded' from me :redface:

noidea

2008-10-07 19:14:38

What for Hy :eek:

MylesMadness

2008-10-07 19:31:50

Yeah, The only reason I didn't get timer in trouble for the stealing of his template and upload was my hosting would die as well.

Swift

2008-10-08 09:00:08

Just make sure that you guys are monitoring the files being uploaded. :)

ConneX

2008-10-08 11:01:47

I know better :P
http://imuri.viive.fi/upload/index.php
I mean faster.

Negaal

2008-10-08 11:43:04

@ConneX, because you live in Finland -.-, and server places at finland aswell.

Have to say it could be done better. 1 thing I really don't like is the link with filename as random string..

Better add it to original filename. like filename_fd5igs6.exe. The whole thing could be done lot better, also bit unsafe.

Try messing this, you can improve a lot with this script.

Scaper

2008-10-08 15:28:40

ok so if i upload a file how do i get iit back when i want it>???

any 1 help please??

MylesMadness

2008-10-08 15:45:35

From: Scaper
ok so if i upload a file how do i get iit back when i want it>???

any 1 help please??
With mine is spits out a link after the file is uploaded

Harry

2008-10-10 18:44:23

From: Mylesmadness
Mines better :p
http://www.pspsquare.com/upload/


From: Mylesmadness
My uploader increased to 50 mb per upload


From: Mylesmadness
With mine is spits out a link after the file is uploaded


Stop advertising yours on my thread please :<

Annnnd..mine puts out the link too Scaper -.- Look at the bottom of the page ?? The big blue URL ??

gl3nni

2008-10-10 20:58:12

ROfl, lets advertise for porn too :D

Harry

2008-10-10 21:24:07

From: gl3nni
ROfl, lets advertise for porn too :D


Would not be cool.

MylesMadness

2008-10-11 20:00:39

It not so much as I'm advertising, its removing popularity from yours

Harry

2008-10-13 16:50:56

Same thing Myles ;O

And Updated, looks a lot nicer, works a lot nicer, and is just leetness++; :)

fastler

2008-10-14 14:50:43

Thats nice and all but is this just a "Here use my file uploader!"? or is someone going to show some source so we can all learn some php?
I kinda made one myself but I'd like to see some amazing ideas that other people came up with…
*whistles* no I'm not trying to steal source (JK I won't…)

Harry

2008-10-18 18:33:00

From: fastler
Thats nice and all but is this just a "Here use my file uploader!"? or is someone going to show some source so we can all learn some php?
I kinda made one myself but I'd like to see some amazing ideas that other people came up with…
*whistles* no I'm not trying to steal source (JK I won't…)


Uuuh, kinda :) I am keeping the source secret, at least for now.

Raskolnikov

2008-10-18 18:39:25

:(


Oh well open source is awesome communism :p

Please release the source!

Ontopic: This really helps. Now I can have a seperate server to put my scripts on!

Cut em2 it

Swift

2008-10-18 19:23:14

I tried to upload a .rar earlier, it wouldn't take it though…

Harry

2008-11-22 22:47:11

C-C-Combobreaker.

Anyways Swift, the upload probably timed out, or it was too big.

Any here's the source anyways >_< Don't bash it or find my bugs and abuse them :p
[php]
<?php

// Define your reCAPTCHA public/private keys here.
$r_public = "GET YOUR OWN RECAPTCHA KEY";
$r_private = "GET YOUR OWN RECAPTCHA KEY";

// Paths for stuff.
$file_path = "./upload"; // Do not touch
$IP_ADDR = $_SERVER['REMOTE_ADDR']; // Gets IP Address of user
$CONTACT_LOC = "http://hy71194.mgatesphoto.com/contact.php"; // Full location to PHP contact script. OR mailto:[your email address].


/////////////////
// – End Setup –//
/////////////////

// Path/filename of the reCAPTCHA library.
require_once "recaptcha/recaptchalib.php";

// Generates a string of n characters in length.
function genString($length = 4)
{
// This holds the generated string.
$str = "";

// These are the characters we will allow in a filename.
$charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

// Filenames can't be less than this many characters in length.
if ($length < 1)
{
$length = 1;
}

// Generate each character in the string.
for ($i = 0; $i < $length; $i++)
{
$pos = mt_rand(0, strlen($charset));
$str .= $charset{$pos};
}

return $str;
}

// Checks to make sure file type is one of the allowed mime-types.
// Returns true if type is okay, false otherwise.
function checkMime($m_type)
{
// Define a list of mime types that we will allow.
$allowed_types = array(
"image/gif", // GIF Image
"image/jpeg", // JPEG Image
"image/png", // PNG Image
"audio/mpeg", // MP3 Audio
"audio/mp4", // MP4 Audio
"audio/wav", // WAV Audio
"video/mp4", // MP4 Video
"audio/3gpp", // 3GP [mobile content] Audio
"video/3gpp", // 3GP Video
"application/x-rar-compressed", // WinRAR Archive
"application/zip", // WinZip archive
"application/x-shockwave-flash", // SWF
"text/x-java", // JAVA file
"text/plain", // Text file
"application/msword", // MS Word file
"application/pdf", // pdf document
"application/x-bittorrent", // bittorrent files
"unknown/unknown" // .SCAR files [possibably unsafe!?]
); // Any other suggestions?! ;D

// Is the uploaded file's mime type okay?
if (in_array($m_type, $allowed_types))
{
return true;
}
else
{
return false;
}
}

function allowedIP($IP_ADDR)
{
// Define a list of mime types that we will allow.
$blocked_types = array(
"74.208.16.54"
);

if (in_array($IP_ADDR, $blocked_types))
{
return false;
}
else
{
return true;
}
}

// Validates a reCAPTCHA
// returns true on success, false otherwise.
function validateCaptcha($priv_key)
{
$r_resp = recaptcha_check_answer($priv_key,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($r_resp->is_valid)
{
return true;
}
else
{
return false;
}
}

// Uploads (moves) a file to a specified location.
function uploadFile($real_file, $tmp_file, $location)
{
if (move_uploaded_file($tmp_file, $location . "/" . $real_file))
{
return true;
}
else
{
return false;
}
}

// Before we do anything, check to make sure that the upload path exists.
if (!file_exists($file_path))
{
die("<strong>" . $file_path . "</strong> doesn't exist. Please create it?");
}
// Is the file path readable?
if (!is_readable($file_path))
{
die("<strong>" . $file_path . "</strong> isn't readable. Please check your permissions.");
}
// Is the file path writable?
if (!is_writable($file_path))
{
die("<strong>" . $file_path . "</strong> isn't writable. Please check your permissions.");
}
$ip_check = (allowedIP($IP_ADDR) === true) ? "OK": "FAILED";
if ($ip_check != "OK")
{
die("<strong>Your IP address, ". $IP_ADDR .", is blocked from using this program.<br>Please <a href=$CONTACT_LOC>contact me</a> if you think you that have reatched this in error.</strong>");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Simple File Uploader by Hy71194</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META NAME="Description" CONTENT="Quick and easy file uploader tool by Hy71194">
</head>
<body>

<?php
if (isset($_POST) && !empty($_FILES))
{
// Check the reCAPTCHA input
$c_check = (validateCaptcha($r_private) === true) ? "OK": "FAILED";

// Get the extension of the uploaded file. This will be appended to the filename.
$ext = strtolower(substr($_FILES['image_file']['name'], strrpos($_FILES['image_file']['name'], '.') + 1));

// Our new generated filename.
$new_filename = $_FILES['image_file']['name'] . $IP_ADDR . genString() . "." . $ext;

// Check to see if the file's mime type is valid.
$m_check = (checkMime($_FILES['image_file']['type']) === true) ? "OK" : "FAILED";

// Double-check that their IP is allowed.
$ip_check = (allowedIP($IP_ADDR) === true) ? "OK": "FAILED";

echo "<div class=\"status\">";
echo "Original filename: " . $_FILES['image_file']['name'] . "<br>";
echo "Random filename: " . $new_filename . "<br>";
echo "Mime-type: " . $_FILES['image_file']['type'] . " - Result: " . $m_check . "<br>";
echo "reCAPTCHA answer: " . $c_check . "<br>";
echo "IP Address Allowed: " . $ip_check ."<br><br>";

// Attempt to move the uploaded file if the checks above are successful.
if ($m_check == "OK" && $c_check == "OK" && $ip_check == "OK")
{
$result = uploadFile($new_filename, $_FILES['image_file']['tmp_name'], $file_path);
$upload_status = ($result === true) ? "OK" : "FAILED" ;
echo "<span style='font-size:14.0pt;font-family:Tahoma'><b>The upload was a success!</span><br> View your file here..: <a href=\"http://www.hy71194.mgatesphoto.com/files/upload/$new_filename\">http://www.hy71194.mgatesphoto.com/files/upload/$new_filename</a><br/></b>";
echo "<a href=\"$_SERVER[PHP_SELF]\">Click here if you want to upload more files :)</a>\n";
}
else
{
echo "<span style='font-size:14.0pt;font-family:Tahoma'><br>File upload <b>Failed!</b>…</span> <br>Look at the four lines above and make sure you: <br><b> 1.) </b>Have an allowable file type? (look back for all allowed types; if you need a different mime-type allowed, please contact me) <br><b> 2.) </b>You answered the CAPTCHA correctly?, <br><b> 3.) </b>That your file size is not too large to be uploaded here, and <br><b> 4.) </b>Your IP address is not blocked.<br><br>";
echo "<a href=\"$_SERVER[PHP_SELF]\">Click here to retry.</a><br>";
echo "If you still need assistance, please <a href=$CONTACT_LOC>contact me</a>.<br>";
}
echo "</div>";
}
else
{
?>
<span style='font-size:24.0pt;font-family:Tahoma'>Simple File Uploader by Hy71194</span><br><br>
<span style='font-size:12.3pt;font-family:Tahoma'>
Upload a file, and this script will generate a random filename for it, and host it on this server.<br>
Maximum allowed file size is <b>50MB</b> (52,428,800 bytes)<br>
<b>Allowed file types:</b> *.png, jpg, png, mp3, mp4, 3gp, rar, zip, swf, java, txt, doc, pdf, torrent, scar<br><br>
<b>Browse for, select, and then upload your file!</b><br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value=" 52428800" />
<input type="file" name="image_file" size="35" />
<?php echo recaptcha_get_html($r_public); ?>
<input type="submit" name="submit" value="Click here to Upload your file!" /><br>By uploading a file here, you agree to the Terms of Service found <a href="http://www.hy71194.mgatesphoto.com/files/ToS.html">here</a>.
</form><br>
<?
}
?>
</body>
</span>
</html>
<br><iframe Longdesc="HitCounter" width="100%" scrolling=auto style="border:0" src="http://www.hy71194.mgatesphoto.com/index.html" target="_parent"><br><b>Please download a browser that supports iframes, such as <a href="http://www.firefox.com">Mozilla Firefox</a>.</b><noscript><br>Please also enable Javascript to view most sites correctly.</iframe>
[/php]
Enjoy ;)

Nava2

2009-02-09 18:41:49

Gravedigg, but the sauce was useful.

So I think its okay :)

infested999

2009-02-09 18:44:30

How fast is the download?

Da 0wner

2009-02-09 20:10:42

Lol wtf rickroll xD

Nava2

2009-02-09 23:41:48

I more or less bumped for the sauce. Hy is kinda a jerk for rickrolling.. :(

Da 0wner

2009-02-10 01:18:52

Heheh, yea.

Scaper

2009-04-01 19:47:41

ummm hope this isnt a grave dig but anyway i came back here through your sig

well i need the source again but it is hosted on srl server please can you pm me the source please


EDIT:

Nevermind just if i read the thread before posting :s

Harry

2009-04-01 19:48:52

From: Scaper
ummm hope this isnt a grave dig but anyway i came back here through your sig

well i need the source again but it is hosted on srl server please can you pm me the source please

I lol'd..
From: Harry
C-C-Combobreaker.

Anyways Swift, the upload probably timed out, or it was too big.

Any here's the source anyways >_< Don't bash it or find my bugs and abuse them :p
[php]
<?php

// Define your reCAPTCHA public/private keys here.
$r_public = "GET YOUR OWN RECAPTCHA KEY";
$r_private = "GET YOUR OWN RECAPTCHA KEY";

// Paths for stuff.
$file_path = "./upload"; // Do not touch
$IP_ADDR = $_SERVER['REMOTE_ADDR']; // Gets IP Address of user
$CONTACT_LOC = "http://hy71194.mgatesphoto.com/contact.php"; // Full location to PHP contact script. OR mailto:[your email address].


/////////////////
// – End Setup –//
/////////////////

// Path/filename of the reCAPTCHA library.
require_once "recaptcha/recaptchalib.php";

// Generates a string of n characters in length.
function genString($length = 4)
{
// This holds the generated string.
$str = "";

// These are the characters we will allow in a filename.
$charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

// Filenames can't be less than this many characters in length.
if ($length < 1)
{
$length = 1;
}

// Generate each character in the string.
for ($i = 0; $i < $length; $i++)
{
$pos = mt_rand(0, strlen($charset));
$str .= $charset{$pos};
}

return $str;
}

// Checks to make sure file type is one of the allowed mime-types.
// Returns true if type is okay, false otherwise.
function checkMime($m_type)
{
// Define a list of mime types that we will allow.
$allowed_types = array(
"image/gif", // GIF Image
"image/jpeg", // JPEG Image
"image/png", // PNG Image
"audio/mpeg", // MP3 Audio
"audio/mp4", // MP4 Audio
"audio/wav", // WAV Audio
"video/mp4", // MP4 Video
"audio/3gpp", // 3GP [mobile content] Audio
"video/3gpp", // 3GP Video
"application/x-rar-compressed", // WinRAR Archive
"application/zip", // WinZip archive
"application/x-shockwave-flash", // SWF
"text/x-java", // JAVA file
"text/plain", // Text file
"application/msword", // MS Word file
"application/pdf", // pdf document
"application/x-bittorrent", // bittorrent files
"unknown/unknown" // .SCAR files [possibably unsafe!?]
); // Any other suggestions?! ;D

// Is the uploaded file's mime type okay?
if (in_array($m_type, $allowed_types))
{
return true;
}
else
{
return false;
}
}

function allowedIP($IP_ADDR)
{
// Define a list of mime types that we will allow.
$blocked_types = array(
"74.208.16.54"
);

if (in_array($IP_ADDR, $blocked_types))
{
return false;
}
else
{
return true;
}
}

// Validates a reCAPTCHA
// returns true on success, false otherwise.
function validateCaptcha($priv_key)
{
$r_resp = recaptcha_check_answer($priv_key,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($r_resp->is_valid)
{
return true;
}
else
{
return false;
}
}

// Uploads (moves) a file to a specified location.
function uploadFile($real_file, $tmp_file, $location)
{
if (move_uploaded_file($tmp_file, $location . "/" . $real_file))
{
return true;
}
else
{
return false;
}
}

// Before we do anything, check to make sure that the upload path exists.
if (!file_exists($file_path))
{
die("<strong>" . $file_path . "</strong> doesn't exist. Please create it?");
}
// Is the file path readable?
if (!is_readable($file_path))
{
die("<strong>" . $file_path . "</strong> isn't readable. Please check your permissions.");
}
// Is the file path writable?
if (!is_writable($file_path))
{
die("<strong>" . $file_path . "</strong> isn't writable. Please check your permissions.");
}
$ip_check = (allowedIP($IP_ADDR) === true) ? "OK": "FAILED";
if ($ip_check != "OK")
{
die("<strong>Your IP address, ". $IP_ADDR .", is blocked from using this program.<br>Please <a href=$CONTACT_LOC>contact me</a> if you think you that have reatched this in error.</strong>");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Simple File Uploader by Hy71194</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META NAME="Description" CONTENT="Quick and easy file uploader tool by Hy71194">
</head>
<body>

<?php
if (isset($_POST) && !empty($_FILES))
{
// Check the reCAPTCHA input
$c_check = (validateCaptcha($r_private) === true) ? "OK": "FAILED";

// Get the extension of the uploaded file. This will be appended to the filename.
$ext = strtolower(substr($_FILES['image_file']['name'], strrpos($_FILES['image_file']['name'], '.') + 1));

// Our new generated filename.
$new_filename = $_FILES['image_file']['name'] . $IP_ADDR . genString() . "." . $ext;

// Check to see if the file's mime type is valid.
$m_check = (checkMime($_FILES['image_file']['type']) === true) ? "OK" : "FAILED";

// Double-check that their IP is allowed.
$ip_check = (allowedIP($IP_ADDR) === true) ? "OK": "FAILED";

echo "<div class=\"status\">";
echo "Original filename: " . $_FILES['image_file']['name'] . "<br>";
echo "Random filename: " . $new_filename . "<br>";
echo "Mime-type: " . $_FILES['image_file']['type'] . " - Result: " . $m_check . "<br>";
echo "reCAPTCHA answer: " . $c_check . "<br>";
echo "IP Address Allowed: " . $ip_check ."<br><br>";

// Attempt to move the uploaded file if the checks above are successful.
if ($m_check == "OK" && $c_check == "OK" && $ip_check == "OK")
{
$result = uploadFile($new_filename, $_FILES['image_file']['tmp_name'], $file_path);
$upload_status = ($result === true) ? "OK" : "FAILED" ;
echo "<span style='font-size:14.0pt;font-family:Tahoma'><b>The upload was a success!</span><br> View your file here..: <a href=\"http://www.hy71194.mgatesphoto.com/files/upload/$new_filename\">http://www.hy71194.mgatesphoto.com/files/upload/$new_filename</a><br/></b>";
echo "<a href=\"$_SERVER[PHP_SELF]\">Click here if you want to upload more files :)</a>\n";
}
else
{
echo "<span style='font-size:14.0pt;font-family:Tahoma'><br>File upload <b>Failed!</b>…</span> <br>Look at the four lines above and make sure you: <br><b> 1.) </b>Have an allowable file type? (look back for all allowed types; if you need a different mime-type allowed, please contact me) <br><b> 2.) </b>You answered the CAPTCHA correctly?, <br><b> 3.) </b>That your file size is not too large to be uploaded here, and <br><b> 4.) </b>Your IP address is not blocked.<br><br>";
echo "<a href=\"$_SERVER[PHP_SELF]\">Click here to retry.</a><br>";
echo "If you still need assistance, please <a href=$CONTACT_LOC>contact me</a>.<br>";
}
echo "</div>";
}
else
{
?>
<span style='font-size:24.0pt;font-family:Tahoma'>Simple File Uploader by Hy71194</span><br><br>
<span style='font-size:12.3pt;font-family:Tahoma'>
Upload a file, and this script will generate a random filename for it, and host it on this server.<br>
Maximum allowed file size is <b>50MB</b> (52,428,800 bytes)<br>
<b>Allowed file types:</b> *.png, jpg, png, mp3, mp4, 3gp, rar, zip, swf, java, txt, doc, pdf, torrent, scar<br><br>
<b>Browse for, select, and then upload your file!</b><br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value=" 52428800" />
<input type="file" name="image_file" size="35" />
<?php echo recaptcha_get_html($r_public); ?>
<input type="submit" name="submit" value="Click here to Upload your file!" /><br>By uploading a file here, you agree to the Terms of Service found <a href="http://www.hy71194.mgatesphoto.com/files/ToS.html">here</a>.
</form><br>
<?
}
?>
</body>
</span>
</html>
<br><iframe Longdesc="HitCounter" width="100%" scrolling=auto style="border:0" src="http://www.hy71194.mgatesphoto.com/index.html" target="_parent"><br><b>Please download a browser that supports iframes, such as <a href="http://www.firefox.com">Mozilla Firefox</a>.</b><noscript><br>Please also enable Javascript to view most sites correctly.</iframe>
[/php]
Enjoy ;)

And @Nava2, the rickroll was only there for like a week, it was for my school project :rolleyes: