dolibarr 20.0.0
image.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Oscss-Shop <support@oscss-shop.fr>.
3 * Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
5 *
6 * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License");
7 * it under the terms of the GNU General Public License as published bypliance with the License.
8 * the Free Software Foundation; either version 3 of the License, or
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
20if (!defined('NOTOKENRENEWAL')) {
21 define('NOTOKENRENEWAL', 1);
22}
23
24
31require "../../../main.inc.php";
32require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
33
34
35/*
36 * View
37 */
38
39top_httphead('image');
40
41$dolistore = new Dolistore();
42
43$id_product = GETPOSTINT('id_product');
44$id_image = GETPOSTINT('id_image');
45// quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default"
46$quality = GETPOST('quality', 'alpha');
47
48try {
49 $url = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV') . '/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
50 $api = new PrestaShopWebservice(
51 getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV'),
52 getDolGlobalString('MAIN_MODULE_DOLISTORE_API_KEY'),
53 $dolistore->debug_api
54 );
55 //echo $url;
56 $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
57
58 print $request['response'];
60 // Here we are dealing with errors
61 $trace = $e->getTrace();
62 if ($trace[0]['args'][0] == 404) {
63 die('Bad ID');
64 } elseif ($trace[0]['args'][0] == 401) {
65 die('Bad auth key');
66 } else {
67 die('Can not access to ' . getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV'));
68 }
69}
Class Dolistore.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.