diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
| commit | 02608271bb2a9f3a65ed536984d306ee14b48e34 (patch) | |
| tree | 3f23ec48a694ec014e845c4f70d9b5f1c065403c /public/ui-user-management.php | |
| download | kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.gz kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.bz2 kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.zip | |
Diffstat (limited to 'public/ui-user-management.php')
| -rw-r--r-- | public/ui-user-management.php | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/public/ui-user-management.php b/public/ui-user-management.php new file mode 100644 index 0000000..9e9ee24 --- /dev/null +++ b/public/ui-user-management.php @@ -0,0 +1,259 @@ +<?php +include("config/parametres.php"); +include("includes/sessions.php"); +include("includes/functions.php"); + +// if user's ROLE is less then ADMIN : then go to Login | Panel +// ----------------------------------------------------------------------------- +if (ROLE < ADMIN) { + header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); + header("Cache-Control: post-check=0, pre-check=0", false); + header("Pragma: no-cache"); + header("Location: /"); + die(); +} + +// get records +// ----------------------------------------------------------------------------- + + $users = array(); + + // init database connection + $_dbc = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DBMS); + if ($_dbc->connect_errno) { + echo "Database connection failed; Please try in a few minutes. "; + if (TESTING) echo $_dbc->connect_error; + $_dbc->close(); die(); + } + $_dbc->set_charset("utf8"); + + // prepare statemet + $_stm = $_dbc->prepare("SELECT realname, user_id, `user`, role, birthstamp FROM users"); + $_stm->execute(); // execute query + $_stm->store_result(); // store result + + if ($_stm->num_rows) { + + $_stm->bind_result($name, $uid, $email, $role, $tm); // bind result variables + + while ($_stm->fetch()) { + + $users[] = array( + 'uid' => $uid, + 'name' => $name, + 'email' => $email, + 'role' => USER_ROLES[$role], + 'birth' => local_dt($tm) + ); + + } + } + else { + return array('success' => false, 'data' => "No items found"); // return error(s) + } + + $_stm->close(); // close statement + $_dbc->close(); // close connection + +?><!DOCTYPE html> +<html prefix="og: http://ogp.me/ns#" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB" dir="ltr"> + <head> + <!-- Metas + Title --> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + + <title><?=PROJECT?> : Διαχείριση Χρηστών'</title> + + <!-- CSS needed --> + <link href="https://fonts.googleapis.com/css?family=Ubuntu:400,700&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="/css/bootstrap.min.css" /><!-- v4.4.1 --> + <link rel="stylesheet" href="/css/select2.min.css" /><!-- v4.0.10 --> + <link rel="stylesheet" href="/css/pi.css" /> + </head> + <body> + <?php // Menu ---------------------------------------------------------------- + include("includes/menu.php"); + ?> + + <div class="profile-container"> + <div class="row"> + <div class="col-md-12"> + <h2>Διαχείριση Χρηστών</h2> + <h4>Χρήστες</h4> + + <hr /> + + <?php foreach ($users as $key => $user): ?> + + <div class="user-list"> + <div> + <strong><?=$user['name']?> : </strong> <?=$user['role']?><br /> + <?=$user['email']?><br /> + <span class="light-text">* <?=$user['birth']?></span> + + <span class="pi-action"><a class="btn btn-pi-light" href="#">Reset password</a></span> + <span class="pi-action"><a class="btn btn-pi-light" href="#">Επεξεργασία</a></span> + </div> + </div> + + <hr /> + <?php endforeach; ?> + + <div class="some-form"> + <p> + <a class="btn btn-pi-light" data-toggle="collapse" href="#collapse-pass" role="button">Δημιουργία νέου χρήστη</a> + </p> + <div class="collapse" id="collapse-pass"> + <div class="card card-body"> + <form id="change-pass" method="post" action="#"> + + <div class="form-group"> + <label for="name">Ονοματεπώνυμο χρήστη</label> + <input class="form-control" type="password" name="name" disabled> + </div> + <div class="form-group"> + <label for="name">Ρόλος</label> + <select class="form-control" name="role"> + <option>Καταχωρητής / Διορθωτής</option> + <option>Επόπτης</option> + <option>Διαχειριστής</option> + <?php if(ROLE == SYSADMIN) : ?> + <option>System Administrator</option> + <?php endif; ?> + </select> + </div> + <div class="form-group"> + <label for="pass">Email (για σύνδεση)</label> + <input class="form-control" type="email" name="email" disabled> + </div> + <div class="form-group"> + <label for="pass">Κωδικός πρόσβασης</label> + <input class="form-control" type="password" name="pass" disabled> + </div> + <div class="form-group"> + <label for="confirm">Επιβεβαίωση κωδικού</label> + <input class="form-control" type="password" name="confirm" disabled> + </div> + <br /> + + <input class="btn btn-primary" type="submit" value="Δημιουργία χρήστη" disabled> + + </form> + </div> + </div> + </div> + + </div> + </div> + </div> + + <!-- scripts and libraries + load and register one by one, so you don't need to worry about if they are ready --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.4.1/jquery-migrate.min.js"></script> + <script src="/js/bootstrap.min.js"></script> + <script> + + var waitingResponse = false; // flag for an ajax request that was sent and still waiting response + + // functions needed + // --------------------------------------------------------------------------- + + // pure JS ajax GET request + // return data as JSON + // no fancy things like UTF8; if needed use base64 --------------------------- + function ajax_get(url, callback) { + var xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + + try { + var data = JSON.parse(xmlhttp.responseText); + } catch(err) { + console.log(err.message + " in " + xmlhttp.responseText); + return; + } + callback(data); + } + }; + + xmlhttp.open("GET", url, true); + xmlhttp.send(); + } + + // menu management + // --------------------------------------------------------------------------- + $('.dropdown-item').on('click', function(e){ + e.preventDefault(); + + // all data-goto have the format: 'method,uri_address' + // uri_address is the url to call + // method options: + // * url : means goto url (redirect) + // * ajax : means call url via ajax; if 'success = true' then goto '/' after that + // ------------------------------------------------------------------------- + var opt = $(this).data('goto').split(','); // split data-goto + + if (opt[0] == 'url') { // if method = url + window.location.href = opt[1]; + } + else { // else, method = ajax + ajax_get(opt[1], function(response) { + if (response.success) { + window.location.href = '/'; + } + }); + } + }); + + + + // 01. MENU MANAGEMENT + // --------------------------------------------------------------------------- + ////////////////////////////////////////////////////////////////////////////// + + // menu management + // --------------------------------------------------------------------------- + $('.dropdown-item').on('click', function(e){ + e.preventDefault(); + + if (!waitingResponse) { + waitingResponse = true; + + // var r = confirm("Δεν έχετε αποθηκεύσει το τρέχον αντικείμενο!\nΕίστε σίγουροι ότι θέλετε να εγκαταλείψετε τη σελίδα;"); + r = true; // no need for confirmation + if (r == true) { + + // all data-goto have the format: 'method,uri_address' + // uri_address is the url to call + // method options: + // * url : means goto url (redirect) + // * ajax : means call url via ajax; if 'success = true' then goto '/' after that + // ----------------------------------------------------------------------- + var opt = $(this).data('goto').split(','); // split data-goto + + if (opt[0] == 'url') { // if method = url + window.location.href = opt[1]; + } + else { // else, method = ajax + ajax_get(opt[1], function(response) { + if (response.success) { + window.location.href = '/'; + } + }); + } + + } + else { + // user did not confirmed the selection; do nothing + } + + waitingResponse = false; + } + + }); + </script> + + </body> +</html> |
