Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fixing a download php file
Old 02-11-2008, 02:28 AM Fixing a download php file
Average Talker

Posts: 20
Trades: 0
So I got a site and finally got a download and upload feature working on halocemaps.net

So apparently, you can upload ANY file type you want and only 10 mb's max (thats in the php file so you cant go over it).

SO I wanted to know if anyone could help me make it so

A. it only accepts .rars, zipz, and 7z files.

And B. Its can upload up to 100 mbs.

here is the link to the php files and what not

http://custom.simplemachines.org/mods/index.php?mod=992
LOLwut is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-11-2008, 06:29 AM Re: Fixing a download php file
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Upload limit is set within php.ini or httpd.conf if php is run under apache.

Accepting only certain extensions can be done in two ways.

First one is simple but unreliable - check the extension of uploaded file with $_FILES['userfile']['name'] and display error message if the condition is false. This way is unreliable because the file can be named as .zip not actually being a zip archive.

Another way is testing the archive through executing the corresponding command line archiver utility with arguments that tell the archiver to test or list contents of archive. If the command returns true then the archive is an archive indeed and can be processed further. But this way needs more advanced knowledge on php to perform all actions in proper way.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-11-2008, 07:50 AM Re: Fixing a download php file
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Another way is testing the archive through executing the corresponding command line archiver utility
I would rather use the magic file ability of almost any unix os.

I know that the php PECL module "fileinfo" offers a gateway for this, or a shell command "file {file to test}" will return a string with the desired infos:
http://www.php.net/manual/en/ref.fileinfo.php
Quote:
file Les\ incorruptibles.AVI
Les incorruptibles.AVI: RIFF (little-endian) data, AVI, 720 x 304, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)

file vmware-any-any-update114.tar.gz
vmware-any-any-update114.tar.gz: gzip compressed data, from Unix, last modified: Sun Oct 14 10:44:18 2007

file AA\ G310\ -\ EN.pdf
AA G310 - EN.pdf: PDF document, version 1.3
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-11-2008, 04:53 PM Re: Fixing a download php file
Average Talker

Posts: 20
Trades: 0
I honestly feel like a nub, but would anyone do that for me? You guys know what you are talking about. PLEASE! I would appreciate it soo much

They said for file extensions add this but i dont know how!



Quote:
$valid_types = array("rar","zip");
if (in_array($filename, $valid_types))

fatal_error($txt['downloads_error_no_download'],false);


Quote:
function AddDownload2()
{
global $ID_MEMBER, $txt, $db_prefix, $scripturl, $modSettings, $boarddir, $sourcedir, $gd2, $user_info, $boardurl;

isAllowedTo('downloads_add');

if (empty($modSettings['down_path']))
{
$modSettings['down_path'] = $boarddir . '/downloads/';
}
// Check if downloads path is writable
if (!is_writable($modSettings['down_path']))
fatal_error($txt['downloads_write_error'] . $modSettings['down_path']);


$title = htmlspecialchars($_REQUEST['title'],ENT_QUOTES);
$description = htmlspecialchars($_REQUEST['description'],ENT_QUOTES);
$keywords = htmlspecialchars($_REQUEST['keywords'],ENT_QUOTES);
$cat = (int) $_REQUEST['cat'];
$fileurl = htmlspecialchars($_REQUEST['fileurl'],ENT_QUOTES);
$allowcomments = isset($_REQUEST['allowcomments']) ? 1 : 0;
$sendemail = isset($_REQUEST['sendemail']) ? 1 : 0;
$filesize = 0;

GetCatPermission($cat,'addfile');


// Check if downloads are auto approved
$approved = (allowedTo('downloads_autoapprove') ? 1 : 0);

// Allow comments on file if no setting set.
if (empty($modSettings['down_commentchoice']))
$allowcomments = 1;


$valid_types = array("rar","zip");
if (in_array($filename, $valid_types))

fatal_error($txt['downloads_error_no_download'],false);






if ($title == '')
fatal_error($txt['downloads_error_no_title'],false);
if ($cat == '')
fatal_error($txt['downloads_error_no_cat'],false);

if ($modSettings['down_set_enable_multifolder'])
CreateDownloadFolder();

...........................

Last edited by LOLwut; 02-11-2008 at 05:10 PM..
LOLwut is offline
Reply With Quote
View Public Profile
 
Old 02-11-2008, 08:12 PM Re: Fixing a download php file
Average Talker

Posts: 20
Trades: 0
Can anyone help me!
LOLwut is offline
Reply With Quote
View Public Profile
 
Old 02-12-2008, 04:14 AM Re: Fixing a download php file
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Quote:
Originally Posted by LOLwut View Post
Can anyone help me!
No, unless you're gonna pay.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-12-2008, 04:19 AM Re: Fixing a download php file
Average Talker

Posts: 20
Trades: 0
so you smart people couldnt alter one script?
LOLwut is offline
Reply With Quote
View Public Profile
 
Old 02-12-2008, 05:42 AM Re: Fixing a download php file
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Would you clean my room for free?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Fixing a download php file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64225 seconds with 12 queries