CakePHP select a file from server - php

I'm building an app based on CakePHP framework and Croogo CMS. Basically there will be a simple intranet section where after logging in the users will be able to view and download some files.
Within administration I'm planning a simple section where the administrator will select files from ones previously uploaded into CMS and laying in /app/webroot/files folder. Here I would like to implement a simple file picker to let administrator easily select files that will be added to that intranet.
I was googling for a while but found nothing useful - merely pages about file upload.
My question: is there any plugin or something similar to my needs that I could use or do I have to write it down myself?
If there is nothing useable I was planning to do it this way:
administrator will have to upload intranet dedicated files directly to a folder /app/webroot/files/intranet/
within intranet documents administration section I will then list all present files, fill them into <ul> list as links and using jQuery fill some hidden form fields in background from which I would then gather information about files that are being added into the intranet
Is this a good approach or do You have better and simpler solution?
Many thanks for Your responses in advance!

As Lector said, webroot files are public, so you will need to save them to somewhere outside webroot, perhaps in another folder inside app. You can use the Media view to allow download of those restricted files. You could display all the files in a certain folder using PHP similar to how it is done here.

Related

How to create a shared resource folder in Active Directory to search for text in files using LDAP or any PHP method?

I have joomla and moodle sites that are running on the same IIS server. I use active directory to manage users to authenticate with the sites. My aim is to maintain same users and resources to be used by these sites.
So far I'm able to login users using LDAP in PHP. My next objective is have a common folder that i can upload and manage files to be used by both sites. I want to search for text for example a word or a sentence inside text files and return the results in joomla or moodle using PHP.
How can i achieve this? Share your ideas and sample code in PHP to help me solve this.

Link files from file system repository to courses in moodle

I have to create about 2000 course with 5000 documents in Moodle 2.4. I have used Bulk category upload and bulk course upload to create the courses.
As file management in Moodle 2.0 has changed and files cannot be placed directly to moodle appdata folder. I created file system repository in Moodle Appdata and uploaded all files with their course id (id from DB table after creating courses) as directory name.
After enabling file system repository i can now see files in file picker. Now i use file picker to link those files to their courses manually. Another option is drag and drop files to their courses. But it is time consuming and it may lead to human error as every course has to be opened and above options has to be done.
I gone through mdl_files table to link files to their courses but the contents are encrypted and i cannot directly link files to their courses using DB as of in course file area in Moodle 1.9. I wrote script using Moodle File API but that could also be done in course only.
Is there any way that linking of those files can be done through script or database to their corresponding courses in bulk.
Thanks in advance
I'm not aware of a solution that doesn't involve writing some code.
However, you could take a look at the code in course/dnduploadlib.php, as that should be possible to adapt this to loop through all the files in a given directory on the server and convert them into resources.
If you created a draft file area (using the files API), you could then use an adjusted version of the 'handle_file_upload' function (and the functions it calls) to do this.

Virtual file system in php?

We have a system where, a large part of it is the ability to upload and download files if you are logged in and have the correct permissions.
What we are looking at doing to help with the organization from the users point of view is having a virtual file system type layout.
Even if (or even preferably) all the users files are actually just stored in one directory, and the virtual file system is just a screen put up from the database.
What we are wondering before we invest in creating this is if this already exists somewhere, open source (but able to be used in commercial software), free, or paid (first two preferably!).
A simple file system on top of PHP can be done by WebDAV that is built on top of PHP:
http://sabre.io/
This would be a good example, but there are others as well. WebDAV is essentially a web based file system (http://en.wikipedia.org/wiki/WebDAV).
This could not only provide a file system, but also would let you edit files directly with Word/Excel (2007+) in it. Showing then a treeview of folders and files would be quite trivial, using few database tables and some jquery components, such as jsTree and jqGrid.
Although if you are searching for a full document management system: http://www.opendocman.com/ or http://code.google.com/p/simpledoc/ this would be more then enough.
It really depends on how many features you are going to incorporate into this system. Will there be an OCR, would you like to store the files in the cloud service, how many user input there will be (is simple upload enough, or camera, scanners and other devices are needed to be used as well)?
As for the commercial products, you could check out Microsoft SharePoint (http://en.wikipedia.org/wiki/Microsoft_SharePoint) or IBM Lotus Notes (http://en.wikipedia.org/wiki/IBM_Lotus_Notes)

directory browsing within webpage

I would like to give the user a file browser from within a webpage.
Here is what I've tried. I'm trying to present the file contents myself. I am trying to make it so there is div that is the same as what you would get on an ordinary directory browse within the webpage. I have succeeded in making the div work visually, displaying the contents of the selected folder but when trying to click on a file in that directory it can not find the file because it is looking in the wrong file path index.html/ instead of index.html/videos.
Code:
<div id="new-nav"></div>
<script>
$("#new-nav").load("/videos");
</script>
What's the best way to give the user a "file browser" experience in a webpage?
I would recommend using http://ckfinder.com/demo instead.
Features of CkFinder as Listed on their Site
Lightweight interface.
No page refreshes: quick responses.
Folders tree navigation: intuitive for all users.
Quality image thumbnails, making it quick to find things.
Multi-language support with automatic user language detection.
Context-sensitive menus for files and folders.
Multiple file uploads with a progress bar (*).
Full user control of the content: create, rename, and delete
folders and files.
Drag-and-drop support for copying and moving files between folders.
Full developer control: all features can be precisely configured with
a powerful ACL and user roles system.
Flexible configuration: store files in private folders, also
outside the document root.
Secure file uploads: all uploaded files are checked according to
the rules set by the developer.
Full source code included for the server side integration.
Instant integration with CKEditor and FCKeditor.

Central Admin Panel - Managing few sites on external servers - Saving files on external server

I would like to create a system which can manage all my websites from one page. All options of managing are let's say done or I know how to do them, except from editing and creating files on an external server.
I would like to know what is the best way to save files on exteral server. I would like to chang few files at once and would be nice not to leave administration panel. It is important to keep the whole system safe - that nobody could edit it without accesing administration panel.
I thought about changin chmods on each website using a local script and chmod() but then i cant access the files because http:// is not writable protocole i used fwrite() function.
Can you give me some tips how should I create that?

Categories