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

This commit is contained in:
CORP\phedor 2018-03-28 12:43:06 +03:00
parent 8b38b2a3cc
commit f041488554
10 changed files with 39 additions and 33 deletions

View file

@ -1,26 +1,26 @@
<?php
namespace ctiso\Filter;
use ctiso\Shortcut,
ctiso\HttpRequest,
ctiso\Filter\UserAccess;
use ctiso\HttpRequest;
class ActionLogger
{
public $before = array();
public $file;
public $user;
public $action;
public $processor;
function __construct(/*.Filter_Filter.*/$processor) {
function __construct(/*.Filter_Filter.*/$processor, $logPath, $user) {
$this->processor = $processor;
$this->file = fopen(Shortcut::getUrl('access.log'), "a");
$this->user = $user;
$this->file = fopen($logPath, "a");
}
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: " . UserAccess::$name . "\n");
fwrite($this->file, "time: " . date("r", time()) . " query: ". json_encode(array_merge($_POST, $_GET)) . " by: " . $this->user->name . "\n");
}
return $this->processor->execute($request);
}