[*] переименованы методы
This commit is contained in:
1 parent
eb18e5e6c9
commit
b5db27307f
23 files changed
+41
-41
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__ . '/inc/header.php';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once __DIR__ . '/../inc/bootstrap.php';
|
||||
|
||||
if (!CUser::is_user()) {
|
||||
if (!CUser::isUser()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ if (!isset($_REQUEST['deviceId']) or $_REQUEST['deviceId'] == '') {
|
||||
|
||||
$deviceId = prepareString($_REQUEST['deviceId']);
|
||||
|
||||
if (!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::is_admin()) {
|
||||
if (!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once __DIR__ . '/../inc/bootstrap.php';
|
||||
|
||||
if(!CUser::is_user()) {
|
||||
if(!CUser::isUser()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
$sensor = prepareString($_REQUEST['sensor']);
|
||||
|
||||
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::is_admin()) {
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once __DIR__ . '/../inc/bootstrap.php';
|
||||
|
||||
if(!CUser::is_user()) {
|
||||
if(!CUser::isUser()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
$deviceId = prepareString($_REQUEST['deviceId']);
|
||||
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::is_admin()) {
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
$result = [];
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
require_once __DIR__ . '/../inc/bootstrap.php';
|
||||
|
||||
$result = [];
|
||||
if(!CUser::is_user()) {
|
||||
if(!CUser::isUser()) {
|
||||
$result = ['status' => 'fail', 'error' => '403 - Access denied'];
|
||||
} else {
|
||||
$result = ['status' => 'ok'];
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
header("Location: index.php?"); die();
|
||||
}
|
||||
$deviceId = prepareString($_REQUEST['id']);
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::is_admin()) {
|
||||
if(!isHaveAccessToDevice($deviceId, $USER['id']) and !CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__.'/inc/header.php';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
if (!CUSer::is_admin()) {
|
||||
if (!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__ . '/inc/header.php';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__ . '/inc/header.php';
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ require_once __DIR__ . '/inc/header.php';
|
||||
$userId = $USER['id'];
|
||||
|
||||
|
||||
if (isset($_REQUEST['id']) and !empty($_REQUEST['id']) and CUser::is_admin()) {
|
||||
if (isset($_REQUEST['id']) and !empty($_REQUEST['id']) and CUser::isAdmin()) {
|
||||
$userId = $_REQUEST['id'];
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
if (!CUSer::is_admin()) {
|
||||
if (!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__ . '/inc/header.php';
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ CUser::init($DB); // инициализация поддержки п
|
||||
CEvents::init($DB); // инициализация класса журналирования событий
|
||||
CCron::init($DB); // инициализация крона
|
||||
|
||||
if(CUser::is_user()) {
|
||||
if(CUser::isUser()) {
|
||||
$cacheId = md5('CUser::getFields_'.CUser::$id);
|
||||
if(CCache::check($cacheId)) {
|
||||
$USER = CCache::get($cacheId);
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ if(!defined('CORE_LOADED') or CORE_LOADED !== true) {
|
||||
die();
|
||||
}
|
||||
|
||||
if(!CUser::is_user() and $_SERVER['REQUEST_URI'] !== '/login.php') {
|
||||
if(!CUser::isUser() and $_SERVER['REQUEST_URI'] !== '/login.php') {
|
||||
header("Location: login.php");
|
||||
die();
|
||||
}
|
||||
@@ -148,7 +148,7 @@ if(!CUser::is_user() and $_SERVER['REQUEST_URI'] !== '/login.php') {
|
||||
|
||||
<li class="nav-item nav-drawer-header">Компоненты</li>
|
||||
|
||||
<?php if(CUSer::is_admin()): ?>
|
||||
<?php if(CUSer::isAdmin()): ?>
|
||||
<li class="nav-item <?php echo basename($_SERVER['PHP_SELF']) == 'events.php' ? 'active' : '';?>">
|
||||
<a href="<?php echo HOME; ?>/events.php"><i class="fa fa-list"></i> Журнал событий</a>
|
||||
</li>
|
||||
|
||||
@@ -121,7 +121,7 @@ class CUser {
|
||||
* @param string $name
|
||||
* @param string $image
|
||||
*/
|
||||
public static function Registration($login, $password, $email, $level = 'user', $name = '', $image = ''):void {
|
||||
public static function registration($login, $password, $email, $level = 'user', $name = '', $image = ''):void {
|
||||
self::$DB->addItem(self::$table, array('login' => $login, 'password' => $password, 'access_level' => $level, 'name' => $name,'image' => $image, 'email' => $email, 'last_active' => time()));
|
||||
$result = self::$DB->getItem(self::$table, array('login'=>$login, 'password' => $password));
|
||||
|
||||
@@ -142,7 +142,7 @@ class CUser {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function user_exists($login):bool{
|
||||
public static function isUserExists($login):bool{
|
||||
$result = self::$DB->getItem(self::$table, array('login'=>$login));
|
||||
|
||||
if($result) {
|
||||
@@ -157,7 +157,7 @@ class CUser {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function count_users():int{
|
||||
public static function countUsers():int{
|
||||
$result = self::$DB->getItems(self::$table, array('id'=>'>0'));
|
||||
|
||||
if($result) {
|
||||
@@ -174,7 +174,7 @@ class CUser {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function Authorize($id):bool{
|
||||
public static function authorize($id):bool{
|
||||
$result = self::$DB->getItem(self::$table, array('id'=>$id), true);
|
||||
|
||||
if($result) {
|
||||
@@ -198,7 +198,7 @@ class CUser {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function SecurityAuthorize($login, $password):bool{
|
||||
public static function securityAuthorize($login, $password):bool{
|
||||
|
||||
$result = self::$DB->getItem(self::$table, array('login'=>$login, 'password' => $password), true);
|
||||
if($result) {
|
||||
@@ -219,7 +219,7 @@ class CUser {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_user():bool {
|
||||
public static function isUser():bool {
|
||||
if(!isset($_SESSION['authorize']) or empty($_SESSION['authorize']) or $_SESSION['authorize'] !== 'Y') {
|
||||
return false;
|
||||
}
|
||||
@@ -244,8 +244,8 @@ class CUser {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_admin():bool {
|
||||
if(self::is_user()) {
|
||||
public static function isAdmin():bool {
|
||||
if(self::isUser()) {
|
||||
if(self::getFields(self::$id)['access_level'] == 'admin') {
|
||||
return true;
|
||||
} else {
|
||||
@@ -259,7 +259,7 @@ class CUser {
|
||||
/**
|
||||
* Метод выхода из системы
|
||||
*/
|
||||
public static function Logout():void {
|
||||
public static function logout():void {
|
||||
$_SESSION['id'] = '';
|
||||
$_SESSION['authorize'] = '';
|
||||
$_SESSION['login'] = '';
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
*/
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
|
||||
if(CUser::is_user()) {
|
||||
if(CUser::isUser()) {
|
||||
$auth = true;
|
||||
} else {
|
||||
$auth = false;
|
||||
if($_REQUEST['login']!=='' and $_REQUEST['pass']!=='' and !empty($_REQUEST['login'] and !empty($_REQUEST['pass']))){
|
||||
if(CUser::SecurityAuthorize($_REQUEST['login'], $_REQUEST['pass'])) {
|
||||
if(CUser::securityAuthorize($_REQUEST['login'], $_REQUEST['pass'])) {
|
||||
$auth = true;
|
||||
} else {
|
||||
$auth = false;
|
||||
|
||||
+2
-2
@@ -9,9 +9,9 @@
|
||||
}
|
||||
$id = prepareString($_REQUEST['id']);
|
||||
|
||||
CUser::Logout();
|
||||
CUser::logout();
|
||||
session_start(); //TODO: нужно будет убрать при корректировке метода Logout
|
||||
CUser::Authorize($id);
|
||||
CUser::authorize($id);
|
||||
|
||||
header("Location: index.php");
|
||||
die();
|
||||
+1
-1
@@ -7,5 +7,5 @@
|
||||
* Сайт: https://it-stories.ru
|
||||
*/
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
CUser::Logout();
|
||||
CUser::logout();
|
||||
header("Location: index.php");
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__.'/inc/header.php';
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@
|
||||
require_once __DIR__ . '/inc/bootstrap.php';
|
||||
$err_mess = false;
|
||||
|
||||
if(CUser::is_user()) {
|
||||
if(CUser::isUser()) {
|
||||
header("Location: index.php");
|
||||
die();
|
||||
}
|
||||
@@ -19,13 +19,13 @@ if(isset($_REQUEST['reg']) and $_REQUEST['reg'] == 'Y'){
|
||||
isset($_REQUEST['email']) and $_REQUEST['email'] !=='' and
|
||||
isset($_REQUEST['pass']) and $_REQUEST['pass'] !=='') {
|
||||
|
||||
if(!CUser::user_exists($_REQUEST['login'])) {
|
||||
CUser::Registration($_REQUEST['login'],
|
||||
if(!CUser::isUserExists($_REQUEST['login'])) {
|
||||
CUser::registration($_REQUEST['login'],
|
||||
$_REQUEST['pass'],
|
||||
$_REQUEST['email'],
|
||||
'user', $_REQUEST['name'],
|
||||
'assets/img/avatars/default_avatar.jpg');
|
||||
CUser::SecurityAuthorize($_REQUEST['login'], $_REQUEST['pass']);
|
||||
CUser::securityAuthorize($_REQUEST['login'], $_REQUEST['pass']);
|
||||
CEvents::add('Зарегистрирован новый пользователь <b>'.$_REQUEST['login'].'</b>', 'info', 'reguser');
|
||||
header("Location: index.php");
|
||||
die();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__.'/inc/header.php';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Файл для тестирования и отладки нового функционала
|
||||
*/
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUser::is_admin()) {
|
||||
if(!CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
//userSendMail(1, 'Test userMail', 'Hello!!!',false);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Файл для тестирования и отладки нового функционала
|
||||
*/
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUser::is_admin()) {
|
||||
if(!CUser::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__.'/inc/bootstrap.php';
|
||||
if(!CUSer::is_admin()) {
|
||||
if(!CUSer::isAdmin()) {
|
||||
die('403 - Access denied');
|
||||
}
|
||||
require_once __DIR__.'/inc/header.php';
|
||||
@@ -36,7 +36,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
CPagination::execute($_REQUEST['page'], CUser::count_users(), PAGINATION_LIMIT);
|
||||
CPagination::execute($_REQUEST['page'], CUser::countUsers(), PAGINATION_LIMIT);
|
||||
$limit = CPagination::getLimit();
|
||||
?>
|
||||
<?php foreach(CUser::getUsers($limit, 'ASC') as $user): ?>
|
||||
|
||||
Reference in new issue
Block a user