Running custom scripts when users perform various actions

Custom PHP scripts can be automatically executed when the users perform one of the 57 monitored actions (E-mail_notification_system#Actions_keynames).

For example, to automatically run custom PHP code whenever a file is uploaded, you can simply place a PHP file named "upload.php" inside the folder "/path-to-WebFileShare/customizables/events/"

Here's a list of useful scripts:

Set file permissions after upload:

$data = unserialize($data['data']);

chmod($data['full_path'], 0644);


Antivirus check on upload:

 

<?php

global $auth;

$data = unserialize($data['data']);

$info = array(

                "username" => $auth->currentUserInfo['username'],

                "fullPath" => $data['full_path']

);

 

$pathToShellScript = "virus_scan.sh";

//virus_scan.sh will be executed with the username and the file's path

@system($pathToShellScript." ".escapeshellarg($info['username'])." ".escapeshellarg($info['fullPath']);

 

Filter uploaded files by extension:

<?php

$extensions = array("exe", "dll"); //customize the list of banned extensions

 

/*************************************************************/

 

global $fm;

$data = unserialize($data['data']);

$ext = $fm->getExtension($data['filename']);

if (in_array($ext, $extensions)) {

                unlink($data['full_path']);

}

 

 

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
Custom CSS
Viewed 1941 times since Wed, Nov 22, 2017
Forcing certain file types to download
Viewed 2706 times since Thu, Mar 6, 2014
Hiding options from the "Open with..." menu
Viewed 2264 times since Thu, Mar 6, 2014
Custom file actions
Viewed 2456 times since Wed, Mar 5, 2014
External Login Form
Viewed 3929 times since Wed, Nov 22, 2017
Adding links to the menu
Viewed 2498 times since Thu, Mar 6, 2014
Translating Web File Share
Viewed 20062 times since Wed, Mar 5, 2014
Adding custom functionality
Viewed 2403 times since Thu, Mar 6, 2014
Custom "Open with" actions
Viewed 2130 times since Wed, Nov 22, 2017
The API
Viewed 4295 times since Wed, Nov 22, 2017
Recently Viewed
Mobile apps
MENU