Изменен механизм расширения ссылок. Избавление от глобальных переменных

This commit is contained in:
CORP\phedor 2018-04-18 18:20:56 +03:00
parent 524b27936a
commit 40fad0e75b
11 changed files with 77 additions and 61 deletions

View file

@ -3,6 +3,7 @@
namespace ctiso\Filter;
use ctiso\HttpRequest;
/* Переделать формат Логов на список json */
class ActionLogger
{
public $before = array();
@ -14,13 +15,19 @@ class ActionLogger
function __construct(/*.Filter.*/$processor, $logPath, $user) {
$this->processor = $processor;
$this->user = $user;
$this->file = fopen($logPath, "a");
$file = fopen($logPath, "a");
if (is_resource($file)) {
$this->file = $file;
} else {
throw new \Exception('Ошибка открытия файла ' . $logPath);
}
}
function execute(HttpRequest $request) {
$action = $request->getAction();
if(in_array($action, $this->before)) {
fwrite($this->file, "time: " . date("r", time()) . " query: ". json_encode(array_merge($_POST, $_GET)) . " by: " . $this->user->name . "\n");
$message = ["time" => date("r", time()), "query" => array_merge($_POST, $_GET), "user" => $this->user->name];
fwrite($this->file, json_encode($message) . "\n");
}
return $this->processor->execute($request);
}