20 if (!defined(
'NOREQUIRESOC')) {
21 define(
'NOREQUIRESOC',
'1');
24 if (!defined(
'NOCSRFCHECK')) {
25 define(
'NOCSRFCHECK',
'1');
27 if (!defined(
'NOTOKENRENEWAL')) {
28 define(
'NOTOKENRENEWAL',
'1');
30 if (!defined(
'NOREQUIREMENU')) {
31 define(
'NOREQUIREMENU',
'1');
33 if (!defined(
'NOREQUIREHTML')) {
34 define(
'NOREQUIREHTML',
'1');
36 if (!defined(
'NOREQUIREAJAX')) {
37 define(
'NOREQUIREAJAX',
'1');
40 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
41 require
'../../main.inc.php';
47 $query =
GETPOST(
'query',
'alpha');
55 if ($query ==
"cat") {
56 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
60 $result = $object->fetch($id);
62 $upload_dir = $conf->categorie->multidir_output[$object->entity];
63 $pdir =
get_exdir($object->id, 2, 0, 0, $object,
'category').$object->id.
"/photos/";
64 $dir = $upload_dir.
'/'.$pdir;
66 foreach ($object->liste_photos($dir) as $key => $obj) {
67 if ($obj[
'photo_vignette']) {
68 $filename = $obj[
'photo_vignette'];
70 $filename = $obj[
'photo'];
72 $file = DOL_URL_ROOT.
'/viewimage.php?cache=1&publictakepos=1&modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$filename);
73 header(
'Location: '.$file);
76 header(
'Location: ../../public/theme/common/nophoto.png');
77 } elseif ($query ==
"pro") {
78 require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
82 $image = $objProd->show_photos(
'product', $conf->product->multidir_output[$objProd->entity],
'small', 1);
85 preg_match(
'@src="([^"]+)"@', $image, $match);
86 $file = array_pop($match);
88 header(
'Location: ../../public/theme/common/nophoto.png');
90 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
91 header(
'Location: '.$file.
'&cache=1');
93 header(
'Location: '.$file.
'&cache=1&publictakepos=1&modulepart=product');
100 $filename = $query.
".jpg";
103 list($width, $height) = getimagesize($filename);
108 $image_p = imagecreatetruecolor($new_width, $new_height);
109 $image = imagecreatefromjpeg($filename);
110 imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
113 imagejpeg($image_p,
null, 100);