File Manager
Starting from Plesk 11.5, you can create extensions that add functionality to Plesk File Manager and manage domain files by themselves.
File Manager's Context Menu
To add an item to the context menu of the File Manager:
- Create the file
/plib/library/FileManager/Action.php
in your extension directory. - Create the class Modules_MyModule_FileManager_Action that extends the pm_FileManager_Action class in this file. MyModule here is your extension's ID.
An example of such class in provided below:
The variable $this->_item
contains an array with the information about the file or a directory on which the menu is shown:
The result of adding such an extension is shown below:
Managing Webspace Files and Directories
To manage files and directories within a domain, use the pm_FileManager class. This class lets you create and remove files and directories, check for the existence of files and directories, read and write data to files, and also change file and directory permissions (only on Linux).
Important: For security considerations, we strongly recommend that you do not use system calls such as fopen or file_get_contents in the code of your extension. When you use such calls, the extension works with files on behalf of the psaadm
user. In turn, if you use the pm_FileManager class, the manipulations are performed on behalf of the domain owner's system user.
Below is an example of working with files by means of the pm_FileManager class.
The $filePath
path here is an absolute path. It is formed from the relative path within the domain directory $currentDir
by the call of the getFilePath
method.
Managing Server Files and Directories
To manage files and directories anywhere on the server, use the pm_ServerFileManager class. This class enables you to perform the same operations as the pm_FileManager class.
Below is an example of working with files by means of the pm_ServerFileManager class.