diff --git a/src/authenticate.php b/src/authenticate.php index daf3939..9a80d63 100644 --- a/src/authenticate.php +++ b/src/authenticate.php @@ -13,8 +13,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') // Get DB instance. $db = getDbInstance(); - $db->where('user_name', $username); - $row = $db->getOne('admin_accounts'); + $db->where('username', $username); + $row = $db->getOne('users'); if ($db->count >= 1) { @@ -24,7 +24,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') if (password_verify($password, $db_password)) { $_SESSION['user_logged_in'] = TRUE; - $_SESSION['admin_type'] = $row['admin_type']; + $_SESSION['type'] = $row['type']; $_SESSION['user_id'] = $row['id']; if ($remember) @@ -47,7 +47,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') 'remember_token' => $encryted_remember_token, 'expires' =>$expiry_time ); - $db->update('admin_accounts', $update_remember); + $db->update('users', $update_remember); } // Authentication successfull redirect user header('Location: index.php'); diff --git a/src/dynamic_qrcode.php b/src/dynamic_qrcode.php index a242fe3..a466d3c 100644 --- a/src/dynamic_qrcode.php +++ b/src/dynamic_qrcode.php @@ -22,6 +22,7 @@ if($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["edit"])) { isset($_POST["filename"]) && isset($_POST["link"]) && isset($_POST["state"]) && + isset($_POST["id_owner"]) && isset($_POST["id"]) ) $dynamic_qrcode_instance->editQrcode($_POST); @@ -33,7 +34,8 @@ if($_SERVER["REQUEST_METHOD"] === "POST" && !isset($_POST["edit"])) { isset($_POST["background"]) && isset($_POST["link"]) && isset($_POST["filename"]) && - isset($_POST["format"]) + isset($_POST["format"]) && + isset($_POST["id_owner"]) ) $dynamic_qrcode_instance->addQrcode($_POST); } diff --git a/src/dynamic_qrcodes.php b/src/dynamic_qrcodes.php index a01734b..969ed32 100644 --- a/src/dynamic_qrcodes.php +++ b/src/dynamic_qrcodes.php @@ -7,11 +7,17 @@ require_once BASE_PATH . '/lib/DynamicQrcode/DynamicQrcode.php'; $db = getDbInstance(); $dynamic_qrcode = new DynamicQrcode(); -$select = array('id', 'filename', 'identifier', 'link', 'qrcode', 'scan', 'state', 'created_at', 'updated_at'); +$select = array('id', 'id_owner', 'filename', 'identifier', 'link', 'qrcode', 'scan', 'state', 'created_at', 'updated_at'); $search_fields = array('filename', 'identifier', 'link'); require_once BASE_PATH . '/includes/search_order.php'; $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? 1; $db->pageLimit = 15; + +if($_SESSION['type'] !== 'super') { + $db->where("id_owner", $_SESSION['user_id']); + $db->orWhere ("id_owner", NULL, 'IS'); +} + $rows = $db->arraybuilder()->paginate('dynamic_qrcodes', $page, $select); $total_pages = $db->totalPages; ?> diff --git a/src/forms/form_dynamic_add.php b/src/forms/form_dynamic_add.php index fa27e57..e2723ec 100644 --- a/src/forms/form_dynamic_add.php +++ b/src/forms/form_dynamic_add.php @@ -86,7 +86,7 @@
+ + getAllUsers(); + + foreach ($users as $user) { + ?> + + + +
+ + + + diff --git a/src/forms/form_dynamic_edit.php b/src/forms/form_dynamic_edit.php index 091dd51..17c0c7b 100644 --- a/src/forms/form_dynamic_edit.php +++ b/src/forms/form_dynamic_edit.php @@ -34,6 +34,32 @@ required="required" id="disable"/> Disable + + +
+
+ + +
+
+ + + diff --git a/src/forms/form_static_edit.php b/src/forms/form_static_edit.php index 3fee90a..498ed53 100644 --- a/src/forms/form_static_edit.php +++ b/src/forms/form_static_edit.php @@ -7,6 +7,32 @@ + + +
+
+ + +
+
+ + diff --git a/src/forms/form_users.php b/src/forms/form_users.php index 41a1047..55dde3e 100644 --- a/src/forms/form_users.php +++ b/src/forms/form_users.php @@ -7,7 +7,7 @@ - + @@ -31,12 +31,12 @@
+ /> Super admin
+ /> Admin
diff --git a/src/forms/qrcode_options.php b/src/forms/qrcode_options.php index fedb0f3..3594a36 100644 --- a/src/forms/qrcode_options.php +++ b/src/forms/qrcode_options.php @@ -80,4 +80,29 @@ + + +
+
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/src/forms/table_dynamic.php b/src/forms/table_dynamic.php index eda56ab..472c5e6 100644 --- a/src/forms/table_dynamic.php +++ b/src/forms/table_dynamic.php @@ -16,6 +16,7 @@ ID + Owner Filename Unique redirect identifier URL @@ -30,6 +31,21 @@ + + getUser($row['id_owner']); + if($user !== NULL) + echo $user["username"]; + else + echo ""; + } + ?> + diff --git a/src/forms/table_static.php b/src/forms/table_static.php index 0dc94f0..5ec31f0 100644 --- a/src/forms/table_static.php +++ b/src/forms/table_static.php @@ -16,6 +16,7 @@ ID + Owner Filename Type Content @@ -28,6 +29,21 @@ + + getUser($row['id_owner']); + if($user !== NULL) + echo $user["username"]; + else + echo ""; + } + ?> + diff --git a/src/forms/table_users.php b/src/forms/table_users.php index d521620..d78feea 100644 --- a/src/forms/table_users.php +++ b/src/forms/table_users.php @@ -7,7 +7,7 @@ ID Username - Admin type + Type Actions @@ -15,11 +15,11 @@ - - + + - + @@ -46,7 +46,7 @@