TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,996
  • Total Topics: 21,327
  • Online today: 386
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 256
  • Total: 256

Upload Bug

Started by MyFSI, April 20, 2006, 05:22:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MyFSI

when uploading a file named "something.another.zip" it will give an error saying ".another.zip" is not an acceptable extension.

and if the name is "something.another.alsoanother.zip" it will consider the extension as ".another.alsoanother.zip"

IchBin

Of course you know you would be better off using an underscore instead of a period to name your files until Bloc comes up with a solution.

feline

In TPdlmanager.php ...

uses this:
// check the extension
$allowed=explode(',',$context['TPortal']['dl_allowed_types']);
$dlext=substr(strstr($name, '.'),1);
if(!in_array($dlext, $allowed)){
$status='wrongtype';
unlink($_FILES['tp_dluploadfile']['tmp_name']);
$error = $txt['tp-dlexterror'].':<b> <br />'.$context['TPortal']['dl_allowed_types'].'</b><br /><br />'.$txt['tp-dlexterror2'].': <b>'.$dlext.'</b>';
fatal_error($error);
}


Fel

IchBin

A woman that knows how to code.... what a turn on!  :-*  :D

G6Cad


feline

I'm a codewoman IchBin  :coolsmiley:

bloc

Try to replace
$dlext=substr(strstr($name, '.'),1);

with
$dlext=substr(strrchr($name, '.'),1);

..in dlmanager.php.

feline

That will be very complex  ;)

If you try the last dot (strrchr), myfile.tar.gz not work ..  ::)

Fel

bloc

ah..darn, i forgot. :) Ok, scratch that, I need to find a better way.

MyFSI

#9
maybe you could use regular expressions to compare the end of the name with the allowed types:
"(\.zip|\.txt|\.exe|\.tar\.gz|\.rar)$ ";


$allowed=explode(',',$context['TPortal']['dl_allowed_types']);
$pattern="(.".$allowed[0];
foreach($allowed as $ext)
     $pattern.="|.".$ext;
$pattern.=")$ ";
$pattern = str_replace(".", "\.", $pattern);
if (!eregi($pattern, $name)){
$status='wrongtype';
unlink($_FILES['tp_dluploadfile']['tmp_name']);
$error = $txt['tp-dlexterror'].':<b> <br />'.$context['TPortal']['dl_allowed_types'].'</b><br /><br />'.$txt['tp-dlexterror2'].': <b>'.$dlext.'</b>';
fatal_error($error);
}


not sure about this though.

This website is proudly hosted on Crocweb Cloud Website Hosting.