/usr/share/php/Analog/Handler/Post.php is in php-analog 1.0.7-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <?php
namespace Analog\Handler;
/**
* Post the log info to the specified address.
*
* Usage:
*
* $address = 'http://my-log-server/log-me';
* Analog::handler (Analog\Handler\Post::init ($address));
*
* The server will receive an HTTP POST request with four
* parameters:
*
* - machine
* - date
* - level
* - message
*
* Note: Requires cURL.
*/
class Post {
public static function init ($address) {
return function ($info) use ($address) {
if (! extension_loaded ('curl')) {
throw new \LogicException ('CURL extension not loaded.');
}
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, $address);
curl_setopt ($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_VERBOSE, 0);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $info);
curl_exec ($ch);
curl_close ($ch);
};
}
}
|