.pdf)
WHM Plugins
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::changeperm( dir, file, userread, userwrite, userexecute, groupread, groupwrite, groupexecute, worldread, worldwrite, worldexecute, doubleencode ) |
| Description: | Change a file's permissions. This is a deprecated function. You should use Fileman::fileop to change file permissions. |
| Parameters: | |
| dir (string (optional)) | |
| The directory that contains the file to be modified. This value needs to to be relative the account's home directory. Paths provided outside of the home directory will be ignored. If not provided, this parameter will default to the account's home directory. | |
| file (string) | |
| The file whose permissions will be changed. | |
| userread (integer) | |
| This sets the permissions for the user to read the specified file. This parameter should be set to 4 for the user to have read permissions for the file. Otherwise, this should be set to 0. | |
| userwrite (int (optional)) | |
| This sets the permissions for the user to write to the specified file. This parameter should be set to 2 for the user to have write permissions for the file. Otherwise, this should be set to 0. | |
| userexecute (bool (optional)) | |
| This sets the permissions for the user to execute the specified file. This parameter should be set to 1 for the user to have execute permissions for the file. Otherwise, this should be set to 0. | |
| groupread (string) | |
| This sets the permissions for the group to read the specified file. This parameter should be set to 4 for the group to have read permissions for the file. Otherwise, this should be set to 0. | |
| groupwrite (string) | |
| This sets the permissions for the group to write to the specified file. This parameter should be set to 2 for the group to have write permissions for the file. Otherwise, this should be set to 0. | |
| groupexecute (string) | |
| This sets the permissions for the group to execute the specified file. This parameter should be set to 1 for the group to have execute permissions for the file. Otherwise, this should be set to 0. | |
| worldread (string) | |
| This sets the permissions for any user on the system to read the specified file. This parameter should be set to 4 for any user on the system to have read permissions for the file. Otherwise, this should be set to 0. | |
| worldwrite (string) | |
| This sets the permissions for any user on the system to write to the specified file. This parameter should be set to 2 for any user on the system to have write permissions for the file. Otherwise, this should be set to 0. | |
| worldexecute (string) | |
| This sets the permissions for any user on the system to execute the specified file. This parameter should be set to 1 for any user on the system to have execute permissions for the file. Otherwise, this should be set to 0. | |
| doubleencode (boolean (optional)) | |
| A boolean value that specifies whether or not the $file and $dir are encoded in a URI format. | |
| Returns: | |
A message stating whether the operation failed or succeeded. For example: "Set permissions on index.html -> 0755" |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::Empty Trash( ) |
| Description: | Clear the user's trash directory (~/.trash). This call runs the following command: rm -rf ~/.trash. |
| Returns: | |
Nothing if successful.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::delfile( dir, file ) |
| Description: | Delete a file. This will create a backup of the file in the .trash directory (~/.trash) |
| Parameters: | |
| dir (string (optional)) | |
| The location of the directory containing the file to delete. If this parameter is not specified, the home directory will be used. | |
| file (string) | |
| The name of the file to delete. | |
| Returns: | |
'1' if successful. If the function fails, you will receive an error message.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmsavefile( dir, file, page, doubledecode, stripnewline ) |
| Description: | Save the contents of a string to a file. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory that contians the file to be modified. | |
| file (string) | |
| The name of the file to be modified. | |
| page (string) | |
| The string to be saved to the file. | |
| doubledecode (boolean) | |
| Specifying 1 to this parameter causes the function to attempt to decode URL values in dir and file. | |
| stripnewline (boolean) | |
| Specifying 1 to this parameter causes new lines to be stripped. | |
| Returns: | |
This function does not generate output other than the file being saved on the filesystem.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::dofileop( opdir, opfile, dir, fileop ) |
| Description: | Move or copy a file to a different directory. |
| Parameters: | |
| opdir (string (optional)) | |
| The directory that contains the file to move or copy. This value needs to be relative to the account's home directory. | |
| opfile (string) | |
| The name of the file to move or copy. | |
| dir (string) | |
| The destination to which the file should be moved or copied. | |
| fileop (string) | |
| The operation to be performed on the file. "move" and "copy" are the only 2 valid arguments for this parameter. | |
| Returns: | |
Nothing if the function completes successfully. If the function fails, it will output an error message.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::getfile( dir, file ) |
| Description: | Make an HTTP request for a specified file. This function prints the contents of the file to the web browser. It requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory that contains the file to be displayed. | |
| file (string) | |
| The name of the file to be displayed. | |
| Returns: | |
Prints the contents of the file to the browser.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::listtemplates( ) |
| Description: | List available file type templates from /usr/local/cpanel/share/templates. This function requires access to the 'filemanager' feature. |
| Returns: | |
The output should resemble the following: <html> <option value="Text Document">Text Document</option> <option value="HTML Document">HTML Document</option> <option value="Perl Script">Perl Script</option> <option value="Shell Script">Shell Script</option> <option value="Text Document">Text Document</option> </html> |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::savehtmlfile( dir, file, page, skipfile, doubledecode ) |
| Description: | Save the contents of a string to an HTML file. This function is not available in demo mode. This function requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory in which to store the file. | |
| file (string) | |
| The name of the file to be created. | |
| page (string) | |
| The HTML code to be saved, contained within a single string. | |
| skipfile (boolean) | |
| When 1 is passed to this parameter, the function will not open the directory specified in dir before saving the file. | |
| doubledecode (boolean) | |
| When 1 is passed to this parameter, the function will attempt to decode URI encoding in the dir and file parameters. | |
| Returns: | |
No output.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmmkdir( dir, file ) |
| Description: | Create a new directory. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory in which the new directory will be created. | |
| file (string) | |
| The name of the directory to be created. | |
| Returns: | |
The output should resemble the following: Created /home/USER/DIRECTORY |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmsavehtmlfile( dir, file, page, doubledecode ) |
| Description: | Save information supplied to the function as an HTML file. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory in which to save the HTML file. | |
| file (string) | |
| The name of the file to which the data should be saved. | |
| page (string) | |
| The information to save in the HTML file. | |
| doubledecode (boolean) | |
| Setting this parameter to 1, will cause the function to decode any URI encoding in the dir and file parameters. | |
| Returns: | |
This function produces no output other than the saved file on the filesystem.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmpushfile( dir, file ) |
| Description: | Prints a file to the browser, while encoding relevant HTML characters. This function requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory that contains the file to be displayed. | |
| file (string) | |
| The name of the file to be displayed. | |
| Returns: | |
The output displays the following characters as specified: ( '&' => '&&', '<' => '&<', '>' => '&>', '"' => '&"', "'" => '&'' ) |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::listfullbackups( ) |
| Description: | Retrieve a list of full backups in an HTML-encoded format. We recommend using Backups::listfullbackups in place of this function. |
| Returns: | |
HTML similar to: <div class="okmsg"><b><a href="/download?file=backup-11.30.2009_11-18-35_username.tar.gz">backup-11.30.2009_11-18-35_username.tar.gz</a></b> (Mon Nov 30 11:18:35 2009)<br /></div> <div class="warningmsg">backup-2.15.2010_10-32-02_username.tar.gz (Mon Feb 15 10:32:02 2010) [in progress] |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::listfiles( dir, chooser, select, dirselect, usesameframe ) |
| Description: | List files, corresponding permissions, and some display options in one of the account's directories. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory whose files will be listed. This value defaults to the account's home directory. This path may be specified as a full path or a relative path. | |
| chooser (boolean) | |
| Passing 0 to this parameter causes the function to print extra links for uploading files, creating files, and creating new folders. If 1 is passed to this function, the links are not created. | |
| select (string) | |
| If set to a value such as 'select.html' (which is the default value), links are created to send the relevant arguments for the selected file to the specified HTML page. For example, when the function displays a filename, it will be linked to: https://[your ip]:2083/frontend/x3/cpanelpro/$select?dir=%2fhome%2fusername&file=filename. This does not apply to directories (see $dirselect). |
|
| dirselect (string) | |
| Specifies the HTML page on which to create links when displaying directories. This parameter is currently hardcoded to 'seldir.html'. | |
| usesameframe (boolean) | |
| Passing 0 to this parameter causes the function to create links that will open selected files in a new browser window. | |
| Returns: | |
The output should resemble the following: <tr><td><a href="/frontend/x3/your.html?dir=%2fhome%2fUSERNAME/FILENAME"><img src="images/i-directory.gif" border="0"></a></td><td><a href="seldir.html?dir=%2fhome%2fUSERNAME&file=FILENAME">FILENAME</a></td><td></td><td>750</td></tr> |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fullbackup( dest, server, user, pass, email, port, rdir ) |
| Description: | Create a full backup. By default, backups are stored as /home/$username/backup-$date.tar.gz. The new backup can also be transferred to a remote location by specifying the 'dest' parameter (below). |
| Parameters: | |
| dest (string (optional)) | |
| The transfer protocol or destination for the backup. Valid values are scp, ftp, passiveftp, and homedir. Passing 'homedir' to this parameter will cause the backup to be placed in the user's home directory. Specifying any other option causes the function to use the specified protocol to transfer the backup. If no input is received by this parameter, 'homedir' is assumed. | |
| server (string (optional)) | |
| The destination of the new backup (e.g., example.com). This parameter is required when ftp, passiveftp, or scp is specified in the 'dest' parameter. | |
| user (string) | |
| The username to use to log into the remote location. This parameter is required when ftp, passiveftp, or scp is specified in the 'dest' parameter. | |
| pass (string) | |
| The password required to access the remote location. This parameter is required when ftp, passiveftp, or scp is specified in the 'dest' parameter. | |
| email (string) | |
| The email address that will receive a confirmation email when the backup is complete. | |
| port (int) | |
| The port to be used during the transfer. This parameter is required when ftp, passiveftp, or scp is specified in the 'dest' parameter. | |
| rdir (string) | |
| The directory on the remote machine that will store the new backup. This parameter is required when ftp, passiveftp, or scp is specified in the 'dest' parameter. | |
| Returns: | |
Nothing.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmrename( dir, file, filenew, doubledecode ) |
| Description: | Rename a file. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory containing the file to be renamed. | |
| file (string) | |
| The name of the file to be renamed. | |
| filenew (string) | |
| The new name for the file. | |
| doubledecode (boolean) | |
| Passing 1 to this parameter causes the function to attempt to decode URI values assigned to dir and file. | |
| Returns: | |
The output should resemble the following: Renamed test.txt -> newname.txt |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fmmkfile( dir, newfile, template ) |
| Description: | Create a new, mostly blank, file of a specified type. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory where the blank file will be created. | |
| newfile (string) | |
| The name of the file to be created. | |
| template (string) | |
| The template to use for the file. These are located in /usr/local/cpanel/share/templates. Acceptable values are (by default) HTML Document, Perl Script, Shell Script, and Text Document. | |
| Returns: | |
The output should resemble the following: Creation of myfile.pl (Perl Script)succeeded |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::viewfile( dir, file ) |
| Description: | View a specified file. Images and text files are normally displayed in the browser with the corresponding file name and file type information displayed. Archives can be viewed as well. This function requires access to the 'filemanager' feature. This function is not available in demo mode. |
| Parameters: | |
| dir (string) | |
| The directory that contains the file to be viewed. | |
| file (string) | |
| The name of the file to be viewed. | |
| Returns: | |
The output should resemble the following: <img src="images/gnome-textfile.gif"> <b><font size=+1>test.txt</font></b> <br>File Type: ASCII text |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::showperm( dir, file ) |
| Description: | Display permissions for a specified file in a graphical format with predefined checkboxes and JavaScript handlers for making changes. This function requires access to the 'filemananger' feature. |
| Parameters: | |
| dir (string) | |
| The directory containing the file to be queried. | |
| file (string) | |
| The name of the file to be queried. | |
| Returns: | |
The output should resemble the following: <tr> <td><b>Mode</b></td> <td>User</td><td>Group</td> <td>World</td> </tr> <tr> <td>Read</td> <td><input checked="checked" type="checkbox" name="ur" value="4" onClick="calcperm();"></td> <td><input checked="checked" type="checkbox" name="gr" value="4" onClick="calcperm();"></td> <td><input checked="checked" type="checkbox" name="wr" value="4" onClick="calcperm();"></td> </tr> <tr> <td>Write</td> <td><input checked="checked" type="checkbox" name="uw" value="2" onClick="calcperm();"></td> <td><input type="checkbox" name="gw" value="2" onClick="calcperm();"></td> <td><input type="checkbox" name="ww" value="2" onClick="calcperm();"></td> </tr> <tr> <td>Execute</td> <td><input type="checkbox" name="ux" value="1" onClick="calcperm();"></td> <td><input type="checkbox" name="gx" value="1" onClick="calcperm();"></td> <td><input type="checkbox" name="wx" value="1" onClick="calcperm();"></td> </tr> <tr> <td>Permission</td> <td><input type="text" name="u" size="1" readonly="readonly"></td> <td><input type="text" name="g" size="1" readonly="readonly"></td> <td><input type="text" name="w" size="1" readonly="readonly"></td> </tr> |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::uploadfiles( ) |
| Description: | Upload files to the server using cPanel's File Manager. This function is not available in demo mode. Note: You cannot call this function via XML-API. |
| Form Data: | |
| dir (string) | |
| The directory to which to upload the files. | |
| file* (string) | |
| The files to be uploaded, one file per file* form variable. Increment the variable names, starting with file1, file2, and so on. These variables must be submitted via POST requests. In addition, the values must have file- prepended before the filename. Thus, in order to upload a file called test.html, set the value of file1 to file-test.html. Lastly, if -key_relativepath is appended to a variable name, it will create a directory out of the value given. For example, creating a variable file1-key_relativepath and setting it to ../testdir will create the directory relative to the dir variable. The file indicated by the file1 variable will be uploaded to that new directory. |
|
| Returns: | |
The output will contain a status message, such as: test.html (test.html): upload succeeded, overwrote old file. |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::extractfile( dir, file ) |
| Description: | Extract a compressed file. This function requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory that contains the archive to be extracted. | |
| file (string) | |
| The name of the file to be extracted. | |
| Returns: | |
<img src="images/gnome-compressed.gif"> <b><font size=+1>file.tar.gz</font></b> <br>File Type: gzip compressed data, was "test.tar", from Unix, last modified: Thu Feb 4 21:38:37 2010 <br><hr><pre> file1 |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::htmleditor( dir, file, baseurl, basedir, charset, write_stdin ) |
| Description: | Open a specified file in the file manager's HTML editor. This function requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory that contains the file to be opened. | |
| file (string) | |
| The name of the file to be opened in the HTML editor. | |
| baseurl (string) | |
| The base URL for automated functions (e.g., http://www.example.com/my/directory/here). | |
| basedir (string) | |
| The base directory for the HTML file. This parameter defaults to /$home/user/public_html. | |
| charset (string) | |
| The character set in which to encode the HTML (e.g., UTF-8). | |
| write_stdin (boolean) | |
| Specifying 1 to this parameter causes the function to replace the default HTML editor template strings with the values represented in the HTML editor's configuration hash. | |
| Returns: | |
Opens the HTML editor in the browser.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::fileimg( dir, file, new ) |
| Description: | Display the appropriate icon for a specified file type. This function requires access to the 'filemanager' feature. |
| Parameters: | |
| dir (string) | |
| The directory that contains the file whose icon will be displayed. | |
| file (string) | |
| The name of the file whose icon will be displayed. | |
| new (boolean) | |
| Passing '1' to this parameter will cause the function to display the file's icon based on its MIME type, rather than the file extension. | |
| Returns: | |
<html> <img src="images/gnome-image-jpeg.gif" border="0" /> </html> |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::killdir( ) |
| Description: | Remove a specified directory. |
| Form Data: | |
| dir: (string) | |
| The directory to be removed, contained within a form parameter (e.g., dir:directory). For example, dir:test would remove a directory named test from the home directory. | |
| Returns: | |
None.
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::restorefile( file ) |
| Description: | Restore a file in ~/.trash to its previous directory. This function requires access to the 'backup' feature. |
| Parameters: | |
| file (string) | |
| The name of the file to restore. | |
| Returns: | |
The output should resemble the following: Restored deleted.file -> /home/<username>/deleted.file |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::restoredb( file-* ) |
| Description: | Restore a database backup. This function requires access to the 'backup' feature. This function is not available in demo mode. |
| Parameters: | |
| file-* (string) | |
| The database file to be restored. This parameter should be used with a POST request, while the parameter name should start with file-*. For example, multiple databases can be restored at once by POSTing file-1, file-2, etc. The function will create a database if it does not exist before the restoration. | |
| Form Data: | |
| dir (string) | |
| The directory into which to uncompress the backup file. The uncompressed files are left in this directory when the restoration is complete. | |
| Returns: | |
The output will contain a series of SQL statements pertaining to the restoration performed
|
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::restorefiles( ) |
| Description: | Restore a home directory backup to a specified directory. This function requires access to the 'backup' feature. This function is not available in demo mode. |
| Form Data: | |
| dir (string (optional)) | |
| The directory in which to store the uncompressed files. This value defaults to the account's home directory. | |
| file-* (string) | |
| This parameter takes names of files to be uploaded. The filenames should begin with file-. Arguments and files should be used with an HTTP POST request. | |
| Returns: | |
The output should resemble the following: ./ ./ssl/ ./ssl/certs/ ./ssl/certs/example.com.csr ./ssl/certs/example.com.crt ./ssl/private/ ./ssl/private/example.com.old.1265939365.key ... |
| API Version: | 1 - Click here for documentation |
|---|---|
| Syntax: | Fileman::restoreaf( dir ) |
| Description: | Restore email filters or email forwarders backups. This function requires access to the 'backup' feature. This function is not available in demo mode. It takes some arguments for the FORM hash that determines which kind of backup to restore. |
| Parameters: | |
| dir (string (optional)) | |
| The directory in which to store the uncompressed backups. If no value is specified for this parameter, it will default to the account's home directory. | |
| Form Data: | |
| file-* (string) | |
| This parameter takes form keys. Each key should start with file- (e.g. file-aliases.example.com.gz), followed by the filename generated by cPanel when the backup was created. For example, if the file is aliases.example.com.gz, the function will treat the file as an alias. Thus, valid parameter names must follow the convention: * file-aliases.example.com.gz - for forwarders * file-filter.example.com.gz - for filters Failure to specify the name correctly will result in filters being written to /etc/valiases or aliases being written to /etc/vfilters. Files should be uploaded via an HTTP POST request. . |
|
| Returns: | |
The output for this function will contain the contents of the uploaded file.
|