Files
anpdf/app/api/client.php
Andrey Kuvshinov c92457b901 add api
2020-04-28 21:16:20 +03:00

59 lines
1.1 KiB
PHP

<?php
function api_client_kuri($hash){
$sql = "SELECT client_id FROM `clients` WHERE `clienthash` = '$hash' LIMIT 1 ";
$client = db_get($sql);
if (isset($client['client_id']))
return $client;
return false;
}
function clientbooks_kuri($client_id){
$buysql = "SELECT * FROM anbuy WHERE client_id = '$client_id'";
echo $buysql;
$buys = db_get($buysql);
return $buys;
}
//весь активный архив
function api_arch_kuri($clienthash, $page = 1){
$limit = 25;
/** $scount = "
SELECT COUNT(price.price_id) AS count
FROM price
WHERE category_id = 1
LIMIT 1";
$count = db_get($scount);*
*/
$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";
}
$items = db_get($pricesql);
foreach ($items as $item){
$item['pic'] = IMGSRV."price/180x280/{$item['price_id']}.{$item['priceimg']}";
$result[] = $item;
}
return $result;
}