add Dockerfile
This commit is contained in:
38
Dockerfile
Normal file
38
Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
FROM alpine:3.8
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
ENV TIMEZONE Europe/Moscow
|
||||||
|
ENV PHP_MEMORY_LIMIT 1024M
|
||||||
|
ENV MAX_UPLOAD 128M
|
||||||
|
ENV PHP_MAX_FILE_UPLOAD 128
|
||||||
|
ENV PHP_MAX_POST 128M
|
||||||
|
ENV PHPUSER 1000
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk upgrade && \
|
||||||
|
apk add pdftk \
|
||||||
|
php7 php7-fpm php7-opcache php7-pdo php7-pdo_mysql php7-json php7-mbstring && \
|
||||||
|
rm -rf /var/cache/apk/* && \
|
||||||
|
#add localuser
|
||||||
|
addgroup -g ${PHPUSER} -S www-data && \
|
||||||
|
adduser -u ${PHPUSER} -D -S -G www-data www-data && \
|
||||||
|
#localuser
|
||||||
|
sed -i -e "s/user\s*=\s*nobody/user = www-data/g" /etc/php7/php-fpm.d/www.conf && \
|
||||||
|
sed -i -e "s/group\s*=\s*nobody/group = www-data/g" /etc/php7/php-fpm.d/www.conf && \
|
||||||
|
#connect
|
||||||
|
sed -i "s|;*listen\s*=\s*127.0.0.1:9000|listen = 9000|g" /etc/php7/php-fpm.d/www.conf && \
|
||||||
|
sed -i "s|;*listen\s*=\s*/||g" /etc/php7/php-fpm.d/www.conf && \
|
||||||
|
#vars
|
||||||
|
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php7/php.ini && \
|
||||||
|
sed -i "s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i" /etc/php7/php.ini && \
|
||||||
|
sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini
|
||||||
|
|
||||||
|
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
WORKDIR /vhosts
|
||||||
|
|
||||||
|
CMD ["php-fpm7", "-F"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?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' AND `buy_status` = '1'";
|
|
||||||
echo $buysql;
|
|
||||||
$buys = db_get($buysql);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $buys;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//весь активный архив
|
|
||||||
function api_arch($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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php":">=5.3.0",
|
"php":">=5.3.0",
|
||||||
"masterforweb/kuri":"dev-master",
|
"masterforweb/kuri":"dev-master",
|
||||||
"masterforweb/db_lite":"dev-master"
|
"masterforweb/db_lite":"dev-master",
|
||||||
|
"mikehaertl/php-pdftk": "^0.8.0"
|
||||||
},
|
},
|
||||||
"repositories":[
|
"repositories":[
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
ini_set('display_errors','on');
|
ini_set('display_errors', 1);
|
||||||
error_reporting(E_ALL);
|
ini_set('display_startup_errors', 1);
|
||||||
|
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_HOST']))
|
if (isset($_SERVER['HTTP_HOST']))
|
||||||
define('SITE', 'http://'.$_SERVER['HTTP_HOST'].'/');
|
define('SITE', 'http://'.$_SERVER['HTTP_HOST'].'/');
|
||||||
@@ -13,6 +14,7 @@ else
|
|||||||
|
|
||||||
define('PDFDIR', '/vhosts/anpdf/app/pub/files/pdf/');
|
define('PDFDIR', '/vhosts/anpdf/app/pub/files/pdf/');
|
||||||
define('PGDIR', '/vhosts/anpdf/app/pub/files/pages/');
|
define('PGDIR', '/vhosts/anpdf/app/pub/files/pages/');
|
||||||
|
define('APPPATH', SITEPATH);
|
||||||
define('VIEWPATH', SITEPATH.'views/');
|
define('VIEWPATH', SITEPATH.'views/');
|
||||||
define('API', 'http://api.argumenti.ru/');
|
define('API', 'http://api.argumenti.ru/');
|
||||||
define('IMGSRV', 'https://imgurl.argumenti.ru/');
|
define('IMGSRV', 'https://imgurl.argumenti.ru/');
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ require 'confg.php';
|
|||||||
require 'routes/price.php';
|
require 'routes/price.php';
|
||||||
require 'routes/client.php';
|
require 'routes/client.php';
|
||||||
require 'routes/anpdf.php';
|
require 'routes/anpdf.php';
|
||||||
|
require 'routes/auth.php';
|
||||||
|
|
||||||
#api
|
#api
|
||||||
require 'api/client.php';
|
require 'api/apiclient.php';
|
||||||
|
|
||||||
_kuri();
|
_kuri();
|
||||||
|
|
||||||
function index_kuri(){
|
function index_kuri(){
|
||||||
anpromo_kuri();
|
echo 'index';
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,10 @@ h1 {
|
|||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.book_small{
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 560px) {
|
@media screen and (max-width: 560px) {
|
||||||
#brand_title, #page_title {
|
#brand_title, #page_title {
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
ini_set('display_errors','off');
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
function anpromo_kuri($page = 1, $scale = 1){
|
function anpromo_kuri($page = 1, $scale = 1){
|
||||||
|
|
||||||
// $pdfile = 'https://argumenti.ru/templinks/md5files/f9598f88e667146d50d106eeedbd74c1.pdf';
|
// $pdfile = 'https://argumenti.ru/templinks/md5files/f9598f88e667146d50d106eeedbd74c1.pdf';
|
||||||
@@ -136,6 +132,7 @@ function promo_kuri($hash, $page = 1, $scale = 2, $promo = false){
|
|||||||
$id = $price['price_id'];
|
$id = $price['price_id'];
|
||||||
$pdfile = "/file/$hash";
|
$pdfile = "/file/$hash";
|
||||||
$maxpage = 32;
|
$maxpage = 32;
|
||||||
|
|
||||||
if ($page > 1)
|
if ($page > 1)
|
||||||
$title = $price['pricename']."- $page";
|
$title = $price['pricename']."- $page";
|
||||||
else
|
else
|
||||||
@@ -159,4 +156,41 @@ function promo_kuri($hash, $page = 1, $scale = 2, $promo = false){
|
|||||||
include ('anpdf2.phtml');
|
include ('anpdf2.phtml');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function pdfscan_kuri(){
|
||||||
|
|
||||||
|
$pdfsql = "SELECT price_id, pricehash FROM price WHERE category_id = 1";
|
||||||
|
$path = '~/vhosts/anpdf/pub/files/pages/';
|
||||||
|
|
||||||
|
|
||||||
|
echo exec('whoami');
|
||||||
|
|
||||||
|
$pdfs = dbl_get($pdfsql);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($pdfs as $pdf){
|
||||||
|
|
||||||
|
$pagedir = $path.$pdf['pricehash'];
|
||||||
|
|
||||||
|
if(!is_dir($pagedir)) {
|
||||||
|
mkdir($pagedir);
|
||||||
|
$cmd = 'docker run --name pdftk -it --rm \
|
||||||
|
--user $(id -u):$(id -g) \
|
||||||
|
-v "$PDFDIR:/workdir/pdf" \
|
||||||
|
-v "$OUTDIR:/workdir/pages" \
|
||||||
|
-w "/workdir" \
|
||||||
|
masterforweb/pdftk pdftk "pdf/$file" burst output "pages/${name}/${name}-%1d.pdf';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function addclient_kuri(){
|
function addclient(){
|
||||||
|
|
||||||
$buys = db_get("SELECT `buy_id`, `buy_email`, `date_start` FROM `anbuy`");
|
$buys = db_get("SELECT `buy_id`, `buy_email`, `date_start` FROM `anbuy`");
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ function addclient_kuri(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addclientid_kuri(){
|
function addclientid(){
|
||||||
|
|
||||||
$buys = db_get("SELECT `buy_id`, `buy_email` FROM `anbuy` WHERE `client_id` = 0");
|
$buys = db_get("SELECT `buy_id`, `buy_email` FROM `anbuy` WHERE `client_id` = 0");
|
||||||
|
|
||||||
@@ -82,42 +82,42 @@ function addcard($id, $date) {
|
|||||||
|
|
||||||
function mybooks_kuri($clienthash, $page = 1){
|
function mybooks_kuri($clienthash, $page = 1){
|
||||||
|
|
||||||
|
$limit = 25;
|
||||||
$client = api_client_kuri($clienthash);
|
$client = api_client_kuri($clienthash);
|
||||||
|
$baseurl = SITE."mybooks/$clienthash/";
|
||||||
|
|
||||||
if (!$client) {
|
if (!$client) {
|
||||||
echo 'Пользователь не найден';
|
echo 'Пользователь не найден';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = api_arch($page);
|
$items = clientbuys_kuri($client['client_id'], $page);
|
||||||
|
$count = $items['count'];
|
||||||
|
|
||||||
foreach ($items as $item){
|
if ($count > $limit){
|
||||||
if ($item['price_id'] = 486){ //ищем подписку = доступ на весь архив
|
$pages = ceil($count / $limit);
|
||||||
$all = True;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($page > 1) {
|
||||||
|
$title = "Моя библиотека - страница $page";
|
||||||
|
$prevpage = $page - 1 ;
|
||||||
|
$prevurl = $baseurl.$prevpage;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$title = "Моя библиотека";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($all){
|
|
||||||
$books = api_arch($page);
|
|
||||||
|
|
||||||
if ($page > 1)
|
|
||||||
$title = "Архив номеров - $page";
|
if ($pages > $page){
|
||||||
else
|
$nextpage = $page + 1;
|
||||||
$title = "Архив номеров";
|
$nexturl = $baseurl.$nextpage;
|
||||||
|
$endurl = $baseurl.$pages;
|
||||||
|
}
|
||||||
|
|
||||||
$tempcontent = VIEWPATH.'allbooks.phtml';
|
$tempcontent = VIEWPATH.'allbooks.phtml';
|
||||||
include VIEWPATH.'layout.phtml';
|
include VIEWPATH.'layout.phtml';
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$books = $items;
|
|
||||||
}
|
|
||||||
|
|
||||||
//$books = clientbooks_kuri($client['client_id']);
|
|
||||||
|
|
||||||
// print_r($books);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@
|
|||||||
|
|
||||||
<div id="pdfprogress">Идет обращение к серверу...</div>
|
<div id="pdfprogress">Идет обращение к серверу...</div>
|
||||||
|
|
||||||
<canvas id="the-canvas"></canvas>
|
<canvas id="the-canvas">
|
||||||
|
</canvas>
|
||||||
<script>startpdfviewer(newcurr);</script>
|
<script>startpdfviewer(newcurr);</script>
|
||||||
<div id="stuff-bar">
|
<div id="stuff-bar">
|
||||||
<div id="zoomnav">
|
<div id="zoomnav">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<title>Еженедельник Аргументы Недели - <?=$title?></title>
|
<title>Еженедельник Аргументы Недели - <?=$title?></title>
|
||||||
<script src="/pub/scripts/pdf.min.js"></script>
|
<script src="/pub/scripts/pdf.min.js"></script>
|
||||||
<script src="/pub/scripts/anviewer.js?ver=43"></script>
|
<script src="/pub/scripts/anviewer.js?ver=43"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/pub/css/an.css?ver=36">
|
<link rel="stylesheet" type="text/css" href="/pub/css/an.css?ver=37">
|
||||||
<link rel="icon" type="image/ico" href="https://argumenti.ru/favicon.ico">
|
<link rel="icon" type="image/ico" href="https://argumenti.ru/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="/pub/fontawesome/css/all.css">
|
<link rel="stylesheet" href="/pub/fontawesome/css/all.css">
|
||||||
|
|||||||
2
composer.sh
Normal file → Executable file
2
composer.sh
Normal file → Executable file
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
docker run --rm --interactive --tty \
|
docker run --rm --interactive --tty \
|
||||||
--volume $PWD/app:/app \
|
--volume $PWD/app:/app \
|
||||||
composer update
|
composer "$@"
|
||||||
Reference in New Issue
Block a user