File manager php class

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

With this File Manager prepared for PHP/Js, you can perform all file operations on your server without any problems.

demirtanzer/FileManager

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Читайте также:  Java file class url

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

With this File Manager prepared for PHP/Js, you can perform all file operations on your server without any problems.

Instead of downloading and integrating the file manager I need in the projects I prepared, I decided to create both OOP experience and my own PHP FileManager class and a visual interface that I can use in this class.

Contrary to the standards, I do the version notification using the following method so that it is clear what content I am using during a possible change in the future.

  • In FileManager.php v2 I used the FMP namespace and the fmp class name to further reduce the code complexity found in v1.
  • Unlike the previous version, in this version, graphic files are previewed with the «tempImage()» function in the class instead of standard icons.
  • Quick access thanks to the folder tree, which can be used on a screen with a resolution of 640px and above for ease of use.
  • Popup menus with customized jQuery-ui plugin
  • Multi-language support with xml format
  • Built-in FontAwesome 4 icons
  • The interface will not work without jQuery and console.log() will create a record
  • With the «config.xml» file, the root directory, color scheme and maximum file upload size can be specified.

FMP class in FileManager.php;

  1. First of all, I had to redefine functions such as mime_content_type() and realpath() in the class in order not to cause software errors between possible PHP versions.
  2. fmp->post($_POST variable)
    To be able to use the posted data securely. Returns «false» if the value is undefined/empty, otherwise returns the posted data.
  3. fmp->tempImage(imageLocation,desiredType,tempFolder)
    If there is no image sent in the specified tempFolder, it will be reduced to 45px*45px and saved in the tempFolder with a new name in md5() format. Returns null if imageLocation is not found, otherwise returns with image content
  4. fmp->details(adress)
    type(text file), graphic(true/false), server location(/home/dir/), web location(/dir), size( Returns 1mb), edit date(Ynd H:i:sa), and privacy(777)
  5. fmp->create(name,path,type)
    Creates the desired name and type (file/folder) at the specified path. Adds a number to the end of the filename if there is content with the same name in the specified path. If there is no error, it returns the name of the created content.
  6. fmp->fileSave(file,content)
    Replaces the contents of the file at the specified address. returns true/false
  7. fmp->listing(folder,requestType
    ) Returns the contents of the specified folder in the desiredType (all, folders only, only files) as an array variable.
  8. fmp->folderList(folder)
    On the contrary, fmp->listing() function returns only the folders in the specified folder in string format with comma marks (,) between them.
  9. fmp->download(file)
    It provides a secure download of the desired file by making the necessary header() definitions.
  10. fmp->delete(files)
    Deletes the file/s sent in both array and string form. Returns deleted and non-deletable filenames.
  11. fmp->move(files,movingFolder) Moves files,
    both array and string, to the specified moveFolder. Returns True/False.
  12. fmp->copy(files,copyFolder) Copies
    both array and string files to the specified copyFolder. Returns True/False.
  13. fmp->rename(oldName,newName)
    renames oldName content with newName.
  14. fmp->upload(files, uploadFolder) Uploads
    files sent either as array or string to the upload folder and names them according to the file existence. Returns with array elements named Error and done
  15. fmp->createZip(files,creationFolder)
    Creates a zip archive with both array and string files, in the specified creationFolder. It returns array elements named Error and done.
  16. fmp->unZip(archiveFile,folder)
    Extracts the specified archiveFile in the desired directory. Returns True/False.
  17. In case of a possible error in all operations , the error date, operation and necessary information are recorded in the «/manager/fm_error_log.txt» file.

About

With this File Manager prepared for PHP/Js, you can perform all file operations on your server without any problems.

Источник

Файловый менеджер на PHP, с правами, контролем версий и AJAX-ом

Особенности файлового менеджера:
— Можно задавать права доступа на файлы и директории. Права двух типов: есть доступ или нет доступа. Файлы хранятся в недоступной для скачивания по прямой ссылке папке. Скачивание файла происходит с предварительной проверкой пользователя и прав доступа на файл. Любой пользователь файлового менеджера может обладать правами администратора, что указывается при добавлении нового или редактировании существующего пользователя. Администратор может видеть все, в том числе «удалённые» файлы.
— Контроль версий каждого файла. После загрузки файла он сохраняется с именем, которое не позволяет перезаписать существующие файлы, а его «оригинальное» имя сохраняется в БД. Данный подход разрешает хранить разные состояния файлов.
— Автоматическое создание превью загружаемых изображений.
— Файл в менеджере можно сделать доступным для скачивания
— GPL, код доступен на github

FM создан без использования фреймворков. Это довольно обычное MVC приложение, где основные действия контроллера могут быть вызваны AJAX запросом, например:
— при инициализации приложения вызывается AJAX контроллер /ajax/fm/?action=files, функция files() в зависимости от текущей директории, которая хранится в сессии, получает список файлов и директорий.
— клик на файле делает активным DIV с а в зависимости от выбранной вкладки диалогового окна получает необходимые данные для текущего файла.

Пройдя по ссылке можно ознакомиться с основами функционирования приложения.

Для загрузки файлов используется Ajax Upload. Он поддерживает мультизагрузку и позволяет загружать файлы, переместив их drag&drop-ом на кнопку «Загрузка файлов». Главный недостаток: Ajax Upload не работает на планшетных (Android) устройствах.

Установка:
1) Скачать код файлового менеджера github
2) Создать базу данных и пользователя для доступа к базе. Дамп хранится в папке /sql/fm.sql
3) Распаковать исходный код системы в любую директорию веб-сервера
4) Выставить права на запись для необходимых директорий:
/cache/ /upload/ /upload/_thumb/

5) Отредактировать файл /system/config.ini:
; включить кеширование, ускоряет выполнение php скриптов
twig_cache = false

; пути, используемые системой, менять не нужно
[path]
application = «/system/»
library = «/system/library/»
controller = «/system/Controller/»
templates = «/system/View/templates/»
layouts = «/system/View/layouts/»
cache = «/cache»
upload = «upload/»

[fm]
; максимальный размер загружаемого файла в байтах
sizeLimit = 10485760
; цвет фона для создаваемых превьюшек и качество сжатия JPEG
rgb = 0xFFFFFF
quality = 100

; параметры для доступа к БД
; т.к. используется PDO можно использовать другие базы
[db]
adapter = «mysql»
host = «localhost»
username = «»
password = «»
dbname = «»
6) Открыть в браузере файловый менеджер. Для входа filemanager/filemanager
Логин/Пароль пользователя с правами администратора

1) Ajax Upload
valums.com/ajax-upload/
2) Иконки типов файлов: OSX 3.3

P.S. В demo файлового менеджера нельзя сделать какие-то изменения. ReadOnly, это специально.
Интерфейс файлового менеджера довольно прост, если проект заинтересует — над интерфейсом обещаю потрудиться.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A fairly full featured file manager all in one file

benergize/Single-File-PHP-file-manager

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

The inspiration for this project was my inability to use an FTP client remotely when working on CS projects that required I save my work to a campus-hosted server. I built a really terrible solution at the time which did some really janky things and was mostly contained in one enormous echo block, but I recently revisited it and rewrote it from the ground up.

The biggest challenge was keeping everything in one file while maintaining a decent feature set and preserving readability. The latter was the real challenge. By and large things are well commented, though, I did have to use section comments which I’m not crazy about. There’s some cases where things are shoved into one line, but only when it’s self explanatory when the formatting doesn’t look terrible.

  • View file list (with FontAwesome icons!)
  • Filter results in file list
  • Copy/delete/rename/preview/change permissions
  • Drag and drop file movement between directories
  • Create new files/folder
  • file uploading
  • AJAX (not more broken refresh/back buttons
  • Simple login/’security’
  • It’s all in one PHP file!
  • Dragging and dropping onto action buttons produces an error
  • Top directory dragging/dropping doesn’t work

This project makes use of Bootstrap, jQuery and FontAwesome, as well as a few functions which were created by users on PHP.net and Stack Overflow—These are credited in the source.

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A fairly full featured file manager all in one file

Источник

Оцените статью