diff --git a/.gitignore b/.gitignore index e69de29..6e4e282 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,4 @@ + + +/README.md +/READ_ME.txt diff --git a/.htaccess b/.htaccess index c5eef73..a1d7444 100644 --- a/.htaccess +++ b/.htaccess @@ -56,6 +56,7 @@ Header set X-XSS-Protection "1; mode=block" ## do not cache if these files are already cached SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip + ## manage very olds browsers BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip @@ -126,6 +127,7 @@ Header append Vary User-Agent env=!dont-vary ## END Cache-Control Headers + ################# ### END CACHE ### ################# diff --git a/API/api.json b/API/api.json index 7c7c834..5f132e1 100644 --- a/API/api.json +++ b/API/api.json @@ -14,7 +14,7 @@ "LANG_BACK": "en", "LANG_FRONT": "en", "LANG_LOCALE": "en_US", - "LAST_UPDATE": "Monday, December 5, 2022 at 5:20 AM", + "LAST_UPDATE": "Sunday, December 11, 2022 at 10:45 PM", "LOGO": "logo-shop-alhnzivtfyqrcswogebdxmukpj-0-1670200102.png", "LOGO_SN": "logo-sn-wnrbfzqchoiykdtaegpumxjvls-0-1670213667.png", "LOGO_SN_SIZE": 900, @@ -31,6 +31,6 @@ }, "TIMEZONE": "America\/Los_Angeles", "TOKEN_TIME": 7200, - "VERSION": "2.1.5", + "VERSION": "2.1.6", "WEBSITE_TITLE": "Placido-Shop" } diff --git a/CSS/api.css b/CSS/api.css index 3e7e7b1..04eae16 100644 --- a/CSS/api.css +++ b/CSS/api.css @@ -177,7 +177,7 @@ ul#select_nb_options { align-content: center; } .head_text { - padding: 0% 20px 0 26px; + padding: 0 26px 0; line-height: 26px; } .info_slider_prod { @@ -331,45 +331,43 @@ img.first_img { } /* INLINE PRODUCTS */ .prods_inl .box_gen { - background: var(--bkg-products); - width: 100%; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: space-between; - align-items: flex-start; - margin: 0 0 16px; - padding: 10px; + background: var(--bkg-products); + width: 100%; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-between; + align-items: flex-start; + margin: 0 0 16px; + padding: 10px; } .prods_inl .box_product { - width: 200px; - margin: 0; + width: 200px; + margin: 0; } .prods_inl .show_info_product { - - margin: 0; + margin: 0; } #products_view.prods_inl img { - margin: 0 0 0 0 !important; - min-width: 200px; + margin: 0 0 0 0 !important; + min-width: 200px; } .prods_inl .cont_title_descr { - width: 40%; + width: 40%; } .prods_inl .prod_title { - display: block; - font-size: var(--text-large); - margin: 10px auto 0 16px; - color: var(--color-text); - font-weight: 400; - min-width: 375px; + display: block; + font-size: var(--text-large); + margin: 10px auto 0 16px; + color: var(--color-text); + font-weight: 400; + min-width: 375px; } .prods_inl .cont_prod_infos { - width: 23%; + width: 23%; } /* END INLINE PRODUCTS */ /* END PRODUCTS CSS */ - /* single product thumbnails */ img.other_imgs { width: 100px; @@ -448,10 +446,10 @@ img.other_imgs { .slider_short_text { display: none; } - /* not show -> button display products */ - #products_display { - display: none; - } + /* not show -> button display products */ + #products_display { + display: none; + } } /* END media querys 900px */ /* media querys 768px */ diff --git a/CSS/shop.css b/CSS/shop.css index e1657f6..a31e54a 100644 --- a/CSS/shop.css +++ b/CSS/shop.css @@ -1,14 +1,13 @@ /* ________ GLOBAL SHOP CSS ________ */ /* i. - This file will never updated */ - body { background: url(../img/background.jpg), no-repeat; background-size: auto; background-attachment: fixed; - /* minium font size */ + /* minium font size */ font-size: 16px; - /* "Open Sans" is downloaded otherwise use system font */ - font-family: "Open Sans", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + /* "Open Sans" is downloaded otherwise use system font */ + font-family: "Open Sans", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; } /* i. :ROOT vars -> use it like : .my_text { @@ -303,40 +302,40 @@ span.erase_search { } /* STATIC PAGES */ #page { - background: var(--bkg-content); - padding: 2% 4% 4%; - color: var(--color-text); + background: var(--bkg-content); + padding: 2% 4% 4%; + color: var(--color-text); } #page h2 { - font-size: var(--text-xxlarge); - margin: 10px 0 50px; - color: var(--color-text); - font-weight: 500 !important; + font-size: var(--text-xxlarge); + margin: 10px 0 50px; + color: var(--color-text); + font-weight: 500 !important; } #page h3 { - font-size: var(--text-xlarge); - margin: 36px 0 0; - color: var(--color-text); - font-weight: 500; + font-size: var(--text-xlarge); + margin: 36px 0 0; + color: var(--color-text); + font-weight: 500; } #page p { - margin: 26px 0 0; - font-size: var(--text-large); - color: var(--color-text); + margin: 26px 0 0; + font-size: var(--text-large); + color: var(--color-text); } #page strong { - font-size: var(--text-large); - font-weight: 500; + font-size: var(--text-large); + font-weight: 500; } #page ul { - padding: 0; - margin: 16px 0 42px; + padding: 0; + margin: 16px 0 42px; } #page li { - list-style-type: none; - font-size: var(--text); - border-bottom: none; - margin: 1% 2% 0; + list-style-type: none; + font-size: var(--text); + border-bottom: none; + margin: 1% 2% 0; } /*
*/ /* header bar - all but not slider OR jumbo text */ @@ -377,7 +376,7 @@ h1#title_shop { margin: 0 auto 0 4%; font-size: 40px; font-weight: 400; - line-height: 48px; + line-height: 48px; } /* A - 2 - CART BTN + MENU BTN */ #cart_container {} @@ -568,10 +567,10 @@ footer hr { line-height: 32px; } #page h2 { - font-size: var(--text-xxlarge); - margin: 10px 0 0; - text-align: left !important; - } + font-size: var(--text-xxlarge); + margin: 10px 0 0; + text-align: left !important; + } #toast-container>.toast { width: 97% !important; } @@ -617,10 +616,9 @@ footer hr { /* end media querys 768px */ /* media querys 580px */ @media all and (max-width: 580px) { - - h1#title_shop { - font-size: 30px; - } + h1#title_shop { + font-size: 30px; + } } /* media querys 580px */ /* ________ GLOBAL SHOP CSS ________ */ diff --git a/INSTALL/placido-tables.sql b/INSTALL/placido-tables.sql index d0f1092..f7cf18b 100644 --- a/INSTALL/placido-tables.sql +++ b/INSTALL/placido-tables.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Hôte : localhost:3306 --- Généré le : lun. 05 déc. 2022 à 02:17 +-- Généré le : Dim 11 déc. 2022 à 22:42 -- Version du serveur : 10.5.18-MariaDB -- Version de PHP : 7.4.30 @@ -40,7 +40,7 @@ CREATE TABLE `admins` ( -- INSERT INTO `admins` (`id`, `mail`, `passw`, `name`) VALUES -(0, 'user@placido-shop.com', '$2y$10$zLZOUnbeh7t/gB4FQApwYuejeAy5F3mF3cc7zJJxsosoTe4I/iReW', 'Admin'); +(0, 'user@placido-shop.com', '$2y$10$Z3/XcJVvyVTy.e6xSmLNKOYFIssjN6zjtCEo0id/YKiS6zFOXcj26', 'Admin'); -- -------------------------------------------------------- @@ -550,7 +550,7 @@ ALTER TABLE `user_shop` -- AUTO_INCREMENT pour la table `categories` -- ALTER TABLE `categories` - MODIFY `cat_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59; + MODIFY `cat_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `customers` @@ -562,7 +562,7 @@ ALTER TABLE `customers` -- AUTO_INCREMENT pour la table `messages` -- ALTER TABLE `messages` - MODIFY `mess_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `mess_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `new_sales` @@ -574,13 +574,13 @@ ALTER TABLE `new_sales` -- AUTO_INCREMENT pour la table `products` -- ALTER TABLE `products` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=57; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `products_imgs` -- ALTER TABLE `products_imgs` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=142; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT pour la table `sold_products` @@ -592,7 +592,7 @@ ALTER TABLE `sold_products` -- AUTO_INCREMENT pour la table `static_pages` -- ALTER TABLE `static_pages` - MODIFY `page_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=46; + MODIFY `page_id` int(11) NOT NULL AUTO_INCREMENT; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/JS/api_loader.js b/JS/api_loader.js index cef20ba..7c14c19 100644 --- a/JS/api_loader.js +++ b/JS/api_loader.js @@ -93,7 +93,7 @@ $(function(){ // end splash screen // enable sticky_header - $.sticky_header_init = true; + $.sticky_header_init = false; // check cart in memory $.check_cart_in_memory(); diff --git a/JS/main.js b/JS/main.js index 6421814..e159656 100644 --- a/JS/main.js +++ b/JS/main.js @@ -1769,10 +1769,12 @@ $.extend({ sticky_header_init : false, sticky_header : function(){ + + // no sticky header if( $.sticky_header_init == false ){ return; } - // NO STICKY HEADER IN CONTEXT + // if orientation == 'landscape' on mobile + NOT IN CART -> this bad UX if( $(window).width() < 800 || ( $(window).width() < 800 && window.screen.orientation.type == 'landscape-primary' ) diff --git a/JS/tools.js b/JS/tools.js index a513b33..3fa298d 100644 --- a/JS/tools.js +++ b/JS/tools.js @@ -321,16 +321,11 @@ $.extend({ event.preventDefault(); - // include header bar pdding - var pad_top = ( $('#featured_products').is(':visible') == true ) - ? $('#header_bar').outerHeight(true) - : 0; - var speed = 700; // Durée de l'animation (en ms) // animate the scroll $('html, body') - .animate( { scrollTop: Math.round($(elem).offset().top-pad_top) }, speed ); + .animate( { scrollTop: Math.round($(elem).offset().top) }, speed ); }, /** diff --git a/PHP/control.php b/PHP/control.php index a514cd3..a4ff3e5 100644 --- a/PHP/control.php +++ b/PHP/control.php @@ -37,12 +37,12 @@ public static function router(){ // for test // control::test_router(); - // REQ METHOD + // REQUEST METHOD $method = $_SERVER['REQUEST_METHOD']; // test length (in octets) of request -> too long -> exit // accept only POST OR GET requests -> other -> exit - if( strlen($_SERVER['REQUEST_URI']) > 3000 + if( strlen($_SERVER['REQUEST_URI']) > 1000 || $method != 'GET' && $method != 'POST' ){ // -> redirect to 404 @@ -57,107 +57,111 @@ public static function router(){ return $method; } - // trim / escape url request - $request = trim(htmlspecialchars($_SERVER['REQUEST_URI'])); + // check that the request is indeed the GET method + if( $method != 'GET' ){ + // -> redirect to 404 + header('Location: https://'.HOST.'/404.php'); + exit; - // capture GET url requests - if( $method == 'GET' ){ + } - // default - if( $request == '/' ){ - // ask program to give the home page - program::get_home_page(); // this exit in program:: - } - // default - FB REQUEST - if( !empty($_GET['fbclid']) ){ + // trim / escape url request + $request = trim(htmlspecialchars($_SERVER['REQUEST_URI'])); - program::get_home_page(); - } + // default + if( $request == '/' ){ + // ask program to give the home page + program::get_home_page(); // this exit in program:: + } - // EXPLODE URL by '/' - // this return an array - $TAB_url = explode('/', $_SERVER['REQUEST_URI'] ); + // default - FB REQUEST + if( !empty($_GET['fbclid']) ){ - // limit 10 items in array - $c = count($TAB_url); + $request = explode("?",$request)[0]; + } - if( $c > 10 ){ - // -> redirect to 404 - header('Location: https://'.HOST.'/404.php'); - exit; - } + // EXPLODE URL by '/' + // this return an array + $TAB_url = explode('/', $request ); + // limit 10 items in array + $c = count($TAB_url); - // if( product ?) ^(.*)/product/([0-9]+)$ - if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'product' ){ + if( $c > 10 ){ - api::$REQ = array( 'prod_id' => $TAB_url[$c-1], - 'url_request' => 'single_product' ); + // -> redirect to 404 + header('Location: https://'.HOST.'/404.php'); + exit; + } - program::get_home_page(); - } - // end prod + // if( product ?) ^(.*)/product/([0-9]+)$ + if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'product' ){ - // if( category ?) ^(.*)/category/([0-9]+)$ - if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'category' ){ + api::$REQ = array( 'prod_id' => $TAB_url[$c-1], + 'url_request' => 'single_product' ); - api::$REQ = array( 'cat_id' => $TAB_url[$c-1], - 'url_request' => 'cat' ); + program::get_home_page(); + } + // end prod - program::get_home_page(); - } - // end category + // if( category ?) ^(.*)/category/([0-9]+)$ + if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'category' ){ - // if( cart ?) ^cart/(.*)$ - if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'cart' ){ - // page_api=cart - api::$REQ = array( 'page_api' => 'cart' ); + api::$REQ = array( 'cat_id' => $TAB_url[$c-1], + 'url_request' => 'cat' ); - program::get_home_page(); - } - // end cart + program::get_home_page(); + } + // end category - // if( sale ?) ^sale/(.*)/(.*)$ $1: sale_id , $2: hash_customer - if( isset($TAB_url[$c-3]) && $TAB_url[$c-3] == 'sale' ){ - // page_api=sale - api::$REQ = array( 'page_api' => 'sale' , - 'sale_id' => $TAB_url[$c-2], - 'hash_customer' => $TAB_url[$c-1], - ); + // if( cart ?) ^cart/(.*)$ + if( isset($TAB_url[$c-2]) && $TAB_url[$c-2] == 'cart' ){ + // page_api=cart + api::$REQ = array( 'page_api' => 'cart' ); - program::get_home_page(); - } - // end sale + program::get_home_page(); + } + // end cart - // if( static_page ?) ^(.*).html$ - if( isset($TAB_url[$c-1]) - && boolval(preg_match( '/(\.html)/i', $TAB_url[$c-1] )) === true ){ + // if( sale ?) ^sale/(.*)/(.*)$ $1: sale_id , $2: hash_customer + if( isset($TAB_url[$c-3]) && $TAB_url[$c-3] == 'sale' ){ + // page_api=sale + api::$REQ = array( 'page_api' => 'sale' , + 'sale_id' => $TAB_url[$c-2], + 'hash_customer' => $TAB_url[$c-1] + ); - // page=url without '.html' - $page = substr($TAB_url[$c-1], 0, strpos($TAB_url[$c-1],'.html') ); + program::get_home_page(); + } + // end sale - api::$REQ = array( 'page' => $page ); - program::get_home_page(); - } - // end static page + // if( static_page ?) ^(.*).html$ + if( isset($TAB_url[$c-1]) + && boolval(preg_match( '/(\.html)/i', $TAB_url[$c-1] )) === true ){ + // page=url without '.html' + $page = substr($TAB_url[$c-1], 0, strpos($TAB_url[$c-1],'.html') ); - // default : - // -> redirect to 404 - header('Location: https://'.HOST.'/404.php'); - exit; + api::$REQ = array( 'page' => $page ); + program::get_home_page(); } - // END capture GET url requests + // end static page + + + // default : + // -> redirect to 404 + header('Location: https://'.HOST.'/404.php'); + exit; } /** diff --git a/PHP/pay_process.php b/PHP/pay_process.php index 5aaa202..49f9b37 100644 --- a/PHP/pay_process.php +++ b/PHP/pay_process.php @@ -1430,8 +1430,8 @@ public static function check_mode_payment_shop( $pay_with ){ } // test TEST PRODUCTION CARD - if( !empty($PUBLIC_KEYS['prod_pub_key']) - && !empty($PUBLIC_KEYS['prod_pub_key']) + if( !empty($SHOP['prod_pub_key']) + && !empty($SHOP['prod_priv_key']) && boolval($SHOP['mode']) == true ){ $SHOP['mode_payment'] = 'card_production'; diff --git a/PHP/program.php b/PHP/program.php index 847f605..d30a086 100644 --- a/PHP/program.php +++ b/PHP/program.php @@ -28,17 +28,19 @@ class program { */ public static function get_home_page(){ - - // STORE DATAS API IN SESSION FOR AJAX REQUEST - session_start([ - 'name' => 'PLACIDO-SHOP', - 'use_strict_mode' => true, - 'cookie_samesite' => 'Strict', - 'cookie_lifetime' => 30, // 30 sec. - 'gc_maxlifetime' => 30, - 'cookie_secure' => true, - 'cookie_httponly' => true - ]); + if (session_status() === PHP_SESSION_NONE){ + + // STORE DATAS API IN SESSION FOR AJAX REQUEST + session_start([ + 'name' => 'PLACIDO-SHOP', + 'use_strict_mode' => true, + 'cookie_samesite' => 'Strict', + 'cookie_lifetime' => 30, // 30 sec. + 'gc_maxlifetime' => 30, + 'cookie_secure' => true, + 'cookie_httponly' => true + ]); + } // AJAX REQUEST WHEN SESSION EXIST - SAVE ENERGY @@ -50,6 +52,7 @@ public static function get_home_page(){ && isset($_SESSION['datas']) ){ // RENDER JS OBJECT + header('Content-type: application/json'); echo json_encode($_SESSION['datas'], JSON_NUMERIC_CHECK); // DELETING SESSION - do not deleting the session globally