dolibarr  13.0.2
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 
20 if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
21 if (!defined('NOTOKENRENEWAL')) {
22  define('NOTOKENRENEWAL', 1);
23 }
24 
25 
31 require "../../../main.inc.php";
32 
33 // CORE
34 
35 global $lang, $user, $conf;
36 
37 
38 require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
39 $dolistore = new Dolistore();
40 
41 $id_product = GETPOST('id_product', 'int');
42 $id_image = GETPOST('id_image', 'int');
43 // quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default"
44 $quality = GETPOST('quality', 'alpha');
45 
46 try {
47  $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
48  $api = new PrestaShopWebservice(
49  $conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
50  $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api
51  );
52  //echo $url;
53  $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
54  header('Content-type:image');
55  print $request['response'];
56 } catch (PrestaShopWebserviceException $e) {
57  // Here we are dealing with errors
58  $trace = $e->getTrace();
59  if ($trace[0]['args'][0] == 404) die('Bad ID');
60  elseif ($trace[0]['args'][0] == 401) die('Bad auth key');
61  else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
62 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
print
Draft customers invoices.
Definition: index.php:89
Class Dolistore.