From c10650e888c624f43fb68fd6ecaa3c1204c7a453 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Wed, 19 Feb 2025 08:26:06 +0100 Subject: [PATCH] =?UTF-8?q?Zaktualizuj=20rozmiary=20plik=C3=B3w=20w=20konf?= =?UTF-8?q?iguracji=20oraz=20popraw=20logik=C4=99=20logowania=20u=C5=BCytk?= =?UTF-8?q?ownik=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/ftp-kr.sync.cache.json | 50 ++++++++++++++----------------- autoload/controls/class.Site.php | 8 ++--- autoload/controls/class.Users.php | 11 ++++--- autoload/factory/class.Users.php | 11 +++++-- index.php | 1 + 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index d459fbd..30b3897 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -63,12 +63,6 @@ "modified": false }, "controls": { - "class.Backpro.php": { - "type": "-", - "size": 368, - "lmtime": 0, - "modified": false - }, "class.Crm.php": { "type": "-", "size": 1824, @@ -101,14 +95,14 @@ }, "class.Tasks.php": { "type": "-", - "size": 13505, - "lmtime": 1739545030143, + "size": 14373, + "lmtime": 1739910394588, "modified": false }, "class.Users.php": { "type": "-", - "size": 3091, - "lmtime": 0, + "size": 3357, + "lmtime": 1739908495902, "modified": false }, "class.Wiki.php": { @@ -145,8 +139,8 @@ }, "class.Tasks.php": { "type": "-", - "size": 16421, - "lmtime": 1739545261687, + "size": 16915, + "lmtime": 1739910024244, "modified": false }, "class.Users.php": { @@ -197,20 +191,20 @@ "layout": { "style.css": { "type": "-", - "size": 21465, - "lmtime": 1739868350549, + "size": 21592, + "lmtime": 1739911190575, "modified": false }, "style.css.map": { "type": "-", - "size": 37249, - "lmtime": 1739868350549, + "size": 37528, + "lmtime": 1739911190575, "modified": false }, "style.scss": { "type": "-", - "size": 25925, - "lmtime": 1739868350325, + "size": 26162, + "lmtime": 1739911190405, "modified": false } }, @@ -388,8 +382,8 @@ }, "layout-logged.php": { "type": "-", - "size": 5693, - "lmtime": 1733745379453, + "size": 5371, + "lmtime": 1739908447871, "modified": false }, "layout-unlogged.php": { @@ -458,8 +452,8 @@ "tasks": { "filtr_save_form.php": { "type": "-", - "size": 707, - "lmtime": 0, + "size": 775, + "lmtime": 1739909969622, "modified": false }, "main_view_by_ajax.php": { @@ -470,8 +464,8 @@ }, "main_view.php": { "type": "-", - "size": 24715, - "lmtime": 1739545325088, + "size": 27106, + "lmtime": 1739911170901, "modified": false }, "task_edit.php": { @@ -482,14 +476,14 @@ }, "task_popup.php": { "type": "-", - "size": 6217, - "lmtime": 1739544589356, + "size": 6222, + "lmtime": 1739908742525, "modified": false }, "task_single.php": { "type": "-", - "size": 2866, - "lmtime": 1734256298399, + "size": 2893, + "lmtime": 1739911073279, "modified": false }, "work-time.php": { diff --git a/autoload/controls/class.Site.php b/autoload/controls/class.Site.php index 2d5bef7..4a42ebe 100644 --- a/autoload/controls/class.Site.php +++ b/autoload/controls/class.Site.php @@ -5,15 +5,15 @@ class Site public static function route() { global $user; - + $class = '\controls\\'; - + $results = explode( '_', \S::get( 'module' ) ); if ( is_array( $results ) ) foreach ( $results as $row ) $class .= ucfirst( $row ); - + $action = \S::get( 'action' ); - + if ( class_exists( $class ) and method_exists( new $class, $action ) ) { if ( \controls\Users::permissions( $user['id'], \S::get( 'module' ) ) ) diff --git a/autoload/controls/class.Users.php b/autoload/controls/class.Users.php index bb1ad35..2b86e51 100644 --- a/autoload/controls/class.Users.php +++ b/autoload/controls/class.Users.php @@ -82,10 +82,7 @@ class Users public static function login() { - if ( $user = \factory\Users::login( - \S::get( 'email' ), - md5( \S::get( 'password' ) ) - ) ) + if ( $user = \factory\Users::login( \S::get( 'email' ), md5( \S::get( 'password' ) ) ) ) { // zapamiętaj logowanie if ( \S::get( 'remember' ) ) @@ -98,6 +95,12 @@ class Users setcookie( $cookie_name, $value, strtotime( "+1 year" ), "/", $domain ); } + else + { + $domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] ); + $cookie_name = str_replace( '.', '-', $domain ); + setcookie( $cookie_name, "", strtotime( "-1 year" ), "/", $domain ); + } \S::set_session( 'user', $user ); echo json_encode( [ 'result' => 'true', 'msg' => 'Właśnie zostałeś zalogowany. Za chwilę nastąpi przekierowanie.', 'default_project' => $user[ 'default_project' ] ] ); diff --git a/autoload/factory/class.Users.php b/autoload/factory/class.Users.php index 54d9ba2..2d6edd5 100644 --- a/autoload/factory/class.Users.php +++ b/autoload/factory/class.Users.php @@ -39,6 +39,7 @@ class Users public static function users_list() { global $mdb, $user; + $users = $mdb -> select( 'users', '*' ); if ( $user['id'] === 1 ) @@ -48,10 +49,10 @@ class Users else { $users_list = []; - foreach ( $users as $user ) + foreach ( $users as $user_tmp ) { if ( $user['id'] != 6 ) - $users_list[] = $user; + $users_list[] = $user_tmp; } return $users_list; @@ -78,10 +79,14 @@ class Users return false; else { - if ( $password == $result['password'] or $password == md5( 'ProjectPro2025!' ) ) + if ( $password == $result['password'] and $email == $result['email'] ) + { return $result; + } else + { return false; + } } } } diff --git a/index.php b/index.php index f652ee6..6f896dd 100644 --- a/index.php +++ b/index.php @@ -65,6 +65,7 @@ if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) ) } $user = \S::get_session('user'); + if ( !$user and !in_array( $_SERVER['REQUEST_URI'], [ '/logowanie', '/rejestracja', '/users/login/', '/cron/main_view/' ] ) ) { header( 'Location: /logowanie' );