Page 1 of 1

Not allowed extension

Posted: 1. November 2011 02:43
by KillBill

Code: Select all

[phpBB Debug] PHP Notice: in file /portal/includes/functions_upload.php on line 159: Undefined variable: mod_dir
Otherwise, congratulations on this portal engine, very nice work.

Upload new module

Posted: 2. November 2011 18:54
by KillBill
Acp/mods/portal/Upload module

The field is empty then an error occurs.

Code: Select all

[phpBB Debug] PHP Notice: in file /portal/includes/functions_upload.php on line 58: Undefined index: NO_UPLOAD_FILE
-----------------------------------------------------------------------------------------------

Other:

A default mod directory structure is as follows.
  • contrib
    • ...
  • root
    • ...
  • install.xml
  • license.txt
  • modx.prosilver.en.xsl
In this case, the module will upload error add. (Module corrupted)
So I propose the following change.

portal/includes/functions_upload.php

find

Code: Select all

                    // make sure we set $mod_dir to the correct folder after the above step
                    $mod_dir = (isset($new_mod_dir)) ? $new_mod_dir : $mod_dir; 
after add

Code: Select all

                    // check root folder
                    $relative_mod_dir = (file_exists("$mod_dir/root")) ? "$mod_dir/root" : $mod_dir; 
find

Code: Select all

                    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($mod_dir)); // requires PHP 5  
replace

Code: Select all

                    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($relative_mod_dir)); // requires PHP 5  
find

Code: Select all

                    foreach($iterator as $cur_file)
                    { 
after add

Code: Select all

                        if (in_array($cur_file->getFilename(), array('.', '..', 'license.txt')))
                        {
                            continue;
                        } 
find

Code: Select all

                        $cur_path = str_replace($mod_dir . '/', '', $cur_path);
                        $cut_pos = strpos($cur_path, '/');
                        
                        // Only allow files in adm, language, portal and styles folder
                        if(!in_array(substr($cur_path, 0, $cut_pos), array('adm', 'language', 'portal', 'styles')) && $cur_file->getFilename() != 'license.txt') 
replace

Code: Select all

                        $cur_path = str_replace($relative_mod_dir . '/', '', $cur_path);
                        $cut_pos = strpos($cur_path, '/');

                        // Only allow files in adm, language, portal and styles folder
                        if (!in_array(substr($cur_path, 0, $cut_pos), array('adm', 'language', 'portal', 'styles'))) 
find

Code: Select all

                            $actions['NEW_FILES'][$mod_dir . '/' . $cur_path] = $phpbb_root_path . $cur_path; 
replace

Code: Select all

                            $actions['NEW_FILES'][$relative_mod_dir . '/' . $cur_path] = $phpbb_root_path . $cur_path; 
So the upload modul is successful.

------------------------------------------------
Other:

Code: Select all

        @chmod($to, octdec(0644)); 
deleted

//@chmod($to, octdec(0644));

or changed

@chmod($to, 0644);

The files attribute is too small, so the portal can not display icon image.
Files attributes after uploading = 420

Re: Not allowed extension

Posted: 5. November 2011 23:36
by MyLady
Files attributes after uploading = 420
I've noticed that too

Re: Not allowed extension

Posted: 14. January 2012 17:07
by KillBill
If no new module and click add module

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/includes/acp/acp_portal.php on line 845: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag