From 41709e6da2f61330b7461f9ea160b046dfab6383 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 2 Jan 2024 16:22:57 +0700 Subject: [PATCH 1/4] style code update --- admin/controllers/category/edit.php | 4 +- admin/controllers/category/index.php | 2 +- admin/controllers/comment/edit.php | 8 +- admin/controllers/comment/index.php | 2 +- admin/controllers/feedback/add.php | 4 +- admin/controllers/feedback/edit.php | 6 +- admin/controllers/feedback/myfeedback.php | 2 +- admin/controllers/feedback/reply.php | 2 +- admin/controllers/feedback/view.php | 12 +- .../header-footer/editMenuFooter.php | 2 +- admin/controllers/header-footer/index.php | 2 +- .../header-footer/listMenuFooter.php | 4 +- admin/controllers/home/logout.php | 2 +- admin/controllers/media/add.php | 2 +- admin/controllers/media/edit.php | 2 +- admin/controllers/media/image-gallery.php | 4 +- admin/controllers/media/index.php | 4 +- admin/controllers/order/index.php | 6 +- admin/controllers/order/order-cancell.php | 4 +- admin/controllers/order/order-complete.php | 4 +- admin/controllers/order/view.php | 4 +- admin/controllers/page/add.php | 2 +- admin/controllers/page/edit.php | 4 +- admin/controllers/page/index.php | 4 +- admin/controllers/page/public.php | 4 +- admin/controllers/page/viewdraft.php | 4 +- admin/controllers/page/viewtrash.php | 4 +- admin/controllers/post/add.php | 2 +- admin/controllers/post/edit.php | 4 +- admin/controllers/post/index.php | 4 +- admin/controllers/post/public.php | 4 +- admin/controllers/post/viewdraft.php | 4 +- admin/controllers/post/viewtrash.php | 4 +- admin/controllers/product/edit.php | 10 +- admin/controllers/purchase/cancelled.php | 2 +- admin/controllers/purchase/confirmed.php | 2 +- admin/controllers/purchase/delivery.php | 2 +- admin/controllers/purchase/index.php | 4 +- admin/controllers/purchase/receied.php | 2 +- admin/controllers/purchase/view.php | 2 +- admin/controllers/role/admin.php | 2 +- admin/controllers/role/edit.php | 4 +- admin/controllers/role/index.php | 4 +- admin/controllers/shared/statistics.php | 106 ++++++++-------- admin/controllers/shop/edit.php | 2 +- admin/controllers/shop/index.php | 4 +- admin/controllers/slide/edit.php | 2 +- admin/controllers/slide/index.php | 2 +- admin/controllers/user/add.php | 2 +- admin/controllers/user/change-password.php | 4 +- admin/controllers/user/delete.php | 2 +- admin/controllers/user/edit.php | 4 +- admin/controllers/user/info.php | 4 +- admin/controllers/user/listall.php | 4 +- admin/controllers/user/result.php | 2 +- admin/models/category.php | 2 +- admin/models/media.php | 2 +- admin/models/products.php | 2 +- admin/models/shop.php | 2 +- admin/models/slides.php | 2 +- admin/models/users.php | 10 +- admin/views/category/index.php | 2 +- admin/views/comment/tableIndex.php | 10 +- admin/views/comment/tablePending.php | 10 +- admin/views/comment/tableSpam.php | 10 +- admin/views/comment/tableTrash.php | 10 +- admin/views/feedback/tableMyFeedback.php | 2 +- admin/views/feedback/tableOrder.php | 6 +- admin/views/feedback/tableOther.php | 6 +- admin/views/feedback/tablePending.php | 4 +- admin/views/feedback/tableProduct.php | 6 +- admin/views/home/index.php | 12 +- admin/views/home/login.php | 2 +- admin/views/order/index.php | 2 +- admin/views/order/tableOrderCancell.php | 4 +- admin/views/order/tableOrderComplete.php | 2 +- admin/views/order/tableOrderInprocess.php | 4 +- admin/views/order/tableOrderNoprocess.php | 4 +- admin/views/page/formAdd.php | 2 +- admin/views/page/formEdit.php | 2 +- admin/views/page/index.php | 2 +- admin/views/page/viewdraft.php | 2 +- admin/views/page/viewtrash.php | 2 +- admin/views/post/formAdd.php | 2 +- admin/views/post/formEdit.php | 2 +- admin/views/post/index.php | 2 +- admin/views/post/viewdraft.php | 2 +- admin/views/post/viewtrash.php | 2 +- admin/views/product/formEdit.php | 2 +- admin/views/product/tableoUpdateproduct.php | 4 +- admin/views/product/tableofHotproduct.php | 2 +- admin/views/product/tableofNewproduct.php | 2 +- admin/views/product/tableofSaleproduct.php | 2 +- admin/views/shared/header.php | 4 +- admin/views/shared/rightnavbar.php | 14 +-- content/controllers/cart/add.php | 2 +- content/controllers/cart/order.php | 2 +- content/controllers/category/index.php | 10 +- content/controllers/comment/index.php | 4 +- content/controllers/feedback/index.php | 4 +- .../forgot-password/change-password.php | 4 +- .../controllers/forgot-password/request.php | 2 +- .../result-change-password.php | 2 +- .../forgot-password/resultcode.php | 2 +- content/controllers/home/index.php | 10 +- content/controllers/page/index.php | 4 +- content/controllers/post/all.php | 2 +- content/controllers/post/index.php | 4 +- content/controllers/product/all.php | 4 +- content/controllers/product/index.php | 10 +- content/controllers/register/activate.php | 2 +- content/controllers/register/index.php | 2 +- content/controllers/register/reactivate.php | 2 +- content/controllers/register/resend.php | 2 +- content/controllers/search/index.php | 4 +- content/controllers/shop/index.php | 8 +- content/controllers/type/index.php | 6 +- content/models/cart.php | 8 +- content/views/product/index.php | 2 +- content/views/shared/header.php | 10 +- content/views/shared/sidebar.php | 10 +- lib/config/config.php | 9 +- lib/config/database.php | 10 +- lib/config/sendmail.php | 9 +- lib/functions.php | 4 +- lib/model.php | 119 ++++++++++-------- register.php | 4 +- 127 files changed, 379 insertions(+), 362 deletions(-) diff --git a/admin/controllers/category/edit.php b/admin/controllers/category/edit.php index cef10bb1..8f7b2560 100644 --- a/admin/controllers/category/edit.php +++ b/admin/controllers/category/edit.php @@ -9,7 +9,7 @@ updateSubCategory(); } -$categories = get_all('categories', array( +$categories = getAll('categories', array( 'select' => 'id,category_name', 'order_by' => 'id' )); @@ -22,6 +22,6 @@ $title = $subCateId === 0 ? 'Thêm danh mục con' : 'Sửa danh mục con'; $navCategory = 'class="active open"'; -$subcategory = get_a_record('subcategory', $subCateId); +$subcategory = getRecord('subcategory', $subCateId); require('admin/views/category/edit.php'); diff --git a/admin/controllers/category/index.php b/admin/controllers/category/index.php index 398e22fb..b8b50ec9 100644 --- a/admin/controllers/category/index.php +++ b/admin/controllers/category/index.php @@ -9,7 +9,7 @@ 'order_by' => 'id' ); $title = 'Danh mục sản phẩm'; -$subcategories = get_all('subcategory', $options); +$subcategories = getAll('subcategory', $options); $navCategory = 'class="active open"'; require('admin/views/category/index.php'); diff --git a/admin/controllers/comment/edit.php b/admin/controllers/comment/edit.php index 62357575..aaafa0ee 100644 --- a/admin/controllers/comment/edit.php +++ b/admin/controllers/comment/edit.php @@ -15,18 +15,18 @@ } $title = $commentId === 0 ? '' : 'Sửa phần bình luận của khách hàng'; -$comment = get_a_record('comments', $commentId); +$comment = getRecord('comments', $commentId); if ($comment['post_id'] <> 0) { - $post = get_a_record('posts', $comment['post_id']); + $post = getRecord('posts', $comment['post_id']); } if ($comment['page_id'] <> 0) { - $page = get_a_record('posts', $comment['page_id']); + $page = getRecord('posts', $comment['page_id']); } if ($comment['product_id'] <> 0) { - $product = get_a_record('products', $comment['product_id']); + $product = getRecord('products', $comment['product_id']); } $navComment = 'class="active open"'; diff --git a/admin/controllers/comment/index.php b/admin/controllers/comment/index.php index 00ea04da..fb4eb21b 100644 --- a/admin/controllers/comment/index.php +++ b/admin/controllers/comment/index.php @@ -10,6 +10,6 @@ 'order_by' => 'id desc', 'where' => 'status<>3 and status<>2' ); -$comments = get_all('comments', $option); +$comments = getAll('comments', $option); require('admin/views/comment/index.php'); diff --git a/admin/controllers/feedback/add.php b/admin/controllers/feedback/add.php index 7f438064..63aae817 100644 --- a/admin/controllers/feedback/add.php +++ b/admin/controllers/feedback/add.php @@ -13,11 +13,11 @@ $orderId = 0; } -$order = get_a_record('orders', $orderId); +$order = getRecord('orders', $orderId); $orderDetail = orderDetail($orderId); if (isset($userNav)) { - $user_action = get_a_record('users', $userNav); + $user_action = getRecord('users', $userNav); } $status = array( diff --git a/admin/controllers/feedback/edit.php b/admin/controllers/feedback/edit.php index 2bf83134..203d1b15 100644 --- a/admin/controllers/feedback/edit.php +++ b/admin/controllers/feedback/edit.php @@ -18,14 +18,14 @@ $title = $feedbackId === 0 ? '' : 'Sửa phần phản hồi của khách hàng'; $navFeedback = 'class="active open"'; -$feedback = get_a_record('feedbacks', $feedbackId); +$feedback = getRecord('feedbacks', $feedbackId); if ($feedback['order_id'] <> 0) { $orderDetail = orderDetail($feedback['order_id']); - $order = get_a_record('orders', $feedback['order_id']); + $order = getRecord('orders', $feedback['order_id']); } if ($feedback['product_id'] <> 0) { - $product = get_a_record('products', $feedback['product_id']); + $product = getRecord('products', $feedback['product_id']); } $status = array( diff --git a/admin/controllers/feedback/myfeedback.php b/admin/controllers/feedback/myfeedback.php index aaea6335..62ffb72f 100644 --- a/admin/controllers/feedback/myfeedback.php +++ b/admin/controllers/feedback/myfeedback.php @@ -8,6 +8,6 @@ 'order_by' => 'id desc', 'where' => 'user_id=' . $userNav ); -$feedbacks = get_all('feedbacks', $option); +$feedbacks = getAll('feedbacks', $option); require('admin/views/feedback/myfeedback.php'); diff --git a/admin/controllers/feedback/reply.php b/admin/controllers/feedback/reply.php index 7ddc5a15..80f843a1 100644 --- a/admin/controllers/feedback/reply.php +++ b/admin/controllers/feedback/reply.php @@ -16,7 +16,7 @@ } $title = $feedbackId === 0 ? '' : 'Trả lời cho phản hồi của khách hàng'; -$feedback = get_a_record('feedbacks', $feedbackId); +$feedback = getRecord('feedbacks', $feedbackId); $navFeedback = 'class="active open"'; require('admin/views/feedback/reply.php'); diff --git a/admin/controllers/feedback/view.php b/admin/controllers/feedback/view.php index 3bcaf4ac..a0f94c58 100644 --- a/admin/controllers/feedback/view.php +++ b/admin/controllers/feedback/view.php @@ -12,23 +12,23 @@ } $title = $feedbackId === 0 ? '' : 'Xem chi tiết phản hồi của khách hàng'; -$feedback = get_a_record('feedbacks', $feedbackId); +$feedback = getRecord('feedbacks', $feedbackId); if ($feedback['order_id'] <> 0) { $orderDetail = orderDetail($feedback['order_id']); - $order = get_a_record('orders', $feedback['order_id']); + $order = getRecord('orders', $feedback['order_id']); } if ($feedback['product_id'] <> 0) { - $product = get_a_record('products', $feedback['product_id']); + $product = getRecord('products', $feedback['product_id']); } -$status = array( +$status = [ 0 => 'Đã xác nhận', 1 => 'Đã xử lý - Done', 2 => 'Đang xử lý - giao hàng', 3 => 'Đã bị hủy' -); +]; $navFeedback = 'class="active open"'; -require('admin/views/feedback/view.php'); \ No newline at end of file +require('admin/views/feedback/view.php'); diff --git a/admin/controllers/header-footer/editMenuFooter.php b/admin/controllers/header-footer/editMenuFooter.php index 0e8bcbdd..70ae6879 100644 --- a/admin/controllers/header-footer/editMenuFooter.php +++ b/admin/controllers/header-footer/editMenuFooter.php @@ -25,6 +25,6 @@ $title = 'Sửa menu link footer website'; $navHF = 'class="active open"'; -$menuFooter = get_a_record('menu_footers', $menuFooterId); +$menuFooter = getRecord('menu_footers', $menuFooterId); require('admin/views/header-footer/editMenuFooter.php'); diff --git a/admin/controllers/header-footer/index.php b/admin/controllers/header-footer/index.php index 4e93c1c4..b7a37af8 100644 --- a/admin/controllers/header-footer/index.php +++ b/admin/controllers/header-footer/index.php @@ -11,6 +11,6 @@ $title = 'Sửa header footer website'; $navHF = 'class="active open"'; -$contact = get_a_record('contacts', 1); +$contact = getRecord('contacts', 1); require('admin/views/header-footer/index.php'); diff --git a/admin/controllers/header-footer/listMenuFooter.php b/admin/controllers/header-footer/listMenuFooter.php index b96f9b43..31ed91c5 100644 --- a/admin/controllers/header-footer/listMenuFooter.php +++ b/admin/controllers/header-footer/listMenuFooter.php @@ -9,11 +9,11 @@ ); $title = 'Danh sách link Footer'; $navHF = 'class="active open"'; -$menuFooterLinks = get_all('menu_footers', $linkOptions); +$menuFooterLinks = getAll('menu_footers', $linkOptions); $titleOptions = array( 'order_by' => 'id ASC', 'where' => 'parent=1' ); -$titleFooterLinks = get_all('menu_footers', $titleOptions); +$titleFooterLinks = getAll('menu_footers', $titleOptions); require('admin/views/header-footer/listMenuFooter.php'); diff --git a/admin/controllers/home/logout.php b/admin/controllers/home/logout.php index 4e0d2a78..680ad5bc 100644 --- a/admin/controllers/home/logout.php +++ b/admin/controllers/home/logout.php @@ -4,7 +4,7 @@ global $userNav; -$user_login = get_a_record('users', $userNav); +$user_login = getRecord('users', $userNav); unset($_SESSION['user']); cartDestroy(); diff --git a/admin/controllers/media/add.php b/admin/controllers/media/add.php index cc9f0ca1..b38cda4a 100644 --- a/admin/controllers/media/add.php +++ b/admin/controllers/media/add.php @@ -16,6 +16,6 @@ $title = ($mediaId == 0) ? '' : 'Cập nhật ảnh'; $navMedia = 'class="active open"'; -$mediaInfo = get_a_record('media', $mediaId); +$mediaInfo = getRecord('media', $mediaId); require('admin/views/media/add.php'); diff --git a/admin/controllers/media/edit.php b/admin/controllers/media/edit.php index d26cd307..c279e247 100644 --- a/admin/controllers/media/edit.php +++ b/admin/controllers/media/edit.php @@ -17,6 +17,6 @@ $title = ($mediaId == 0) ? 'Thêm Ảnh mới' : 'Cập nhật ảnh'; $navMedia = 'class="active open"'; -$mediaInfo = get_a_record('media', $mediaId); +$mediaInfo = getRecord('media', $mediaId); require('admin/views/media/edit.php'); diff --git a/admin/controllers/media/image-gallery.php b/admin/controllers/media/image-gallery.php index 5cd7ce5e..077abd93 100644 --- a/admin/controllers/media/image-gallery.php +++ b/admin/controllers/media/image-gallery.php @@ -5,13 +5,13 @@ permission_user(); -$userInfoNav = get_a_record('users', $userNav); +$userInfoNav = getRecord('users', $userNav); $options = array( 'order_by' => 'id ASC' ); $title = 'Image gellery'; $navMedia = 'class="active open"'; -$products = get_all('products', $options); +$products = getAll('products', $options); require('admin/views/media/image-gallery.php'); diff --git a/admin/controllers/media/index.php b/admin/controllers/media/index.php index 7683f650..165e756c 100644 --- a/admin/controllers/media/index.php +++ b/admin/controllers/media/index.php @@ -9,6 +9,6 @@ ); $title = 'Media List'; $navMedia = 'class="active open"'; -$listMedia = get_all('media', $options); +$listMedia = getAll('media', $options); -require('admin/views/media/index.php'); \ No newline at end of file +require('admin/views/media/index.php'); diff --git a/admin/controllers/order/index.php b/admin/controllers/order/index.php index a03dff79..4d40d713 100644 --- a/admin/controllers/order/index.php +++ b/admin/controllers/order/index.php @@ -13,10 +13,10 @@ ); $url = 'admin.php?controller=order'; -$totalRows = get_total('orders', $options); +$totalRows = getTotal('orders', $options); $title = 'Đơn hàng'; $orderNav = 'class="active open"'; -$orders = get_all('orders', $options); +$orders = getAll('orders', $options); $status = array( 0 => 'Chưa xử lý', @@ -24,4 +24,4 @@ 2 => 'Đang xử lý', 3 => 'Đã bị hủy' ); -require('admin/views/order/index.php'); \ No newline at end of file +require('admin/views/order/index.php'); diff --git a/admin/controllers/order/order-cancell.php b/admin/controllers/order/order-cancell.php index f8de4e3c..07fa87c2 100644 --- a/admin/controllers/order/order-cancell.php +++ b/admin/controllers/order/order-cancell.php @@ -7,7 +7,7 @@ 'order_by' => 'createtime DESC' ); -$orderComplete = get_all('orders', $options); +$orderComplete = getAll('orders', $options); $title = 'Đơn hàng đã bị hủy'; $orderNav = 'class="active open"'; @@ -18,4 +18,4 @@ 3 => 'Đã bị hủy' ); -require('admin/views/order/order-cancell.php'); \ No newline at end of file +require('admin/views/order/order-cancell.php'); diff --git a/admin/controllers/order/order-complete.php b/admin/controllers/order/order-complete.php index 6ab2db39..269f5e29 100644 --- a/admin/controllers/order/order-complete.php +++ b/admin/controllers/order/order-complete.php @@ -6,7 +6,7 @@ 'where' => 'status = 1', 'order_by' => 'createtime DESC' ); -$orderComplete = get_all('orders', $options); +$orderComplete = getAll('orders', $options); $title = 'Đơn hàng đã xử lý'; $orderNav = 'class="active open"'; @@ -15,4 +15,4 @@ 1 => 'Đã xử lý', 2 => 'Đang xử lý' ); -require('admin/views/order/order-complete.php'); \ No newline at end of file +require('admin/views/order/order-complete.php'); diff --git a/admin/controllers/order/view.php b/admin/controllers/order/view.php index a2bafa1c..0f6d6b0f 100644 --- a/admin/controllers/order/view.php +++ b/admin/controllers/order/view.php @@ -7,7 +7,7 @@ $orderId = intval($_GET['order_id']); else $orderId = 0; -$order = get_a_record('orders', $orderId); +$order = getRecord('orders', $orderId); if (!$order) { show_404(); @@ -24,4 +24,4 @@ 1 => 'Đã giao hàng', 3 => 'Đơn hàng đã hủy' ); -require('admin/views/order/view.php'); \ No newline at end of file +require('admin/views/order/view.php'); diff --git a/admin/controllers/page/add.php b/admin/controllers/page/add.php index 8998b340..19082a72 100644 --- a/admin/controllers/page/add.php +++ b/admin/controllers/page/add.php @@ -12,7 +12,7 @@ $postId = intval($_GET['post_id']); else $postId = 0; -$post = get_a_record('posts', $postId); +$post = getRecord('posts', $postId); $pageNav = 'class="active open"'; $title = 'Thêm trang mới - Chị Kòi Quán'; diff --git a/admin/controllers/page/edit.php b/admin/controllers/page/edit.php index 76d1da0e..e29bc3f4 100644 --- a/admin/controllers/page/edit.php +++ b/admin/controllers/page/edit.php @@ -15,9 +15,9 @@ $title = 'Sửa trang - Chị Kòi Quán'; $pageNav = 'class="active open"'; -$post = get_a_record('posts', $postId); +$post = getRecord('posts', $postId); global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { if ($post['post_author'] == $userNav) diff --git a/admin/controllers/page/index.php b/admin/controllers/page/index.php index 1a57773d..7f41c26e 100644 --- a/admin/controllers/page/index.php +++ b/admin/controllers/page/index.php @@ -21,10 +21,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$pages = get_all('posts', $options); +$pages = getAll('posts', $options); $url = 'admin.php?controller=page'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/page/public.php b/admin/controllers/page/public.php index 68e5bbd5..5007f4c2 100644 --- a/admin/controllers/page/public.php +++ b/admin/controllers/page/public.php @@ -6,9 +6,9 @@ $pageId = intval($_GET['post_id']); -$post = get_a_record('posts', $pageId); +$post = getRecord('posts', $pageId); global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { if ($post['post_author'] == $userNav) { diff --git a/admin/controllers/page/viewdraft.php b/admin/controllers/page/viewdraft.php index 050ce235..24abe3c4 100644 --- a/admin/controllers/page/viewdraft.php +++ b/admin/controllers/page/viewdraft.php @@ -20,10 +20,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$pages = get_all('posts', $options); +$pages = getAll('posts', $options); $url = 'admin.php?controller=page&action=viewdraft'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/page/viewtrash.php b/admin/controllers/page/viewtrash.php index 3919c1f0..e4c79a6d 100644 --- a/admin/controllers/page/viewtrash.php +++ b/admin/controllers/page/viewtrash.php @@ -20,10 +20,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$pages = get_all('posts', $options); +$pages = getAll('posts', $options); $url = 'admin.php?controller=page&action=viewtrash'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/post/add.php b/admin/controllers/post/add.php index b9ccb049..deba46f9 100644 --- a/admin/controllers/post/add.php +++ b/admin/controllers/post/add.php @@ -13,7 +13,7 @@ $postId = intval($_GET['post_id']); else $postId = 0; -$post = get_a_record('posts', $postId); +$post = getRecord('posts', $postId); $title = 'Thêm trang mới - Chị Kòi Quán'; $postNav = 'class="active open"'; diff --git a/admin/controllers/post/edit.php b/admin/controllers/post/edit.php index 2ed0cc13..590dd351 100644 --- a/admin/controllers/post/edit.php +++ b/admin/controllers/post/edit.php @@ -15,9 +15,9 @@ $title = 'Sửa bài viết - Chị Kòi Quán'; $postNav = 'class="active open"'; -$post = get_a_record('posts', $postId); +$post = getRecord('posts', $postId); global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { if ($post['post_author'] == $userNav) diff --git a/admin/controllers/post/index.php b/admin/controllers/post/index.php index bae63dbc..131503b7 100644 --- a/admin/controllers/post/index.php +++ b/admin/controllers/post/index.php @@ -21,10 +21,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$posts = get_all('posts', $options); +$posts = getAll('posts', $options); $url = 'admin.php?controller=post'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/post/public.php b/admin/controllers/post/public.php index fada0e47..8b77f828 100644 --- a/admin/controllers/post/public.php +++ b/admin/controllers/post/public.php @@ -5,9 +5,9 @@ $postId = intval($_GET['post_id']); -$post = get_a_record('posts', $postId); +$post = getRecord('posts', $postId); global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { if ($post['post_author'] == $userNav) { diff --git a/admin/controllers/post/viewdraft.php b/admin/controllers/post/viewdraft.php index d428774b..56a8ba39 100644 --- a/admin/controllers/post/viewdraft.php +++ b/admin/controllers/post/viewdraft.php @@ -21,10 +21,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$posts = get_all('posts', $options); +$posts = getAll('posts', $options); $url = 'admin.php?controller=post&action=viewdraft'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/post/viewtrash.php b/admin/controllers/post/viewtrash.php index eaf5b231..8dd46a23 100644 --- a/admin/controllers/post/viewtrash.php +++ b/admin/controllers/post/viewtrash.php @@ -21,10 +21,10 @@ 'offset' => $offset, 'order_by' => 'id DESC' ); -$posts = get_all('posts', $options); +$posts = getAll('posts', $options); $url = 'admin.php?controller=post&action=viewtrash'; -$totalRows = get_total('posts', $options); +$totalRows = getTotal('posts', $options); $total = ceil($totalRows / $limit); $pagination = adminPagination($url, $page, $total); diff --git a/admin/controllers/product/edit.php b/admin/controllers/product/edit.php index 6111db20..b6173d71 100644 --- a/admin/controllers/product/edit.php +++ b/admin/controllers/product/edit.php @@ -15,24 +15,24 @@ $title = ($productId == 0) ? 'Thêm sản phẩm' : 'Sửa sản phẩm: '; $productNav = 'class="active open"'; -$product = get_a_record('products', $productId); +$product = getRecord('products', $productId); if ($productId <> 0) $title .= $product['product_name']; $options = array( 'order_by' => 'createDate' ); -$products = get_all('products', $options); -$categories = get_all('categories', array( +$products = getAll('products', $options); +$categories = getAll('categories', array( 'select' => 'id,category_name', 'order_by' => 'id' )); -$subcategories = get_all('subcategory', array( +$subcategories = getAll('subcategory', array( 'select' => 'id,subcategory_name', 'order_by' => 'subcategory_name' )); -$types = get_all('types', array( +$types = getAll('types', array( 'select' => 'id,type_name', 'order_by' => 'id' )); diff --git a/admin/controllers/purchase/cancelled.php b/admin/controllers/purchase/cancelled.php index 880258d1..507b736d 100644 --- a/admin/controllers/purchase/cancelled.php +++ b/admin/controllers/purchase/cancelled.php @@ -9,7 +9,7 @@ 'where' => 'status = 3 and user_id =' . $userNav, 'order_by' => 'createtime DESC' ); - $cancelledOrders = get_all('orders', $options); + $cancelledOrders = getAll('orders', $options); $title = 'Đơn hàng đã hủy'; $yourPurchaseNav = 'class="active open"'; $status = array( diff --git a/admin/controllers/purchase/confirmed.php b/admin/controllers/purchase/confirmed.php index 60719699..6d9a014e 100644 --- a/admin/controllers/purchase/confirmed.php +++ b/admin/controllers/purchase/confirmed.php @@ -9,7 +9,7 @@ 'where' => 'status = 0 and user_id =' . $userNav, 'order_by' => 'createtime DESC' ); - $confirmedOrders = get_all('orders', $options); + $confirmedOrders = getAll('orders', $options); $title = 'Đơn hàng đã xác nhận'; $yourPurchaseNav = 'class="active open"'; $status = array( diff --git a/admin/controllers/purchase/delivery.php b/admin/controllers/purchase/delivery.php index ecdfa1e0..10f05452 100644 --- a/admin/controllers/purchase/delivery.php +++ b/admin/controllers/purchase/delivery.php @@ -9,7 +9,7 @@ 'where' => 'status = 2 and user_id =' . $userNav, 'order_by' => 'createtime DESC' ); - $deliveryOrders = get_all('orders', $options); + $deliveryOrders = getAll('orders', $options); $title = 'Đơn hàng đang vận chuyển'; $yourPurchaseNav = 'class="active open"'; $status = array( diff --git a/admin/controllers/purchase/index.php b/admin/controllers/purchase/index.php index 8fed7771..bdf543a5 100644 --- a/admin/controllers/purchase/index.php +++ b/admin/controllers/purchase/index.php @@ -9,7 +9,7 @@ 'where' => 'user_id =' . $userNav, 'order_by' => 'createtime DESC' ); - $orders = get_all('orders', $options); + $orders = getAll('orders', $options); $title = 'Tất cả đơn hàng của bạn'; $yourPurchaseNav = 'class="active open"'; $status = array( @@ -20,4 +20,4 @@ ); } -require('admin/views/purchase/index.php'); \ No newline at end of file +require('admin/views/purchase/index.php'); diff --git a/admin/controllers/purchase/receied.php b/admin/controllers/purchase/receied.php index b09238cf..011a6c3d 100644 --- a/admin/controllers/purchase/receied.php +++ b/admin/controllers/purchase/receied.php @@ -9,7 +9,7 @@ 'where' => 'status = 1 and user_id =' . $userNav, 'order_by' => 'createtime DESC' ); - $receiedOrders = get_all('orders', $options); + $receiedOrders = getAll('orders', $options); $title = 'Đơn hàng đã nhận'; $yourPurchaseNav = 'class="active open"'; $status = array( diff --git a/admin/controllers/purchase/view.php b/admin/controllers/purchase/view.php index a1bff71a..e30b60ba 100644 --- a/admin/controllers/purchase/view.php +++ b/admin/controllers/purchase/view.php @@ -6,7 +6,7 @@ $orderId = intval($_GET['order_id']); else $orderId = 0; -$order = get_a_record('orders', $orderId); +$order = getRecord('orders', $orderId); if (!$order) { show_404(); diff --git a/admin/controllers/role/admin.php b/admin/controllers/role/admin.php index 46475773..9f3ae0cb 100644 --- a/admin/controllers/role/admin.php +++ b/admin/controllers/role/admin.php @@ -9,6 +9,6 @@ ); $title = 'Danh sách Admin'; $adminNav = 'class="active open"'; -$list_user = get_all('users', $options); +$list_user = getAll('users', $options); require('admin/views/role/admin.php'); diff --git a/admin/controllers/role/edit.php b/admin/controllers/role/edit.php index 313e586e..78148a1e 100644 --- a/admin/controllers/role/edit.php +++ b/admin/controllers/role/edit.php @@ -15,6 +15,6 @@ $title = ($roleId == 0) ? 'Thêm quyền truy cập' : 'Sửa quyền truy cập'; $adminNav = 'class="active open"'; -$role = get_a_record('roles', $roleId); +$role = getRecord('roles', $roleId); -require('admin/views/role/edit.php'); \ No newline at end of file +require('admin/views/role/edit.php'); diff --git a/admin/controllers/role/index.php b/admin/controllers/role/index.php index 61e4ed60..eaa14755 100644 --- a/admin/controllers/role/index.php +++ b/admin/controllers/role/index.php @@ -18,6 +18,6 @@ ); $title = 'Danh sách quyền truy cập website'; $adminNav = 'class="active open"'; -$roles = get_all('roles', $options); +$roles = getAll('roles', $options); -require('admin/views/role/index.php'); \ No newline at end of file +require('admin/views/role/index.php'); diff --git a/admin/controllers/shared/statistics.php b/admin/controllers/shared/statistics.php index a2f12a62..cf7c97de 100644 --- a/admin/controllers/shared/statistics.php +++ b/admin/controllers/shared/statistics.php @@ -7,61 +7,61 @@ 'where' => 'status = 1', 'order_by' => 'createtime DESC' ); -$orderCompletes = get_all('orders', $options_order_complete); +$orderCompletes = getAll('orders', $options_order_complete); $options_order = array( 'order_by' => 'id DESC' ); -$total_order = get_total('orders', $options_order); +$total_order = getTotal('orders', $options_order); $options_order_mine = array( 'order_by' => 'id DESC', 'where' => 'user_id=' . $userNav ); -$total_order_mine = get_total('orders', $options_order_mine); +$total_order_mine = getTotal('orders', $options_order_mine); $options_comlete = array( 'where' => 'status = 1', 'order_by' => 'id DESC' ); -$total_order_prosess = get_total('orders', $options_comlete); +$total_order_prosess = getTotal('orders', $options_comlete); $options_order_new = array( 'limit' => 1, 'offset' => 0, 'order_by' => 'id DESC' ); -$order_new = select_a_record('orders', $options_order_new); +$order_new = getByOptions('orders', $options_order_new); $options_inprocess = array( 'where' => 'status = 2', 'order_by' => 'id DESC' ); -$total_order_inprosess = get_total('orders', $options_inprocess); +$total_order_inprosess = getTotal('orders', $options_inprocess); $options_mine_inprocess = array( 'where' => 'status = 2 and user_id=' . $userNav, 'order_by' => 'id DESC' ); -$total_mine_order_inprosess = get_total('orders', $options_mine_inprocess); +$total_mine_order_inprosess = getTotal('orders', $options_mine_inprocess); $options_mine_complete = array( 'where' => 'status = 1 and user_id=' . $userNav, 'order_by' => 'id DESC' ); -$total_mine_order_complete = get_total('orders', $options_mine_complete); +$total_mine_order_complete = getTotal('orders', $options_mine_complete); $options_cancell_total = array( 'where' => 'status = 3', 'order_by' => 'id DESC' ); -$total_order_cancell = get_total('orders', $options_cancell_total); +$total_order_cancell = getTotal('orders', $options_cancell_total); $options_noprocess = array( 'where' => 'status = 0', 'order_by' => 'id DESC' ); -$total_order_noprosess = get_total('orders', $options_noprocess); +$total_order_noprosess = getTotal('orders', $options_noprocess); $options_cancell = array( 'where' => 'status = 3', @@ -69,13 +69,13 @@ 'offset' => 0, 'order_by' => 'id DESC' ); -$order_cancell = select_a_record('orders', $options_cancell); +$order_cancell = getByOptions('orders', $options_cancell); $options_order_status = array( 'where' => 'status=1 or status=3', 'order_by' => 'id DESC' ); -$total_order_status = get_total('orders', $options_order_status); +$total_order_status = getTotal('orders', $options_order_status); if ($total_order_status != 0) $order_ratio = ($total_order_status / $total_order) * 100; else $order_ratio = 0; @@ -83,69 +83,69 @@ $options_feedback = array( 'order_by' => 'createTime DESC' ); -$total_feedback = get_total('feedbacks', $options_feedback); +$total_feedback = getTotal('feedbacks', $options_feedback); $options_feedback_order = array( 'order_by' => 'createTime DESC', 'where' => 'order_id<>0' ); -$total_feedback_order = get_total('feedbacks', $options_feedback_order); +$total_feedback_order = getTotal('feedbacks', $options_feedback_order); $options_feedback_five = array( 'limit' => 5, 'offset' => 0, 'order_by' => 'id DESC' ); -$feedback_five = get_all('feedbacks', $options_feedback_five); +$feedback_five = getAll('feedbacks', $options_feedback_five); $options_feedback_noaccept = array( 'order_by' => 'id DESC', 'where' => 'status=0' ); -$total_feedback_noaccept = get_total('feedbacks', $options_feedback_noaccept); +$total_feedback_noaccept = getTotal('feedbacks', $options_feedback_noaccept); $options_feedback_mine = array( 'order_by' => 'id DESC', 'where' => 'user_id=' . $userNav ); -$total_feedback_mine = get_total('feedbacks', $options_feedback_mine); +$total_feedback_mine = getTotal('feedbacks', $options_feedback_mine); $options_feedback_mine_product = array( 'order_by' => 'id DESC', 'where' => 'product_id<>0 and user_id=' . $userNav ); -$total_feedback_mine_product = get_total('feedbacks', $options_feedback_mine_product); +$total_feedback_mine_product = getTotal('feedbacks', $options_feedback_mine_product); $options_feedback_mine_order = array( 'order_by' => 'id DESC', 'where' => 'product_id<>0 and user_id=' . $userNav ); -$total_feedback_mine_order = get_total('feedbacks', $options_feedback_mine_order); +$total_feedback_mine_order = getTotal('feedbacks', $options_feedback_mine_order); $options_feedback_new = array( 'limit' => 1, 'offset' => 0, 'order_by' => 'id DESC' ); -$feedback_new = select_a_record('feedbacks', $options_feedback_new); +$feedback_new = getByOptions('feedbacks', $options_feedback_new); $options_feedback_product = array( 'order_by' => 'createTime DESC', 'where' => 'product_id<>0' ); -$total_feedback_product = get_total('feedbacks', $options_feedback_product); +$total_feedback_product = getTotal('feedbacks', $options_feedback_product); $options_feedback_noaccept = array( 'order_by' => 'createTime DESC', 'where' => 'status=0' ); -$total_feedback_noaccept = get_total('feedbacks', $options_feedback_noaccept); +$total_feedback_noaccept = getTotal('feedbacks', $options_feedback_noaccept); $options_feedback_status = array( 'order_by' => 'createTime DESC', 'where' => 'status=1' ); -$total_feedback_status = get_total('feedbacks', $options_feedback_status); +$total_feedback_status = getTotal('feedbacks', $options_feedback_status); if ($total_feedback_status != 0) $feedback_ratio = $total_feedback_status / $total_feedback * 100; else $feedback_ratio = 0; @@ -153,19 +153,19 @@ $options_comments = array( 'order_by' => 'id DESC' ); -$totalRows_comment = get_total('comments', $options_comments); +$totalRows_comment = getTotal('comments', $options_comments); $options_comments_mine = array( 'order_by' => 'id DESC', 'where' => 'user_id=' . $userNav ); -$total_mine_comment = get_total('comments', $options_comments_mine); +$total_mine_comment = getTotal('comments', $options_comments_mine); $options_mine_comment_noaccept = array( 'order_by' => 'id DESC', 'where' => 'status=0 and user_id=' . $userNav ); -$total_mine_comment_noaccept = get_total('comments', $options_mine_comment_noaccept); +$total_mine_comment_noaccept = getTotal('comments', $options_mine_comment_noaccept); $options_comment_five = array( 'limit' => 5, @@ -173,38 +173,38 @@ 'where' => 'status<>3 and status<>2', 'order_by' => 'id DESC' ); -$comment_five = get_all('comments', $options_comment_five); +$comment_five = getAll('comments', $options_comment_five); $options_comment_new = array( 'limit' => 1, 'offset' => 0, 'order_by' => 'id DESC' ); -$comment_new = select_a_record('comments', $options_comment_new); +$comment_new = getByOptions('comments', $options_comment_new); $options_comment_noaccept = array( 'order_by' => 'id DESC', 'where' => 'status=0' ); -$total_comment_noaccept = get_total('comments', $options_comment_noaccept); +$total_comment_noaccept = getTotal('comments', $options_comment_noaccept); $options_comment_trash = array( 'order_by' => 'id DESC', 'where' => 'status=2' ); -$total_comment_trash = get_total('comments', $options_comment_trash); +$total_comment_trash = getTotal('comments', $options_comment_trash); $options_comment_spam = array( 'order_by' => 'id DESC', 'where' => 'status=3' ); -$total_comment_spam = get_total('comments', $options_comment_spam); +$total_comment_spam = getTotal('comments', $options_comment_spam); $options_comment_accept = array( 'order_by' => 'id DESC', 'where' => 'status=1' ); -$total_comment_accept = get_total('comments', $options_comment_accept); +$total_comment_accept = getTotal('comments', $options_comment_accept); if ($total_comment_accept != 0) $comment_ratio = $total_comment_accept / $totalRows_comment * 100; else $comment_ratio = 0; @@ -215,42 +215,42 @@ 'where' => 'post_type=2', 'order_by' => 'id DESC' ); -$page_new = select_a_record('posts', $options_page_new); +$page_new = getByOptions('posts', $options_page_new); $options_post = array( 'order_by' => 'id DESC', 'where' => 'post_type=1', ); -$total_post = get_total('posts', $options_post); +$total_post = getTotal('posts', $options_post); $options_page = array( 'order_by' => 'id DESC', 'where' => 'post_type=2', ); -$total_page = get_total('posts', $options_page); +$total_page = getTotal('posts', $options_page); $options_trash = array( 'order_by' => 'id DESC', 'where' => 'post_status="Trash"', ); -$total_post_trash = get_total('posts', $options_trash); +$total_post_trash = getTotal('posts', $options_trash); $options_posts = array( 'order_by' => 'id DESC' ); -$total_posts = get_total('posts', $options_posts); +$total_posts = getTotal('posts', $options_posts); $options_posts_status = array( 'order_by' => 'id DESC', 'where' => 'post_status="Publiced"', ); -$total_posts_status = get_total('posts', $options_posts_status); +$total_posts_status = getTotal('posts', $options_posts_status); $options_page_draft = array( 'order_by' => 'id DESC', 'where' => 'post_type=2 and post_status="Draft"' ); -$total_page_draft = get_total('posts', $options_page_draft); +$total_page_draft = getTotal('posts', $options_page_draft); $options_post_new = array( 'limit' => 1, @@ -258,13 +258,13 @@ 'where' => 'post_type=1', 'order_by' => 'id DESC' ); -$post_new = select_a_record('posts', $options_post_new); +$post_new = getByOptions('posts', $options_post_new); $options_post_draft = array( 'order_by' => 'id DESC', 'where' => 'post_type=1 and post_status="Draft"' ); -$total_post_draft = get_total('posts', $options_post_draft); +$total_post_draft = getTotal('posts', $options_post_draft); if ($total_posts_status != 0) $posts_ratio = ($total_posts_status / $total_posts) * 100; else $posts_ratio = 0; @@ -272,7 +272,7 @@ $options_user_online = array( 'order_by' => 'session' ); -$users_online = get_all('users_online', $options_user_online); +$users_online = getAll('users_online', $options_user_online); $users_online_total = 0; foreach ($users_online as $user) { if ($user['dateonline'] >= date('Y-m-d H:i:s', mktime(date('H'), date('i') - 10, date('s'), date('m'), date('d'), date('Y')) + 7 * 3600)) { @@ -283,38 +283,38 @@ $options_user_online_all = array( 'order_by' => 'session' ); -$users_online_all = get_total('users_online', $options_user_online_all); +$users_online_all = getTotal('users_online', $options_user_online_all); //product $options_product_total = array( 'order_by' => 'id' ); -$total_product = get_total('products', $options_product_total); +$total_product = getTotal('products', $options_product_total); $options_New_product_total = array( 'order_by' => 'id', 'where' => 'product_typeid=2' ); -$total_new_product = get_total('products', $options_New_product_total); +$total_new_product = getTotal('products', $options_New_product_total); $options_hot_product_total = array( 'order_by' => 'id', 'where' => 'product_typeid=1' ); -$total_hot_product = get_total('products', $options_hot_product_total); +$total_hot_product = getTotal('products', $options_hot_product_total); $options_sale_product_total = array( 'order_by' => 'id', 'where' => 'product_typeid=3' ); -$total_sale_product = get_total('products', $options_sale_product_total); +$total_sale_product = getTotal('products', $options_sale_product_total); $options_product_update = array( 'limit' => 1, 'offset' => 0, 'order_by' => 'editDate DESC' ); -$product_update = select_a_record('products', $options_product_update); +$product_update = getByOptions('products', $options_product_update); //user $options_user_update = array( @@ -322,30 +322,30 @@ 'offset' => 0, 'order_by' => 'editTime DESC' ); -$user_update = select_a_record('users', $options_user_update); +$user_update = getByOptions('users', $options_user_update); $options_user_all = array( 'order_by' => 'editTime DESC' ); -$user_all_total = get_total('users', $options_user_all); +$user_all_total = getTotal('users', $options_user_all); $options_user_not_veri = array( 'order_by' => 'editTime DESC', 'where' => 'verified=0' ); -$user_not_veri_total = get_total('users', $options_user_not_veri); +$user_not_veri_total = getTotal('users', $options_user_not_veri); $options_user_new = array( 'limit' => 1, 'offset' => 0, 'order_by' => 'createDate DESC' ); -$user_new = select_a_record('users', $options_user_new); +$user_new = getByOptions('users', $options_user_new); $options_user = array( 'order_by' => 'editTime DESC' ); -$users = get_all('users', $options_user); +$users = getAll('users', $options_user); $user_total_7day = 0; foreach ($users as $user) { if (strtotime($user['createDate']) > strtotime(date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), (date('d') - 7), date('Y'))))) diff --git a/admin/controllers/shop/edit.php b/admin/controllers/shop/edit.php index 945b0fdd..72e545f3 100644 --- a/admin/controllers/shop/edit.php +++ b/admin/controllers/shop/edit.php @@ -14,7 +14,7 @@ else $categoryId = 0; $title = ($categoryId == 0) ? 'Thêm danh mục' : 'Sửa danh mục'; -$category = get_a_record('categories', $categoryId); +$category = getRecord('categories', $categoryId); $navCategory = 'class="active open"'; require('admin/views/shop/edit.php'); diff --git a/admin/controllers/shop/index.php b/admin/controllers/shop/index.php index f114557c..56f76761 100644 --- a/admin/controllers/shop/index.php +++ b/admin/controllers/shop/index.php @@ -9,8 +9,8 @@ 'order_by' => 'id' ); $title = 'Nhóm Danh mục sản phẩm'; -$categories = get_all('categories', $options); +$categories = getAll('categories', $options); $navCategory = 'class="active open"'; //load view -require('admin/views/shop/index.php'); \ No newline at end of file +require('admin/views/shop/index.php'); diff --git a/admin/controllers/slide/edit.php b/admin/controllers/slide/edit.php index 8e6be291..e97df114 100644 --- a/admin/controllers/slide/edit.php +++ b/admin/controllers/slide/edit.php @@ -10,5 +10,5 @@ else $slideId = 0; $title = ($slideId == 0) ? 'Thêm slides' : 'Sửa slides'; $navHF = 'class="active open"'; -$slide = get_a_record('slides', $slideId); +$slide = getRecord('slides', $slideId); require('admin/views/slide/edit.php'); diff --git a/admin/controllers/slide/index.php b/admin/controllers/slide/index.php index 6bd731a3..578bae56 100644 --- a/admin/controllers/slide/index.php +++ b/admin/controllers/slide/index.php @@ -7,5 +7,5 @@ ); $navHF = 'class="active open"'; $title = 'Slide Show HomePage'; -$slides = get_all('slides', $options); +$slides = getAll('slides', $options); require('admin/views/slide/index.php'); diff --git a/admin/controllers/user/add.php b/admin/controllers/user/add.php index 47a3a077..6abcbc0b 100644 --- a/admin/controllers/user/add.php +++ b/admin/controllers/user/add.php @@ -9,5 +9,5 @@ else $userId = 0; $title = ($userId == 0) ? 'Thêm thông tin' : 'Cập nhật thông tin tài khoản'; $nav_user = 'class="active open"'; -$user_info = get_a_record('users', $userId); +$user_info = getRecord('users', $userId); require('admin/views/user/add.php'); diff --git a/admin/controllers/user/change-password.php b/admin/controllers/user/change-password.php index 2902c3be..6cf98580 100644 --- a/admin/controllers/user/change-password.php +++ b/admin/controllers/user/change-password.php @@ -3,11 +3,11 @@ if (isset($_GET['user_id'])) $userId = intval($_GET['user_id']); else $userId = 0; global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($userId != $userNav && $loginUser['role_id'] == 0) { header('location:index.php'); exit; } -$user_info = get_a_record('users', $userId); +$user_info = getRecord('users', $userId); $nav_user = $nav_profile = 'class="active open"'; require('admin/views/user/change-password.php'); diff --git a/admin/controllers/user/delete.php b/admin/controllers/user/delete.php index f909fb8b..4c0d9485 100644 --- a/admin/controllers/user/delete.php +++ b/admin/controllers/user/delete.php @@ -3,7 +3,7 @@ require_once('admin/models/users.php'); $userId = intval($_GET['user_id']); global $userNav; -$user = get_a_record('users', $userNav); +$user = getRecord('users', $userNav); if ($_GET['user_id'] == $userNav || $user['role_id'] <> 1) { echo '
Error! Bạn không có quyền hoặc không được phép xóa người dùng này.

Hãy Quay lại .!!
'; require('admin/views/user/result.php'); diff --git a/admin/controllers/user/edit.php b/admin/controllers/user/edit.php index b7c779ac..ebd16e23 100644 --- a/admin/controllers/user/edit.php +++ b/admin/controllers/user/edit.php @@ -7,7 +7,7 @@ if (isset($_GET['user_id'])) $userId = intval($_GET['user_id']); else $userId = 0; global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($userId != $userNav && $loginUser['role_id'] == 0) { header('location:index.php'); } elseif ($userId != $userNav && $loginUser['role_id'] == 2) { @@ -19,5 +19,5 @@ } $title = ($userId == 0) ? 'Thêm thông tin' : 'Cập nhật thông tin tài khoản'; $nav_user = 'class="active open"'; -$user_info = get_a_record('users', $userId); +$user_info = getRecord('users', $userId); require('admin/views/user/edit.php'); diff --git a/admin/controllers/user/info.php b/admin/controllers/user/info.php index 093dcb76..b8bbb9fe 100644 --- a/admin/controllers/user/info.php +++ b/admin/controllers/user/info.php @@ -11,7 +11,7 @@ exit; } global $userNav; -$loginUser = get_a_record('users', $userNav); +$loginUser = getRecord('users', $userNav); if ($userId != $userNav && $loginUser['role_id'] == 0) { header('location:index.php'); exit; @@ -19,5 +19,5 @@ header('location:admin.php'); exit; } -$user_info = get_a_record('users', $userId); +$user_info = getRecord('users', $userId); require('admin/views/user/info.php'); diff --git a/admin/controllers/user/listall.php b/admin/controllers/user/listall.php index 253e049f..81a65a4f 100644 --- a/admin/controllers/user/listall.php +++ b/admin/controllers/user/listall.php @@ -7,5 +7,5 @@ ); $title = 'Danh sách Thành viên'; $nav_user = 'class="active open"'; -$list_user = get_all('users', $options); -require('admin/views/user/listall.php'); \ No newline at end of file +$list_user = getAll('users', $options); +require('admin/views/user/listall.php'); diff --git a/admin/controllers/user/result.php b/admin/controllers/user/result.php index b808dd72..59375f15 100644 --- a/admin/controllers/user/result.php +++ b/admin/controllers/user/result.php @@ -2,7 +2,7 @@ require_once('admin/models/users.php'); if (isset($_POST['id_change'])) { global $userNav; - $loginUser = get_a_record('users', $userNav); + $loginUser = getRecord('users', $userNav); if ($_POST['id_change'] != $userNav && $loginUser['role_id'] == 0) { header('location:index.php'); } diff --git a/admin/models/category.php b/admin/models/category.php index 7634ce5a..cb3c0945 100644 --- a/admin/models/category.php +++ b/admin/models/category.php @@ -7,7 +7,7 @@ function deleteSubCategory($id) 'select' => 'id', 'where' => 'sub_category_id=' . $id ); - $products = get_all('products', $options); + $products = getAll('products', $options); foreach ($products as $product) { postDestroy($product['id']); } diff --git a/admin/models/media.php b/admin/models/media.php index b06f9e91..3d2c8a3b 100644 --- a/admin/models/media.php +++ b/admin/models/media.php @@ -4,7 +4,7 @@ function mediaDestroy($id) if (isset($_GET['media_id'])) { $id = intval($_GET['media_id']); } else show_404(); - $media = get_a_record('media', $id); + $media = getRecord('media', $id); $image = 'public/upload/media/' . $media['slug']; if (is_file($image)) { unlink($image); diff --git a/admin/models/products.php b/admin/models/products.php index b9ddc118..50c92ae9 100644 --- a/admin/models/products.php +++ b/admin/models/products.php @@ -4,7 +4,7 @@ function postDestroy($id) if (isset($_GET['product_id'])) { $id = intval($_GET['product_id']); } else show_404(); - $product = get_a_record('products', $id); + $product = getRecord('products', $id); $image = 'public/upload/products/' . $product['img1']; if (is_file($image)) { unlink($image); diff --git a/admin/models/shop.php b/admin/models/shop.php index e918c822..2dba127e 100644 --- a/admin/models/shop.php +++ b/admin/models/shop.php @@ -7,7 +7,7 @@ function categoryDestroy($id) 'select' => 'id', 'where' => 'category_id=' . $id ); - $products = get_all('products', $options); + $products = getAll('products', $options); foreach ($products as $product) { postDestroy($product['id']); } diff --git a/admin/models/slides.php b/admin/models/slides.php index a7ab7bb8..cf37f750 100644 --- a/admin/models/slides.php +++ b/admin/models/slides.php @@ -2,7 +2,7 @@ function slide_delete($id) { $id = intval($id); - $slide = get_a_record('slides', $id); + $slide = getRecord('slides', $id); $image1 = 'public/upload/slides/' . $slide['slide_img1']; if (is_file($image1)) { unlink($image1); diff --git a/admin/models/users.php b/admin/models/users.php index ae877699..d79f4ab1 100644 --- a/admin/models/users.php +++ b/admin/models/users.php @@ -39,7 +39,7 @@ function userLogin($input, $password) } function userDestroy($id) { - $user = get_a_record('users', $id); + $user = getRecord('users', $id); $image = 'public/upload/images/' . $user['user_avatar']; if (is_file($image)) { unlink($image); @@ -69,7 +69,7 @@ function changePassword($id, $newpassword, $currentPassword) require 'vendor/autoload.php'; include 'lib/config/sendmail.php'; $mail = new PHPMailer(true); - $user = get_a_record('users', $id); + $user = getRecord('users', $id); $email = $user['user_email']; try { //content @@ -112,7 +112,7 @@ function changePassword($id, $newpassword, $currentPassword) function user_update() { global $userNav; - $user_login = get_a_record('users', $userNav); + $user_login = getRecord('users', $userNav); if ($_POST['user_id'] <> 0) $editTime = gmdate('Y-m-d H:i:s', time() + 7 * 3600); else $editTime = '0000-00-00 00:00:00'; @@ -137,7 +137,7 @@ function user_update() require('admin/views/user/result.php'); exit; } else { - $get_currentEmail_user = get_a_record('users', $_POST['user_id']); + $get_currentEmail_user = getRecord('users', $_POST['user_id']); $currentEmail = $get_currentEmail_user['user_email']; $userId = save('users', $user_edit); $avatar_name = 'avatar-user' . $userId . '-' . slug($_POST['username']); @@ -155,7 +155,7 @@ function user_update() ); save('users', $user_edit); } - $user_edited = get_a_record('users', $userId); + $user_edited = getRecord('users', $userId); if ($user_edited['user_email'] != $currentEmail) { //send mail require 'vendor/autoload.php'; diff --git a/admin/views/category/index.php b/admin/views/category/index.php index 97f62256..7cd46bc1 100644 --- a/admin/views/category/index.php +++ b/admin/views/category/index.php @@ -68,7 +68,7 @@ - 0) $product = get_a_record('products', $comment['product_id']); - elseif ($comment['post_id'] <> 0) $post = get_a_record('posts', $comment['post_id']); - elseif ($comment['page_id'] <> 0) $page = get_a_record('posts', $comment['page_id']); + if ($comment['product_id'] <> 0) $product = getRecord('products', $comment['product_id']); + elseif ($comment['post_id'] <> 0) $post = getRecord('posts', $comment['post_id']); + elseif ($comment['page_id'] <> 0) $page = getRecord('posts', $comment['page_id']); if ($comment['status'] == 1) : ?> '; ?> - | + |
0) { ?> 0) { ?> @@ -63,7 +63,7 @@ '; ?> - | + |
0) { ?> 0) { ?> diff --git a/admin/views/comment/tablePending.php b/admin/views/comment/tablePending.php index c7fdda29..ead0f951 100644 --- a/admin/views/comment/tablePending.php +++ b/admin/views/comment/tablePending.php @@ -3,7 +3,7 @@ 'order_by' => 'id desc', 'where' => 'status=0' ); -$comments_pending = get_all('comments', $option); +$comments_pending = getAll('comments', $option); ?>
@@ -41,13 +41,13 @@ 0) $product = get_a_record('products', $comment['product_id']); - elseif ($comment['post_id'] <> 0) $post = get_a_record('posts', $comment['post_id']); - elseif ($comment['page_id'] <> 0) $page = get_a_record('posts', $comment['page_id']); ?> + if ($comment['product_id'] <> 0) $product = getRecord('products', $comment['product_id']); + elseif ($comment['post_id'] <> 0) $post = getRecord('posts', $comment['post_id']); + elseif ($comment['page_id'] <> 0) $page = getRecord('posts', $comment['page_id']); ?> '; ?> - | + |
0) { ?> 0) { ?> diff --git a/admin/views/comment/tableSpam.php b/admin/views/comment/tableSpam.php index df6ca9a6..e8ca1443 100644 --- a/admin/views/comment/tableSpam.php +++ b/admin/views/comment/tableSpam.php @@ -3,7 +3,7 @@ 'order_by' => 'id desc', 'where' => 'status=3' ); -$comments = get_all('comments', $option); +$comments = getAll('comments', $option); ?>
@@ -42,13 +42,13 @@ 0) $product = get_a_record('products', $comment['product_id']); - elseif ($comment['post_id'] <> 0) $post = get_a_record('posts', $comment['post_id']); - elseif ($comment['page_id'] <> 0) $page = get_a_record('posts', $comment['page_id']); ?> + if ($comment['product_id'] <> 0) $product = getRecord('products', $comment['product_id']); + elseif ($comment['post_id'] <> 0) $post = getRecord('posts', $comment['post_id']); + elseif ($comment['page_id'] <> 0) $page = getRecord('posts', $comment['page_id']); ?> '; ?> - | + |
0) { ?> 0) { ?> diff --git a/admin/views/comment/tableTrash.php b/admin/views/comment/tableTrash.php index 04b095eb..808047b1 100644 --- a/admin/views/comment/tableTrash.php +++ b/admin/views/comment/tableTrash.php @@ -3,7 +3,7 @@ 'order_by' => 'id desc', 'where' => 'status=2' ); -$comments = get_all('comments', $option); +$comments = getAll('comments', $option); ?>
@@ -42,13 +42,13 @@ 0) $product = get_a_record('products', $comment['product_id']); - elseif ($comment['post_id'] <> 0) $post = get_a_record('posts', $comment['post_id']); - elseif ($comment['page_id'] <> 0) $page = get_a_record('posts', $comment['page_id']); ?> + if ($comment['product_id'] <> 0) $product = getRecord('products', $comment['product_id']); + elseif ($comment['post_id'] <> 0) $post = getRecord('posts', $comment['post_id']); + elseif ($comment['page_id'] <> 0) $page = getRecord('posts', $comment['page_id']); ?> '; ?> - | + |
0) { ?> 0) { ?> diff --git a/admin/views/feedback/tableMyFeedback.php b/admin/views/feedback/tableMyFeedback.php index 8c07d6d9..5973c3ba 100644 --- a/admin/views/feedback/tableMyFeedback.php +++ b/admin/views/feedback/tableMyFeedback.php @@ -38,7 +38,7 @@ - + diff --git a/admin/views/feedback/tableOrder.php b/admin/views/feedback/tableOrder.php index 70d938c6..8ad1a984 100644 --- a/admin/views/feedback/tableOrder.php +++ b/admin/views/feedback/tableOrder.php @@ -3,7 +3,7 @@ 'order_by' => 'id desc', 'where' => 'order_id<>0' ); -$feedbacks = get_all('feedbacks', $options); +$feedbacks = getAll('feedbacks', $options); ?>
@@ -51,7 +51,7 @@ if ($feedback['status'] == 1) : ?> | - + | - + 'id desc', 'where' => 'order_id=0 and product_id=0' ); -$feedbacks = get_all('feedbacks', $options); +$feedbacks = getAll('feedbacks', $options); ?>
@@ -51,7 +51,7 @@ if ($feedback['status'] == 1) : ?> | - + | - + 'id desc', 'where' => 'status=0' ); -$feedbacks_pending = get_all('feedbacks', $option); +$feedbacks_pending = getAll('feedbacks', $option); ?>
@@ -51,7 +51,7 @@ | - + 'id desc', 'where' => 'product_id<>0' ); -$feedbacks = get_all('feedbacks', $options); +$feedbacks = getAll('feedbacks', $options); ?>
@@ -51,7 +51,7 @@ if ($feedback['status'] == 1) : ?> | - + | - + Đơn hàng mới - + Đơn chưa xử lý @@ -152,7 +152,7 @@ Bình luận mới - + BLuận Chưa Xử lý @@ -160,7 +160,7 @@ Phản hồi mới - + Phản hồi Chưa Xử lý @@ -168,7 +168,7 @@ Trang mới - + Trang nháp @@ -176,7 +176,7 @@ Bài viết mới - + Bài viết nháp @@ -373,7 +373,7 @@ Sản phẩm mới cập nhật - + Người dùng mới diff --git a/admin/views/home/login.php b/admin/views/home/login.php index 8356b3fa..8b95f9e1 100644 --- a/admin/views/home/login.php +++ b/admin/views/home/login.php @@ -1,5 +1,5 @@ +$contacts = getRecord('contacts', 1); ?> diff --git a/admin/views/order/index.php b/admin/views/order/index.php index e608b6bd..feaa8d79 100644 --- a/admin/views/order/index.php +++ b/admin/views/order/index.php @@ -74,7 +74,7 @@ - 0) : $user_order = get_a_record('users', $order['user_id']) ?> + 0) : $user_order = getRecord('users', $order['user_id']) ?> | diff --git a/admin/views/order/tableOrderCancell.php b/admin/views/order/tableOrderCancell.php index 53c7b439..4a081e1b 100644 --- a/admin/views/order/tableOrderCancell.php +++ b/admin/views/order/tableOrderCancell.php @@ -3,7 +3,7 @@ 'where' => 'status = 3', 'order_by' => 'createtime DESC' ); -$order_noprocess = get_all('orders', $options); +$order_noprocess = getAll('orders', $options); $status = array( 0 => 'Chưa xử lý', 1 => 'Đã xử lý', @@ -59,7 +59,7 @@ - 0) : $user_order = get_a_record('users', $order['user_id']) ?> + 0) : $user_order = getRecord('users', $order['user_id']) ?> | diff --git a/admin/views/order/tableOrderComplete.php b/admin/views/order/tableOrderComplete.php index c6760588..bcd81c53 100644 --- a/admin/views/order/tableOrderComplete.php +++ b/admin/views/order/tableOrderComplete.php @@ -47,7 +47,7 @@ - 0) : $user_order = get_a_record('users', $order['user_id']) ?> + 0) : $user_order = getRecord('users', $order['user_id']) ?> | diff --git a/admin/views/order/tableOrderInprocess.php b/admin/views/order/tableOrderInprocess.php index b3bab171..8d3425c6 100644 --- a/admin/views/order/tableOrderInprocess.php +++ b/admin/views/order/tableOrderInprocess.php @@ -3,7 +3,7 @@ 'where' => 'status = 2', 'order_by' => 'createtime DESC' ); -$orderInProcess = get_all('orders', $options); +$orderInProcess = getAll('orders', $options); $status = array( 0 => 'Chưa xử lý', 1 => 'Đã xử lý', @@ -58,7 +58,7 @@ - 0) : $user_order = get_a_record('users', $order['user_id']) ?> + 0) : $user_order = getRecord('users', $order['user_id']) ?> | diff --git a/admin/views/order/tableOrderNoprocess.php b/admin/views/order/tableOrderNoprocess.php index de2113cd..90f48d47 100644 --- a/admin/views/order/tableOrderNoprocess.php +++ b/admin/views/order/tableOrderNoprocess.php @@ -3,7 +3,7 @@ 'where' => 'status = 0', 'order_by' => 'createtime DESC' ); -$order_noprocess = get_all('orders', $options); +$order_noprocess = getAll('orders', $options); $status = array( 0 => 'Chưa xử lý', 1 => 'Đã xử lý', @@ -58,7 +58,7 @@ - 0) : $user_order = get_a_record('users', $order['user_id']) ?> + 0) : $user_order = getRecord('users', $order['user_id']) ?> | diff --git a/admin/views/page/formAdd.php b/admin/views/page/formAdd.php index cdb6955c..2fed16cc 100644 --- a/admin/views/page/formAdd.php +++ b/admin/views/page/formAdd.php @@ -33,7 +33,7 @@
+ $get_user_by = getRecord('users', $userNav) ?> diff --git a/admin/views/page/formEdit.php b/admin/views/page/formEdit.php index b47f2905..3a361a6b 100644 --- a/admin/views/page/formEdit.php +++ b/admin/views/page/formEdit.php @@ -33,7 +33,7 @@
+ $get_user_by = getRecord('users', $userNav) ?> diff --git a/admin/views/page/index.php b/admin/views/page/index.php index ffb0a3cc..e8238f8e 100644 --- a/admin/views/page/index.php +++ b/admin/views/page/index.php @@ -56,7 +56,7 @@ - +
  • Avatar
  • diff --git a/admin/views/page/viewdraft.php b/admin/views/page/viewdraft.php index 920fcbf7..d3b07e77 100644 --- a/admin/views/page/viewdraft.php +++ b/admin/views/page/viewdraft.php @@ -57,7 +57,7 @@ - +
    • Avatar
    • diff --git a/admin/views/page/viewtrash.php b/admin/views/page/viewtrash.php index 56978628..5264c914 100644 --- a/admin/views/page/viewtrash.php +++ b/admin/views/page/viewtrash.php @@ -57,7 +57,7 @@ - +
      • Avatar
      • diff --git a/admin/views/post/formAdd.php b/admin/views/post/formAdd.php index a683c159..015fac3b 100644 --- a/admin/views/post/formAdd.php +++ b/admin/views/post/formAdd.php @@ -33,7 +33,7 @@
        + $get_user_by = getRecord('users', $userNav) ?> diff --git a/admin/views/post/formEdit.php b/admin/views/post/formEdit.php index 32b733a3..58cb27be 100644 --- a/admin/views/post/formEdit.php +++ b/admin/views/post/formEdit.php @@ -33,7 +33,7 @@
        + $get_user_by = getRecord('users', $userNav) ?> diff --git a/admin/views/post/index.php b/admin/views/post/index.php index 6a253d48..f3ae6d06 100644 --- a/admin/views/post/index.php +++ b/admin/views/post/index.php @@ -56,7 +56,7 @@ - +
        • Avatar
        • diff --git a/admin/views/post/viewdraft.php b/admin/views/post/viewdraft.php index 8e7af690..9ed5e285 100644 --- a/admin/views/post/viewdraft.php +++ b/admin/views/post/viewdraft.php @@ -57,7 +57,7 @@ - +
          • Avatar
          • diff --git a/admin/views/post/viewtrash.php b/admin/views/post/viewtrash.php index 4b2aa43d..e2d1c51c 100644 --- a/admin/views/post/viewtrash.php +++ b/admin/views/post/viewtrash.php @@ -57,7 +57,7 @@ - +
            • Avatar
            • diff --git a/admin/views/product/formEdit.php b/admin/views/product/formEdit.php index 6256eef9..b36c174c 100644 --- a/admin/views/product/formEdit.php +++ b/admin/views/product/formEdit.php @@ -90,7 +90,7 @@
              + $get_user_by = getRecord('users', $userNav) ?> diff --git a/admin/views/product/tableoUpdateproduct.php b/admin/views/product/tableoUpdateproduct.php index ad120c7e..5c0ed791 100644 --- a/admin/views/product/tableoUpdateproduct.php +++ b/admin/views/product/tableoUpdateproduct.php @@ -3,7 +3,7 @@ $options_product_update = array( 'order_by' => 'editDate DESC' ); -$total_product_update = get_all('products', $options_product_update); ?> +$total_product_update = getAll('products', $options_product_update); ?>
              @@ -58,7 +58,7 @@ - + '; ?> diff --git a/admin/views/product/tableofHotproduct.php b/admin/views/product/tableofHotproduct.php index 0d60abdd..d6a93040 100644 --- a/admin/views/product/tableofHotproduct.php +++ b/admin/views/product/tableofHotproduct.php @@ -3,7 +3,7 @@ 'where' => 'product_typeid = 1', 'order_by' => 'createDate' ); -$products = get_all('products', $options); ?> +$products = getAll('products', $options); ?>
              diff --git a/admin/views/product/tableofNewproduct.php b/admin/views/product/tableofNewproduct.php index fcd0090c..41705204 100644 --- a/admin/views/product/tableofNewproduct.php +++ b/admin/views/product/tableofNewproduct.php @@ -3,7 +3,7 @@ 'where' => 'product_typeid = 2', 'order_by' => 'createDate' ); -$products = get_all('products', $options); ?> +$products = getAll('products', $options); ?>
              diff --git a/admin/views/product/tableofSaleproduct.php b/admin/views/product/tableofSaleproduct.php index 704c542a..fbc2b659 100644 --- a/admin/views/product/tableofSaleproduct.php +++ b/admin/views/product/tableofSaleproduct.php @@ -3,7 +3,7 @@ 'where' => 'product_typeid = 3', 'order_by' => 'createDate' ); -$products = get_all('products', $options); ?> +$products = getAll('products', $options); ?>
              diff --git a/admin/views/shared/header.php b/admin/views/shared/header.php index 2434b527..b0b3890c 100644 --- a/admin/views/shared/header.php +++ b/admin/views/shared/header.php @@ -1,7 +1,7 @@ +$userInfoNav = getRecord('users', $userNav) ?> diff --git a/admin/views/shared/rightnavbar.php b/admin/views/shared/rightnavbar.php index 7e8e2754..3ffabcff 100644 --- a/admin/views/shared/rightnavbar.php +++ b/admin/views/shared/rightnavbar.php @@ -73,7 +73,7 @@
              @@ -82,7 +82,7 @@
              @@ -91,7 +91,7 @@
              @@ -100,7 +100,7 @@
              @@ -109,7 +109,7 @@
              @@ -118,7 +118,7 @@
              @@ -131,4 +131,4 @@
            -
        \ No newline at end of file +
        diff --git a/content/controllers/cart/add.php b/content/controllers/cart/add.php index f7242cb2..4ea4595d 100644 --- a/content/controllers/cart/add.php +++ b/content/controllers/cart/add.php @@ -6,7 +6,7 @@ 'select' => 'slug', 'where' => 'id=' . $productId ); -$product_slugs = get_all('products', $option_slug_product); +$product_slugs = getAll('products', $option_slug_product); foreach ($product_slugs as $slug) { $product_slug = $slug['slug']; } diff --git a/content/controllers/cart/order.php b/content/controllers/cart/order.php index 143f821b..1d1698cc 100644 --- a/content/controllers/cart/order.php +++ b/content/controllers/cart/order.php @@ -5,6 +5,6 @@ header('location:.'); } global $userNav; -if (isset($userNav)) $user_login = get_a_record('users', $userNav); +if (isset($userNav)) $user_login = getRecord('users', $userNav); //load view require('content/views/cart/order.php'); diff --git a/content/controllers/category/index.php b/content/controllers/category/index.php index 0d9859f7..27af9273 100644 --- a/content/controllers/category/index.php +++ b/content/controllers/category/index.php @@ -2,11 +2,11 @@ if (isset($_GET['id'])) { $categoryId = intval($_GET['id']); } else show_404(); -$category = get_a_record('subcategory', $categoryId); +$category = getRecord('subcategory', $categoryId); if (!$category) { show_404(); } -$categories = get_all('subcategory', array( +$categories = getAll('subcategory', array( 'select' => 'id, subcategory_name', 'order_by' => 'id ASC' )); @@ -26,13 +26,13 @@ $url = 'category/' . $categoryId . '-' . $category['slug']; -$totalRows = get_total('products', $options); +$totalRows = getTotal('products', $options); $total = ceil($totalRows / $limit); -$products = get_all('products', $options); +$products = getAll('products', $options); $pagination = pagination($url, $page, $total); -$subcategories = get_a_record('subcategory', $_GET["id"]); +$subcategories = getRecord('subcategory', $_GET["id"]); if ($subcategories['id'] != 0) { $breadCrumb = $subcategories['subcategory_name']; } diff --git a/content/controllers/comment/index.php b/content/controllers/comment/index.php index beff0974..fee54f2e 100644 --- a/content/controllers/comment/index.php +++ b/content/controllers/comment/index.php @@ -50,7 +50,7 @@ // $option = array('product_id' => intval($productID)); -// $commentList = get_all('comments',$option); +// $commentList = getAll('comments',$option); // echo json_encode($commentList); -// echo 'aaaa'; \ No newline at end of file +// echo 'aaaa'; diff --git a/content/controllers/feedback/index.php b/content/controllers/feedback/index.php index be56d99e..9dab861c 100644 --- a/content/controllers/feedback/index.php +++ b/content/controllers/feedback/index.php @@ -5,9 +5,9 @@ } if (isset($_GET['product_id'])) $productId = intval($_GET['product_id']); else $productId = 0; -$product = get_a_record('products', $productId); +$product = getRecord('products', $productId); if (isset($userNav)) { - $user_action = get_a_record('users', $userNav); + $user_action = getRecord('users', $userNav); } $title = 'Gửi phản hồi của bạn đến Chị Kòi Quán'; require('content/views/feedback/index.php'); diff --git a/content/controllers/forgot-password/change-password.php b/content/controllers/forgot-password/change-password.php index a621c8bf..5658122c 100644 --- a/content/controllers/forgot-password/change-password.php +++ b/content/controllers/forgot-password/change-password.php @@ -1,5 +1,5 @@ 'id' ); - $users = get_all('users', $option); + $users = getAll('users', $option); foreach ($users as $user) { if ($user['user_email'] == $email) { $verification_Code = $user['verificationCode']; diff --git a/content/controllers/forgot-password/result-change-password.php b/content/controllers/forgot-password/result-change-password.php index 45144bb9..b377af58 100644 --- a/content/controllers/forgot-password/result-change-password.php +++ b/content/controllers/forgot-password/result-change-password.php @@ -10,7 +10,7 @@ $newpassword = md5($_POST['newpassword']); $confirmNewPassword = md5($_POST['confirmNewPassword']); - $user = get_a_record('users', $id); + $user = getRecord('users', $id); $email = $user['user_email']; if ($newpassword == $user['user_password']) { echo "
        NO! Việc thay đổi mật khẩu có vấn đề. Mật khẩu mới của bạn vừa nhập là mật khẩu của bạn hiện tại đó.

        Bạn đã nhớ lại mật khẩu của mình chưa !!
        Trở lại hoặc Đến trang chủ
        "; diff --git a/content/controllers/forgot-password/resultcode.php b/content/controllers/forgot-password/resultcode.php index 333865f3..c6cfaf8a 100644 --- a/content/controllers/forgot-password/resultcode.php +++ b/content/controllers/forgot-password/resultcode.php @@ -5,7 +5,7 @@ 'order_by' => 'id' ); $verifi_id_user = 0; - $user_need_change_pass = get_all('users', $select_user_option); + $user_need_change_pass = getAll('users', $select_user_option); foreach ($user_need_change_pass as $user) { if ($user['verificationCode'] == $_GET['code']) { $verifi_id_user = 1; diff --git a/content/controllers/home/index.php b/content/controllers/home/index.php index 50b8f23e..240bc3af 100644 --- a/content/controllers/home/index.php +++ b/content/controllers/home/index.php @@ -5,30 +5,30 @@ 'offset' => '0', 'order_by' => 'createDate DESC' ); -$hot_products = get_all('products', $options_hotproduct); +$hot_products = getAll('products', $options_hotproduct); $options_newproduct = array( 'where' => 'product_typeid = 2', 'limit' => '12', 'offset' => '0', 'order_by' => 'createDate DESC' ); -$new_products = get_all('products', $options_newproduct); +$new_products = getAll('products', $options_newproduct); $options_saleproduct = array( 'where' => 'product_typeid = 3', 'limit' => '12', 'offset' => '0', 'order_by' => 'createDate DESC' ); -$saleoff_products = get_all('products', $options_saleproduct); +$saleoff_products = getAll('products', $options_saleproduct); $title = 'Trang chủ - Quán Chị Kòi'; $option_slide = array( 'order_by' => 'id asc' ); -$slides = get_all('slides', $option_slide); +$slides = getAll('slides', $option_slide); foreach ($slides as $action) { if ($action['status'] == 1) $idslide = $action['id']; } if (isset($idslide)) { - $slide = get_a_record('slides', $idslide); + $slide = getRecord('slides', $idslide); } require('content/views/home/index.php'); diff --git a/content/controllers/page/index.php b/content/controllers/page/index.php index 4fd3d037..453bbfd7 100644 --- a/content/controllers/page/index.php +++ b/content/controllers/page/index.php @@ -3,8 +3,8 @@ if (isset($_GET['id'])) { $postId = intval($_GET['id']); } else show_404(); -$page = get_a_record('posts', $postId); -$user = get_a_record('users', $page['post_author']); +$page = getRecord('posts', $postId); +$user = getRecord('users', $page['post_author']); if (!$page || $page['post_status'] <> 'Publiced') { show_404(); } else updateCountView($postId); diff --git a/content/controllers/post/all.php b/content/controllers/post/all.php index 79b5a96d..8696a45e 100644 --- a/content/controllers/post/all.php +++ b/content/controllers/post/all.php @@ -3,7 +3,7 @@ $option = array( 'order_by' => 'id desc' ); -$posts = get_a_record('posts', $option); +$posts = getRecord('posts', $option); if (empty($posts)) show_404(); $title = 'All Posts - Quán Chị Kòi'; //load view diff --git a/content/controllers/post/index.php b/content/controllers/post/index.php index f51d321b..7576a59a 100644 --- a/content/controllers/post/index.php +++ b/content/controllers/post/index.php @@ -3,8 +3,8 @@ if (isset($_GET['id'])) { $postId = intval($_GET['id']); } else show_404(); -$post = get_a_record('posts', $postId); -$user = get_a_record('users', $post['post_author']); +$post = getRecord('posts', $postId); +$user = getRecord('users', $post['post_author']); if (!$post || $post['post_status'] <> 'Publiced') { show_404(); } else updateCountView($postId); diff --git a/content/controllers/product/all.php b/content/controllers/product/all.php index b5b6c286..b7606763 100644 --- a/content/controllers/product/all.php +++ b/content/controllers/product/all.php @@ -13,9 +13,9 @@ ); $url = 'index.php?controller=product&action=all'; -$totalRows = get_total('products', $options); +$totalRows = getTotal('products', $options); $total = ceil($totalRows / $limit); $pagination = pagination($url, $page, $total); -$products_all = get_all('products', $options); +$products_all = getAll('products', $options); require('content/views/product/all.php'); diff --git a/content/controllers/product/index.php b/content/controllers/product/index.php index 805ab0cc..1aaeee32 100644 --- a/content/controllers/product/index.php +++ b/content/controllers/product/index.php @@ -3,7 +3,7 @@ if (isset($_GET['id'])) { $productId = intval($_GET['id']); } else show_404(); -$product = get_a_record('products', $productId); +$product = getRecord('products', $productId); if (!$product) { show_404(); @@ -11,11 +11,11 @@ $title = $product['product_name'] . ' - Quán Chị Kòi'; $image_product = PATH_URL . 'public/upload/products/' . $product['img1']; $url_product = 'product/' . $product['id'] . '-' . $product['slug']; -$categories = get_all('categories', array( +$categories = getAll('categories', array( 'select' => 'id, category_name', 'order_by' => 'id ASC' )); -$subcategories = get_a_record('subcategory', $product['sub_category_id']); +$subcategories = getRecord('subcategory', $product['sub_category_id']); if ($product['sub_category_id'] != 0) { $breadCrumb = $subcategories['subcategory_name']; } @@ -28,7 +28,7 @@ $comment_total_option = array( 'where' => 'product_id=' . $product['id'] ); -$comments = get_all('comments', $comment_option); -$comments_total = get_total('comments', $comment_total_option); +$comments = getAll('comments', $comment_option); +$comments_total = getTotal('comments', $comment_total_option); //load view require('content/views/product/index.php'); diff --git a/content/controllers/register/activate.php b/content/controllers/register/activate.php index 48c438c2..5851f197 100644 --- a/content/controllers/register/activate.php +++ b/content/controllers/register/activate.php @@ -3,7 +3,7 @@ $select_user_option = array( 'order_by' => 'id' ); - $user_need_activate = get_all('users', $select_user_option); + $user_need_activate = getAll('users', $select_user_option); foreach ($user_need_activate as $user) { if ($user['verificationCode'] == $_GET['code']) { $verifi_id_user = $user['id']; diff --git a/content/controllers/register/index.php b/content/controllers/register/index.php index 2d37254b..38546cd5 100644 --- a/content/controllers/register/index.php +++ b/content/controllers/register/index.php @@ -19,7 +19,7 @@ 'order_by' => 'id', ); //lấy id người đăng ký để resend - $user_of_email = get_all('users', $get_user_email_option); + $user_of_email = getAll('users', $get_user_email_option); foreach ($user_of_email as $user) { if ($user['user_email'] == $email) { $get_userid_of_email = $user['id']; diff --git a/content/controllers/register/reactivate.php b/content/controllers/register/reactivate.php index 80207c27..255e5cd9 100644 --- a/content/controllers/register/reactivate.php +++ b/content/controllers/register/reactivate.php @@ -4,7 +4,7 @@ $select_user_option = array( 'order_by' => 'id' ); - $user_need_activate = get_all('users', $select_user_option); + $user_need_activate = getAll('users', $select_user_option); foreach ($user_need_activate as $user) { if ($user['verificationCode'] == $_GET['code']) { $verifi_id_user = $user['id']; diff --git a/content/controllers/register/resend.php b/content/controllers/register/resend.php index 38f9489f..f65f1e37 100644 --- a/content/controllers/register/resend.php +++ b/content/controllers/register/resend.php @@ -8,7 +8,7 @@ $option = array( 'order_by' => 'id' ); - $get_user_notActive = get_all('users', $option); + $get_user_notActive = getAll('users', $option); foreach ($get_user_notActive as $user) { if ($user['id'] == $_GET['id']) { $email = $user['user_email']; diff --git a/content/controllers/search/index.php b/content/controllers/search/index.php index 8bd46a3c..1695cb8c 100644 --- a/content/controllers/search/index.php +++ b/content/controllers/search/index.php @@ -17,11 +17,11 @@ 'order_by' => 'id DESC' ); $url = 'index.php?controller=search&keyword=' . $keyword; -$totalRows = get_total('products', $options); +$totalRows = getTotal('products', $options); $total = ceil($totalRows / $limit); //data -$products = get_all('products', $options); +$products = getAll('products', $options); $pagination = pagination($url, $page, $total); //load view require('content/views/search/index.php'); diff --git a/content/controllers/shop/index.php b/content/controllers/shop/index.php index 0d2eee58..239f1649 100644 --- a/content/controllers/shop/index.php +++ b/content/controllers/shop/index.php @@ -2,9 +2,9 @@ if (isset($_GET['id'])) { $shop_id = intval($_GET['id']); } else show_404(); -$category = get_a_record('categories', $shop_id); +$category = getRecord('categories', $shop_id); if (!$category) show_404(); -$categories = get_all('categories', array( +$categories = getAll('categories', array( 'select' => 'id, category_name', 'order_by' => 'category_position ASC' )); @@ -24,10 +24,10 @@ ); $url = 'shop/' . $shop_id . '-' . $category['slug']; -$totalRows = get_total('products', $options); +$totalRows = getTotal('products', $options); $total = ceil($totalRows / $limit); -$products = get_all('products', $options); +$products = getAll('products', $options); $pagination = pagination($url, $page, $total); if ($category['id'] != 0) { diff --git a/content/controllers/type/index.php b/content/controllers/type/index.php index b9c91c0a..e77e1a69 100644 --- a/content/controllers/type/index.php +++ b/content/controllers/type/index.php @@ -2,7 +2,7 @@ if (isset($_GET['id'])) { $type_id = intval($_GET['id']); } else show_404(); -$type = get_a_record('types', $type_id); +$type = getRecord('types', $type_id); if (!$type) show_404(); if (isset($_GET['page'])) $page = intval($_GET['page']); @@ -18,9 +18,9 @@ 'order_by' => 'id DESC' ); $url = 'type/' . $type_id . '-' . $type['slug']; -$totalRows = get_total('products', $options); +$totalRows = getTotal('products', $options); $total = ceil($totalRows / $limit); -$products = get_all('products', $options); +$products = getAll('products', $options); $pagination = pagination($url, $page, $total); if ($type['id'] != 0) { diff --git a/content/models/cart.php b/content/models/cart.php index 94a6e702..aa63ded4 100644 --- a/content/models/cart.php +++ b/content/models/cart.php @@ -9,7 +9,7 @@ function cart_add($productId, $number) $_SESSION['cart'][$productId]['number'] += $number; } else { //lấy thông tin sản phẩm từ CSDL và lưu vào giỏ hàng - $product = get_a_record('products', $productId); + $product = getRecord('products', $productId); $_SESSION['cart'][$productId] = array( 'id' => $productId, @@ -32,7 +32,7 @@ function updateCartSession() 'order_by' => 'id asc', 'where' => 'user_id=' . $userNav ); - $product_of_user = get_all('cart_user', $option); + $product_of_user = getAll('cart_user', $option); if (!empty($product_of_user)) { foreach ($product_of_user as $product) { if (isset($_SESSION['cart'][$product['product_id']]) && mysqli_num_rows(mysqli_query($linkConnectDB, "SELECT product_id FROM cart_user WHERE product_id=" . $product['product_id'] . "")) == 1) { @@ -40,7 +40,7 @@ function updateCartSession() $_SESSION['cart'][$product['product_id']]['number'] += $product['number']; } else { //lấy thông tin sản phẩm từ CSDL và lưu vào giỏ hàng - $info_product = get_a_record('products', $product['product_id']); + $info_product = getRecord('products', $product['product_id']); $_SESSION['cart'][$product['product_id']] = array( 'id' => $product['product_id'], 'name' => $info_product['product_name'], @@ -72,7 +72,7 @@ function mergeCartSessionWithDB() 'where' => 'user_id=' . $userNav ); //duyệt mảng cart_user với user là người đang đăng nhập - $cart_users = get_all('cart_user', $option_cart_user); + $cart_users = getAll('cart_user', $option_cart_user); foreach ($cart_users as $cart_user) { if ($cart_user['product_id'] == $product_cart['id']) { $status = 1; diff --git a/content/views/product/index.php b/content/views/product/index.php index 874edded..ce0b5df9 100644 --- a/content/views/product/index.php +++ b/content/views/product/index.php @@ -293,7 +293,7 @@ class="btn btn-primary" data-loading-text="Loading...">Xác nhận

        Sản phẩm Liên quan danh mục

        - '8', 'where' => $subcategories['id'] . '=sub_category_id and id<>' . $product['id'], //liên quan theo category 'offset' => '0', diff --git a/content/views/shared/header.php b/content/views/shared/header.php index 4356b741..c0935ccb 100644 --- a/content/views/shared/header.php +++ b/content/views/shared/header.php @@ -4,11 +4,11 @@ $options = array( 'order_by' => 'id' ); -$ccategories = get_all('categories', $options); +$ccategories = getAll('categories', $options); $contact_option = array( 'where' => 'id=1' ); -$contacts = get_all('contacts', $contact_option); +$contacts = getAll('contacts', $contact_option); foreach ($contacts as $contact) { $phone = preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $contact['phone']); $phone2 = preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $contact['phone_2']); @@ -29,9 +29,9 @@ 'offset' => 15 ); -$menu_footers = get_all('menu_footers', $options_menu_footer); +$menu_footers = getAll('menu_footers', $options_menu_footer); global $userNav; -$user_login = get_a_record('users', $userNav); +$user_login = getRecord('users', $userNav); if (isset($image_product)) $link_image = $image_product; else $link_image = PATH_URL . 'public/img/bang-hieu-chikoishop.jpg'; @@ -168,7 +168,7 @@ $options2 = array( 'where' => $ccategory['id'] . '=category_id' ); - $ssubcategory = get_all('subcategory', $options2); + $ssubcategory = getAll('subcategory', $options2); foreach ($ssubcategory as $subcate) : ?>
      • diff --git a/content/views/shared/sidebar.php b/content/views/shared/sidebar.php index 13fa4b7a..df2bdd15 100644 --- a/content/views/shared/sidebar.php +++ b/content/views/shared/sidebar.php @@ -2,15 +2,15 @@ $get_id = array( 'order_by' => 'id' ); -$sub_cate = get_all('subcategory', $get_id); -$shops = get_all('categories', $get_id); -$types = get_all('types', $get_id); -$product_top = get_all('products', array( +$sub_cate = getAll('subcategory', $get_id); +$shops = getAll('categories', $get_id); +$types = getAll('types', $get_id); +$product_top = getAll('products', array( 'limit' => '6', 'offset' => '0', 'order_by' => 'totalView DESC' )); -$product_new = get_all('products', array( +$product_new = getAll('products', array( 'limit' => '5', 'offset' => '0', 'order_by' => 'id DESC' diff --git a/lib/config/config.php b/lib/config/config.php index 173f72e1..f67558c4 100644 --- a/lib/config/config.php +++ b/lib/config/config.php @@ -1,5 +1,6 @@ 0) { - $data = mysqli_fetch_assoc($query); - mysqli_free_result($query); - } - return $data; + + $query = executeQuery($sql); + $result = $query->get_result()->fetch_assoc(); + $query->close(); + + return $result; } /** @@ -26,11 +33,10 @@ function get_a_record($table, $id, $select = '*') * @param array $options * * @return array - * @throws Exception */ -function get_all(string $table, array $options = []): array +function getAll(string $table, array $options = []): array { - $select = isset($options['select']) ? $options['select'] : '*'; + $select = $options['select'] ?? '*'; $where = isset($options['where']) ? 'WHERE ' . $options['where'] : ''; $order_by = isset($options['order_by']) ? 'ORDER BY ' . $options['order_by'] : ''; $limit = isset($options['offset']) && isset($options['limit']) ? 'LIMIT ' . $options['offset'] . ',' . $options['limit'] : ''; @@ -45,13 +51,14 @@ function get_all(string $table, array $options = []): array } /** + * Get total data in table by options + * * @param string $table * @param array $options * * @return mixed - * @throws Exception */ -function get_total(string $table, array $options = []): mixed +function getTotal(string $table, array $options = []): mixed { $where = isset($options['where']) ? 'WHERE ' . $options['where'] : ''; $sql = "SELECT COUNT(*) as total FROM `$table` $where"; @@ -96,49 +103,57 @@ function save_and_get_result($table, $data = array()) } echo $result; } -//lựa chọn bảng theo một mảng -function select_a_record($table, $options = array(), $select = '*') + +/** + * Get the data in the table according to the arbitrary request of options + * + * @param string $table + * @param array $options + * + * @return array|false|null + */ +function getByOptions(string $table, array $options = []): false|array|null { - $select = isset($options['select']) ? $options['select'] : '*'; + $select = $options['select'] ?? '*'; $where = isset($options['where']) ? 'WHERE ' . $options['where'] : ''; + $join = isset($options['join']) ? 'LEFT JOIN ' . $options['join'] : ''; $order_by = isset($options['order_by']) ? 'ORDER BY ' . $options['order_by'] : ''; $limit = isset($options['offset']) && isset($options['limit']) ? 'LIMIT ' . $options['offset'] . ',' . $options['limit'] : ''; - global $linkConnectDB; - $sql = "SELECT $select FROM `$table` $where $order_by $limit"; - $query = mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); - $data = NULL; - if (mysqli_num_rows($query) > 0) { - $data = mysqli_fetch_assoc($query); - mysqli_free_result($query); - } - return $data; + + $sql = "SELECT $select FROM `$table` $join $where $order_by $limit"; + + $query = executeQuery($sql); + $result = $query->get_result()->fetch_assoc(); + $query->close(); + + return $result; } -function get_time($timePost, $timeReply) + +/** + * @param $timePost + * @param $timeReply + * + * @return string + */ +function getTime($timePost, $timeReply): string { - $datePost = date_parse_from_format('Y:m:d H:i:s', $timePost); - $dateReply = date_parse_from_format('Y:m:d H:i:s', $timeReply); - $tsPost = mktime($datePost['hour'], $datePost['minute'], $datePost['second'], $datePost['month'], $datePost['day'], $datePost['year']); - $tsReply = mktime($dateReply['hour'], $dateReply['minute'], $dateReply['second'], $dateReply['month'], $dateReply['day'], $dateReply['year']); - $distance = $tsReply - $tsPost; - - switch ($distance) { - case ($distance < 60): - $result = ($distance == 1) ? $distance . ' second ago' : $distance . ' seconds ago'; - break; - case ($distance >= 60 && $distance < 3600): - $minute = round($distance / 60); - $result = ($minute == 1) ? $minute . ' minute ago' : $minute . ' minutes ago'; - break; - case ($distance >= 3600 && $distance < 86400): - $hour = round($distance / 3600); - $result = ($hour == 1) ? $hour . ' hour ago' : $hour . ' hours ago'; - break; - case (round($distance / 86400) == 1): - $result = 'Yesterday at ' . date('H:i:s', $tsReply); - break; - default: - $result = date('d/m/Y \a\t H:i:s', $tsPost); - break; + $datePost = new DateTime($timePost); + $dateReply = new DateTime($timeReply); + $interval = $datePost->diff($dateReply); + + if ($interval->y == 0 && $interval->m == 0 && $interval->d == 0) { + if ($interval->h == 0 && $interval->i == 0) { + $result = ($interval->s == 1) ? '1 second ago' : $interval->s . ' seconds ago'; + } elseif ($interval->h == 0) { + $result = ($interval->i == 1) ? '1 minute ago' : $interval->i . ' minutes ago'; + } else { + $result = ($interval->h == 1) ? '1 hour ago' : $interval->h . ' hours ago'; + } + } elseif ($interval->d == 1) { + $result = 'Yesterday at ' . $dateReply->format('H:i:s'); + } else { + $result = $datePost->format('d/m/Y \a\t H:i:s'); } + return $result; } diff --git a/register.php b/register.php index 10ba3f7e..819484be 100644 --- a/register.php +++ b/register.php @@ -1,6 +1,6 @@ +$contacts = getRecord('contacts', 1); ?> @@ -83,4 +83,4 @@ - \ No newline at end of file + From 03710eb06b7f5e0442650cabc7c06be1059f8f25 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 2 Jan 2024 16:52:02 +0700 Subject: [PATCH 2/4] format code --- .gitignore | 1 + .php-cs-fixer.dist.php | 40 ++ admin/controllers/category/edit.php | 6 +- admin/controllers/category/index.php | 6 +- admin/controllers/comment/index.php | 6 +- admin/controllers/comment/spam.php | 2 +- admin/controllers/comment/trash.php | 2 +- admin/controllers/feedback/add.php | 6 +- admin/controllers/feedback/edit.php | 6 +- admin/controllers/feedback/index.php | 2 +- admin/controllers/feedback/myfeedback.php | 6 +- admin/controllers/feedback/result.php | 2 +- admin/controllers/feedback/view.php | 2 +- .../header-footer/listMenuFooter.php | 12 +- admin/controllers/media/delete.php | 2 +- admin/controllers/media/image-gallery.php | 6 +- admin/controllers/media/index.php | 6 +- admin/controllers/order/complete.php | 2 +- admin/controllers/order/delete.php | 2 +- admin/controllers/order/index.php | 12 +- admin/controllers/order/inprocess.php | 2 +- admin/controllers/order/order-cancell.php | 12 +- admin/controllers/order/order-complete.php | 12 +- admin/controllers/order/order-noprocess.php | 2 +- admin/controllers/order/view.php | 13 +- admin/controllers/page/add.php | 6 +- admin/controllers/page/delete.php | 2 +- admin/controllers/page/draft.php | 2 +- admin/controllers/page/edit.php | 16 +- admin/controllers/page/index.php | 12 +- admin/controllers/page/restore.php | 2 +- admin/controllers/page/trash.php | 1 + admin/controllers/page/viewdraft.php | 12 +- admin/controllers/page/viewtrash.php | 12 +- admin/controllers/post/add.php | 6 +- admin/controllers/post/delete.php | 2 +- admin/controllers/post/draft.php | 2 +- admin/controllers/post/edit.php | 16 +- admin/controllers/post/index.php | 12 +- admin/controllers/post/public.php | 5 +- admin/controllers/post/restore.php | 2 +- admin/controllers/post/viewdraft.php | 12 +- admin/controllers/post/viewtrash.php | 12 +- admin/controllers/product/delete.php | 2 +- admin/controllers/product/edit.php | 34 +- admin/controllers/product/hotproduct.php | 2 +- admin/controllers/product/index.php | 2 +- admin/controllers/product/newproduct.php | 2 +- admin/controllers/product/saleproduct.php | 3 +- admin/controllers/product/update.php | 2 +- admin/controllers/purchase/cancelled.php | 12 +- admin/controllers/purchase/confirmed.php | 12 +- admin/controllers/purchase/delivery.php | 12 +- admin/controllers/purchase/index.php | 12 +- admin/controllers/purchase/receied.php | 12 +- admin/controllers/purchase/view.php | 12 +- admin/controllers/role/admin.php | 6 +- admin/controllers/role/delete.php | 2 +- admin/controllers/role/edit.php | 6 +- admin/controllers/role/index.php | 6 +- admin/controllers/shared/statistics.php | 341 +++++++++--------- admin/controllers/shop/edit.php | 6 +- admin/controllers/shop/index.php | 6 +- admin/controllers/slide/delete.php | 3 +- admin/controllers/slide/edit.php | 8 +- admin/controllers/slide/index.php | 7 +- admin/controllers/user/add.php | 8 +- admin/controllers/user/change-password.php | 8 +- admin/controllers/user/delete.php | 1 + admin/controllers/user/edit.php | 9 +- admin/controllers/user/info.php | 8 +- admin/controllers/user/listall.php | 7 +- admin/controllers/user/result.php | 5 +- admin/models/backupDB.php | 6 +- admin/models/category.php | 13 +- admin/models/comments.php | 21 +- admin/models/feedbacks.php | 21 +- admin/models/header-footer.php | 35 +- admin/models/media.php | 43 ++- admin/models/order.php | 20 +- admin/models/posts.php | 125 ++++--- admin/models/products.php | 93 +++-- admin/models/purchase.php | 8 +- admin/models/roles.php | 7 +- admin/models/shop.php | 22 +- admin/models/slides.php | 57 +-- admin/models/users.php | 85 +++-- admin/views/backupdb/index.php | 2 +- admin/views/backupdb/list.php | 10 +- admin/views/backupdb/resultBackupdb.php | 2 +- admin/views/category/formEdit.php | 6 +- admin/views/category/index.php | 8 +- admin/views/comment/edit.php | 12 +- admin/views/comment/tableIndex.php | 10 +- admin/views/comment/tablePending.php | 16 +- admin/views/comment/tableSpam.php | 16 +- admin/views/comment/tableTrash.php | 16 +- admin/views/feedback/add.php | 20 +- admin/views/feedback/edit.php | 44 ++- admin/views/feedback/tableOrder.php | 14 +- admin/views/feedback/tableOther.php | 14 +- admin/views/feedback/tablePending.php | 10 +- admin/views/feedback/tableProduct.php | 14 +- admin/views/feedback/view.php | 36 +- admin/views/header-footer/formEdit.php | 4 +- admin/views/header-footer/listMenuFooter.php | 4 +- admin/views/header-footer/result.php | 2 +- admin/views/home/index.php | 10 +- admin/views/media/add.php | 2 +- admin/views/media/edit.php | 2 +- admin/views/order/index.php | 22 +- admin/views/order/tableOrderCancell.php | 12 +- admin/views/order/tableOrderInprocess.php | 12 +- admin/views/order/tableOrderNoprocess.php | 12 +- admin/views/order/view.php | 32 +- admin/views/page/formAdd.php | 4 +- admin/views/page/formEdit.php | 8 +- admin/views/page/result.php | 2 +- admin/views/post/formAdd.php | 4 +- admin/views/post/formEdit.php | 8 +- admin/views/post/result.php | 2 +- admin/views/product/formEdit.php | 60 ++- admin/views/product/tableoUpdateproduct.php | 6 +- admin/views/product/tableofHotproduct.php | 10 +- admin/views/product/tableofNewproduct.php | 10 +- admin/views/product/tableofSaleproduct.php | 6 +- admin/views/purchase/cancelled.php | 4 +- admin/views/purchase/confirmed.php | 4 +- admin/views/purchase/delivery.php | 4 +- admin/views/purchase/index.php | 4 +- admin/views/purchase/receied.php | 4 +- admin/views/purchase/view.php | 32 +- admin/views/role/admin.php | 10 +- admin/views/shared/leftnavbar.php | 22 +- admin/views/shop/formEdit.php | 2 +- admin/views/slide/formEdit.php | 12 +- admin/views/user/add.php | 2 +- admin/views/user/addresult.php | 2 +- admin/views/user/change-password.php | 2 +- admin/views/user/edit.php | 10 +- admin/views/user/formInfo.php | 10 +- admin/views/user/listall.php | 10 +- admin/views/user/result.php | 2 +- content/controllers/cart/add.php | 17 +- content/controllers/cart/checkout.php | 65 ++-- content/controllers/cart/delete.php | 9 +- content/controllers/cart/destroy.php | 5 +- content/controllers/cart/index.php | 5 +- content/controllers/cart/order.php | 7 +- content/controllers/category/index.php | 24 +- content/controllers/comment/index.php | 13 +- content/controllers/feedback/index.php | 8 +- .../forgot-password/change-password.php | 5 +- content/controllers/forgot-password/index.php | 2 +- .../controllers/forgot-password/request.php | 10 +- .../result-change-password.php | 14 +- .../forgot-password/resultcode.php | 7 +- content/controllers/home/index.php | 29 +- content/controllers/page/index.php | 9 +- content/controllers/post/all.php | 11 +- content/controllers/post/index.php | 9 +- content/controllers/product/all.php | 12 +- content/controllers/product/index.php | 27 +- content/controllers/register/activate.php | 13 +- content/controllers/register/index.php | 20 +- content/controllers/register/reactivate.php | 13 +- content/controllers/register/resend.php | 10 +- content/controllers/search/index.php | 13 +- content/controllers/shop/index.php | 28 +- content/controllers/type/index.php | 22 +- content/models/cart.php | 55 +-- content/models/feedbacks.php | 7 +- content/models/posts.php | 4 +- content/models/products.php | 2 + content/views/cart/order.php | 7 +- content/views/category/index.php | 11 +- content/views/comment/index.php | 2 +- content/views/feedback/index.php | 18 +- content/views/feedback/result.php | 2 +- .../views/forgot-password/change-password.php | 4 +- content/views/forgot-password/result.php | 2 +- content/views/home/hotproduct.php | 7 +- content/views/home/index.php | 8 +- content/views/home/newproduct.php | 7 +- content/views/home/saleproduct.php | 7 +- content/views/product/all.php | 13 +- content/views/product/index.php | 22 +- content/views/register/result.php | 2 +- content/views/search/index.php | 11 +- content/views/shared/header.php | 94 +++-- content/views/shared/sidebar.php | 32 +- content/views/shop/index.php | 11 +- content/views/type/index.php | 11 +- 193 files changed, 1663 insertions(+), 1119 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.gitignore b/.gitignore index dd6c59f7..1569daf8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor *.log docker/certs docker/logs +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..58121af9 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/admin/controllers', + __DIR__ . '/admin/models', + __DIR__ . '/admin/views', + __DIR__ . '/content', + ]) + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'trailing_comma_in_multiline' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/admin/controllers/category/edit.php b/admin/controllers/category/edit.php index 8f7b2560..e0de4d84 100644 --- a/admin/controllers/category/edit.php +++ b/admin/controllers/category/edit.php @@ -9,10 +9,10 @@ updateSubCategory(); } -$categories = getAll('categories', array( +$categories = getAll('categories', [ 'select' => 'id,category_name', - 'order_by' => 'id' -)); + 'order_by' => 'id', +]); if (isset($_GET['sub_cate_id'])) { $subCateId = intval($_GET['sub_cate_id']); diff --git a/admin/controllers/category/index.php b/admin/controllers/category/index.php index b8b50ec9..dfee229a 100644 --- a/admin/controllers/category/index.php +++ b/admin/controllers/category/index.php @@ -5,9 +5,9 @@ require_once('admin/models/category.php'); -$options = array( - 'order_by' => 'id' -); +$options = [ + 'order_by' => 'id', +]; $title = 'Danh mục sản phẩm'; $subcategories = getAll('subcategory', $options); $navCategory = 'class="active open"'; diff --git a/admin/controllers/comment/index.php b/admin/controllers/comment/index.php index fb4eb21b..2b47bffb 100644 --- a/admin/controllers/comment/index.php +++ b/admin/controllers/comment/index.php @@ -6,10 +6,10 @@ $title = 'Tổng Danh Sách Bình luận'; $navComment = 'class="active open"'; -$option = array( +$option = [ 'order_by' => 'id desc', - 'where' => 'status<>3 and status<>2' -); + 'where' => 'status<>3 and status<>2', +]; $comments = getAll('comments', $option); require('admin/views/comment/index.php'); diff --git a/admin/controllers/comment/spam.php b/admin/controllers/comment/spam.php index 3b3f062c..503f0ab9 100644 --- a/admin/controllers/comment/spam.php +++ b/admin/controllers/comment/spam.php @@ -7,4 +7,4 @@ $title = 'Bình luận Spam'; $navComment = 'class="active open"'; -require('admin/views/comment/spam.php'); \ No newline at end of file +require('admin/views/comment/spam.php'); diff --git a/admin/controllers/comment/trash.php b/admin/controllers/comment/trash.php index cf9d807f..457a31a5 100644 --- a/admin/controllers/comment/trash.php +++ b/admin/controllers/comment/trash.php @@ -7,4 +7,4 @@ $title = 'Thùng rác'; $navComment = 'class="active open"'; -require('admin/views/comment/trash.php'); \ No newline at end of file +require('admin/views/comment/trash.php'); diff --git a/admin/controllers/feedback/add.php b/admin/controllers/feedback/add.php index 63aae817..eed0e6e5 100644 --- a/admin/controllers/feedback/add.php +++ b/admin/controllers/feedback/add.php @@ -20,12 +20,12 @@ $user_action = getRecord('users', $userNav); } -$status = array( +$status = [ 0 => 'Đã xác nhận', 1 => 'Đã xử lý', 2 => 'Đang xử lý', - 3 => 'Đã bị hủy' -); + 3 => 'Đã bị hủy', +]; $title = 'Gửi phản hồi của bạn đến Chị Kòi Quán'; $navFeedback = 'class="active open"'; diff --git a/admin/controllers/feedback/edit.php b/admin/controllers/feedback/edit.php index 203d1b15..4fcfb230 100644 --- a/admin/controllers/feedback/edit.php +++ b/admin/controllers/feedback/edit.php @@ -28,10 +28,10 @@ $product = getRecord('products', $feedback['product_id']); } -$status = array( +$status = [ 0 => 'Đã xác nhận', 1 => 'Đã xử lý - Done', 2 => 'Đang xử lý - giao hàng', - 3 => 'Đã bị hủy' -); + 3 => 'Đã bị hủy', +]; require('admin/views/feedback/edit.php'); diff --git a/admin/controllers/feedback/index.php b/admin/controllers/feedback/index.php index 9e7d07eb..76cd6dd0 100644 --- a/admin/controllers/feedback/index.php +++ b/admin/controllers/feedback/index.php @@ -6,4 +6,4 @@ $title = 'Tổng Danh Sách Các Phản Hồi'; $navFeedback = 'class="active open"'; -require('admin/views/feedback/index.php'); \ No newline at end of file +require('admin/views/feedback/index.php'); diff --git a/admin/controllers/feedback/myfeedback.php b/admin/controllers/feedback/myfeedback.php index 62ffb72f..db82f8df 100644 --- a/admin/controllers/feedback/myfeedback.php +++ b/admin/controllers/feedback/myfeedback.php @@ -4,10 +4,10 @@ $navFeedback = $yourFeedback = 'class="active open"'; global $userNav; -$option = array( +$option = [ 'order_by' => 'id desc', - 'where' => 'user_id=' . $userNav -); + 'where' => 'user_id=' . $userNav, +]; $feedbacks = getAll('feedbacks', $option); require('admin/views/feedback/myfeedback.php'); diff --git a/admin/controllers/feedback/result.php b/admin/controllers/feedback/result.php index 779c3830..19d7c453 100644 --- a/admin/controllers/feedback/result.php +++ b/admin/controllers/feedback/result.php @@ -1,2 +1,2 @@ 'Đã xác nhận', 1 => 'Đã xử lý - Done', 2 => 'Đang xử lý - giao hàng', - 3 => 'Đã bị hủy' + 3 => 'Đã bị hủy', ]; $navFeedback = 'class="active open"'; diff --git a/admin/controllers/header-footer/listMenuFooter.php b/admin/controllers/header-footer/listMenuFooter.php index 31ed91c5..01618b9c 100644 --- a/admin/controllers/header-footer/listMenuFooter.php +++ b/admin/controllers/header-footer/listMenuFooter.php @@ -3,17 +3,17 @@ permission_user(); permission_moderator(); -$linkOptions = array( +$linkOptions = [ 'order_by' => 'id ASC', - 'where' => 'parent=0' -); + 'where' => 'parent=0', +]; $title = 'Danh sách link Footer'; $navHF = 'class="active open"'; $menuFooterLinks = getAll('menu_footers', $linkOptions); -$titleOptions = array( +$titleOptions = [ 'order_by' => 'id ASC', - 'where' => 'parent=1' -); + 'where' => 'parent=1', +]; $titleFooterLinks = getAll('menu_footers', $titleOptions); require('admin/views/header-footer/listMenuFooter.php'); diff --git a/admin/controllers/media/delete.php b/admin/controllers/media/delete.php index 81189f37..8bae95c2 100644 --- a/admin/controllers/media/delete.php +++ b/admin/controllers/media/delete.php @@ -8,4 +8,4 @@ $mediaId = intval($_GET['media_id']); mediaDestroy($mediaId); -header('location:admin.php?controller=media'); \ No newline at end of file +header('location:admin.php?controller=media'); diff --git a/admin/controllers/media/image-gallery.php b/admin/controllers/media/image-gallery.php index 077abd93..bb67eb7a 100644 --- a/admin/controllers/media/image-gallery.php +++ b/admin/controllers/media/image-gallery.php @@ -7,9 +7,9 @@ $userInfoNav = getRecord('users', $userNav); -$options = array( - 'order_by' => 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $title = 'Image gellery'; $navMedia = 'class="active open"'; $products = getAll('products', $options); diff --git a/admin/controllers/media/index.php b/admin/controllers/media/index.php index 165e756c..d1a962e4 100644 --- a/admin/controllers/media/index.php +++ b/admin/controllers/media/index.php @@ -4,9 +4,9 @@ require_once('admin/models/media.php'); -$options = array( - 'order_by' => 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $title = 'Media List'; $navMedia = 'class="active open"'; $listMedia = getAll('media', $options); diff --git a/admin/controllers/order/complete.php b/admin/controllers/order/complete.php index 915ef8a8..ac37a536 100644 --- a/admin/controllers/order/complete.php +++ b/admin/controllers/order/complete.php @@ -9,4 +9,4 @@ orderComplete($_POST['order_id']); } -header('location:admin.php?controller=order'); \ No newline at end of file +header('location:admin.php?controller=order'); diff --git a/admin/controllers/order/delete.php b/admin/controllers/order/delete.php index 5dedf535..e064098b 100644 --- a/admin/controllers/order/delete.php +++ b/admin/controllers/order/delete.php @@ -9,4 +9,4 @@ orderDestroy($orderId); -header('location:admin.php?controller=order'); \ No newline at end of file +header('location:admin.php?controller=order'); diff --git a/admin/controllers/order/index.php b/admin/controllers/order/index.php index 4d40d713..768d7405 100644 --- a/admin/controllers/order/index.php +++ b/admin/controllers/order/index.php @@ -8,9 +8,9 @@ } } -$options = array( - 'order_by' => 'status ASC, id DESC' -); +$options = [ + 'order_by' => 'status ASC, id DESC', +]; $url = 'admin.php?controller=order'; $totalRows = getTotal('orders', $options); @@ -18,10 +18,10 @@ $orderNav = 'class="active open"'; $orders = getAll('orders', $options); -$status = array( +$status = [ 0 => 'Chưa xử lý', 1 => 'Đã xử lý', 2 => 'Đang xử lý', - 3 => 'Đã bị hủy' -); + 3 => 'Đã bị hủy', +]; require('admin/views/order/index.php'); diff --git a/admin/controllers/order/inprocess.php b/admin/controllers/order/inprocess.php index fc2e269f..fc2d34ba 100644 --- a/admin/controllers/order/inprocess.php +++ b/admin/controllers/order/inprocess.php @@ -9,4 +9,4 @@ orderInProcess($_POST['order_id']); } -header('location:admin.php?controller=order'); \ No newline at end of file +header('location:admin.php?controller=order'); diff --git a/admin/controllers/order/order-cancell.php b/admin/controllers/order/order-cancell.php index 07fa87c2..c46db98b 100644 --- a/admin/controllers/order/order-cancell.php +++ b/admin/controllers/order/order-cancell.php @@ -2,20 +2,20 @@ permission_user(); -$options = array( +$options = [ 'where' => 'status = 3', - 'order_by' => 'createtime DESC' -); + 'order_by' => 'createtime DESC', +]; $orderComplete = getAll('orders', $options); $title = 'Đơn hàng đã bị hủy'; $orderNav = 'class="active open"'; -$status = array( +$status = [ 0 => 'Chưa xử lý', 1 => 'Đã xử lý', 2 => 'Đang xử lý', - 3 => 'Đã bị hủy' -); + 3 => 'Đã bị hủy', +]; require('admin/views/order/order-cancell.php'); diff --git a/admin/controllers/order/order-complete.php b/admin/controllers/order/order-complete.php index 269f5e29..6239f280 100644 --- a/admin/controllers/order/order-complete.php +++ b/admin/controllers/order/order-complete.php @@ -2,17 +2,17 @@ permission_user(); -$options = array( +$options = [ 'where' => 'status = 1', - 'order_by' => 'createtime DESC' -); + 'order_by' => 'createtime DESC', +]; $orderComplete = getAll('orders', $options); $title = 'Đơn hàng đã xử lý'; $orderNav = 'class="active open"'; -$status = array( +$status = [ 0 => 'Chưa xử lý', 1 => 'Đã xử lý', - 2 => 'Đang xử lý' -); + 2 => 'Đang xử lý', +]; require('admin/views/order/order-complete.php'); diff --git a/admin/controllers/order/order-noprocess.php b/admin/controllers/order/order-noprocess.php index e6af7c0d..33a5f200 100644 --- a/admin/controllers/order/order-noprocess.php +++ b/admin/controllers/order/order-noprocess.php @@ -5,4 +5,4 @@ $title = 'Đơn hàng chưa xử lý'; $orderNav = 'class="active open"'; -require('admin/views/order/order-noprocess.php'); \ No newline at end of file +require('admin/views/order/order-noprocess.php'); diff --git a/admin/controllers/order/view.php b/admin/controllers/order/view.php index 0f6d6b0f..15da3693 100644 --- a/admin/controllers/order/view.php +++ b/admin/controllers/order/view.php @@ -1,11 +1,14 @@ 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', 1 => 'Đã giao hàng', - 3 => 'Đơn hàng đã hủy' -); + 3 => 'Đơn hàng đã hủy', +]; require('admin/views/order/view.php'); diff --git a/admin/controllers/page/add.php b/admin/controllers/page/add.php index 19082a72..aaba9cba 100644 --- a/admin/controllers/page/add.php +++ b/admin/controllers/page/add.php @@ -8,9 +8,11 @@ page_add(); } -if (isset($_GET['post_id'])) +if (isset($_GET['post_id'])) { $postId = intval($_GET['post_id']); -else $postId = 0; +} else { + $postId = 0; +} $post = getRecord('posts', $postId); $pageNav = 'class="active open"'; diff --git a/admin/controllers/page/delete.php b/admin/controllers/page/delete.php index 8df4334f..6a16960b 100644 --- a/admin/controllers/page/delete.php +++ b/admin/controllers/page/delete.php @@ -8,4 +8,4 @@ $pageId = intval($_GET['page_id']); postDelete($pageId); -header('location:admin.php?controller=page'); \ No newline at end of file +header('location:admin.php?controller=page'); diff --git a/admin/controllers/page/draft.php b/admin/controllers/page/draft.php index 267c922c..469ff83a 100644 --- a/admin/controllers/page/draft.php +++ b/admin/controllers/page/draft.php @@ -8,4 +8,4 @@ $pageId = intval($_GET['page_id']); postDraft($pageId); -header('location:admin.php?controller=page&action=viewdraft'); \ No newline at end of file +header('location:admin.php?controller=page&action=viewdraft'); diff --git a/admin/controllers/page/edit.php b/admin/controllers/page/edit.php index e29bc3f4..55eced3f 100644 --- a/admin/controllers/page/edit.php +++ b/admin/controllers/page/edit.php @@ -9,9 +9,11 @@ page_update(); } -if (isset($_GET['post_id'])) +if (isset($_GET['post_id'])) { $postId = intval($_GET['post_id']); -else $postId = 0; +} else { + $postId = 0; +} $title = 'Sửa trang - Chị Kòi Quán'; $pageNav = 'class="active open"'; @@ -20,7 +22,11 @@ $loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { - if ($post['post_author'] == $userNav) + 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'); + } else { + header('location:admin.php?controller=page'); + } +} else { + require('admin/views/page/edit.php'); +} diff --git a/admin/controllers/page/index.php b/admin/controllers/page/index.php index 7f41c26e..e4725232 100644 --- a/admin/controllers/page/index.php +++ b/admin/controllers/page/index.php @@ -7,20 +7,22 @@ $title = 'All Page - Chị Kòi Quán'; $pageNav = 'class="active open"'; -if (isset($_GET['page'])) +if (isset($_GET['page'])) { $page = intval($_GET['page']); -else $page = 1; +} else { + $page = 1; +} $page = ($page > 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =2 and post_status<>"Trash"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $pages = getAll('posts', $options); $url = 'admin.php?controller=page'; diff --git a/admin/controllers/page/restore.php b/admin/controllers/page/restore.php index 038a2a63..8c9112d7 100644 --- a/admin/controllers/page/restore.php +++ b/admin/controllers/page/restore.php @@ -8,4 +8,4 @@ $pageId = intval($_GET['post_id']); restorePost($pageId); -header('location:admin.php?controller=page&action=viewtrash'); \ No newline at end of file +header('location:admin.php?controller=page&action=viewtrash'); diff --git a/admin/controllers/page/trash.php b/admin/controllers/page/trash.php index 23dcc521..4922a8d9 100644 --- a/admin/controllers/page/trash.php +++ b/admin/controllers/page/trash.php @@ -1,4 +1,5 @@ 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =2 and post_status="Draft"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $pages = getAll('posts', $options); $url = 'admin.php?controller=page&action=viewdraft'; diff --git a/admin/controllers/page/viewtrash.php b/admin/controllers/page/viewtrash.php index e4c79a6d..e600230a 100644 --- a/admin/controllers/page/viewtrash.php +++ b/admin/controllers/page/viewtrash.php @@ -6,20 +6,22 @@ $pageNav = 'class="active open"'; $title = 'Thùng rác'; -if (isset($_GET['page'])) +if (isset($_GET['page'])) { $page = intval($_GET['page']); -else $page = 1; +} else { + $page = 1; +} $page = ($page > 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =2 and post_status="Trash"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $pages = getAll('posts', $options); $url = 'admin.php?controller=page&action=viewtrash'; diff --git a/admin/controllers/post/add.php b/admin/controllers/post/add.php index deba46f9..2b2c6115 100644 --- a/admin/controllers/post/add.php +++ b/admin/controllers/post/add.php @@ -9,9 +9,11 @@ addPost(); } -if (isset($_GET['post_id'])) +if (isset($_GET['post_id'])) { $postId = intval($_GET['post_id']); -else $postId = 0; +} else { + $postId = 0; +} $post = getRecord('posts', $postId); $title = 'Thêm trang mới - Chị Kòi Quán'; diff --git a/admin/controllers/post/delete.php b/admin/controllers/post/delete.php index fc619f29..ff5f0852 100644 --- a/admin/controllers/post/delete.php +++ b/admin/controllers/post/delete.php @@ -8,4 +8,4 @@ $postId = intval($_GET['post_id']); postDelete($postId); -header('location:admin.php?controller=post'); \ No newline at end of file +header('location:admin.php?controller=post'); diff --git a/admin/controllers/post/draft.php b/admin/controllers/post/draft.php index f062eb31..fbfd6284 100644 --- a/admin/controllers/post/draft.php +++ b/admin/controllers/post/draft.php @@ -8,4 +8,4 @@ $postId = intval($_GET['post_id']); postDraft($postId); -header('location:admin.php?controller=post&action=viewdraft'); \ No newline at end of file +header('location:admin.php?controller=post&action=viewdraft'); diff --git a/admin/controllers/post/edit.php b/admin/controllers/post/edit.php index 590dd351..33bc28eb 100644 --- a/admin/controllers/post/edit.php +++ b/admin/controllers/post/edit.php @@ -9,9 +9,11 @@ post_update(); } -if (isset($_GET['post_id'])) +if (isset($_GET['post_id'])) { $postId = intval($_GET['post_id']); -else $postId = 0; +} else { + $postId = 0; +} $title = 'Sửa bài viết - Chị Kòi Quán'; $postNav = 'class="active open"'; @@ -20,7 +22,11 @@ $loginUser = getRecord('users', $userNav); if ($loginUser['role_id'] == 2) { - if ($post['post_author'] == $userNav) + 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'); + } else { + header('location:admin.php?controller=post'); + } +} else { + require('admin/views/post/edit.php'); +} diff --git a/admin/controllers/post/index.php b/admin/controllers/post/index.php index 131503b7..58a89cce 100644 --- a/admin/controllers/post/index.php +++ b/admin/controllers/post/index.php @@ -7,20 +7,22 @@ $title = 'All Post - Chị Kòi Quán'; $postNav = 'class="active open"'; -if (isset($_GET['page'])) +if (isset($_GET['page'])) { $page = intval($_GET['page']); -else $page = 1; +} else { + $page = 1; +} $page = ($page > 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =1 and post_status<>"Trash"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $posts = getAll('posts', $options); $url = 'admin.php?controller=post'; diff --git a/admin/controllers/post/public.php b/admin/controllers/post/public.php index 8b77f828..6c62258f 100644 --- a/admin/controllers/post/public.php +++ b/admin/controllers/post/public.php @@ -1,4 +1,5 @@
        Tốt! Bạn đã thay đổi trại thái của trang là "Công khai". Giờ đây trang này đã có thể xem được đối với người dùng.

        Đến All post hoặc Trở lại.!!
'; diff --git a/admin/controllers/post/restore.php b/admin/controllers/post/restore.php index 0b221639..c1dee701 100644 --- a/admin/controllers/post/restore.php +++ b/admin/controllers/post/restore.php @@ -8,4 +8,4 @@ $postId = intval($_GET['post_id']); restorePost($postId); -header('location:admin.php?controller=post&action=viewtrash'); \ No newline at end of file +header('location:admin.php?controller=post&action=viewtrash'); diff --git a/admin/controllers/post/viewdraft.php b/admin/controllers/post/viewdraft.php index 56a8ba39..58f153f6 100644 --- a/admin/controllers/post/viewdraft.php +++ b/admin/controllers/post/viewdraft.php @@ -7,20 +7,22 @@ $title = 'Các bản nháp'; $postNav = 'class="active open"'; -if (isset($_GET['page'])) +if (isset($_GET['page'])) { $page = intval($_GET['page']); -else $page = 1; +} else { + $page = 1; +} $page = ($page > 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =1 and post_status="Draft"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $posts = getAll('posts', $options); $url = 'admin.php?controller=post&action=viewdraft'; diff --git a/admin/controllers/post/viewtrash.php b/admin/controllers/post/viewtrash.php index 8dd46a23..b894e5a1 100644 --- a/admin/controllers/post/viewtrash.php +++ b/admin/controllers/post/viewtrash.php @@ -7,20 +7,22 @@ $postNav = 'class="active open"'; $title = 'Thùng rác'; -if (isset($_GET['page'])) +if (isset($_GET['page'])) { $page = intval($_GET['page']); -else $page = 1; +} else { + $page = 1; +} $page = ($page > 0) ? $page : 1; $limit = 20; $offset = ($page - 1) * $limit; -$options = array( +$options = [ 'where' => 'post_type =1 and post_status="Trash"', 'limit' => $limit, 'offset' => $offset, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $posts = getAll('posts', $options); $url = 'admin.php?controller=post&action=viewtrash'; diff --git a/admin/controllers/product/delete.php b/admin/controllers/product/delete.php index 8a754c05..e96467f0 100644 --- a/admin/controllers/product/delete.php +++ b/admin/controllers/product/delete.php @@ -7,4 +7,4 @@ $productId = intval($_GET['product_id']); postDestroy($productId); -header('location:admin.php?controller=product'); \ No newline at end of file +header('location:admin.php?controller=product'); diff --git a/admin/controllers/product/edit.php b/admin/controllers/product/edit.php index b6173d71..9c8911c6 100644 --- a/admin/controllers/product/edit.php +++ b/admin/controllers/product/edit.php @@ -9,32 +9,36 @@ product_update(); } -if (isset($_GET['product_id'])) +if (isset($_GET['product_id'])) { $productId = intval($_GET['product_id']); -else $productId = 0; +} else { + $productId = 0; +} $title = ($productId == 0) ? 'Thêm sản phẩm' : 'Sửa sản phẩm: '; $productNav = 'class="active open"'; $product = getRecord('products', $productId); -if ($productId <> 0) $title .= $product['product_name']; -$options = array( - 'order_by' => 'createDate' -); +if ($productId <> 0) { + $title .= $product['product_name']; +} +$options = [ + 'order_by' => 'createDate', +]; $products = getAll('products', $options); -$categories = getAll('categories', array( +$categories = getAll('categories', [ 'select' => 'id,category_name', - 'order_by' => 'id' -)); -$subcategories = getAll('subcategory', array( + 'order_by' => 'id', +]); +$subcategories = getAll('subcategory', [ 'select' => 'id,subcategory_name', - 'order_by' => 'subcategory_name' -)); + 'order_by' => 'subcategory_name', +]); -$types = getAll('types', array( +$types = getAll('types', [ 'select' => 'id,type_name', - 'order_by' => 'id' -)); + 'order_by' => 'id', +]); require('admin/views/product/edit.php'); diff --git a/admin/controllers/product/hotproduct.php b/admin/controllers/product/hotproduct.php index ec840625..686373ff 100644 --- a/admin/controllers/product/hotproduct.php +++ b/admin/controllers/product/hotproduct.php @@ -14,4 +14,4 @@ $title = 'Sản phẩm mới order'; $productNav = 'class="active open"'; -require('admin/views/product/hotproduct.php'); \ No newline at end of file +require('admin/views/product/hotproduct.php'); diff --git a/admin/controllers/product/index.php b/admin/controllers/product/index.php index 4f356e9e..f2758425 100644 --- a/admin/controllers/product/index.php +++ b/admin/controllers/product/index.php @@ -7,4 +7,4 @@ $title = 'Tổng Danh Sách Các Sản phẩm'; $productNav = 'class="active open"'; -require('admin/views/product/index.php'); \ No newline at end of file +require('admin/views/product/index.php'); diff --git a/admin/controllers/product/newproduct.php b/admin/controllers/product/newproduct.php index cc9dd0c6..6fbb2c4a 100644 --- a/admin/controllers/product/newproduct.php +++ b/admin/controllers/product/newproduct.php @@ -13,4 +13,4 @@ $title = 'Sản phẩm mới - Quản trị Quán Chị Kòi'; $productNav = 'class="active open"'; -require('admin/views/product/newproduct.php'); \ No newline at end of file +require('admin/views/product/newproduct.php'); diff --git a/admin/controllers/product/saleproduct.php b/admin/controllers/product/saleproduct.php index 9d9ceb2c..3123db8c 100644 --- a/admin/controllers/product/saleproduct.php +++ b/admin/controllers/product/saleproduct.php @@ -1,4 +1,5 @@ 'status = 3 and user_id =' . $userNav, - 'order_by' => 'createtime DESC' - ); + 'order_by' => 'createtime DESC', + ]; $cancelledOrders = getAll('orders', $options); $title = 'Đơn hàng đã hủy'; $yourPurchaseNav = 'class="active open"'; - $status = array( + $status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', 1 => 'Đã giao hàng', - 3 => 'Đơn hàng đã hủy' - ); + 3 => 'Đơn hàng đã hủy', + ]; } require('admin/views/purchase/cancelled.php'); diff --git a/admin/controllers/purchase/confirmed.php b/admin/controllers/purchase/confirmed.php index 6d9a014e..c992c85f 100644 --- a/admin/controllers/purchase/confirmed.php +++ b/admin/controllers/purchase/confirmed.php @@ -5,18 +5,18 @@ global $userNav; if (!empty($userNav)) { - $options = array( + $options = [ 'where' => 'status = 0 and user_id =' . $userNav, - 'order_by' => 'createtime DESC' - ); + 'order_by' => 'createtime DESC', + ]; $confirmedOrders = getAll('orders', $options); $title = 'Đơn hàng đã xác nhận'; $yourPurchaseNav = 'class="active open"'; - $status = array( + $status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', - 1 => 'Đã giao hàng' - ); + 1 => 'Đã giao hàng', + ]; } require('admin/views/purchase/confirmed.php'); diff --git a/admin/controllers/purchase/delivery.php b/admin/controllers/purchase/delivery.php index 10f05452..1131c991 100644 --- a/admin/controllers/purchase/delivery.php +++ b/admin/controllers/purchase/delivery.php @@ -5,18 +5,18 @@ global $userNav; if (!empty($userNav)) { - $options = array( + $options = [ 'where' => 'status = 2 and user_id =' . $userNav, - 'order_by' => 'createtime DESC' - ); + 'order_by' => 'createtime DESC', + ]; $deliveryOrders = getAll('orders', $options); $title = 'Đơn hàng đang vận chuyển'; $yourPurchaseNav = 'class="active open"'; - $status = array( + $status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', - 1 => 'Đã giao hàng' - ); + 1 => 'Đã giao hàng', + ]; } require('admin/views/purchase/delivery.php'); diff --git a/admin/controllers/purchase/index.php b/admin/controllers/purchase/index.php index bdf543a5..55b5578d 100644 --- a/admin/controllers/purchase/index.php +++ b/admin/controllers/purchase/index.php @@ -5,19 +5,19 @@ global $userNav; if (!empty($userNav)) { - $options = array( + $options = [ 'where' => 'user_id =' . $userNav, - 'order_by' => 'createtime DESC' - ); + 'order_by' => 'createtime DESC', + ]; $orders = getAll('orders', $options); $title = 'Tất cả đơn hàng của bạn'; $yourPurchaseNav = 'class="active open"'; - $status = array( + $status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', 1 => 'Đã giao hàng', - 3 => 'Đơn hàng đã hủy' - ); + 3 => 'Đơn hàng đã hủy', + ]; } require('admin/views/purchase/index.php'); diff --git a/admin/controllers/purchase/receied.php b/admin/controllers/purchase/receied.php index 011a6c3d..2a770329 100644 --- a/admin/controllers/purchase/receied.php +++ b/admin/controllers/purchase/receied.php @@ -5,18 +5,18 @@ global $userNav; if (!empty($userNav)) { - $options = array( + $options = [ 'where' => 'status = 1 and user_id =' . $userNav, - 'order_by' => 'createtime DESC' - ); + 'order_by' => 'createtime DESC', + ]; $receiedOrders = getAll('orders', $options); $title = 'Đơn hàng đã nhận'; $yourPurchaseNav = 'class="active open"'; - $status = array( + $status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', - 1 => 'Đã giao hàng' - ); + 1 => 'Đã giao hàng', + ]; } require('admin/views/purchase/receied.php'); diff --git a/admin/controllers/purchase/view.php b/admin/controllers/purchase/view.php index e30b60ba..1cc1a6b6 100644 --- a/admin/controllers/purchase/view.php +++ b/admin/controllers/purchase/view.php @@ -2,9 +2,11 @@ require_once('admin/models/order.php'); -if (isset($_GET['order_id'])) +if (isset($_GET['order_id'])) { $orderId = intval($_GET['order_id']); -else $orderId = 0; +} else { + $orderId = 0; +} $order = getRecord('orders', $orderId); @@ -16,11 +18,11 @@ $yourPurchaseNav = 'class="active open"'; $orderDetail = orderDetail($orderId); -$status = array( +$status = [ 0 => 'Đã xác nhận đơn hàng', 2 => 'Đang giao hàng', 1 => 'Đã giao hàng', - 3 => 'Đơn hàng đã hủy' -); + 3 => 'Đơn hàng đã hủy', +]; require('admin/views/purchase/view.php'); diff --git a/admin/controllers/role/admin.php b/admin/controllers/role/admin.php index 9f3ae0cb..574a7983 100644 --- a/admin/controllers/role/admin.php +++ b/admin/controllers/role/admin.php @@ -4,9 +4,9 @@ require_once('admin/models/users.php'); -$options = array( - 'order_by' => 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $title = 'Danh sách Admin'; $adminNav = 'class="active open"'; $list_user = getAll('users', $options); diff --git a/admin/controllers/role/delete.php b/admin/controllers/role/delete.php index 580cd81b..e108aa6b 100644 --- a/admin/controllers/role/delete.php +++ b/admin/controllers/role/delete.php @@ -8,4 +8,4 @@ $roleId = intval($_GET['role_id']); roleDestroy($roleId); -header('location:admin.php?controller=role'); \ No newline at end of file +header('location:admin.php?controller=role'); diff --git a/admin/controllers/role/edit.php b/admin/controllers/role/edit.php index 78148a1e..e2cd067b 100644 --- a/admin/controllers/role/edit.php +++ b/admin/controllers/role/edit.php @@ -9,9 +9,11 @@ role_update(); } -if (isset($_GET['role_id'])) +if (isset($_GET['role_id'])) { $roleId = intval($_GET['role_id']); -else $roleId = 0; +} else { + $roleId = 0; +} $title = ($roleId == 0) ? 'Thêm quyền truy cập' : 'Sửa quyền truy cập'; $adminNav = 'class="active open"'; diff --git a/admin/controllers/role/index.php b/admin/controllers/role/index.php index eaa14755..d83ebc47 100644 --- a/admin/controllers/role/index.php +++ b/admin/controllers/role/index.php @@ -13,9 +13,9 @@ } $url = 'admin.php?controller=role'; -$options = array( - 'order_by' => 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $title = 'Danh sách quyền truy cập website'; $adminNav = 'class="active open"'; $roles = getAll('roles', $options); diff --git a/admin/controllers/shared/statistics.php b/admin/controllers/shared/statistics.php index cf7c97de..7422c1ad 100644 --- a/admin/controllers/shared/statistics.php +++ b/admin/controllers/shared/statistics.php @@ -3,275 +3,287 @@ * @var $userNav */ -$options_order_complete = array( +$options_order_complete = [ 'where' => 'status = 1', - 'order_by' => 'createtime DESC' -); + 'order_by' => 'createtime DESC', +]; $orderCompletes = getAll('orders', $options_order_complete); -$options_order = array( - 'order_by' => 'id DESC' -); +$options_order = [ + 'order_by' => 'id DESC', +]; $total_order = getTotal('orders', $options_order); -$options_order_mine = array( +$options_order_mine = [ 'order_by' => 'id DESC', - 'where' => 'user_id=' . $userNav -); + 'where' => 'user_id=' . $userNav, +]; $total_order_mine = getTotal('orders', $options_order_mine); -$options_comlete = array( +$options_comlete = [ 'where' => 'status = 1', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_order_prosess = getTotal('orders', $options_comlete); -$options_order_new = array( +$options_order_new = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $order_new = getByOptions('orders', $options_order_new); -$options_inprocess = array( +$options_inprocess = [ 'where' => 'status = 2', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_order_inprosess = getTotal('orders', $options_inprocess); -$options_mine_inprocess = array( +$options_mine_inprocess = [ 'where' => 'status = 2 and user_id=' . $userNav, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_mine_order_inprosess = getTotal('orders', $options_mine_inprocess); -$options_mine_complete = array( +$options_mine_complete = [ 'where' => 'status = 1 and user_id=' . $userNav, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_mine_order_complete = getTotal('orders', $options_mine_complete); -$options_cancell_total = array( +$options_cancell_total = [ 'where' => 'status = 3', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_order_cancell = getTotal('orders', $options_cancell_total); -$options_noprocess = array( +$options_noprocess = [ 'where' => 'status = 0', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_order_noprosess = getTotal('orders', $options_noprocess); -$options_cancell = array( +$options_cancell = [ 'where' => 'status = 3', 'limit' => 1, 'offset' => 0, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $order_cancell = getByOptions('orders', $options_cancell); -$options_order_status = array( +$options_order_status = [ 'where' => 'status=1 or status=3', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $total_order_status = getTotal('orders', $options_order_status); -if ($total_order_status != 0) $order_ratio = ($total_order_status / $total_order) * 100; -else $order_ratio = 0; +if ($total_order_status != 0) { + $order_ratio = ($total_order_status / $total_order) * 100; +} else { + $order_ratio = 0; +} //feedbacks -$options_feedback = array( - 'order_by' => 'createTime DESC' -); +$options_feedback = [ + 'order_by' => 'createTime DESC', +]; $total_feedback = getTotal('feedbacks', $options_feedback); -$options_feedback_order = array( +$options_feedback_order = [ 'order_by' => 'createTime DESC', - 'where' => 'order_id<>0' -); + 'where' => 'order_id<>0', +]; $total_feedback_order = getTotal('feedbacks', $options_feedback_order); -$options_feedback_five = array( +$options_feedback_five = [ 'limit' => 5, 'offset' => 0, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $feedback_five = getAll('feedbacks', $options_feedback_five); -$options_feedback_noaccept = array( +$options_feedback_noaccept = [ 'order_by' => 'id DESC', - 'where' => 'status=0' -); + 'where' => 'status=0', +]; $total_feedback_noaccept = getTotal('feedbacks', $options_feedback_noaccept); -$options_feedback_mine = array( +$options_feedback_mine = [ 'order_by' => 'id DESC', - 'where' => 'user_id=' . $userNav -); + 'where' => 'user_id=' . $userNav, +]; $total_feedback_mine = getTotal('feedbacks', $options_feedback_mine); -$options_feedback_mine_product = array( +$options_feedback_mine_product = [ 'order_by' => 'id DESC', - 'where' => 'product_id<>0 and user_id=' . $userNav -); + 'where' => 'product_id<>0 and user_id=' . $userNav, +]; $total_feedback_mine_product = getTotal('feedbacks', $options_feedback_mine_product); -$options_feedback_mine_order = array( +$options_feedback_mine_order = [ 'order_by' => 'id DESC', - 'where' => 'product_id<>0 and user_id=' . $userNav -); + 'where' => 'product_id<>0 and user_id=' . $userNav, +]; $total_feedback_mine_order = getTotal('feedbacks', $options_feedback_mine_order); -$options_feedback_new = array( +$options_feedback_new = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $feedback_new = getByOptions('feedbacks', $options_feedback_new); -$options_feedback_product = array( +$options_feedback_product = [ 'order_by' => 'createTime DESC', - 'where' => 'product_id<>0' -); + 'where' => 'product_id<>0', +]; $total_feedback_product = getTotal('feedbacks', $options_feedback_product); -$options_feedback_noaccept = array( +$options_feedback_noaccept = [ 'order_by' => 'createTime DESC', - 'where' => 'status=0' -); + 'where' => 'status=0', +]; $total_feedback_noaccept = getTotal('feedbacks', $options_feedback_noaccept); -$options_feedback_status = array( +$options_feedback_status = [ 'order_by' => 'createTime DESC', - 'where' => 'status=1' -); + 'where' => 'status=1', +]; $total_feedback_status = getTotal('feedbacks', $options_feedback_status); -if ($total_feedback_status != 0) $feedback_ratio = $total_feedback_status / $total_feedback * 100; -else $feedback_ratio = 0; +if ($total_feedback_status != 0) { + $feedback_ratio = $total_feedback_status / $total_feedback * 100; +} else { + $feedback_ratio = 0; +} //comments -$options_comments = array( - 'order_by' => 'id DESC' -); +$options_comments = [ + 'order_by' => 'id DESC', +]; $totalRows_comment = getTotal('comments', $options_comments); -$options_comments_mine = array( +$options_comments_mine = [ 'order_by' => 'id DESC', - 'where' => 'user_id=' . $userNav -); + 'where' => 'user_id=' . $userNav, +]; $total_mine_comment = getTotal('comments', $options_comments_mine); -$options_mine_comment_noaccept = array( +$options_mine_comment_noaccept = [ 'order_by' => 'id DESC', - 'where' => 'status=0 and user_id=' . $userNav -); + 'where' => 'status=0 and user_id=' . $userNav, +]; $total_mine_comment_noaccept = getTotal('comments', $options_mine_comment_noaccept); -$options_comment_five = array( +$options_comment_five = [ 'limit' => 5, 'offset' => 0, 'where' => 'status<>3 and status<>2', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $comment_five = getAll('comments', $options_comment_five); -$options_comment_new = array( +$options_comment_new = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $comment_new = getByOptions('comments', $options_comment_new); -$options_comment_noaccept = array( +$options_comment_noaccept = [ 'order_by' => 'id DESC', - 'where' => 'status=0' -); + 'where' => 'status=0', +]; $total_comment_noaccept = getTotal('comments', $options_comment_noaccept); -$options_comment_trash = array( +$options_comment_trash = [ 'order_by' => 'id DESC', - 'where' => 'status=2' -); + 'where' => 'status=2', +]; $total_comment_trash = getTotal('comments', $options_comment_trash); -$options_comment_spam = array( +$options_comment_spam = [ 'order_by' => 'id DESC', - 'where' => 'status=3' -); + 'where' => 'status=3', +]; $total_comment_spam = getTotal('comments', $options_comment_spam); -$options_comment_accept = array( +$options_comment_accept = [ 'order_by' => 'id DESC', - 'where' => 'status=1' -); + 'where' => 'status=1', +]; $total_comment_accept = getTotal('comments', $options_comment_accept); -if ($total_comment_accept != 0) $comment_ratio = $total_comment_accept / $totalRows_comment * 100; -else $comment_ratio = 0; +if ($total_comment_accept != 0) { + $comment_ratio = $total_comment_accept / $totalRows_comment * 100; +} else { + $comment_ratio = 0; +} //posts -$options_page_new = array( +$options_page_new = [ 'limit' => 1, 'offset' => 0, 'where' => 'post_type=2', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $page_new = getByOptions('posts', $options_page_new); -$options_post = array( +$options_post = [ 'order_by' => 'id DESC', 'where' => 'post_type=1', -); +]; $total_post = getTotal('posts', $options_post); -$options_page = array( +$options_page = [ 'order_by' => 'id DESC', 'where' => 'post_type=2', -); +]; $total_page = getTotal('posts', $options_page); -$options_trash = array( +$options_trash = [ 'order_by' => 'id DESC', 'where' => 'post_status="Trash"', -); +]; $total_post_trash = getTotal('posts', $options_trash); -$options_posts = array( - 'order_by' => 'id DESC' -); +$options_posts = [ + 'order_by' => 'id DESC', +]; $total_posts = getTotal('posts', $options_posts); -$options_posts_status = array( +$options_posts_status = [ 'order_by' => 'id DESC', 'where' => 'post_status="Publiced"', -); +]; $total_posts_status = getTotal('posts', $options_posts_status); -$options_page_draft = array( +$options_page_draft = [ 'order_by' => 'id DESC', - 'where' => 'post_type=2 and post_status="Draft"' -); + 'where' => 'post_type=2 and post_status="Draft"', +]; $total_page_draft = getTotal('posts', $options_page_draft); -$options_post_new = array( +$options_post_new = [ 'limit' => 1, 'offset' => 0, 'where' => 'post_type=1', - 'order_by' => 'id DESC' -); + 'order_by' => 'id DESC', +]; $post_new = getByOptions('posts', $options_post_new); -$options_post_draft = array( +$options_post_draft = [ 'order_by' => 'id DESC', - 'where' => 'post_type=1 and post_status="Draft"' -); + 'where' => 'post_type=1 and post_status="Draft"', +]; $total_post_draft = getTotal('posts', $options_post_draft); -if ($total_posts_status != 0) $posts_ratio = ($total_posts_status / $total_posts) * 100; -else $posts_ratio = 0; +if ($total_posts_status != 0) { + $posts_ratio = ($total_posts_status / $total_posts) * 100; +} else { + $posts_ratio = 0; +} //uuser online -$options_user_online = array( - 'order_by' => 'session' -); +$options_user_online = [ + 'order_by' => 'session', +]; $users_online = getAll('users_online', $options_user_online); $users_online_total = 0; foreach ($users_online as $user) { @@ -280,74 +292,75 @@ } } -$options_user_online_all = array( - 'order_by' => 'session' -); +$options_user_online_all = [ + 'order_by' => 'session', +]; $users_online_all = getTotal('users_online', $options_user_online_all); //product -$options_product_total = array( - 'order_by' => 'id' -); +$options_product_total = [ + 'order_by' => 'id', +]; $total_product = getTotal('products', $options_product_total); -$options_New_product_total = array( +$options_New_product_total = [ 'order_by' => 'id', - 'where' => 'product_typeid=2' -); + 'where' => 'product_typeid=2', +]; $total_new_product = getTotal('products', $options_New_product_total); -$options_hot_product_total = array( +$options_hot_product_total = [ 'order_by' => 'id', - 'where' => 'product_typeid=1' -); + 'where' => 'product_typeid=1', +]; $total_hot_product = getTotal('products', $options_hot_product_total); -$options_sale_product_total = array( +$options_sale_product_total = [ 'order_by' => 'id', - 'where' => 'product_typeid=3' -); + 'where' => 'product_typeid=3', +]; $total_sale_product = getTotal('products', $options_sale_product_total); -$options_product_update = array( +$options_product_update = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'editDate DESC' -); + 'order_by' => 'editDate DESC', +]; $product_update = getByOptions('products', $options_product_update); //user -$options_user_update = array( +$options_user_update = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'editTime DESC' -); + 'order_by' => 'editTime DESC', +]; $user_update = getByOptions('users', $options_user_update); -$options_user_all = array( - 'order_by' => 'editTime DESC' -); +$options_user_all = [ + 'order_by' => 'editTime DESC', +]; $user_all_total = getTotal('users', $options_user_all); -$options_user_not_veri = array( +$options_user_not_veri = [ 'order_by' => 'editTime DESC', - 'where' => 'verified=0' -); + 'where' => 'verified=0', +]; $user_not_veri_total = getTotal('users', $options_user_not_veri); -$options_user_new = array( +$options_user_new = [ 'limit' => 1, 'offset' => 0, - 'order_by' => 'createDate DESC' -); + 'order_by' => 'createDate DESC', +]; $user_new = getByOptions('users', $options_user_new); -$options_user = array( - 'order_by' => 'editTime DESC' -); +$options_user = [ + 'order_by' => 'editTime DESC', +]; $users = getAll('users', $options_user); $user_total_7day = 0; foreach ($users as $user) { - if (strtotime($user['createDate']) > strtotime(date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), (date('d') - 7), date('Y'))))) + if (strtotime($user['createDate']) > strtotime(date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), (date('d') - 7), date('Y'))))) { $user_total_7day++; + } } diff --git a/admin/controllers/shop/edit.php b/admin/controllers/shop/edit.php index 72e545f3..d4c88088 100644 --- a/admin/controllers/shop/edit.php +++ b/admin/controllers/shop/edit.php @@ -9,9 +9,11 @@ categoryUpdate(); } -if (isset($_GET['cate_id'])) +if (isset($_GET['cate_id'])) { $categoryId = intval($_GET['cate_id']); -else $categoryId = 0; +} else { + $categoryId = 0; +} $title = ($categoryId == 0) ? 'Thêm danh mục' : 'Sửa danh mục'; $category = getRecord('categories', $categoryId); diff --git a/admin/controllers/shop/index.php b/admin/controllers/shop/index.php index 56f76761..2b956c9c 100644 --- a/admin/controllers/shop/index.php +++ b/admin/controllers/shop/index.php @@ -5,9 +5,9 @@ require_once('admin/models/shop.php'); -$options = array( - 'order_by' => 'id' -); +$options = [ + 'order_by' => 'id', +]; $title = 'Nhóm Danh mục sản phẩm'; $categories = getAll('categories', $options); $navCategory = 'class="active open"'; diff --git a/admin/controllers/slide/delete.php b/admin/controllers/slide/delete.php index 688582c5..11219542 100644 --- a/admin/controllers/slide/delete.php +++ b/admin/controllers/slide/delete.php @@ -1,7 +1,8 @@ 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $navHF = 'class="active open"'; $title = 'Slide Show HomePage'; $slides = getAll('slides', $options); diff --git a/admin/controllers/user/add.php b/admin/controllers/user/add.php index 6abcbc0b..2e256235 100644 --- a/admin/controllers/user/add.php +++ b/admin/controllers/user/add.php @@ -1,12 +1,16 @@
NO! NgườI dùng này không tồn tại. Trở lại
"; require('admin/views/user/result.php'); diff --git a/admin/controllers/user/listall.php b/admin/controllers/user/listall.php index 81a65a4f..1f1084e0 100644 --- a/admin/controllers/user/listall.php +++ b/admin/controllers/user/listall.php @@ -1,10 +1,11 @@ 'id ASC' -); +$options = [ + 'order_by' => 'id ASC', +]; $title = 'Danh sách Thành viên'; $nav_user = 'class="active open"'; $list_user = getAll('users', $options); diff --git a/admin/controllers/user/result.php b/admin/controllers/user/result.php index 59375f15..22030583 100644 --- a/admin/controllers/user/result.php +++ b/admin/controllers/user/result.php @@ -1,4 +1,5 @@
NO! Việc thay đổi mật khẩu thất bại. Mật khẩu bạn nhập phải dài từ 8 ký tự trở lên !!
Trở lại hoặc Đến Trang chủ
"; } elseif ($newpassword == $confirmPassword) { echo changePassword($id, $newpassword, $currentpassword); -} else echo "
NO! Việc thay đổi mật khẩu có vấn đề. Ô nhập xác thực mật khẩu không đúng với mật khẩu mới bạn nhập vào !!
Trở lại hoặc Đến Dashboard
"; +} else { + echo "
NO! Việc thay đổi mật khẩu có vấn đề. Ô nhập xác thực mật khẩu không đúng với mật khẩu mới bạn nhập vào !!
Trở lại hoặc Đến Dashboard
"; +} require('admin/views/user/result.php'); diff --git a/admin/models/backupDB.php b/admin/models/backupDB.php index 98707b20..77554804 100644 --- a/admin/models/backupDB.php +++ b/admin/models/backupDB.php @@ -1,10 +1,11 @@ 'id', - 'where' => 'sub_category_id=' . $id - ); + 'where' => 'sub_category_id=' . $id, + ]; $products = getAll('products', $options); foreach ($products as $product) { postDestroy($product['id']); @@ -17,12 +18,12 @@ function deleteSubCategory($id) } function updateSubCategory() { - $subcategory = array( + $subcategory = [ 'id' => intval($_POST['sub_cate_id']), 'subcategory_name' => escape($_POST['name']), 'slug' => slug($_POST['name']), - 'category_id' => intval($_POST['category_id']) - ); + 'category_id' => intval($_POST['category_id']), + ]; save('subcategory', $subcategory); header('location:admin.php?controller=category'); } diff --git a/admin/models/comments.php b/admin/models/comments.php index de51a45f..d12979f7 100644 --- a/admin/models/comments.php +++ b/admin/models/comments.php @@ -1,9 +1,12 @@ intval($_POST['comment_id']), 'author' => escape($_POST['name']), 'email' => escape($_POST['email']), 'content' => escape($_POST['subject']), 'editTime' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'status' => intval($_POST['status']), - ); + ]; save('comments', $comment); header('location:admin.php?controller=comment'); } diff --git a/admin/models/feedbacks.php b/admin/models/feedbacks.php index a65e3dd7..28344632 100644 --- a/admin/models/feedbacks.php +++ b/admin/models/feedbacks.php @@ -1,11 +1,11 @@ intval($_POST['feedback_id']), 'name' => escape($_POST['name']), 'createTime' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), @@ -15,8 +15,8 @@ function addFeedbackOrder() 'user_id' => intval($_POST['user_id']), 'product_id' => 0, 'order_id' => intval($_POST['order_id']), - 'status' => 0 - ); + 'status' => 0, + ]; save('feedbacks', $feedback_add); echo "
Done! Thư phản hồi của bạn đã được gửi đến hệ thống của quán Chị Kòi. Cảm ơn bạn đã gửi lại phải hồi về quán.

Hãy đến Dashboard
"; require('content/views/feedback/result.php'); @@ -31,7 +31,7 @@ function deleteFeedback($id) } function updateFeedback() { - $feedback = array( + $feedback = [ 'id' => intval($_POST['feedback_id']), 'name' => escape($_POST['name']), 'email' => escape($_POST['email']), @@ -39,7 +39,7 @@ function updateFeedback() 'subject' => escape($_POST['subject']), 'editTime' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'status' => intval($_POST['status']), - ); + ]; save('feedbacks', $feedback); header('location:admin.php?controller=feedback'); } @@ -49,6 +49,7 @@ function feedbackReplyMail($html, $email) require 'vendor/autoload.php'; include 'lib/config/sendmail.php'; $mail = new PHPMailer(true); + try { //content $htmlStr = $html; @@ -84,7 +85,9 @@ function approveFeedback($id) { if (isset($_GET['feedback_id'])) { $id = intval($_GET['feedback_id']); - } else show_404(); + } else { + show_404(); + } global $linkConnectDB; $sql = "UPDATE feedbacks SET status=1 where id=" . $id; mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); @@ -93,7 +96,9 @@ function unApproveFeedback($id) { if (isset($_GET['feedback_id'])) { $id = intval($_GET['feedback_id']); - } else show_404(); + } else { + show_404(); + } global $linkConnectDB; $sql = "UPDATE feedbacks SET status=0 where id=" . $id; mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); diff --git a/admin/models/header-footer.php b/admin/models/header-footer.php index d7cf7ebf..e97a3375 100644 --- a/admin/models/header-footer.php +++ b/admin/models/header-footer.php @@ -1,7 +1,8 @@ intval($_POST['contact_id']), 'contact_name' => escape($_POST['name']), 'address' => escape($_POST['address']), @@ -16,46 +17,46 @@ function updateHeaderFooter() 'zalo' => escape($_POST['zalo']), 'link_about' => escape($_POST['link_about']), 'about_footer' => escape($_POST['about_footer']), - ); + ]; $contact_id = save('contacts', $contacts); $image_name1 = 'logo-chikoiquan-' . slug($_POST['name']); - $config = array( + $config = [ 'name' => $image_name1, 'upload_path' => 'public/img/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); - $image1 = upload('logo', $config); //$field = name of input + ]; + $image1 = upload('logo', $config); //$field = name of input if ($image1) { - $contacts = array( + $contacts = [ 'id' => $contact_id, - 'link_Logo' => $image1 - ); + 'link_Logo' => $image1, + ]; save('contacts', $contacts); } $image_name2 = 'favicon-chikoiquan-' . slug($_POST['name']); - $config2 = array( + $config2 = [ 'name' => $image_name2, 'upload_path' => 'public/img/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); - $image2 = upload('favicon', $config2); //$field = name of input + ]; + $image2 = upload('favicon', $config2); //$field = name of input if ($image2) { - $contacts = array( + $contacts = [ 'id' => $contact_id, - 'favicon' => $image2 - ); + 'favicon' => $image2, + ]; save('contacts', $contacts); } header('location:admin.php?controller=header-footer'); } function updateMenuFooter() { - $menuFooter = array( + $menuFooter = [ 'id' => intval($_POST['menu_footer_id']), 'menu_name' => escape($_POST['name']), 'menu_url' => escape($_POST['menu_url']), - 'menu_description' => escape($_POST['menu_description']) - ); + 'menu_description' => escape($_POST['menu_description']), + ]; save('menu_footers', $menuFooter); header('location:admin.php?controller=header-footer&action=listMenuFooter'); } diff --git a/admin/models/media.php b/admin/models/media.php index 3d2c8a3b..93b93749 100644 --- a/admin/models/media.php +++ b/admin/models/media.php @@ -1,9 +1,12 @@ intval($_POST['media_id']), 'media_name' => escape($_POST['name']), - 'createDate' => gmdate('Y-m-d H:i:s', time() + 7 * 3600) - ); - $mediaId = save('media', $mediaStore); + 'createDate' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), + ]; + $mediaId = save('media', $mediaStore); $slugg = slug($_POST['name']); - $config = array( + $config = [ 'name' => $slugg, - 'upload_path' => 'public/upload/media/', + 'upload_path' => 'public/upload/media/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $images = upload('imggggg', $config); if ($images) { - $mediaStore = array( + $mediaStore = [ 'id' => $mediaId, - 'slug' => $images - ); + 'slug' => $images, + ]; save('media', $mediaStore); } header('location:admin.php?controller=media'); } function mediaUpdate() { - $media_edit = array( + $media_edit = [ 'id' => intval($_POST['media_id']), 'media_name' => escape($_POST['name']), - ); - $mediaId = save('media', $media_edit); + ]; + $mediaId = save('media', $media_edit); $slugg = slug($_POST['name']); - $config = array( + $config = [ 'name' => $slugg, - 'upload_path' => 'public/upload/media/', + 'upload_path' => 'public/upload/media/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $images = upload('imggggg', $config); if ($images) { - $media_edit = array( + $media_edit = [ 'id' => $mediaId, - 'slug' => $images - ); + 'slug' => $images, + ]; save('media', $media_edit); } header('location:admin.php?controller=media'); diff --git a/admin/models/order.php b/admin/models/order.php index 2fdcf1fa..0136e3c9 100644 --- a/admin/models/order.php +++ b/admin/models/order.php @@ -1,4 +1,5 @@ 0) { while ($row = mysqli_fetch_assoc($query)) { $data[] = $row; } mysqli_free_result($query); } + return $data; } function orderDestroy($id) { if (isset($_GET['order_id'])) { $id = intval($_GET['order_id']); - } else show_404(); + } else { + show_404(); + } global $linkConnectDB; $sql = "DELETE FROM orders WHERE id=$id"; mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); @@ -28,18 +32,18 @@ function orderDestroy($id) function orderComplete($id) { $id = intval($_POST['order_id']); - $order = array( + $order = [ 'id' => $id, - 'status' => 1 - ); + 'status' => 1, + ]; save('orders', $order); } function orderInProcess($id) { $id = intval($_POST['order_id']); - $order = array( + $order = [ 'id' => $id, - 'status' => 2 - ); + 'status' => 2, + ]; save('orders', $order); } diff --git a/admin/models/posts.php b/admin/models/posts.php index a0bbe806..e06f923c 100644 --- a/admin/models/posts.php +++ b/admin/models/posts.php @@ -1,9 +1,12 @@ = 5) $slug = slug($_POST['slug']); - else $slug = slug($name); - $post = array( + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } + $post = [ 'id' => intval($_POST['post_id']), 'post_title' => $name, 'post_slug' => $slug, @@ -55,23 +67,23 @@ function page_update() 'post_modified' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'post_modified_user' => escape($_POST['editby']), 'totalview' => intval($_POST['totalview']), - 'post_type' => 2 - ); + 'post_type' => 2, + ]; $postId = save('posts', $post); //upload ảnh 1 của post $image_name1 = slug($name) . '-' . $postId . 'page'; - $config1 = array( + $config1 = [ 'name' => $image_name1, - 'upload_path' => 'public/upload/ckeditorimages/', + 'upload_path' => 'public/upload/ckeditorimages/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('post_avatar', $config1); //$field = name of input - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image1) { - $post = array( + $post = [ 'id' => $postId, - 'post_avatar' => $image1 - ); + 'post_avatar' => $image1, + ]; save('posts', $post); } //chuyển hướng nếu có cập nhật @@ -80,9 +92,12 @@ function page_update() function page_add() { $name = escape($_POST['title']); - if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']); - else $slug = slug($name); - $post = array( + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } + $post = [ 'id' => intval($_POST['post_id']), 'post_title' => $name, 'post_slug' => $slug, @@ -90,23 +105,23 @@ function page_add() 'post_author' => intval($_POST['createby']), 'totalview' => intval($_POST['totalview']), 'post_type' => 2, - 'post_status' => 'Draft' - ); + 'post_status' => 'Draft', + ]; $postId = save('posts', $post); //upload ảnh 1 của post $image_name1 = slug($name) . '-' . $postId . 'page'; - $config1 = array( + $config1 = [ 'name' => $image_name1, - 'upload_path' => 'public/upload/ckeditorimages/', + 'upload_path' => 'public/upload/ckeditorimages/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('post_avatar', $config1); //$field = name of input - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image1) { - $post = array( + $post = [ 'id' => $postId, - 'post_avatar' => $image1 - ); + 'post_avatar' => $image1, + ]; save('posts', $post); } //chuyển hướng nếu có thêm mới @@ -115,9 +130,12 @@ function page_add() function post_update() { $name = escape($_POST['title']); - if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']); - else $slug = slug($name); - $post = array( + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } + $post = [ 'id' => intval($_POST['post_id']), 'post_title' => $name, 'post_slug' => $slug, @@ -125,23 +143,23 @@ function post_update() 'post_modified' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'post_modified_user' => escape($_POST['editby']), 'totalview' => intval($_POST['totalview']), - 'post_type' => 1 - ); + 'post_type' => 1, + ]; $postId = save('posts', $post); //upload ảnh 1 của post $image_name1 = slug($name) . '-' . $postId . 'post'; - $config1 = array( + $config1 = [ 'name' => $image_name1, - 'upload_path' => 'public/upload/ckeditorimages/', + 'upload_path' => 'public/upload/ckeditorimages/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('post_avatar', $config1); //$field = name of input - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image1) { - $post = array( + $post = [ 'id' => $postId, - 'post_avatar' => $image1 - ); + 'post_avatar' => $image1, + ]; save('posts', $post); } //chuyển hướng nếu có cập nhật @@ -150,9 +168,12 @@ function post_update() function addPost() { $name = escape($_POST['title']); - if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']); - else $slug = slug($name); - $post = array( + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } + $post = [ 'id' => intval($_POST['post_id']), 'post_title' => $name, 'post_slug' => $slug, @@ -160,23 +181,23 @@ function addPost() 'post_author' => intval($_POST['createby']), 'totalview' => intval($_POST['totalview']), 'post_type' => 1, - 'post_status' => 'Draft' - ); + 'post_status' => 'Draft', + ]; $postId = save('posts', $post); //upload ảnh 1 của post $image_name1 = slug($name) . '-' . $postId . 'post'; - $config1 = array( + $config1 = [ 'name' => $image_name1, - 'upload_path' => 'public/upload/ckeditorimages/', + 'upload_path' => 'public/upload/ckeditorimages/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('post_avatar', $config1); //$field = name of input - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image1) { - $post = array( + $post = [ 'id' => $postId, - 'post_avatar' => $image1 - ); + 'post_avatar' => $image1, + ]; save('posts', $post); } //chuyển hướng nếu có thêm mới diff --git a/admin/models/products.php b/admin/models/products.php index 50c92ae9..669a64c6 100644 --- a/admin/models/products.php +++ b/admin/models/products.php @@ -1,9 +1,12 @@ 0) $editDate = gmdate('Y-m-d H:i:s', time() + 7 * 3600); - else $editDate = '0000-00-00 00:00:00'; + if ($_POST['product_id'] <> 0) { + $editDate = gmdate('Y-m-d H:i:s', time() + 7 * 3600); + } else { + $editDate = '0000-00-00 00:00:00'; + } - if ($_POST['createdate'] == NULL || $_POST['createdate'] == 'dd/mm/yyyy') $createDate = date('Y-m-d H:i:s', time() + 7 * 3600); - else $createDate = $_POST['createdate']; + if ($_POST['createdate'] == null || $_POST['createdate'] == 'dd/mm/yyyy') { + $createDate = date('Y-m-d H:i:s', time() + 7 * 3600); + } else { + $createDate = $_POST['createdate']; + } $name = escape($_POST['name']); - if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']); - else $slug = slug($name); + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } - $product = array( + $product = [ 'id' => intval($_POST['product_id']), 'category_id' => intval($_POST['category_id']), 'sub_category_id' => intval($_POST['subcategory_id']), @@ -59,71 +74,71 @@ function product_update() 'product_detail' => ($_POST['detail']), 'createBy' => escape($_POST['createby']), 'editBy' => escape($editby), - 'editDate' => $editDate - ); + 'editDate' => $editDate, + ]; $productId = save('products', $product); //upload ảnh 1 của product $image_name1 = $slug . '-' . $productId . 'img1'; - $config1 = array( + $config1 = [ 'name' => $image_name1, - 'upload_path' => 'public/upload/products/', + 'upload_path' => 'public/upload/products/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('img1', $config1); - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image1) { - $product = array( + $product = [ 'id' => $productId, - 'img1' => $image1 - ); + 'img1' => $image1, + ]; save('products', $product); } //upload ảnh 2 của product $image_name2 = $slug . '-' . $productId . 'img2'; - $config2 = array( + $config2 = [ 'name' => $image_name2, - 'upload_path' => 'public/upload/products/', + 'upload_path' => 'public/upload/products/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image2 = upload('img2', $config2); //cập nhật ảnh mới lên database if ($image2) { - $product = array( + $product = [ 'id' => $productId, - 'img2' => $image2 - ); + 'img2' => $image2, + ]; save('products', $product); } //upload ảnh 3 của product $image_name3 = $slug . '-' . $productId . 'img3'; - $config3 = array( + $config3 = [ 'name' => $image_name3, - 'upload_path' => 'public/upload/products/', + 'upload_path' => 'public/upload/products/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image3 = upload('img3', $config3); - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image3) { - $product = array( + $product = [ 'id' => $productId, - 'img3' => $image3 - ); + 'img3' => $image3, + ]; save('products', $product); } //upload ảnh 4 của product $image_name4 = $slug . '-' . $productId . 'img4'; - $config4 = array( + $config4 = [ 'name' => $image_name4, - 'upload_path' => 'public/upload/products/', + 'upload_path' => 'public/upload/products/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image4 = upload('img4', $config4); - //cập nhật ảnh mới lên database + //cập nhật ảnh mới lên database if ($image4) { - $product = array( + $product = [ 'id' => $productId, - 'img4' => $image4 - ); + 'img4' => $image4, + ]; save('products', $product); } //chuyển hướng nếu có cập nhật diff --git a/admin/models/purchase.php b/admin/models/purchase.php index 6300c26d..8ac0df63 100644 --- a/admin/models/purchase.php +++ b/admin/models/purchase.php @@ -1,9 +1,12 @@ 0) { while ($row = mysqli_fetch_assoc($query)) { $data[] = $row; } mysqli_free_result($query); } + return $data; } diff --git a/admin/models/roles.php b/admin/models/roles.php index df1ee0a0..5fa765ea 100644 --- a/admin/models/roles.php +++ b/admin/models/roles.php @@ -1,4 +1,5 @@ intval($_POST['role_id']), 'role_name' => escape($_POST['name']), - 'role_desc' => ($_POST['description']) - ); + 'role_desc' => ($_POST['description']), + ]; save('roles', $role); header('location:admin.php?controller=role'); } diff --git a/admin/models/shop.php b/admin/models/shop.php index 2dba127e..0ee465f5 100644 --- a/admin/models/shop.php +++ b/admin/models/shop.php @@ -1,12 +1,13 @@ 'id', - 'where' => 'category_id=' . $id - ); + 'where' => 'category_id=' . $id, + ]; $products = getAll('products', $options); foreach ($products as $product) { postDestroy($product['id']); @@ -18,15 +19,18 @@ function categoryDestroy($id) function categoryUpdate() { $name = escape($_POST['name']); - if (strlen($_POST['slug']) >= 5) $slug = slug($_POST['slug']); - else $slug = slug($name); + if (strlen($_POST['slug']) >= 5) { + $slug = slug($_POST['slug']); + } else { + $slug = slug($name); + } - $category = array( + $category = [ 'id' => intval($_POST['cate_id']), 'category_name' => escape($_POST['name']), - 'slug' => $slug, - 'category_position' => intval($_POST['position']) - ); + 'slug' => $slug, + 'category_position' => intval($_POST['position']), + ]; save('categories', $category); header('location:admin.php?controller=shop'); } diff --git a/admin/models/slides.php b/admin/models/slides.php index cf37f750..334f8073 100644 --- a/admin/models/slides.php +++ b/admin/models/slides.php @@ -1,4 +1,5 @@ intval($_POST['slide_id']), 'slide_name' => escape($_POST['name']), 'slide_text1' => escape($_POST['slide_text1']), @@ -38,77 +39,77 @@ function slide_update() 'slide_text3' => escape($_POST['slide_text3']), 'slide_text4' => escape($_POST['slide_text4']), 'slide_text5' => escape($_POST['slide_text5']), - 'status' => intval($_POST['status']) - ); + 'status' => intval($_POST['status']), + ]; $slideId = save('slides', $slides); $image_name1 = 'image1' . '-' . $slideId . '-' . slug($name); - $config = array( + $config = [ 'name' => $image_name1, 'upload_path' => 'public/upload/slides/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image1 = upload('image1', $config); //$field = name of input if ($image1) { - $slides = array( + $slides = [ 'id' => $slideId, - 'slide_img1' => $image1 - ); + 'slide_img1' => $image1, + ]; save('slides', $slides); } $image_name2 = 'image2' . '-' . $slideId . '-' . slug($name); - $config = array( + $config = [ 'name' => $image_name2, 'upload_path' => 'public/upload/slides/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image2 = upload('image2', $config); if ($image2) { - $slides = array( + $slides = [ 'id' => $slideId, - 'slide_img2' => $image2 - ); + 'slide_img2' => $image2, + ]; save('slides', $slides); } $image_name3 = 'image3' . '-' . $slideId . '-' . slug($name); - $config = array( + $config = [ 'name' => $image_name3, 'upload_path' => 'public/upload/slides/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image3 = upload('image3', $config); if ($image3) { - $slides = array( + $slides = [ 'id' => $slideId, - 'slide_img3' => $image3 - ); + 'slide_img3' => $image3, + ]; save('slides', $slides); } $image_name4 = 'image4' . '-' . $slideId . '-' . slug($name); - $config = array( + $config = [ 'name' => $image_name4, 'upload_path' => 'public/upload/slides/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image4 = upload('image4', $config); if ($image4) { - $slides = array( + $slides = [ 'id' => $slideId, - 'slide_img4' => $image4 - ); + 'slide_img4' => $image4, + ]; save('slides', $slides); } $image_name5 = 'image5' . '-' . $slideId . '-' . slug($name); - $config = array( + $config = [ 'name' => $image_name5, 'upload_path' => 'public/upload/slides/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $image5 = upload('image5', $config); if ($image5) { - $slides = array( + $slides = [ 'id' => $slideId, - 'slide_img5' => $image5 - ); + 'slide_img5' => $image5, + ]; save('slides', $slides); } header('location:admin.php?controller=slide'); diff --git a/admin/models/users.php b/admin/models/users.php index d79f4ab1..9e7c2f45 100644 --- a/admin/models/users.php +++ b/admin/models/users.php @@ -1,8 +1,9 @@ 1) { return "
NO! Việc thay đổi mật khẩu có vấn đề. Bạn đã nhập mật khẩu hiện tại không đúng !!
Trở lại hoặc Đến Dashboard
" . mysqli_error($linkConnectDB); } else { - $options = array( + $options = [ 'id' => $id, 'user_password' => $newpassword, - 'editTime' => gmdate('Y-m-d H:i:s', time() + 7 * 3600) + 'editTime' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), - ); + ]; save('users', $options); //sendmail require 'vendor/autoload.php'; @@ -71,6 +74,7 @@ function changePassword($id, $newpassword, $currentPassword) $mail = new PHPMailer(true); $user = getRecord('users', $id); $email = $user['user_email']; + try { //content $htmlStr = ""; @@ -106,6 +110,7 @@ function changePassword($id, $newpassword, $currentPassword) } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } + return '
Tốt! Bạn đã thay đổi mật khẩu thành công. Và một tin nhắn thông báo đã được gửi đến Email của người dùng này. Hãy Đăng xuất và đăng nhập lại.!!
'; } } @@ -113,13 +118,19 @@ function user_update() { global $userNav; $user_login = getRecord('users', $userNav); - if ($_POST['user_id'] <> 0) $editTime = gmdate('Y-m-d H:i:s', time() + 7 * 3600); - else $editTime = '0000-00-00 00:00:00'; + if ($_POST['user_id'] <> 0) { + $editTime = gmdate('Y-m-d H:i:s', time() + 7 * 3600); + } else { + $editTime = '0000-00-00 00:00:00'; + } - if (isset($_POST['roleid']) && $user_login['role_id'] == 1) $roleid = $_POST['roleid']; - else $roleid = $user_login['role_id']; + if (isset($_POST['roleid']) && $user_login['role_id'] == 1) { + $roleid = $_POST['roleid']; + } else { + $roleid = $user_login['role_id']; + } - $user_edit = array( + $user_edit = [ 'id' => intval($_POST['user_id']), 'user_email' => escape($_POST['email']), 'user_username' => escape($_POST['username']), @@ -127,8 +138,8 @@ function user_update() 'user_address' => escape($_POST['address']), 'user_phone' => escape($_POST['phone']), 'editTime' => $editTime, - 'role_id' => $roleid - ); + 'role_id' => $roleid, + ]; global $linkConnectDB; $email_check = addslashes($_POST['email']); $id_check = intval($_POST['user_id']); @@ -139,20 +150,20 @@ function user_update() } else { $get_currentEmail_user = getRecord('users', $_POST['user_id']); $currentEmail = $get_currentEmail_user['user_email']; - $userId = save('users', $user_edit); + $userId = save('users', $user_edit); $avatar_name = 'avatar-user' . $userId . '-' . slug($_POST['username']); - $config = array( + $config = [ 'name' => $avatar_name, - 'upload_path' => 'public/upload/images/', + 'upload_path' => 'public/upload/images/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $avatar = upload('imagee', $config); //cập nhật ảnh mới if ($avatar) { - $user_edit = array( + $user_edit = [ 'id' => $userId, - 'user_avatar' => $avatar - ); + 'user_avatar' => $avatar, + ]; save('users', $user_edit); } $user_edited = getRecord('users', $userId); @@ -162,6 +173,7 @@ function user_update() include 'lib/config/sendmail.php'; $email = $user_edited['user_email']; $mail = new PHPMailer(true); + try { $verificationCode = md5(uniqid("Email của bạn vừa mới đổi đó và chưa active đâu. Nhấn vào đây để active nhé! Yêu bạn 3 nghìn", true)); //https://www.php.net/manual/en/function.uniqid $verificationLink = PATH_URL . "index.php?controller=register&action=reactivate&code=" . $verificationCode; @@ -200,11 +212,11 @@ function user_update() } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } - $verificationCode_add = array( + $verificationCode_add = [ 'id' => $userId, 'verificationCode' => $verificationCode, - 'verified' => 0 - ); + 'verified' => 0, + ]; save('users', $verificationCode_add); } header('location:admin.php?controller=user&action=info&user_id=' . intval($_POST['user_id'])); @@ -212,7 +224,7 @@ function user_update() } function user_add() { - $user_add = array( + $user_add = [ 'id' => intval($_POST['user_id']), 'user_username' => escape($_POST['username']), 'user_password' => md5($_POST['password']), @@ -221,8 +233,8 @@ function user_add() 'user_name' => escape($_POST['name']), 'user_address' => escape($_POST['address']), 'createDate' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), - 'user_phone' => escape($_POST['phone']) - ); + 'user_phone' => escape($_POST['phone']), + ]; global $linkConnectDB; $username = addslashes($_POST['username']); $email = addslashes($_POST['email']); @@ -243,25 +255,26 @@ function user_add() require('admin/views/user/addresult.php'); exit; } else { - $userId = save('users', $user_add); + $userId = save('users', $user_add); $avatar_name = 'avatar-user' . $userId . '-' . slug($_POST['username']); - $config = array( + $config = [ 'name' => $avatar_name, - 'upload_path' => 'public/upload/images/', + 'upload_path' => 'public/upload/images/', 'allowed_exts' => 'jpg|jpeg|png|gif', - ); + ]; $avatar = upload('imagee', $config); if ($avatar) { - $user_add = array( + $user_add = [ 'id' => $userId, - 'user_avatar' => $avatar - ); + 'user_avatar' => $avatar, + ]; save('users', $user_add); } //send mail require 'vendor/autoload.php'; include 'lib/config/sendmail.php'; $mail = new PHPMailer(true); + try { $verificationCode = md5(uniqid("Email của bạn vừa mới đổi đó và chưa active đâu. Nhấn vào đây để active nhé! Yêu bạn 3 nghìn", true)); //https://www.php.net/manual/en/function.uniqid $verificationLink = PATH_URL . "index.php?controller=register&action=activate&code=" . $verificationCode; @@ -300,11 +313,11 @@ function user_add() } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } - $verificationCode_add = array( + $verificationCode_add = [ 'id' => $userId, 'verificationCode' => $verificationCode, - 'verified' => 0 - ); + 'verified' => 0, + ]; save('users', $verificationCode_add); header('location:admin.php?controller=user&action=info&user_id=' . $userId); } diff --git a/admin/views/backupdb/index.php b/admin/views/backupdb/index.php index 483991e4..3b8cacdf 100644 --- a/admin/views/backupdb/index.php +++ b/admin/views/backupdb/index.php @@ -10,7 +10,7 @@
-

+