From 537673748f0b01539fc5839c2af1bacbefafc86d Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Fri, 5 May 2023 04:07:05 +0300 Subject: the penalty form (input, new record) --- core/classes/session/DefaultSession.php | 6 + public/app/config/app_constants.php | 43 ++++- public/app/controllers/Auth.php | 19 +- public/app/controllers/JsonToForm.php | 4 +- public/app/controllers/Office.php | 7 +- public/app/views/components/header_includes.php | 20 ++- public/app/views/templates/course.php | 93 ---------- public/app/views/templates/lesson.php | 82 --------- public/app/views/templates/page.php | 64 ------- public/app/views/templates/penalty.php | 227 ++++++++++++++++-------- public/app/views/user/invitation.php | 166 +++++++++++------ public/app/views/user/login.php | 82 +++++---- public/assets/css/class.css | 81 ++++++++- public/assets/css/overides.css | 120 ++++++++----- public/assets/js/cookie.js | 41 ++++- 15 files changed, 578 insertions(+), 477 deletions(-) delete mode 100644 public/app/views/templates/course.php delete mode 100644 public/app/views/templates/lesson.php delete mode 100644 public/app/views/templates/page.php diff --git a/core/classes/session/DefaultSession.php b/core/classes/session/DefaultSession.php index 819f00a..5e7ce39 100644 --- a/core/classes/session/DefaultSession.php +++ b/core/classes/session/DefaultSession.php @@ -16,6 +16,12 @@ class DefaultSession implements SessionHandlerInterface { // and let the session* functions // do what they know ini_set( "session.gc_maxlifetime", MAX_SESSION_LIFE ); + session_set_cookie_params([ + 'path' => '/', + // 'domain' => COOKIE_DOMAIN, # on localhost must be omitted entirely + 'secure' => COOKIE_SECURE, + 'samesite' => COOKIE_SAMESITE + ]); session_name(SESSION_NAME); session_start(); } diff --git a/public/app/config/app_constants.php b/public/app/config/app_constants.php index 262a727..3404033 100644 --- a/public/app/config/app_constants.php +++ b/public/app/config/app_constants.php @@ -23,7 +23,7 @@ if (file_exists("../core/auth/.env")) { // WEB-APP name and url // --- -- -- - - - define('SITE_TITLE', 'Classroom'); -define('SITE_URL', 'http://localhost'); +define('SITE_URL', $env['ANOM_HOSTNAME']); // Session and cookie names // --- -- -- - - - @@ -31,6 +31,19 @@ define('SESSION_NAME', 'offticket'); // cookie for session (office ticket) define('CONNECTION_COOKIE', 'con'); // cookie for connection define('MAX_SESSION_LIFE', 2*60*60); // maximum session lifetime (2 hours) +// Cookie Policy +// --- -- -- - - - +# define('COOKIE_DOMAIN', $env['ANOM_HOSTNAME']); // domain to be visible on +define('COOKIE_SECURE', false); // Secure cookie policy [true|false] +define('COOKIE_SAMESITE', 'Strict'); // SameSite cookie policy [Strict|Lax|None] + // recomended values: + // COOKIE_SECURE=true, COOKIE_SAMESITE='Strict' + // --- -- -- - - - + // for more info about cookie policy read: + // https://www.php.net/manual/en/function.session-set-cookie-params.php + + + // email setup // --- -- -- - - - // SMTP @@ -180,7 +193,7 @@ define('REGISTRATION_FORM', [ ], [ 'name' => 'email', - 'label' => 'e-mail', + 'label' => 'Email', 'type' => 'email', 'value' => 'auto', 'attributes' => ['required'] @@ -283,6 +296,11 @@ define('COMMON_REQUEST_FORM', [ 'source' => '\app\controllers\User::current' ], 'form' => [ + [ + 'name' => 'subject', + 'label' => 'Θέμα (χαρακτηριστικός τίτλος για αναφορά)', + 'attributes' => ['required'] + ], [ 'name' => 'first_name', 'label' => 'Όνομα', @@ -363,13 +381,22 @@ define('PENALTY_FORM', [ 'source' => 'user' ], 'form' => [ + [ + 'name' => 'subject', + 'label' => 'Θέμα (χαρακτηριστικός τίτλος για αναφορά)', + 'attributes' => ['required'] + ], + [ + 'label' => '', + 'type' => 'label' + ], [ 'label' => 'Πειθαρχική υπόθεση', 'type' => 'label' ], [ 'name' => 'of_article', - 'label' => 'του/της...', + 'label' => 'του/της/των...', 'type' => 'select', 'options' => [ 'του μαθητή', @@ -377,33 +404,33 @@ define('PENALTY_FORM', [ 'των μαθητών', 'των μαθητριών' ], - 'class' => 'col-4', + 'class' => 'col-md-4', 'attributes' => ['required'] ], [ 'name' => 'student_names', 'label' => '(ονοματεπώνυ-μο/μα, πτώση γενική)', 'type' => 'textarea', - 'class' => 'col-8', + 'class' => 'col-md-8', 'attributes' => ['required'] ], [ 'name' => 'of_department', 'label' => 'του τμήματος...', - 'class' => 'col-4', + 'class' => 'col-md-4', 'attributes' => ['required'] ], [ 'name' => 'date', 'label' => 'Ημερομηνία', 'type' => 'date', - 'class' => 'col-4', + 'class' => 'col-md-4', 'attributes' => ['required'] ], [ 'name' => 'time', 'label' => 'Ώρα', - 'class' => 'col-4', + 'class' => 'col-md-4', 'attributes' => ['required'] ], [ diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php index 118b4d0..f1e9819 100644 --- a/public/app/controllers/Auth.php +++ b/public/app/controllers/Auth.php @@ -62,9 +62,17 @@ class Auth { // set cookie for connected user setcookie( CONNECTION_COOKIE, - 'connected;'. $user->getName(), - time()+60*60*10, // 10 hours - '/' + rawurlencode(json_encode( + [ 'rid' => $record['role_id'], 'name' => $user->getName() ], + JSON_UNESCAPED_UNICODE + )), + [ + 'expires' =>time()+60*60*10, // 10 hours + 'path' => '/', + // 'domain' => COOKIE_DOMAIN, + 'secure' => COOKIE_SECURE, + 'samesite' => COOKIE_SAMESITE + ] ); // login OK, set Token in session @@ -174,7 +182,10 @@ class Auth { ]); - Render::view('user/invitation', ['form' => $form]); + Render::view('user/invitation', [ + 'form' => $form, + 'invitation_number' => $user->invitation + ]); } diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php index 5df650d..7df8098 100644 --- a/public/app/controllers/JsonToForm.php +++ b/public/app/controllers/JsonToForm.php @@ -219,7 +219,7 @@ class JsonToForm // print_r([ $set_value, $name, ($default_values->$name ?? 'none') ]); $appendKey = in_array('append-key', $attributes) ? true : false; // append key (for selects) - $required = in_array('required', $attributes) ? '' : ''; // required + $required = in_array('required', $attributes) ? 'required' : ''; // required $asterisk = in_array('required', $attributes) ? '*' : ''; // asterisk in label if required $html .= " @@ -239,7 +239,7 @@ class JsonToForm // prepare initialization of select2 (multiple) $initSelectsJS .= " var {$name} = $('#{$name}'); - {$name}.select2({ width: '100%', placeholde: '{$label}' });"; + {$name}.select2({ width: '100%' });"; if ($set_value) { // if default value is set $initSelectsJS .= " diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index cfadde3..44428af 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -160,6 +160,11 @@ class Office { } + private static function render_common_petition($opts) + { + + } + private static function render_penalty_form($opts) { $user_id = $opts['user']->getID(); @@ -193,7 +198,7 @@ class Office { // get Form's HTML and Jsvascript $form = JsonToForm::json_form($form_setup, [ - ['name' => 'id', 'value' => $user_id] // pass user identity + ['name' => 'user_id', 'value' => $user_id] // pass user identity ]); Render::view('templates/penalty', ['form' => $form]); diff --git a/public/app/views/components/header_includes.php b/public/app/views/components/header_includes.php index 433cc4e..15685b5 100644 --- a/public/app/views/components/header_includes.php +++ b/public/app/views/components/header_includes.php @@ -4,14 +4,24 @@ } ?> - + + + + + + + + + + + @@ -21,6 +31,7 @@ + @@ -28,11 +39,11 @@ - - + + @@ -51,7 +62,6 @@ - -

- -

- - - - $id, - 'breadcrumbs' => $breadcrumbs - ]) - ?> - - - - - -
Μαθήματα
- - $lessons, - 'fieldset' => ['intro', 'level'] // ['intro', 'date'] - ]); - ?> - - - - - - - - - - - - - - - - diff --git a/public/app/views/templates/lesson.php b/public/app/views/templates/lesson.php deleted file mode 100644 index 0867cd3..0000000 --- a/public/app/views/templates/lesson.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - <?=SITE_TITLE?> - <?=$title?> - - - - - - - $id, - 'label' => $breadcrumbs[ $course_id ]['rec']['label'], - 'parents' => $breadcrumbs[ $course_id ]['parents'] - ]); - ?> - - -
-
- - - -
- - -

- -

- - - -

- - - -
- text($lesson['body']); - - ?> -
- - -
- -
-
- - - - - - - diff --git a/public/app/views/templates/page.php b/public/app/views/templates/page.php deleted file mode 100644 index 6afe45e..0000000 --- a/public/app/views/templates/page.php +++ /dev/null @@ -1,64 +0,0 @@ - - - - - <?=SITE_TITLE?> - <?=$page['title']?> - - - - - - - 0, - 'label' => '', - 'parents' => [] - ]); - ?> - - -
- - -
- - -

- -

- - -
- text($page['body']); - - ?> -
- - -
- -
- - - - - - - diff --git a/public/app/views/templates/penalty.php b/public/app/views/templates/penalty.php index bbd7b4a..17e5426 100644 --- a/public/app/views/templates/penalty.php +++ b/public/app/views/templates/penalty.php @@ -9,115 +9,198 @@ Render::view('components/header_includes'); ?> - - -
-
-
- -
+ + +
+
+
-

Πρακτικό Πειθαρχικής Υπόθεσης

+

Πρακτικό Πειθαρχικής Υπόθεσης

+

- +
-
-

Απαιτείται η συμπλήρωση όλων των στοιχείων προκειμένου να γίνεται γρήγορα η σύνταξη των εγγράφων. Τα στοιχεία σας δεν πρόκειται να δημοσιοποιηθούν και προστατεύονται κατά την εισαγωγή τους με κρυπτογράφιση AES. Παράλληλα η σύνδεση στο site γίνεται με χρήση πιστοποιητικού SSL (RSA 2048 bits).

-

Αν έχετε ενεργοποιήσει ήδη το λογαρισμό σας μπορείτε να συνδεθείτε.

-
- + diff --git a/public/app/views/user/invitation.php b/public/app/views/user/invitation.php index eb34bc4..564b722 100644 --- a/public/app/views/user/invitation.php +++ b/public/app/views/user/invitation.php @@ -8,71 +8,55 @@ //////////////////////////////////////////////////////////////////////// Render::view('components/header_includes'); ?> - - - + +
-
+
+
- +

1o Γυμνάσιο Ραφήνας

+

+ Πλατφόρμα ηλεκτρονικών αιτήσεων + και δημιουργίας διαδικαστικών εγγράφων. +

+
-

1o Γυμνάσιο Ραφήνας /
- Πλατφόρμα ηλεκτρονικών αιτήσεων και δημιουργίας διαδικαστικών εγγράφων

- -

Πρόσκληση #

+

Πρόσκληση #

+

- +
-

Απαιτείται η συμπλήρωση όλων των στοιχείων προκειμένου να γίνεται γρήγορα η σύνταξη των εγγράφων. Τα στοιχεία σας δεν πρόκειται να δημοσιοποιηθούν και προστατεύονται κατά την εισαγωγή τους με κρυπτογράφιση AES. Παράλληλα η σύνδεση στο site γίνεται με χρήση πιστοποιητικού SSL (RSA 2048 bits).

-

Αν έχετε ενεργοποιήσει ήδη το λογαρισμό σας μπορείτε να συνδεθείτε.

+

+ Απαιτείται η συμπλήρωση όλων των στοιχείων + προκειμένου να γίνεται γρήγορα η σύνταξη των εγγράφων. +

+

+ Αν έχετε ενεργοποιήσει ήδη το λογαρισμό σας + μπορείτε να συνδεθείτε. +

+

+ Τα στοιχεία σας δεν πρόκειται να δημοσιοποιηθούν και προστατεύονται + κατά την μεταφορά τους στον server με ισχυρή κρυπτογράφιση. + Η ασφάλεια της σύνδεσης με το site πιστοποιείται από την + Let's Encrypt. +

+
+