From d328ffa7b05311191515a19f440026f1f8608b2e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 19 Jun 2021 23:26:37 +0300 Subject: [PATCH] add order route --- app/api/apiclient.php | 31 ++++++++++++++++++ app/api/book.php | 2 +- app/confg.php | 3 ++ app/index.php | 1 + app/routes/books.php | 6 +++- app/routes/client.php | 2 -- app/routes/order.php | 69 ++++++++++++++++++++++++++++++++++++++++ app/views/book.phtml | 12 +++++-- app/views/checkout.phtml | 24 ++++++++++++++ 9 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 app/routes/order.php create mode 100644 app/views/checkout.phtml diff --git a/app/api/apiclient.php b/app/api/apiclient.php index 6b8559d..e7b719b 100644 --- a/app/api/apiclient.php +++ b/app/api/apiclient.php @@ -221,6 +221,37 @@ function client_find_email_kuri($mail){ } + +# узнаем id клиента по мылу или создаем его +function api_add_client($mail){ + + $find_mail = dbl_get("SELECT `client_id`, `clienthash` FROM `clients` WHERE `clientmail` = '$mail' LIMIT 1"); + + if (isset($find_mail['client_id'])){ + $result = $find_mail['clienthash']; + } + else { + $add['clientmail'] = $mail; + $add['clienthash'] = md5($mail); + $add['clientdate'] = date("Y-m-d H:i:s"); + + $res = db_insert('clients', $add, 'chitatel'); + + if ($res > 0){ + $result = $add['clienthash']; + } + else{ + $result = false; + } + + } + + return $result; + + +} + + function client_find_hash($hash){ diff --git a/app/api/book.php b/app/api/book.php index 12fa4c9..ac3c0aa 100644 --- a/app/api/book.php +++ b/app/api/book.php @@ -7,7 +7,7 @@ function bookid_kuri($slug) { $query = " SELECT - `price_id`, `pricename`, `categoryname`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `price`, `sub` + `price_id`, `pricename`, `categoryname`, `priceslug`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `price`, `offline_price`, `sub` FROM `price` LEFT JOIN `pricecategory` diff --git a/app/confg.php b/app/confg.php index 5170ec4..99a989d 100644 --- a/app/confg.php +++ b/app/confg.php @@ -31,6 +31,8 @@ define('VIEWPATH', SITEPATH.'views/'); define('API', 'http://api.argumenti.ru/'); define('IMGSRV', 'https://imgurl.argumenti.ru/'); +define('PAYSITE', 'https://pay.argumenti.ru/'); //сервис оплаты + /** отправка уведомлений */ /*set('noreply', [ @@ -57,3 +59,4 @@ db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOh db_config('chitatel', 'mysql:host=mysql;dbname=argumentiru', 'chitatel', 'hjYu78kl*90Uio'); db_config('klan', 'mysql:host=mysql;dbname=argumentiru', 'klan', 'zpFGhyuRty765Jk'); +// GRANT ALL PRIVILEGES ON argumentiru.* TO 'hitatel'@'%' IDENTIFIED BY 'hjYu78kl*90Uio' diff --git a/app/index.php b/app/index.php index f248e2b..ee77f67 100644 --- a/app/index.php +++ b/app/index.php @@ -11,6 +11,7 @@ require 'routes/auth.php'; require 'routes/pdfserver.php'; require 'routes/email.php'; require 'routes/books.php'; +require 'routes/order.php'; #api require 'api/apiclient.php'; diff --git a/app/routes/books.php b/app/routes/books.php index 27859a1..61f3360 100644 --- a/app/routes/books.php +++ b/app/routes/books.php @@ -4,7 +4,6 @@ function product_kuri($slug){ $book = bookid_kuri($slug); - $breadcrumbs = [ $book['categoryname'] => SITE.'category/'.$book['categoryslug'], 'page' => $book['pricename'] @@ -25,6 +24,11 @@ function product_kuri($slug){ # купил ли эту книжку $buy_status = client_status_book($books['book_id'], CLIENT_ID); } + + # линки на оформление заказа + $link_online = SITE.'checkout/'.$book['priceslug'].'/1'; + $link_offline = SITE.'checkout/'.$book['priceslug'].'/2'; + $link_subscript = SITE.'checkout/podpiska-na-elektronnuyu-versiyu-gazety-argumenty-nedeli-na-god/1'; $tempcontent = VIEWPATH.'book.phtml'; include VIEWPATH.'layout.phtml'; diff --git a/app/routes/client.php b/app/routes/client.php index 6d7e8c8..3affc38 100644 --- a/app/routes/client.php +++ b/app/routes/client.php @@ -92,8 +92,6 @@ function restoration_kuri(){ $hashlink = SITE.'resetlink/'.$hash; } - echo $hashlink; - $tempcontent = VIEWPATH.'restore_add.phtml'; include VIEWPATH.'layout.phtml'; } diff --git a/app/routes/order.php b/app/routes/order.php new file mode 100644 index 0000000..e374363 --- /dev/null +++ b/app/routes/order.php @@ -0,0 +1,69 @@ +Скачать PDF

- -

Купить за руб.

+ + 0):?> +

Электронная за руб.

+ + +

Доступ к библиотеке за 490 руб. в год

+ + 0):?> +

Бумажная за руб.

+ diff --git a/app/views/checkout.phtml b/app/views/checkout.phtml new file mode 100644 index 0000000..d056d98 --- /dev/null +++ b/app/views/checkout.phtml @@ -0,0 +1,24 @@ + + + +

Просим прощения, но такой товар не найден!

+ + +
+ + +

Неверный адрес электронной почты

+ + +

+

+

+

+ +
+ + + + + + \ No newline at end of file