Monsta FTP allows you to log all user actions, either to a predefined log format, or via your own function. This article explains how to enable logging or implement your own.
Open the file /mftp/settings/config.php and look for these two variables (if you have a version older than 2.9.2 you'll need to manually add these.)
If you're using a version older than 2.9.2 you'll need to manually add the above variables as well as the two lines below in the define area.
The first var $configMftpActionLogPath is used where you want to use the default logging format. You'll replace null with your preferred path to the log file. Examples of this are:
The log file is written in the following format:
The second var $configMftpActionLogFunction is used where you want to write your own logging function. Setting this value will disable the default logging option (to disable it the value must be set to null.
To enable custom logging you need to give the name of your PHP function as the value. For example, if your function is myMonstaLogger(), you'll add this as:
On page load, Monsta FTP will check for a file called mftp_extensions.php (in the same directory as the index.php file) and include it if it exists. This is where you'll define the actual code for your function.
The $action variable will be one of: Log in, Edit file, Move file, Delete file, Rename file, CHMOD file, Fetch file, Download file, Upload file
$action | Action performed |
$clientIp | Logged in user's IP |
$host | User's FTP host address |
$username | User's FTP username |
$folderPath | Folder path where action took place |
$fileName | File or folder name affected by action |
$error | Any reported error |
The $userIp variable is the value of $_SERVER['REMOTE_ADDR']. If you need to determine this some other way (e.g. $_SERVER['X_FORWARDED_FOR']) then your custom function should handle this.