Directory engine in PHP to host files from that directory - php

I'm looking for a sort of directory engine (preferably in PHP) which allows to serve files from that directory to the clients. The directory may contain files of different types. The files may be organized in a hierarchy using sub-directories.
The solution I'm looking for should be able to build a view from such a directory structure with downloadable links to the files, file descriptions, custom thumbnails. The thumbnails could be possible to assign manually for files and directories, they shouldn't be generated automatically. The sub-directories treated as the categories so it should allow some kind of navigation between them.
The view should be highly customizable, allowing to change layout and look & feel.
I like how the information is presented at the following page:
http://www.doctohelp.com/SuperProducts/ChartWinForms/Chart+Types/
I searched the web but haven't found any appropriate solution at the moment. Mostly there are flat file managers which don't support meta-data or lack for customization.
Is someone aware of such a thing? I would be thankful for any link to already existent solution or some advise on of what components the solution can be built.

I'd put a vote in for ResourceSpace. I've not used it yet, but am considering integrating it into one of my projects. It appears to have meta data, has a customisable look and feel, and contains previewers for a lot of file types.

Have a look at http://gallery.sf.net
Its an image library in php but can be used for any kind of files. Gallery will not directly use your directory structure, but you can for example upload from server. Gallery is highly extendable and you can customize the views.
http://codex.gallery2.org/Category:Gallery_3:Modules
With native directory views (coming with nearly any webservers) you will not have a file description or thumbnails.

Related

Are symbolic links harmful for understanding and maintaining code?

I use symbolic links in my web project. There is a source folder and an additional folder for an email task which is executed by a service.
Both the website and the task are written in PHP and use my util.php, sql_functions.php and config.php files.
Rather than hardcoding the locations of these three files, I created symbolic links to these three utility files and some directories so that they are available from each of my subdirectories. The code works.
I also created a batch file which automatically creates these links and documented the installation procedure.
Below you can find a screenshot of the folder that contains my email task. sql_functions.php loads the configuration data and is being used by email.php to access the SQL Server. The symlink to the sql folder also helps.
All of these folders are in the same repository, so there is no real risk that any dependencies might not be loaded.
It just feels like dirty programming.
Although symbolic links by themselves shouldn't be harmful to the understanding and maintaining of the codebase, your case in kind of brutal. Puting a symlink in everyone of your files looks like overkill there. There are more options than just choosing betwen hardcodes paths and such a violent solution.
For example, you could set the path of these files in a constant that is loaded at the begining of each files through a require(), or many others solutions. In the end, it depends on the way your website works, but I doubt your solution is the most flexible you could come up with.

WordPress or PHP script to pick an image file from a plugin folder

I'm creating a WordPress plugin that allows a user to select one of several image files that are distributed with it. Is there a simple technique for allowing the user to view the files in a filebrowser-like interface and pick one? I want it to look as similar as possible to picking a file in the normal file upload dialog.
I ended up adapting the code from this filebrowser that utilizes scandir. It has a nice simple interface and the code is simple enough to incorporate into a plugin.

Best pracice to initialize a web application in oop (no framework)

I'm writing a web application and I would like to know how to initialize all constant (such as db connection data, directories etc), classes and so on.
I read about bootstrap file but I'm not sure I understand the technique ( more details here: https://stackoverflow.com/questions/9774105/htaccess-and-bootstrap-file).
A more specific case would be better. In this case, your question on settings, there are different approaches. Generally a config file is most used in projects. That way it can easily be excluded from version control systems.
Bootstrap files are not the location to store settings.
So bootstrap load the config file and following to that the bootstrap initiates the system.
Generally a config file is the most accepted choice.
For paths there are different parts. You have in-app paths. Keep them in your code, your system should be able to find the right files. Might be done with a PHP Autoloader for example.
Then you have paths to resources like images, pdf files and other data. Keep that part strongly separated from your application. Preferably via a class which handles all those files. That way you are free to move them to another server, move them to Amazon for example when your project grows etc.
So don't try to hardcode paths and keep things separated.

PHP Application Structure/Pattern - 2 sites with shared libraries and assets

I'm having a bit of an application structure design dilemma.
I have created a web app that creates online surveys. It all works fine, but I would now like to create a new site that does different types of online surveys. This new site will be pretty much 95% similar in terms of layout, logic, functions, etc.
Rather than duplicate all the code from the current web app, I'd like the new app to share in the "fountain of knowledge" created by the current app - so to speak.
Can anyone enlighten me with their experiences of doing this sort of thing? Their best practices?
As a rough guide, I'm currently thinking of using symlinks for all the major logic files (library.php, functions.php, etc), and then deciding which logic to use based on which URL the user logged-in from.
Does that sound like a good or bad idea?
Would it be any better or worse to divide the whole system in to 3 sites, with the site in the middle containing all the common elements and logic? This middle site would have no independent use - it would be used from either of the 2 applications looking for functionality and assets, etc.
Any help and experience on this matter is very much appreciated indeed.
I'm very wary of going down a dead-end solution.
Kind Regards,
Seb
Good solution if:
you host your website yourself and creating symlinks between differents virtual hosts is not a problem
you won't have to make significative changes between the 2 websites
But instead of using symlinks, I could take advantage of PHP's include_path directive and put the common libraries in this path. This way, just write your includes relative to this path, the files will be accessible from any site you want on the same server.
The second advantage of using include_path is you can bypass any open_basedir directives which wouldn't allow you to include files which are not in the same virtual host base dir.
This is how I'd do it...
Create a core library.
Create you 2 site directories.
Create site specific code folders in
each site.
Create core library folders in each
site that simlink to the main core
library created.

Where should I place downloadable files for my component?

I am developing a Joomla Component which will allow visitors to download a sound file (be it mp3, or wave, does not matter). Those files are managed in the admin interface and can be unpublished in there.
Therefore, it seems that placing them in the assets section is not an option, as it would make them accessible directly from the server. I want to avoid direct access and only serve them through my MVC structure (usnig RAW document type) after verifying that the requested file is published.
Are there any conventions on the placement of those files inside my component's directory structure?
My first idea is to create a folder inside the administrator/components/com_mycomponent and keep the files there. Do I need to restrict access to this new folder with a new .htaccess file, or is it already taken care of by Joomla with a global .htaccess?
you should place the files in the media directory. It is supported by the installer and is much better place. The logic is to have code in com_mycomponent for site and admin and both of those will share media (images/css/js), downloads, etc...
/media/com_mycomponent/
Restrictions are up to you.
Here is Joomla installation structure, http://docs.joomla.org/Components:xml_installfile

Categories