2017-08-22 14:47:01 +02:00
< ? php
/* Copyright ( C ) 2017 Oscss - Shop < support @ oscss - shop . fr >.
* Copyright ( C ) 2008 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2022-04-03 12:56:07 +02:00
* Copyright ( C ) 2020 Frédéric France < frederic . france @ netlogic . fr >
2017-08-22 14:47:01 +02:00
*
* This program is free software ; you can redistribute it and / or modifyion 2.0 ( the " License " );
* it under the terms of the GNU General Public License as published bypliance with the License .
* the Free Software Foundation ; either version 3 of the License , or
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
* or see https :// www . gnu . org /
2017-08-22 14:47:01 +02:00
*/
2020-05-11 20:42:47 +02:00
if ( ! defined ( 'NOTOKENRENEWAL' )) {
2020-10-31 14:32:18 +01:00
define ( 'NOTOKENRENEWAL' , 1 );
2020-05-11 20:42:47 +02:00
}
2017-08-22 14:47:01 +02:00
/**
2018-08-31 23:12:55 +02:00
* \file htdocs / admin / dolistore / ajax / image . php
2018-07-26 11:57:25 +02:00
* \ingroup admin
2018-08-31 23:12:55 +02:00
* \brief Page des informations dolistore
2017-08-22 14:47:01 +02:00
*/
2018-07-26 11:57:25 +02:00
require " ../../../main.inc.php " ;
2017-08-22 14:47:01 +02:00
// CORE
global $lang , $user , $conf ;
2017-09-01 23:56:59 +02:00
require_once DOL_DOCUMENT_ROOT . '/admin/dolistore/class/dolistore.class.php' ;
2017-08-22 14:47:01 +02:00
$dolistore = new Dolistore ();
$id_product = GETPOST ( 'id_product' , 'int' );
$id_image = GETPOST ( 'id_image' , 'int' );
// quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default"
$quality = GETPOST ( 'quality' , 'alpha' );
try {
2020-03-23 15:54:02 +01:00
$url = $conf -> global -> MAIN_MODULE_DOLISTORE_API_SRV . '/api/images/products/' . $id_product . '/' . $id_image . '/' . $quality ;
$api = new PrestaShopWebservice (
$conf -> global -> MAIN_MODULE_DOLISTORE_API_SRV ,
2021-02-26 22:04:03 +01:00
$conf -> global -> MAIN_MODULE_DOLISTORE_API_KEY ,
$dolistore -> debug_api
2020-03-23 15:54:02 +01:00
);
//echo $url;
$request = $api -> executeRequest ( $url , array ( CURLOPT_CUSTOMREQUEST => 'GET' ));
header ( 'Content-type:image' );
print $request [ 'response' ];
2017-08-22 14:47:01 +02:00
} catch ( PrestaShopWebserviceException $e ) {
2020-03-23 15:54:02 +01:00
// Here we are dealing with errors
$trace = $e -> getTrace ();
2021-02-26 22:04:03 +01:00
if ( $trace [ 0 ][ 'args' ][ 0 ] == 404 ) {
die ( 'Bad ID' );
} elseif ( $trace [ 0 ][ 'args' ][ 0 ] == 401 ) {
die ( 'Bad auth key' );
} else {
die ( 'Can not access to ' . $conf -> global -> MAIN_MODULE_DOLISTORE_API_SRV );
}
2017-09-24 01:36:20 +02:00
}