This articles shows how to use scripting, event-handling and session information from within Syncplify.me Server! For the sake of this example we will only log such information in the log file, but in real-life production scenarios you can use these info as you wish (for example you may want to send them via email to someone, or even make decisions based upon them).
Let’s start by preparing the script that – as we said – will log some info in your Syncplify.me Server!’s log file:
AddToLog('Script being run: '+ScriptName+' (ID: '+ScriptID+')');
AddToLog('Triggered by event: '+EventHandler+' (Priority: '+IntToStr(HandlerPriority)+')');
AddToLog('Virtual object affected: '+VirtualObjectName);
AddToLog('Physical object (available only for "Disk*" VFSs): '+ObjectName);
AddToLog('Client connected from: '+Session.ClientIP);
AddToLog('Client software: '+Session.ClientSoftware);
AddToLog('User authenticated as: '+Session.ReqUsername);
AddToLog('Files uploaded so far during this session: '+IntToStr(Session.FilesUp)+' (KB: '+FloatToStr(Session.KBUp)+')');
AddToLog('Files downloaded so far during this session: '+IntToStr(Session.FilesDown)+' (KB: '+FloatToStr(Session.KBDown)+')');
AddToLog('Last client command: '+Session.LastCommand+' ('+FloatToStr(now-Session.LastCommandTS*24*60)+' minutes ago)');
We save the above script with the following name/description: “Log several client and connection info”.
Then we add an event-handler to trigger the execution of the script. Since the script contain references to file-transfer-related variables (VirtualObjectName and ObjectName) it seems obvious to trigger its execution upon occurrence of a file-transfer-related event. For the sake of this example we have chosen the AfterFileUpload event, which occurs every time a file is successfully uploaded by a client onto the server. Continue reading