2015-10-14 15:16:14 +02:00
|
|
|
<?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');
|
|
|
|
|
2017-03-02 14:17:33 +01:00
|
|
|
// --- Options
|
|
|
|
$displayUsage = false;
|
2015-10-14 15:16:14 +02:00
|
|
|
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();
|
2017-03-02 14:17:33 +01:00
|
|
|
$optsNb = $opts->getOptions();
|
2015-10-14 15:16:14 +02:00
|
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
2017-03-02 14:17:33 +01:00
|
|
|
$displayUsage = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- Aide / Options
|
|
|
|
if ($optsNb == 0 || isset($opts->help)) {
|
|
|
|
$displayUsage = true;
|
2015-10-14 15:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- Usage
|
2017-03-02 14:17:33 +01:00
|
|
|
if ($displayUsage) {
|
2015-10-14 15:16:14 +02:00
|
|
|
echo "Proxy Event Trigger.\n";
|
|
|
|
echo $opts->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- Basic file information
|
|
|
|
if (empty($opts->file)) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2017-03-02 14:37:05 +01:00
|
|
|
$logPath = realpath(__DIR__ . '/../shared');
|
|
|
|
|
2015-10-14 15:16:14 +02:00
|
|
|
$pathParts = pathinfo($opts->file);
|
|
|
|
$filename = $pathParts['basename'];
|
|
|
|
$extension = $pathParts['extension'];
|
|
|
|
|
|
|
|
switch($opts->event)
|
|
|
|
{
|
|
|
|
case 'IN_CLOSE_WRITE':
|
|
|
|
if ($extension == 'tck') {
|
2017-03-02 14:37:05 +01:00
|
|
|
passthru(__DIR__ . '/tck.php --file '.$opts->file.' >> '.$logPath.'/tck.log 2>&1');
|
2015-10-14 15:16:14 +02:00
|
|
|
} else {
|
2017-03-02 14:37:05 +01:00
|
|
|
passthru(__DIR__ . '/send.php --file '.$opts->file.' >> '.$logPath.'/send.log 2>&1');
|
2015-10-14 15:16:14 +02:00
|
|
|
}
|
2015-11-19 16:25:31 +01:00
|
|
|
break;
|
2015-10-14 15:16:14 +02:00
|
|
|
case 'IN_ACCESS':
|
2015-11-25 11:22:01 +01:00
|
|
|
case 'IN_CLOSE_NOWRITE':
|
2017-03-02 14:37:05 +01:00
|
|
|
passthru(__DIR__ . '/read.php --file '.$opts->file.' >> '.$logPath.'/read.log 2>&1');
|
2015-10-14 15:16:14 +02:00
|
|
|
break;
|
|
|
|
case 'IN_DELETE':
|
2017-03-02 14:37:05 +01:00
|
|
|
passthru(__DIR__ . '/read.php --file '.$opts->file.' >> '.$logPath.'/read.log 2>&1');
|
2015-10-14 15:16:14 +02:00
|
|
|
break;
|
|
|
|
}
|