22 if (!defined(
'NOREQUIRESOC')) {
23 define(
'NOREQUIRESOC',
'1');
26 if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29 if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32 if (!defined(
'NOREQUIREHTML')) {
33 define(
'NOREQUIREHTML',
'1');
35 if (!defined(
'NOREQUIREAJAX')) {
36 define(
'NOREQUIREAJAX',
'1');
39 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
40 require
'../../main.inc.php';
46 $query =
GETPOST(
'query',
'alpha');
54 if ($query ==
"cat") {
55 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
59 $result = $object->fetch($id);
61 $upload_dir = $conf->categorie->multidir_output[$object->entity];
62 $pdir =
get_exdir($object->id, 2, 0, 0, $object,
'category').$object->id.
"/photos/";
63 $dir = $upload_dir.
'/'.$pdir;
65 foreach ($object->liste_photos($dir) as $key => $obj) {
66 if ($obj[
'photo_vignette']) {
67 $filename = $obj[
'photo_vignette'];
69 $filename = $obj[
'photo'];
71 $file = DOL_URL_ROOT.
'/viewimage.php?cache=1&publictakepos=1&modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$filename);
72 header(
'Location: '.$file);
75 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');
91 if (!defined(
'INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
92 header(
'Location: '.$file.
'&cache=1');
95 header(
'Location: '.$file.
'&cache=1&publictakepos=1&modulepart=product');
103 $filename = $query.
".jpg";
106 list($width, $height) = getimagesize($filename);
111 $image_p = imagecreatetruecolor($new_width, $new_height);
112 $image = imagecreatefromjpeg($filename);
113 imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
116 imagejpeg($image_p,
null, 100);
Class to manage categories.
Class to manage products or services.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.