From 4b7535e963479115eedd492eb3a8d4ad1c27e2b1 Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Wed, 8 Apr 2020 23:26:46 +0300 Subject: [PATCH] copy file cache --- .gitignore | 1 + app/confg.php | 2 ++ app/routes/price.php | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5650dce..ae8f228 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor +pdf/ diff --git a/app/confg.php b/app/confg.php index d9e6c50..47bab10 100644 --- a/app/confg.php +++ b/app/confg.php @@ -11,6 +11,8 @@ if (isset($_SERVER['HTTP_HOST'])) else define('SITEPATH', dirname(__FILE__)); +define('PDFDIR', '/vhosts/app/pub/files/pdf/'); + db_config('argumentiru', 'mysql:host=mysql;dbname=argumentiru', 'newser', 'Chjk90yuiREY'); db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOhg56Fh'); diff --git a/app/routes/price.php b/app/routes/price.php index d961c21..f0d662b 100644 --- a/app/routes/price.php +++ b/app/routes/price.php @@ -18,8 +18,12 @@ function anfilename($id){ + function file_kuri($hash) { + + + $price = db_get("SELECT `price_id`, `pricename` FROM `price` WHERE `pricehash` = '$hash' LIMIT 1"); @@ -27,10 +31,15 @@ function file_kuri($hash) { header("HTTP/1.0 404 Not Found"); echo "file not found"; return False; - } + } + + $id = $price['price_id']; $pdfile = anfilename($id); + $newF = PDFDIR.$hash.'.pdf'; + if (!file_exists($newF)) + copy($pdfile, $newF); $request = $_SERVER['REQUEST_URI']; $filename = basename($request);