The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Sep 17, 2005 7:11 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Sep 11, 2005 10:42 pm
Posts: 47
Problem Exists in administrator/components/com_media/admin.media.php

As the function steps throught the array, if variable $format does not equal $ext, it will echo the message saying "File Type Not Support"

To fix this, i removed the strcasecmp and added the function strtolower() on $format.


Fix:

On line 160

Change
Code:
$format = substr( $file['name'], -3 );

to
Code:
$format = strtolower(substr( $file['name'], -3 ));



Around line 179 remove the following code
Code:
foreach( $allowable as $ext ) {
                        if ( strcasecmp( $format, $ext ) ) {
                                mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'],
'This file type is not supported' );

   }
      }

And replace it with
Code:
 $allowed = FALSE;

                foreach( $allowable as $ext ) {
                        if ( $ext == $format){
                        $allowed = TRUE;
        }
                }
                if ($allowed == FALSE){
                 mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'],
'This file type is not supported');
}


Furthermore, file extenstions that are ".jpeg" will not work with Media manager. This is because of the following function
Code:
substr( $file['name'], -3 )

To fix this

Add
Code:
Change array allowable at line 169 from

                $allowable = array (
                        'xcf',
                        'odg',
                        'gif',
                        'jpg',
                        'png',
                        'bmp',
                        'doc',
                        'xls',
                        'ppt',
                        'swf',
                        'pdf',
                        'odt',
                        'ods',
                        'odp'
                );


to

Code:
                $allowable = array (
                        'xcf',
                        'odg',
                        'gif',
                        'jpg',
                        'png',
                        'bmp',
                        'doc',
                        'xls',
                        'ppt',
                        'swf',
                        'pdf',
                        'odt',
                        'ods',
                        'odp',
           'epg'
                );


Notice the epg at the end. This is because the substr function only takes off the last three characters of the file extenstion.
Thus "jpeg" would be "epg"

Kudos to gunther

http://forum.joomla.org/index.php/topic ... l#msg48059

The following code would work if you added strtolower() to the $format = substr( $file['name'], -3 );

Otherwise, the file type JPG wouldnt not work.. Only jpg..

NOTE TO gunther: You beat me by 10 min or so.. Need coffee!!


Top
 Profile  
 
PostPosted: Sat Sep 17, 2005 7:26 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Sep 11, 2005 10:42 pm
Posts: 47
NEW PROBLEM!

Problem with deleting files with media manager..
Code:
function delete_file($delfile, $listdir) {
        global $mosConfig_absolute_path;
        $del_image = $mosConfig_absolute_path."/images/stories".$listdir."/".$delfile;
        unlink($del_image);
}


Problem exists because $listdir isnt defined + the path has /stories in it

Replace the above with
Code:
function delete_file($delfile, $listdir) {
        global $mosConfig_absolute_path;
        $del_image = $mosConfig_absolute_path."/images/".$listdir."/".$delfile;
        unlink($del_image);
}


If this still doesnt work, the $listdir may not be specified correctly before executing the function. To ensure that it is properly specified, use the code below

Code:
function delete_file($delfile, $listdir) {
        global $mosConfig_absolute_path;
        $listdir = $_POST['listdir'];
        $del_image = $mosConfig_absolute_path."/images/".$listdir."/".$delfile;
        unlink($del_image);
}


Top
 Profile  
 
PostPosted: Sat Sep 17, 2005 7:30 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Sep 11, 2005 10:42 pm
Posts: 47
$listdir is corretly specified.. Use the code without "$listdir = $_POST['listdir'];" for better performance.. Was modifiying code in wrong putty window when i made changes.. My mistake..

NOTE TO ADMIN

I cant close or solve bugs on the sourceforge bug tracker.. I can only open a new one.. I dont want to clutter it up.. Permission to leave comments, change status, upload code [patch files] would be appreciated..


Top
 Profile  
 
PostPosted: Sat Sep 17, 2005 7:44 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 07, 2005 3:30 am
Posts: 31
ustler wrote:
$listdir is corretly specified.. Use the code without "$listdir = $_POST['listdir'];" for better performance.. Was modifiying code in wrong putty window when i made changes.. My mistake..

NOTE TO ADMIN

I cant close or solve bugs on the sourceforge bug tracker.. I can only open a new one.. I dont want to clutter it up.. Permission to leave comments, change status, upload code [patch files] would be appreciated..


Hi,
I replaced the $_POST with a $_GET and it worked. But then I saw that $listdir is already defined in line 33 and just left out the listdir = $_POST['listdir'];
G.


Top
 Profile  
 
PostPosted: Sat Sep 17, 2005 7:47 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Sep 11, 2005 10:42 pm
Posts: 47
Yea i posted that in the post above.. The problem was i have 4 SSH connections running at once and sometimes i forget which one im in, so i went to another one and couldnt figure out why it didnt work.. Leave out the $_POST['listdir'].. That was my fault


Top
 Profile  
 
PostPosted: Tue Sep 20, 2005 3:10 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Sep 20, 2005 3:03 pm
Posts: 1
ustler wrote:
Notice the epg at the end. This is because the substr function only takes off the last three characters of the file extenstion.
Thus "jpeg" would be "epg"


The "epg" in the allowable-array should be a "peg".
Code:
  $allowable = array (
                        'xcf',
                        'odg',
                        'gif',
                        'jpg',
                        'png',
                        'bmp',
                        'doc',
                        'xls',
                        'ppt',
                        'swf',
                        'pdf',
                        'odt',
                        'ods',
                        'odp',
                   'peg'
                );


Top
 Profile  
 
PostPosted: Tue Sep 20, 2005 4:15 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 07, 2005 3:30 am
Posts: 31
moettti wrote:
ustler wrote:
Notice the epg at the end. This is because the substr function only takes off the last three characters of the file extenstion.
Thus "jpeg" would be "epg"


The "epg" in the allowable-array should be a "peg".


And by using some additional code, you do not have to abbreaviate the filename extension at all:
http://forum.joomla.org/index.php/topic,6483.msg48690.html#msg48690


Top
 Profile  
 
PostPosted: Thu Sep 22, 2005 3:55 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Thu Sep 22, 2005 3:52 pm
Posts: 585
Location: Egypt
And yet another way around it.

Code:


$format = strtolower(array_pop(explode(".",$file['name'])));




you wouldn't have to abbreviate the extension in this case either.

_________________
http://mostafa.mosmar.com/blog | My blog
http://mostafa.mosmar.com/jforms | JForms - WYSIWYG Forms Component for J! 1.5 (Beta)


Last edited by dr_drsh on Thu Sep 22, 2005 3:57 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Sep 22, 2005 4:02 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Sep 07, 2005 3:30 am
Posts: 31
dr_drsh wrote:
And yet another way around it.

Code:


$format = strtolower(array_pop(explode(".",$file['name'])));




you wouldn't have to abbreviate the extension in this case either.


Yep! Many ways ... same result. The beauty of programming  :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group