From 3ce5f6db6e8b6318e42b0d68d8a599c5fb9fe2a6 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Wed, 16 Oct 2024 10:23:54 +0300 Subject: [PATCH] fix images + add readme --- README.md | 43 ++++++++++++++++++- .../system/public/import.php | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e386e5..bfb1f3a 100755 --- a/README.md +++ b/README.md @@ -1,2 +1,43 @@ -# parser_from_rossko +# Parser of products from [rossko.ru](https://krsk.rossko.ru) +* Saves products from an excel file with products sent to email from [rossko.ru](https://krsk.rossko.ru) in SQlite3 +* Downloads images directly from the [rossko.ru](https://krsk.rossko.ru) website for all products +* Generates excel documents formatted for the [drom.ru](https://drom.ru) and [avito](https://avito.ru) trading platforms with the added reseller markup + +## Installation + +### NGINX +1. Example of NGINX server file +```nginx +location / { + try_files $uri $uri/ /index.php; +} + +# Excel-files +location ~ /(?drom|avito)(?/avaiable|/order)?$ { + root /var/www/parser_from_rossko/mirzaev/parser_from_rossko/system/storage/$type$file; + add_header Content-Disposition "attachment; filename=$type.xlsx"; + try_files /export.xlsx =404; +} + +# Images +location ~ /(?[A-z0-9]+)/(?[0-9]+\.[jJ][pP][gG])$ { + root /var/www/parser_from_rossko/mirzaev/parser_from_rossko/system/storage/images/$nomenclature; + add_header Content-Disposition "attachment; filename=$image"; + try_files /$image =404; +} + +location ~ \.php$ { + ... +} +``` + +2. Issue yourself an SSL/TLS certificate using Certbot: `sudo certbot --nginx` + + +### SystemD (or any alternative you like) + +1. Execute: `sudo cp rossko.service /etc/systemd/system/rossko.service` + +*before you execute the command think about **what it does** and whether the **paths** are specified correctly*
+*the configuration file is very simple and you can remake it for any alternative to SystemD that you like* diff --git a/mirzaev/parser_from_rossko/system/public/import.php b/mirzaev/parser_from_rossko/system/public/import.php index 05b049a..7570738 100644 --- a/mirzaev/parser_from_rossko/system/public/import.php +++ b/mirzaev/parser_from_rossko/system/public/import.php @@ -141,7 +141,7 @@ if (!empty($document) ?? file_exists($document)) { $response = $client->send($request); // Инициализация изображений - $images = json_decode((string) $response->getBody(), true)['mainPart']['images']; + $images = json_decode((string) $response->getBody(), true)['mainPart']['images'] ?? null; foreach ($images ?? [] as $image) { // Перебор изображений