Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean code for files #19

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin/controllers/feedback/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
$order = get_a_record('orders', $order_id);
$order_detail = order_detail($order_id);

if (isset($user_nav)) {
$user_action = get_a_record('users', $user_nav);
if (isset($userNav)) {
$user_action = get_a_record('users', $userNav);
}

$status = array(
Expand Down
4 changes: 2 additions & 2 deletions admin/controllers/feedback/myfeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

$title = 'Tất cả phản hồi của bạn';
$navFeedback = $yourFeedback = 'class="active open"';
global $user_nav;
global $userNav;

$option = array(
'order_by' => 'id desc',
'where' => 'user_id=' . $user_nav
'where' => 'user_id=' . $userNav
);
$feedbacks = get_all('feedbacks', $option);

Expand Down
4 changes: 2 additions & 2 deletions admin/controllers/header-footer/editMenuFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$menuFooterId = 0;
}

global $linkconnectDB;
global $linkConnectDB;

if (mysqli_num_rows(mysqli_query($linkconnectDB, "SELECT id FROM menu_footers WHERE id='$menuFooterId'")) == 0) {
if (mysqli_num_rows(mysqli_query($linkConnectDB, "SELECT id FROM menu_footers WHERE id='$menuFooterId'")) == 0) {
echo "<div style='padding-top: 200px' class='container'><div class='alert alert-danger' style='text-align: center;'><strong>NO!</strong> Trường này không tồn tại. <a href='javascript: history.go(-1)'>Trở lại</a></div></div>";
require('admin/views/header-footer/result.php');
exit;
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/header-footer/listMenuFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
'order_by' => 'id ASC',
'where' => 'parent=1'
);
$link_title_footer = get_all('menu_footers', $titleOptions);
$titleFooterLinks = get_all('menu_footers', $titleOptions);

require('admin/views/header-footer/listMenuFooter.php');
13 changes: 6 additions & 7 deletions admin/controllers/home/index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

$user = $_SESSION['user'];
global $user_nav;
global $userNav;

require_once('admin/controllers/shared/statistics.php');

$title = 'Quản trị hệ thống - Quán Chị Kòi';
$home_nav = 'class="active open"';
$homeNav = 'class="active open"';

require('admin/views/home/index.php');
16 changes: 7 additions & 9 deletions admin/controllers/home/login.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

require_once('admin/models/users.php');
require_once('content/models/cart.php');

if (!empty($_POST)) {
$email = escape($_POST['email']);
$password = md5($_POST['password']);
Expand All @@ -14,15 +11,16 @@

if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];

update_sesion_cart();
update_cart_user_db();

if ($user['role_id'] == 1 || $user['role_id'] == 2) {
update_sesion_cart();
update_cart_user_db();
header('location:admin.php');
} elseif ($user['role_id'] == 0) {
update_sesion_cart();
update_cart_user_db();
header('location:index.php');
}
}
$title = 'Administrator - Login Quản Trị Shop';

require('admin/views/home/login.php');
20 changes: 9 additions & 11 deletions admin/controllers/home/logout.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

require_once('content/models/cart.php');
global $user_nav;
$user_login = get_a_record('users', $user_nav);

global $userNav;

$user_login = get_a_record('users', $userNav);

unset($_SESSION['user']);
cart_destroy();

if ($user_login['role_id'] == 0) {
unset($_SESSION['user']);
cart_destroy();
header('location:index.php');
} else {
unset($_SESSION['user']);
cart_destroy();
header('location:admin.php');
}
20 changes: 12 additions & 8 deletions admin/controllers/media/add.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

permission_user();

require_once('admin/models/media.php');

if (!empty($_POST)) {
media_add();
}
if (isset($_GET['media_id'])) $media_id = intval($_GET['media_id']);
else $media_id = 0;

if (isset($_GET['media_id'])) {
$media_id = intval($_GET['media_id']);
} else {
$media_id = 0;
}

$title = ($media_id == 0) ? '' : 'Cập nhật ảnh';
$nav_media = 'class="active open"';
$navMedia = 'class="active open"';
$media_info = get_a_record('media', $media_id);

require('admin/views/media/add.php');
9 changes: 4 additions & 5 deletions admin/controllers/media/delete.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

permission_user();
permission_moderator();

require_once('admin/models/media.php');

$media_id = intval($_GET['media_id']);
media_delete($media_id);

header('location:admin.php?controller=media');
20 changes: 12 additions & 8 deletions admin/controllers/media/edit.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

permission_user();
permission_moderator();

require_once('admin/models/media.php');

if (!empty($_POST)) {
media_update();
}
if (isset($_GET['media_id'])) $media_id = intval($_GET['media_id']);
else $media_id = 0;

if (isset($_GET['media_id'])) {
$media_id = intval($_GET['media_id']);
} else {
$media_id = 0;
}

$title = ($media_id == 0) ? 'Thêm Ảnh mới' : 'Cập nhật ảnh';
$nav_media = 'class="active open"';
$navMedia = 'class="active open"';
$media_info = get_a_record('media', $media_id);

require('admin/views/media/edit.php');
16 changes: 9 additions & 7 deletions admin/controllers/media/image-gallery.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php
/**
* @var $userNav
*/

permission_user();
$user_info_nav = get_a_record('users', $user_nav);

$user_info_nav = get_a_record('users', $userNav);

$options = array(
'order_by' => 'id ASC'
);
$title = 'Image gellery';
$nav_media = 'class="active open"';
$navMedia = 'class="active open"';
$products = get_all('products', $options);

require('admin/views/media/image-gallery.php');
13 changes: 6 additions & 7 deletions admin/controllers/media/index.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<!--
Developed by: TanHongIT
Website: https://tanhongit.com - https://tanhongit.net
Github: https://github.com/TanHongIT
-->
<?php

permission_user();

require_once('admin/models/media.php');

$options = array(
'order_by' => 'id ASC'
);
$title = 'Media List';
$nav_media = 'class="active open"';
$list_media = get_all('media', $options);
$navMedia = 'class="active open"';
$listMedia = get_all('media', $options);

require('admin/views/media/index.php');
6 changes: 3 additions & 3 deletions admin/controllers/page/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$title = 'Sửa trang - Chị Kòi Quán';
$nav_page = 'class="active open"';
$post = get_a_record('posts', $post_id);
global $user_nav;
$login_user = get_a_record('users', $user_nav);
global $userNav;
$login_user = get_a_record('users', $userNav);
if ($login_user['role_id'] == 2) {
if ($post['post_author'] == $user_nav) require('admin/views/page/edit.php');
if ($post['post_author'] == $userNav) require('admin/views/page/edit.php');
else header('location:admin.php?controller=page');
} else require('admin/views/page/edit.php');
6 changes: 3 additions & 3 deletions admin/controllers/page/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
$page_id = intval($_GET['post_id']);

$post = get_a_record('posts', $page_id);
global $user_nav;
$login_user = get_a_record('users', $user_nav);
global $userNav;
$login_user = get_a_record('users', $userNav);

if ($login_user['role_id'] == 2) {
if ($post['post_author'] == $user_nav) {
if ($post['post_author'] == $userNav) {
post_public($page_id);
require('admin/views/page/result.php');
} else header('location:admin.php?controller=page');
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/post/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$title = 'Sửa bài viết - Chị Kòi Quán';
$nav_post = 'class="active open"';
$post = get_a_record('posts', $post_id);
global $user_nav;
$login_user = get_a_record('users', $user_nav);
global $userNav;
$login_user = get_a_record('users', $userNav);
if ($login_user['role_id'] == 2) {
if ($post['post_author'] == $user_nav) require('admin/views/post/edit.php');
if ($post['post_author'] == $userNav) require('admin/views/post/edit.php');
else header('location:admin.php?controller=post');
} else require('admin/views/post/edit.php');
6 changes: 3 additions & 3 deletions admin/controllers/post/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
$post_id = intval($_GET['post_id']);

$post = get_a_record('posts', $post_id);
global $user_nav;
$login_user = get_a_record('users', $user_nav);
global $userNav;
$login_user = get_a_record('users', $userNav);

if ($login_user['role_id'] == 2) {
if ($post['post_author'] == $user_nav) {
if ($post['post_author'] == $userNav) {
post_public($post_id);
require('admin/views/post/result.php');
} else header('location:admin.php?controller=post');
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/purchase/cancelled.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
-->
<?php
require_once('admin/models/purchase.php');
global $user_nav;
if (!empty($user_nav)) {
global $userNav;
if (!empty($userNav)) {
$options = array(
'where' => 'status = 3 and user_id =' . $user_nav,
'where' => 'status = 3 and user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$order_cancelled = get_all('orders', $options);
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/purchase/confirmed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
-->
<?php
require_once('admin/models/purchase.php');
global $user_nav;
if (!empty($user_nav)) {
global $userNav;
if (!empty($userNav)) {
$options = array(
'where' => 'status = 0 and user_id =' . $user_nav,
'where' => 'status = 0 and user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$order_confirmed = get_all('orders', $options);
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/purchase/delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
-->
<?php
require_once('admin/models/purchase.php');
global $user_nav;
if (!empty($user_nav)) {
global $userNav;
if (!empty($userNav)) {
$options = array(
'where' => 'status = 2 and user_id =' . $user_nav,
'where' => 'status = 2 and user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$order_delivery = get_all('orders', $options);
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/purchase/index.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
require_once('admin/models/purchase.php');
global $user_nav;
if (!empty($user_nav)) {
global $userNav;
if (!empty($userNav)) {
$options = array(
'where' => 'user_id =' . $user_nav,
'where' => 'user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$order_all = get_all('orders', $options);
Expand Down
6 changes: 3 additions & 3 deletions admin/controllers/purchase/receied.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
require_once('admin/models/purchase.php');
global $user_nav;
if (!empty($user_nav)) {
global $userNav;
if (!empty($userNav)) {
$options = array(
'where' => 'status = 1 and user_id =' . $user_nav,
'where' => 'status = 1 and user_id =' . $userNav,
'order_by' => 'createtime DESC'
);
$order_receied = get_all('orders', $options);
Expand Down
Loading