63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
// --- Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(__DIR__ . '/application'));
|
|
|
|
// --- Define application environment
|
|
defined('APPLICATION_ENV')
|
|
| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
// --- Composer autoload
|
|
require_once realpath(__DIR__ . '/vendor/autoload.php');
|
|
|
|
// --- Create application, bootstrap, and run
|
|
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
|
|
|
try {
|
|
// --- Options
|
|
$opts = new Zend_Console_Getopt(array(
|
|
'help|?' => "Displays usage information.",
|
|
'file|f=s' => "Full file path to integrate",
|
|
'event=s' => "Event",
|
|
));
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
// --- Usage
|
|
if( isset($opts->help) || count($opts->getOptions())==0 )
|
|
{
|
|
echo "Proxy Event Trigger.\n";
|
|
echo $opts->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
// --- Basic file information
|
|
if (empty($opts->file)) {
|
|
exit;
|
|
}
|
|
|
|
$pathParts = pathinfo($opts->file);
|
|
$filename = $pathParts['basename'];
|
|
$extension = $pathParts['extension'];
|
|
|
|
switch($opts->event)
|
|
{
|
|
case 'IN_CLOSE_WRITE':
|
|
if ($extension == 'tck') {
|
|
passthru(__DIR__ . '/fileTck.php --file '.$opts->file.' >> /home/log/tck.log 2>&1');
|
|
} else {
|
|
passthru(__DIR__ . '/fileSend.php --file '.$opts->file.' >> /home/log/send.log 2>&1');
|
|
}
|
|
break;
|
|
case 'IN_ACCESS':
|
|
case 'IN_CLOSE_NOWRITE':
|
|
passthru(__DIR__ . '/fileRead.php --file '.$opts->file.' >> /home/log/read.log 2>&1');
|
|
break;
|
|
case 'IN_DELETE':
|
|
passthru(__DIR__ . '/fileRead.php --file '.$opts->file.' >> /home/log/read.log 2>&1');
|
|
break;
|
|
}
|