Beispiel #1
0
#!/usr/bin/php
<?php 
date_default_timezone_set('Europe/Amsterdam');
echo "----------------------------------\n";
echo "MiniThor flow queue system started\n";
echo date('Y-m-d H:i:s') . "\n";
echo "----------------------------------\n";
$pheanstalkClassRoot = '../contrib/Pheanstalk';
require_once $pheanstalkClassRoot . '/Pheanstalk/ClassLoader.php';
Pheanstalk_ClassLoader::register($pheanstalkClassRoot);
$pheanstalk = new Pheanstalk('nurgle.nl');
$continue = true;
$restart = false;
do {
    $job = $pheanstalk->watch('testtube')->ignore('default')->reserve();
    $jobData = $job->getData();
    echo '> ' . date('H:i:s') . ' - ' . $jobData . "\n";
    if ($jobData == 'restart') {
        $continue = false;
        $restart = true;
    } else {
        if ($jobData == 'stop') {
            $continue = false;
        }
    }
    $pheanstalk->delete($job);
} while ($continue);
if ($restart) {
    $exitCode = 98;
    // Planned restart
} else {
Beispiel #2
0
require $ruta . "/config/config.php";
if (!$config['activar_antivirus']) {
    echo "El antivirus no está activo\n";
    exit(1);
}
// Biblioteca pheanstalk
require_once $ruta . 'app/libraries/pheanstalk/pheanstalk_init.php';
// Analizador
require_once $ruta . 'app/libraries/Avengine.php';
require_once $ruta . 'app/libraries/avmodules/' . $config['avmodule'] . '.php';
$avconfig = $config['avconfig'];
$av = new $config['avmodule']($avconfig);
try {
    $pheanstalk = new Pheanstalk($config['beanstalkd_host'], $config['beanstalkd_port']);
    while (1) {
        $job = $pheanstalk->watch($config['beanstalkd_tube'])->ignore('default')->reserve();
        if ($job === FALSE) {
            debug("Reintentando en unos segundos...");
            sleep(5);
        } else {
            $exito = FALSE;
            debug($job->getData());
            $trozos = preg_split('/ /', $job->getData());
            if ($trozos[0] == 'SCAN') {
                $fid = $trozos[1];
                // Procesado con el antivirus
                $path = $config['directorio_ficheros'] . '/' . $fid;
                debug('Escaneando ' . $fid);
                $resav = $av->scan($path);
                if ($resav[0] == 2) {
                    // Error pasando clamav
<?php

require_once 'php-airbrake-notifier/Services/Airbrake.php';
require_once 'pheanstalk/pheanstalk_init.php';
$airbrake = new Services_Airbrake(HOPTOAD_API_KEY);
$k = array_rand($BEANSTALK_SERVERS);
$pheanstalk = new Pheanstalk($BEANSTALK_SERVERS[$k]['host'], $BEANSTALK_SERVERS[$k]['port']);
$pheanstalk->watch('airbrake')->ignore('default');
while ($job = $pheanstalk->reserve()) {
    $data = json_decode($job->getData());
    echo date('Y-m-d H:i:s') . ' Processing Error: ' . $data->url . "\n";
    $airbrake->curlRequest($data->url, $data->headers, $data->body);
    $pheanstalk->delete($job);
}