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

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);
}

View file

@ -19,7 +19,7 @@ class Filter
return $this->processor->execute($request);
}
public function getView($name, $class = 'View_Top')
public function getView($name, $class = 'ctiso\\View\\Top')
{
return $this->processor->getView($name, $class);
}

View file

@ -74,7 +74,7 @@ class Login extends Filter
// Если $hash не совпадает $_SESSION['hash'] то удаляем сессию
if (isset($_SESSION ['access']) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) {
if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) {
$this->user = $user = $role->getUserById($_SESSION['access']); // Поиск по идентификатору
$this->user = $user = $this->role->getUserById($_SESSION['access']); // Поиск по идентификатору
if ($user && isset($_SESSION['random']) && ($user->get('sid') == $_SESSION['random'])) {
return true;
}