From 7f4b9ec4ef8f363fc8290896b8ac9b17d6b7c504 Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Fri, 8 May 2020 21:53:23 +0300 Subject: [PATCH] add apiclient --- app/api/apiclient.php | 125 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 app/api/apiclient.php diff --git a/app/api/apiclient.php b/app/api/apiclient.php new file mode 100644 index 0000000..c08964c --- /dev/null +++ b/app/api/apiclient.php @@ -0,0 +1,125 @@ + 1){ + $offset = $limit * ($page -1); + $pricesql .= " OFFSET $offset"; + } + + $books = db_get($buysql); + + $result['books'] = clientbooks($books, $client_id); + $result['count'] = $buycount['count']; + + return $result; + +} + + + +function clientmail($mail, $hash){ + + $client = db_get("SELECT * FROM `clients` WHERE `clientmail` = $mail LIMIT 1"); + + if (!isset($client['client_id'])){ + echo 'Не верный запрос'; + return; + } + + + if ($client['clienthash'] !== $hash){ + echo 'Не верный запрос'; + return; + } + + + +} + + + +//весь активный архив +function clients_arch($page = 1){ + + $limit = 25; + + $countsql = "SELECT COUNT(price_id) AS count + FROM price + WHERE category_id = 1 + LIMIT 1"; + + $count = db_get($countsql); + + + $pricesql = "SELECT price_id, pricehash, pricename, priceimg FROM price WHERE category_id = 1 ORDER BY price_id DESC LIMIT $limit"; + + + if ($page > 1){ + $offset = $limit * ($page -1); + $pricesql .= " OFFSET $offset"; + } + + $books = db_get($pricesql); + + $result['books'] = clientbooks($books, $clienthash); + $result['subscript'] = true; + $result['count'] = $count['count']; + + return $result; + +} + + +function clientbooks($books, $clienthash){ + + + if (!is_array($books)) + return null; + + + foreach($books as $book){ + $book['pic'] = IMGSRV."price/180x280/{$book['price_id']}.{$book['priceimg']}"; + $book['link'] = 'read/'.$clienthash; + $result[] = $book; + } + + return $result; + +} \ No newline at end of file