Plugins for TFU/JFU/WFU

Since version 2.9 TFU does support that you can include and execute your own code after the upload. In TinyWebGallery e.g. the cache images are automatically created. You can e.g. write a log file or enter the upload data to your database.
You can also track downloads, deletes or any other file function since TFU 2.10.7. Check the log plugins for working implementations!

On this page you find all available plugins, how to install them and how to create your own plugins.

The plugins do work for TWG, TFU, JFU and WFU.

 Available plugins

PluginDescriptionDownload
Log

The log plugin logs each upload, download and delete to the tfu.log file.

For each upload the file name, file path, the full path, the login and the description (if given) is stored. If you use Joomla and a user is registered you additionally get the user id, user name and the user e-mail.

Make sure the tfu folder is writeable!

Please note: The tfu.log has a maximum filesize of 2 MB. When the limit is reached the file is renamed to tfu.log.bak and a new log file is started. So you have a maximum of 4 MB of log data. If you need more please change the log file size or the implementation in tfu_helper.php (line 53 ff) or use the database plugin.


Download
Database

The database plugin logs each upload, download and delete to a database table.

For each upload the file name, file path, the full path, the login, upload time and the description (if given) is stored. If you use Joomla and a user is registered you additionally get the user id, user name and the user e-mail.
The database table is created automatically if it does not exist yet.

Setup:

  • TFU/WFU - Open the db_plugin.php and enter your database parameters in the file where you find the text
    // enter your db values below! (line 38ff.)
    'joomla_flash_uploader_log' is the default table name
     
  • Joomla - the Joomla db parameters are used. So you can use the plugin without any modification.
    '<dbprefix>joomla_flash_uploader_log' is the default table name.


Download
Thumbnail

The thumbnail plugin creates a thumbnail after the upload.

This plugin creates the thumbnail in the same folder. The file name for the thumb is the original file name plus '.thumb.jpg'. The internal resize function is used in the plugin. Therefore the file is first copied and resized afterwards.


Download
Prefix

The prefix plugin adds a prefix to each uploaded file.

For each upload you can add a timestamp or e.g. the user name added to the file name.

Setup:

  • By default a timestamp is used: A file will e.g. get the prefix '20090829_' when it is uploaded at the 29.8.2009
     
  • If you want a different prefix please modify prefix_plugin.php. The plugin is prepared to add the login or if used in Joomla the user id, user name or user e-mail

Please note: The plugin file name is a_prefix_plugin.php. The reason is that this plugin changes the file name and plugins are executed in alphabetical order. This plugin should be executed first because otherwise other plugins use a wrong file name.


Download
Form

The form plugin is an example how to get input elements from a HTML page where the flash is included.

You can use this plugin with the default tfu.htm page that comes with TFU. There the value of the language drop down is sent with the upload.
Set $form_fields = 'select'; in tfu_config.php and make sure you have at least a professional license. Then in the tfu.log you get the value of the drop down as last parameter.

Make sure the tfu folder is writeable!


Download


Feel free to extend any of the plugins to your needs.

 How to install plugins

Installing a plugin is really simple. Just extract the php file in the zip to the directory where the tfu_upload.php is located:

  • TFU -   main folder
  • JFU -   <Joomla main folder>/administrator/components/com_joomla_flash_uploader/tfu
  • WFU - <Wordpress main folder>/wp-content/plugins/wp-flash-uploader/tfu

Please check the description for the setup you have to do for some plugins. Feel free to extend any of the plugin to your needs.

Don't forget to delete your plugins before you uninstall JFU.

Plugins are executed in alphabetical order! If a plugin depends on other plugins (like the prefix plugin) take this into account if you create your own plugins.

 How to create your own plugins

Creating your own plugin is really simple. The tfu_upload.php look for all files which end with _plugin.php. If you e.g. want to create a plugin that copies the file with ftp somewhere else a good name for the plugin would be ftp_plugin.php. You should use one of the existing plugins and modify to your needs.

ftp is now the name of the plugin and you have to create the two functions in this file called:

function ftp_plugin_process_upload_file($folder, $fullpath ,$filename) {
// is called after the upload
}

/* optional for file operations */
function ftp_plugin_process_file($action, $fullpath, $folder) {
// is called by all file operations - See tfu_file.php for available actions.
}

Just check the existing plugins as examples. This function is called by tfu_upload.php after the upload or by tfu_file.php. The available parameters are:

  • $folder - relative folder the file is uploaded too.
  • $fullpath - the full path to the file - use this to copy the file somewhere.
  • $filename - the name of the file.
  • $action - the performed action - e.g. delete. See tfu_file.php for available actions.

In the session and in the request are some more data you might want to use:

$username = (isset($_SESSION['TFU_USER'])) ? $_SESSION['TFU_USER'] : $_SERVER['REMOTE_ADDR'];
$description = (isset($_GET['description'])) ? $_GET['description'] : '';

If you want to check if this is the last file of the upload use:

global $remaining;
if ($remaining == 0) {
// do whatever you want at the last upload
}

If you have a post upload window you get the data here:

$_SESSION['TFU_PRE_UPLOAD_DATA']

If you need a list of the files uploaded in this upload so far:

$_SESSION['TFU_LAST_UPLOADS']

If you need any of the parameters from the config please use the global statement.

The next 3 values only available if you use Joomla and a user is registered:

$userid = (isset($_SESSION['TFU_USER_ID'])) ? $_SESSION['TFU_USER_ID'] : '';
$userdisplayname = (isset($_SESSION['TFU_USER_NAME'])) ? $_SESSION['TFU_USER_NAME'] : '';
$useremail = (isset($_SESSION['TFU_USER_EMAIL'])) ? $_SESSION['TFU_USER_EMAIL'] : '';
$isbackend = isset($_SESSION['IS_ADMIN']);

Make sure that each plugin contains this line at the top to make sure noone else can call the plugin:

defined('_VALID_TWG') or die('Direct Access to this location is not allowed.');

If you have written a plugin that is maybe useful for others please send it to me. I will include it to this page.

Bookmark at
...

       
       

Follow TWG at
Twitter