add api
This commit is contained in:
59
app/api/client.php
Normal file
59
app/api/client.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,21 +52,8 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (file_exists($pgfile)){
|
if (file_exists($pgfile)){
|
||||||
$pdfile = '/pages/'.$hash.'/'.$hash.'-'.$page.'.pdf';
|
$pdfile = '/pages/'.$hash.'/'.$hash.'-'.$page.'.pdf';
|
||||||
|
|
||||||
if ($page > 1 or $promo){
|
|
||||||
$fullpdf = $pdfile;
|
|
||||||
$downtitle = 'Если, по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$downtitle = 'Если, по какой-то причине у вас не загрузилось издание ниже, то нажмите сюда, чтобы скачать pdf';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$pagenum = 1;
|
$pagenum = 1;
|
||||||
}
|
}
|
||||||
elseif (file_exists($cachefile)){
|
elseif (file_exists($cachefile)){
|
||||||
@@ -78,6 +65,18 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){
|
|||||||
$pagenum = $page;
|
$pagenum = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($page > 1 or $promo){
|
||||||
|
$fullpdf = $pdfile;
|
||||||
|
$downtitle = 'Если по какой-то причине у вас не загрузилась страница ниже, то нажмите сюда, чтобы скачать pdf';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$downtitle = 'Если по какой-то причине у вас не загрузилось издание ниже, то нажмите сюда, чтобы скачать pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$id = $price['price_id'];
|
$id = $price['price_id'];
|
||||||
$maxpage = 24;
|
$maxpage = 24;
|
||||||
$title = $price['pricename'];
|
$title = $price['pricename'];
|
||||||
@@ -85,7 +84,6 @@ function read_kuri($hash, $page = 1, $scale = 1.5, $promo = false){
|
|||||||
if ($promo){
|
if ($promo){
|
||||||
$filedown = True;
|
$filedown = True;
|
||||||
$baseurl = "/promo/$hash/";
|
$baseurl = "/promo/$hash/";
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$filedown = True;
|
$filedown = True;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ function file_kuri($hash) {
|
|||||||
$id = $price['price_id'];
|
$id = $price['price_id'];
|
||||||
$pdfile = anfilename($id);
|
$pdfile = anfilename($id);
|
||||||
$newF = PDFDIR.$hash.'.pdf';
|
$newF = PDFDIR.$hash.'.pdf';
|
||||||
echo $newF;
|
|
||||||
if (!file_exists($newF))
|
if (!file_exists($newF))
|
||||||
copy($pdfile, $newF);
|
copy($pdfile, $newF);
|
||||||
|
|
||||||
@@ -93,3 +92,5 @@ function addhash_kuri(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user