dolibarr  7.0.0-beta
image.php
1 <?php
2 /* Copyright (C) 2017 Oscss-Shop <support@oscss-shop.fr>.
3  * Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License");
6  * it under the terms of the GNU General Public License as published bypliance with the License.
7  * the Free Software Foundation; either version 3 of the License, or
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
19 if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
20 
21 
27 $res = 0;
28 if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php");
29 if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php");
30 if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php");
31 if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php");
32 if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php"))
33  $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
34 if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php"))
35  $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
36 if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php"))
37  $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
38 if (!$res) die("Include of main fails");
39 
40 // CORE
41 
42 global $lang, $user, $conf;
43 
44 
45 require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
46 $dolistore = new Dolistore();
47 
48 $id_product = GETPOST('id_product', 'int');
49 $id_image = GETPOST('id_image', 'int');
50 // quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default"
51 $quality = GETPOST('quality', 'alpha');
52 
53 try {
54  $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
55  $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
56  $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api);
57  //echo $url;
58  $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
59  header('Content-type:image');
60  print $request['response'];
61 } catch (PrestaShopWebserviceException $e) {
62  // Here we are dealing with errors
63  $trace = $e->getTrace();
64  if ($trace[0]['args'][0] == 404) die('Bad ID');
65  else if ($trace[0]['args'][0] == 401) die('Bad auth key');
66  else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
67 }
68 
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
Class Dolistore.