splittingred / filelister Goto Github PK
View Code? Open in Web Editor NEWFile listing snippet for MODx Revolution
File listing snippet for MODx Revolution
After recent server upgrades, a site with FileLister stopped displaying the file. It is now only linking back to the listing page without any file reference.
When changing the lines
/** @var DirectoryIterator $file */
foreach (new DirectoryIterator($curPath) as $file) {
with
/** @var DirectoryIterator $file */
$di = new RecursiveDirectoryIterator($path);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
FileLister iterates recursivly into the subdirectories of a given path.
Changed
$filePath = $relPath.(!empty($relPath) ? '/' :
with
$filePath = str_replace($path, '', $filePath);
and the download links working.
I'm not a developer and I think this is a hack without knowing if I produced a security risk or other issues with that change...
Would be great if this functionality is integrated into FileLister.
Thanks.
FileLister doesn't generate any output in modx 2.3.
*** UPDATE ***
Sorry, my bad. Did not use a relative path. Started with a / in the filepath. When removing the slash the path is relative and works
Parent directory link when in a sub directory listing and not the root.
I implemented using a link to go back to previous page if the navkey was not empty in the url, but if there was a pagination option for the listing then this would not work.
I get the following error with using filelister (has ID 26 on my site):
[2010-08-15 11:23:03](ERROR @ /home/public_html/core/cache/elements/modsnippet/26.include.cache.php : 248) PHP warning: implode() [function.implode]: Invalid arguments passed
I checked my setup of filelister but couldn't find any error.
How I call FileLister:
[[!FileLister?
&path=assets/media/[[*id]]/
&fileTpl=listIMG
&showExt=jpg,gif,png
&showDirectories=0
]]
listIMG Chunk just outputs an IMG-Element with use of the placeholder [[+path]]
The path field in the db contains assets/downloads/file.ext, but $file->getPathname()
in snippet.filelister.php returns assets/downloads\file.ext on Windows systems (with a backslash). So $modx->getCount('feoDownload',$w)
(line 188) returns zero, because it doesn't find the path in the db.
I fixed it by changing line 160 to $fileArray['path'] = str_replace('\\', '/', $file->getPathname());
. Perhaps it should be solved in an other way, but this was the simplest solution for me.
I need to cache file listings generated by FileLister. In most cases I use getPage, which offers caching, but I can't manage to cache totalVar
value. I put snippet output to a placeholder with toPlaceholder
. I tried getCache too but with the same result.
How should it be made the proper way?
Hi,
Really good snippet ;)
One feature request: it would be great to be able to hide or replace root path string with a custom one, like 'home'.
Currently [[+filelister.path]] placeholder is returning the root path string ,ie 'assets/.../...', so it shows where the files are located; it would be nice to start with a custom string like 'home' or 'root',
Thanks,
Kevin
Hi, I'm having an issue with attempting to download large files - anything over 70mb is being truncated. I'm running modx on a shared server where the PHP memory limit is 80mb - could this be an issue? I don't need the security of a hash - is there any way the plugin could return the actual path of the file, as I'm guessing this might resolve the issue?
Thanks,
Dave Vernon
Looks like one more condition needed, because sometimes apache writes error.log with
PHP Notice: Undefined variable: scriptProperties in .../core/components/filelister/model/filelister/filelister.class.php on line 124
I've tried setting filelister.ipinfodb_api_key at the context, system, snippet level, no joy.
All I ever get in the database for the geolocation info (country, zip etc) is the default blank values.
Can you confirm it works for you?
Shaun - all geolocation entries in modx_filelister_downloads are showing : {"Ip":"0.0.0.0","Status":"MOVED","CountryCode":"","CountryName":"","RegionCode":"","RegionName":"","City":"","ZipPostalCode":"","Latitude":"0","Longitude":"0","Timezone":"0","Gmtoffset":"0","Dstoffset":"0"}
Presumably because they've moved server to api.ipinfodb.com, added a $version and need for a key. New class here: http://mirrors.ipinfodb.com/ipinfodb/classes/geolocationapi_class.zip
(not skilled enough to fork and update myself, sorry).
I am using requireAuthDownload=1
and allowDownloadGroups=mygroup
in a filelister call which is working correctly in that it is making the file a link when I am logged in and just text when not logged in. The problem is when I click on the file to download it all it does is just refresh the page and doesn't download the file?
check download access is not working like it should. if i anyhow get a download link for a file and not logged in as a user/manager i could nevertheless download the file. reordering some of your code fixes this problem for me
/* check download access */
$allowDownloadGroups = $modx->getOption('allowDownloadGroups',$scriptProperties,'');
if (!empty($allowDownloadGroups)) $allowDownloadGroups = explode(',',$allowDownloadGroups);
$canDownload = $modx->getOption('allowDownload',$scriptProperties,true);
if ($modx->getOption('requireAuthDownload',$scriptProperties,false)) {
$requireAuthContext = $modx->getOption('requireAuthContext',$scriptProperties,$modx->context->get('key'));
$canDownload = $modx->user->hasSessionContext($requireAuthContext);
}
if (!empty($allowDownloadGroups)) {
$canDownload = $modx->user->isMember($allowDownloadGroups);
}
unset($requireAuthContext,$allowDownloadGroups);
/* if pointing to file, output file */
if (!is_dir($curPath) && is_file($curPath) && $canDownload) {
Apologies - closed #8 by mistake:
I've tried setting filelister.ipinfodb_api_key at the context, system, snippet level, no joy.
All I ever get in the database for the geolocation info (country, zip etc) is the default blank values.
I've manually replaced the URL in ipinfodb.class.php to a known working url that returns an XML file, but I cannot get the script to enter the loop in lines 100-110 of snippet.filelister.php - presumably because the array is empty. Also, a $geolocation array is created on line 99 that doesn't seem to do anything.
It still shows directories. The call I'm using is
[[!FileLister? &path=
assets/member/ &allowDownloadGroups=
Members &requireAuthDownload=
1 showDirectories=
0]]
Having a param for limit of files per page and adding navigation links (pagination) or a tutorial of how to get it working with getpage
Would love to be able to target an individual file within a directory if required.
Possibly by using some new new property called &doc=``
[[!FileLister? &path=/docs/marketing/
&doc=my-document.doc
&allowDownloadGroups=Marketing,CEO
]]
Would be useful where I need to protect docments from inputting an absolute URL in a browser window.
Shouldn't $dl->save()
in line 111 be moved out of the if condition if ($useGeolocation && !empty($geoApiKey)) { ... }
starting at line 94?
The way it's handled currently, causes that the download is logged only, when using the geolocation feature and I think this is not intended.
get this error in the apache error log. I'm on mac os x. any idea?
Line 96 of the snippet is
$dl->set('referer',$_SERVER['HTTP_REFERER']);
However, some user agents can leave that field empty, which prevents downloading. It needs a fallback for when their's no referrer.
Filelister stops working when I upgrade from php 7.1 to 7.2 or 7.3. Rolling back to 7.1 makes it work again.
would be keen on having the row td (class) indicate odd or even for displaying alternate rows with different background colour.
# @186 string FileLister snippet
$fileArray['extension'] = strtolower(pathinfo($fileArray['path'],PATHINFO_EXTENSION));
# @234 string feoheaders.class.php
$extension = strtolower(pathinfo($file,PATHINFO_EXTENSION));
docx files attempt to download as a zipped folder in IE8.
I realise this is only a minor issue and easy to fix, add 'docx' => 'application/msword' to the feoheaders file, as well as becoming quickly irrelevant but I just thought I'd raise it. I was baffled for a while thinking my mime types were not set correctly on my server!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.