7 require_once
'base/Ego_System.php';
8 require_once
'base/functions.php';
55 private $info = array();
69 private $mime_type =
'';
83 private $generator =
'Server-File';
104 private $is_image =
false;
111 private $is_valid =
false;
118 private $web_format =
false;
125 private $temporary =
false;
132 private $quality = 100;
139 private $multipart_support =
false;
149 'mime' =>
'image/avif'
153 'mime' =>
'image/webp'
162 private $converted =
'';
169 private $error =
false;
178 public function __construct($source =
null, $pool =
'', $dir =
'') {
179 if (is_a($source,
'Page')) {
181 $this->page = $source;
182 $this->site = $this->page->getSite();
185 if ($dir ==
'' && ($_REQUEST[
'dir'] || $_REQUEST[
'c_date'])) {
186 $dir = $_REQUEST[
'dir'] ?: $_REQUEST[
'c_date'];
187 if ($_REQUEST[
'c_date'] && !is_numeric($dir) && strpos($dir, DIRECTORY_SEPARATOR) ===
false) {
189 $dir = strtotime($dir);
193 if ($_REQUEST[
'thumbnail']) {
195 [$width, $height, $index] = explode(
'x', $_REQUEST[
'thumbnail'], 3);
196 $this->file = $this->getThumbnail((
int) $width, (
int) ($height ?? $width), $pool, $dir, [
197 'index' => (
int) $index
199 $this->detectMimeType();
200 $this->is_image =
true;
206 $file = $this->page->getMediapool()->get($this->pool, $dir);
208 if (!$file[
'quarantine']) {
209 $this->file = $file[
'file'];
213 $this->info[
'convert']
214 && $this->info[
'isImage']
215 && isset(self::$convert_types[$this->info[
'suffix']])
218 $this->
convertImage($this->info[
'suffix'], (
bool) $_REQUEST[
'reset']);
219 }
else if ($this->info[
'isVideo'] && $this->site->admin[
'mediapool'][
'video_compress'] && !$GLOBALS[
'is_index']) {
221 require_once
'base/Ego_Mobile.php';
223 $is_mobile = $mobile->isMobile();
224 $is_tablet = $mobile->isTablet();
229 $files[
"{$height}p"] = $this->page->getMediapool()->get(
"{$this->info['title']}_{$height}p.mp4",
'_compress');
232 $files = array_reverse($files);
235 ($is_mobile && !$is_tablet && ($data = $files[
'360p']))
236 || ($is_tablet && ($data = $files[
'720p']))
237 || ($data = $files[
'1080p'])
239 $this->file = $data[
'file'];
240 $this->mime_type = $data[
'mime'];
243 $existing_files = array_filter($files);
244 if ($data = array_pop($existing_files)) {
245 $this->file = $data[
'file'];
246 $this->mime_type = $data[
'mime'];
250 $this->detectMimeType();
252 $type = $file[
'suffix'];
253 } elseif (!$this->page->extra[
'quarantine']) {
255 if ($this->page->field[
'type'] ==
'multimedia/image' && $this->page->extra[
'crop_image']) {
257 'edit' => $this->page->extra[
'edit'],
260 $this->page = $this->page->getParents()->nextPage();
261 $this->page->extra = array_merge($this->page->extra, $extra);
264 $this->file = $GLOBALS[
'egotec_conf'][
'var_dir'].
'media/'.$this->site->name.
'/';
265 if ($_REQUEST[
'c_date']) {
267 $archive_file = $this->file . $this->page->getMediaFilename(
272 $this->file = $archive_file;
275 $this->file .= $this->page->getMediaFilename();
278 $this->file .= $this->page->getMediaFilename();
280 $this->mime_type = $this->page->extra[
'mime_type'];
283 $this->page->field[
'type'] ==
'multimedia/image'
284 && isset(self::$convert_types[ltrim($_SERVER[
'REQUEST_SUFFIX'],
'.')])
285 && !in_array($this->mime_type, [
'image/svg+xml', self::$convert_types[ltrim($_SERVER[
'REQUEST_SUFFIX'],
'.')][
'mime']])
288 $this->
convertImage($type = $this->page->extra[
'image_type'] = ltrim($_SERVER[
'REQUEST_SUFFIX'],
'.'), (
bool) $_REQUEST[
'reset']);
290 $type = $this->page->extra[
'image_type'];
294 if ($this->site->admin[
'video'][
'compress'] && !$GLOBALS[
'is_index']) {
295 require_once
'base/Ego_Mobile.php';
298 '360p' => $this->page->getMediapool()->get(
'360p.mp4'),
299 '720p' => $this->page->getMediapool()->get(
'720p.mp4'),
300 '1080p' => $this->page->getMediapool()->get(
'1080p.mp4')
302 $is_mobile = $mobile->isMobile();
303 $is_tablet = $mobile->isTablet();
305 ($is_mobile && !$is_tablet && ($data = $files[
'360p']))
306 || ($is_tablet && ($data = $files[
'720p']))
307 || ($data = $files[
'1080p'])
309 $this->file = $data[
'file'];
310 $this->mime_type = $data[
'mime'];
313 $existing_files = array_filter($files);
314 if ($data = array_pop($existing_files)) {
315 $this->file = $data[
'file'];
316 $this->mime_type = $data[
'mime'];
325 'docx' =>
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
326 'pptx' =>
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
327 'pptm' =>
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
328 'xlsx' =>
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
329 'xlsm' =>
'application/vnd.ms-excel.sheet.macroEnabled.12',
330 'xps' =>
'application/vnd.ms-xpsdocument',
331 'svg' =>
'image/svg+xml'
333 if (array_key_exists($type, $formats)) {
334 $this->mime_type = $formats[$type];
337 } elseif (is_string($source)) {
338 if (strpos($source,
'string:') === 0) {
340 $file = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'output');
348 if (!empty($GLOBALS[
'site']) && is_a($GLOBALS[
'site'],
'Site')) {
349 $this->site = $GLOBALS[
'site'];
350 } elseif (class_exists(
'Site')) {
351 $this->site =
new Site();
356 $ignore_image_mimes = array(
'image/svg+xml',
'image/x-icon',
'image/vnd.microsoft.icon');
357 $ignore_image_types = array(
'svg',
'ico');
359 if (!$this->is_image) {
360 if ($this->page && $this->page->field[
'type'] ==
'multimedia/image') {
361 $this->is_image = !in_array($this->page->extra[
'mime_type'], $ignore_image_mimes);
362 } elseif ($this->file) {
364 $this->is_image = preg_match(
369 function ($type) use ($ignore_image_types) {
370 return !in_array($type, $ignore_image_types);
377 $this->is_image = !(strpos($this->mime_type,
'image') ===
false || in_array($this->mime_type, $ignore_image_mimes));
378 if ($this->page && $this->page->extra[
'mime_type'] && $this->page->extra[
'image_type']) {
379 $this->is_valid =
true;
385 if ($this->is_image) {
386 $this->web_format = in_array(
390 if (is_numeric($_REQUEST[
'quality'])) {
392 $this->quality = (int) $_REQUEST[
'quality'];
393 }
else if (is_numeric($GLOBALS[
'quality'])) {
395 $this->quality = (int) $GLOBALS[
'quality'];
396 } elseif (is_numeric($GLOBALS[
'egotec_conf'][
'image'][
'quality'])) {
398 $this->quality = (int) $GLOBALS[
'egotec_conf'][
'image'][
'quality'];
409 private function isValid($download =
false) {
414 in_array($this->page->field[
'type'], array(
'multimedia/file',
'multimedia/image',
'multimedia/category'))
420 && $this->page->field[
'type'] ==
'multimedia/category'
424 && $this->page->hasRights(
'view')
437 if ($this->file && $this->page) {
438 $cache_file = $GLOBALS[
'egotec_conf'][
'var_dir']
440 . $this->page->getSite()->name .
'/'
441 . $this->page->getSite()->language .
'/'
442 . $this->page->field[
'id'] .
'/'
443 . $format .
'_' . md5($this->file) .
'_' . md5(filemtime($this->file));
446 if (isset(self::$convert_types[$format])) {
447 $this->mime_type = self::$convert_types[$format][
'mime'];
452 $this->file = $cache_file;
457 $tmp_file = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'convert');
461 $method = $GLOBALS[
'egotec_conf'][
'files'][
"convert_$format"] ?:
'';
467 '--jobs ' . ($GLOBALS[
'egotec_conf'][
'files'][
'max_cores'] ?: 1),
481 $this->file = $cache_file;
485 require_once
'base/Ego_Image.php';
488 if ($converted_file = $image->convert($format, [
489 'output' => $cache_file
492 $this->file = $converted_file;
500 $this->converted = $format;
501 $this->name = preg_replace(
'/\.[^.]+$/',
".$format", $this->
getName());
503 return $this->converted !=
'';
513 if ($this->file && $this->page) {
515 $GLOBALS[
'egotec_conf'][
'var_dir']
517 . $this->page->getSite()->name .
'/'
518 . $this->page->getSite()->language .
'/'
519 . $this->page->field[
'id'] .
'/'
520 . ($format ?:
'[!_]*') .
'_' . md5($this->file) .
'_*'
535 if ($this->file && $this->page) {
537 $GLOBALS[
'egotec_conf'][
'var_dir']
539 . $this->page->getSite()->name .
'/'
540 . $this->page->getSite()->language .
'/'
541 . $this->page->field[
'id'] .
'/'
542 .
'[!_]*_' . md5($this->file) .
'_*'
544 if (preg_match(
'/^([^_]+)_/', basename($file), $matches)) {
546 'format' => $format = $matches[1],
547 'label' => self::$convert_types[$format][
'label'],
563 private function detectMimeType() {
564 require_once
'base/Ego_MimeType.php';
566 $this->mime_type = $mime->autoDetect($this->file);
576 public function error($image =
false, $code = 404) {
579 $forced_error_image = [];
580 if (($this->is_image || $image || !empty($forced_error_image = $this->forceErrorImage())) && !$this->
error) {
582 if (class_exists(
'Imagick')) {
583 $width = $this->page ? $this->page->extra[
'origImgWidth'] : 0;
584 if (!is_numeric($width) || $_REQUEST[
'width']) {
585 $width = (int) ($_REQUEST[
'width'] ?? $forced_error_image[
'width']);
587 $height = $this->page ? $this->page->extra[
'origImgHeight'] : 0;
588 if (!is_numeric($height) || $_REQUEST[
'height']) {
589 $height = (int) ($_REQUEST[
'height'] ?? $forced_error_image[
'height']);
592 if ($width && $height) {
593 $this->file = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'transform');
595 $image =
new Imagick();
596 $draw =
new ImagickDraw();
597 $image->newImage($width, $height,
new ImagickPixel(
'grey'));
599 $font_size = ceil(min(array($width, $height)) / 6);
600 $draw->setFillColor(
'lightgrey');
601 $draw->setFontSize($font_size);
602 $draw->setTextAlignment(Imagick::ALIGN_CENTER);
603 $image->annotateImage(
606 ceil($height / 2) + ceil($font_size / 2),
610 $image->setImageFormat(
'png');
611 $image->writeImage($this->file);
615 $error_image =
false;
619 $this->file = $GLOBALS[
'egotec_conf'][
'egotec_dir'] .
'pub' .
620 DIRECTORY_SEPARATOR .
'missing_file.gif';
622 $this->detectMimeType();
623 $this->is_valid =
true;
625 $error = $this->
read();
626 } elseif ($this->site) {
627 $error = $this->site->getErrorPage();
630 $error = $site->getErrorPage();
642 private function forceErrorImage() {
646 $this->mime_type ==
'image/svg+xml'
647 || ($this->pool && mb_substr(mb_strtolower($this->pool), -4) ==
'.svg')
668 private function prepend(&$page, &$site, &$auth, &$smarty) {
673 && ($file = $site->getSiteFile($page->field[
'type'].DIRECTORY_SEPARATOR.
'index.php'))
695 if ($this->name !=
'') {
697 } elseif ($this->pool) {
699 } elseif ($this->page) {
700 $suffix =
'.'.$this->page->extra[
'image_type'];
702 '/'.preg_quote($suffix,
'/').
'$/i',
704 strtr($this->page->field[
'name'],
'/\:*?"<>|',
'_________')
707 return basename($this->file);
717 private function setDefaultHeaders($length = 0) {
718 if (!empty($this->etag)) {
722 $t = $this->page ? $this->site->getCacheExpire() : 0;
734 $_SERVER[
'HTTPS'] ==
'on'
736 mb_strtolower($this->page->extra[
'image_type']),
737 array(
'pdf',
'doc',
'docx',
'dot')
743 $this->page->field[
'cache']&2
744 && $GLOBALS[
'auth']->isNobody()
753 if (!$GLOBALS[
'egotec_conf'][
'no_content_length_header']) {
755 $length = $this->getFilesize($this->file);
761 if ($this->page->extra[
'meta_robots'] && $this->page->extra[
'meta_robots'] !=
'index') {
772 private function setSingleHeaders() {
778 $this->setDefaultHeaders();
781 readfile_chunked($this->file);
789 private function setRangeHeaders() {
790 $fp = @fopen($this->file,
'rb');
791 $size = $this->getFilesize($this->file);
795 if (isset($_SERVER[
'HTTP_RANGE'])) {
797 [, $range] = explode(
'=', $_SERVER[
'HTTP_RANGE'], 2);
798 if (strpos($range,
',') !==
false) {
800 if ($this->multipart_support) {
801 $boundary = md5(
'multipart_byteranges');
805 foreach (explode(
',', $range) as $multi_range) {
806 $multi_range = explode(
'-', trim($multi_range));
807 if ($multi_range[0] ==
'-') {
808 $start = $size - substr($multi_range, 1);
811 $start = $multi_range[0];
812 $end = (isset($multi_range[1]) && is_numeric($multi_range[1])) ? $multi_range[1] : $size;
816 echo
"--{$boundary}\r\n";
817 echo
"Content-Type: {$this->mime_type}\r\n";
818 echo
"Content-Range: bytes $start-$end/$size\r\n\r\n";
819 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
820 if ($p + $buffer > $end) {
821 $buffer = $end - $p + 1;
824 echo fread($fp, $buffer);
829 echo
"--{$boundary}--\r\n\r\n";
833 $this->setDownloadHeaders();
838 if ($range[0] ==
'-') {
839 $c_start = $size - substr($range, 1);
841 $range = explode(
'-', $range);
842 $c_start = $range[0];
843 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
845 $c_end = $c_end > $end ? $end : $c_end;
846 if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
853 $length = $end - $start + 1;
859 $this->setDefaultHeaders($length);
861 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
862 if ($p + $buffer > $end) {
863 $buffer = $end - $p + 1;
866 echo fread($fp, $buffer);
877 private function setDownloadHeaders() {
882 $this->setDefaultHeaders();
885 readfile_chunked($this->file);
894 public function read($download =
false) {
898 && $_SERVER[
'HTTP_IF_NONE_MATCH'] ==
'"' . $this->etag .
'"'
899 && $GLOBALS[
'auth']->isNobody()
906 if ($this->isValid($download)) {
907 $this->prepend($this->page, $this->site, $GLOBALS[
'auth'], $GLOBALS[
'smarty']);
911 $GLOBALS[
'egotec_conf'][
'dev'][
'images']
920 $modify_keys = array(
'clip',
'rotation',
'mirror',
'grayscale');
921 if ($_REQUEST[
'original'] && !$GLOBALS[
'auth']->isNobody()) {
923 unset($_REQUEST[
'width'], $_REQUEST[
'height']);
926 $modify_keys = array(
'rotation',
'mirror',
'grayscale');
929 foreach ($modify_keys as $param) {
930 if (isset($_REQUEST[$param])) {
931 $modify[$param] = $_REQUEST[$param];
934 if (isset($this->info[$param]) && !empty($this->info[$param])) {
935 $modify[$param] = $this->info[$param];
937 } elseif ($this->page->field[
'type'] ==
'multimedia/image') {
938 if (isset($this->page->extra[
'edit'][$param])) {
939 $modify[$param] = $this->page->extra[
'edit'][$param];
946 (!$download || !empty($modify))
948 && ($_REQUEST[
'width']
949 || $_REQUEST[
'height']
950 || $this->quality != 100
951 || !$this->web_format
956 $this->
transform((
int) $_REQUEST[
'width'], (
int) $_REQUEST[
'height'], $modify);
958 $this->
error(
true, 406);
964 && @is_dir($this->file)
971 && $this->page->field[
'type'] ==
'multimedia/category'
972 && !empty($this->site->admin[
'allow_download'])
973 && !empty($this->page->extra[
'allow_download'])
976 $this->file = $this->page->export();
977 $this->detectMimeType();
979 $this->page->extra[
'image_type'] =
'tar.gz';
982 $this->setDownloadHeaders();
988 isset($_SERVER[
'HTTP_RANGE'])
991 !preg_match(
'/MSIE (.*?);/', $_SERVER[
'HTTP_USER_AGENT'], $matches)
996 $this->setRangeHeaders();
1000 $this->setSingleHeaders();
1005 && !empty($this->cache)
1006 && ($this->page->field[
'cache']&3) != 0
1007 && !$GLOBALS[
'no_cache']
1011 'headers' => $GLOBALS[
'egotec'][
'response_headers'],
1012 'stats' => $GLOBALS[
'stats'],
1013 'type' => $this->page->field[
'type']
1015 $this->site->setCacheEntry($this->cache .
'.info', $info);
1016 $this->site->setCacheEntry($this->cache, $this->file);
1019 if ($this->temporary) {
1020 @unlink($this->file);
1024 return $this->
error($this->page && strpos($this->page->extra[
'mime_type'],
'image/') === 0);
1034 return $this->
read(
true);
1048 public function pdf($name =
'', $temporary =
true, $cookie =
true, $return = 1) {
1049 if ($this->isValid()) {
1051 $smarty = $GLOBALS[
'smarty'];
1052 $site = $this->site;
1053 $page = $this->page;
1055 if ($cookie && !empty($_COOKIE[EGOTEC])) {
1056 $context = stream_context_create(array(
1059 'header' =>
"Cookie: ".EGOTEC.
"=".$_COOKIE[EGOTEC].
"\r\n"
1064 if (!empty($name)) {
1067 $_REQUEST[
'title'] = $this->
getName();
1070 $no_pdf_header =
true;
1071 include(
'pdf/pdf_create.php');
1074 $pdf_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'output'.md5(microtime()).
'.pdf';
1089 return $this->
read();
1095 return $this->
error();
1106 public function transform($width, $height, $modify = array()) {
1107 if ($this->is_image) {
1109 $output_transform = $this->page && method_exists($this->page,
'outputTransform');
1112 $output_watermark =
'';
1115 $list = md5($_REQUEST[
'dir']);
1116 $key = md5($this->pool);
1117 if ($this->page->extra[
'mediapool'][$list][$key][
'watermark']) {
1118 $output_watermark = $this->page->extra[
'mediapool'][$list][$key][
'watermark'];
1120 } elseif ($this->page) {
1122 $inherit = $this->page->inheritExtra(array(
'watermark'));
1123 if ($inherit[
'watermark']) {
1124 $output_watermark = $inherit[
'watermark'];
1129 $quality_mime_types = array(
'image/jpeg',
'image/jpg',
'image/webp',
'image/avif');
1130 $quality = in_array($this->mime_type, $quality_mime_types) ? $this->quality : 0;
1132 if ($width > 0 || $height > 0 || !empty($modify) || $output_transform || $output_watermark || $quality) {
1133 require_once
'base/Ego_Image.php';
1137 if ($width > $size[0] || $height > $size[1]) {
1142 if (!$_REQUEST[
'max'] || $size[0] > $width || $size[1] > $height || !empty($modify)) {
1143 $dir = $GLOBALS[
'egotec_conf'][
'cachemedia_dir'];
1145 $dir .= $this->site->name . DIRECTORY_SEPARATOR . $this->site->language . DIRECTORY_SEPARATOR . $this->page->field[
'id'] . DIRECTORY_SEPARATOR;
1146 $dir .=
Ego_System::dateEncode($_REQUEST[
'c_date'] ? $_REQUEST[
'c_date'] : $this->page->field[
'c_date']) .
1147 DIRECTORY_SEPARATOR;
1149 $dir .=
'_output' . DIRECTORY_SEPARATOR;
1153 $file = $dir . $width .
'x' . $height .
'x' . $this->quality . ($this->web_format ?
'' :
'_jpg');
1155 $file .=
'_' . str_replace(
'.',
'_', base64_encode($this->pool));
1156 } elseif (!$this->page) {
1157 $file .=
'_' . md5($this->file);
1159 if ($output_watermark) {
1160 $file .=
'_' . md5($output_watermark);
1162 if ($this->converted) {
1163 $file .=
'_' . $this->converted;
1165 if (!empty($modify)) {
1166 $file .=
'_' . md5(serialize($modify));
1170 $output_cache = $this->page && method_exists($this->page,
'outputCache');
1173 !$_REQUEST[
'c_date']
1175 && (!$output_cache || $this->page->outputCache($width, $height))
1179 $this->file = $file;
1184 !$_REQUEST[
'c_date']
1185 && $size[0] == $width
1186 && $size[1] == $height
1188 && (!in_array($this->mime_type, $quality_mime_types)
1189 || $this->quality == 100)
1190 && !$output_transform
1191 && !$output_watermark
1198 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'transform');
1201 $imageTransform->load($tmp);
1204 if (!empty($modify)) {
1206 if ($modify[
'mirror']) {
1207 if (strpos($modify[
'mirror'],
'v') !==
false) {
1208 $imageTransform->mirror(
true,
false);
1210 if (strpos($modify[
'mirror'],
'h') !==
false) {
1211 $imageTransform->mirror(
false,
true);
1216 if ($modify[
'rotation']) {
1217 $imageTransform->rotate((
int) $modify[
'rotation']);
1221 if ($modify[
'clip']) {
1222 [$x1, $y1, $x2, $y2] = explode(
',', $modify[
'clip'], 4);
1223 $cwidth = $x2 - $x1;
1224 $cheight = $y2 - $y1;
1226 $imageTransform->crop($x1, $y1, $x2, $y2);
1229 $size[1] = $cheight;
1232 if ($width > $cwidth) {
1234 } elseif (!$width) {
1235 $width = (int)round($cwidth * ($height / $cheight));
1237 if ($height > $cheight) {
1239 } elseif (!$height) {
1240 $height = (int)round($cheight * ($width / $cwidth));
1245 if ($modify[
'grayscale']) {
1246 $imageTransform->grayscale();
1250 if ($_REQUEST[
'max']) {
1254 $h = (int)round($size[1] * ($width / $size[0]));
1256 if ($height && $h > $height) {
1258 $w = (int)round($w * ($height / $h));
1261 $imageTransform->resize($w, $h);
1263 if ($width && $height) {
1265 $imageTransform->resize($width, $height);
1266 }
else if ($width) {
1268 $imageTransform->scaleByX($width);
1269 }
else if ($height) {
1271 $imageTransform->scaleByY($height);
1276 if ($output_transform) {
1277 $this->page->outputTransform($imageTransform, $tmp, $width, $height, $modify);
1281 if ($output_watermark) {
1282 $imageTransform->watermark($output_watermark);
1287 && $imageTransform->save($file, ($this->web_format ?
'' :
'jpeg'), $quality)
1289 $imageTransform->free();
1290 $this->file = $file;
1310 $this->file = $file;
1311 $this->detectMimeType();
1312 $this->is_valid =
true;
1321 @unlink($this->file);
1323 $this->is_valid =
false;
1334 $this->cache = $cache;
1335 $this->etag = $etag;
1345 $this->temporary = $temporary;
1356 if (@is_dir($path)) {
1358 $dir = $GLOBALS[
'egotec_conf'][
'tmp_dir'];
1359 $name = basename($path);
1365 $file = $name.
'.zip';
1366 require_once
'Archive/Zip.php';
1367 $zip =
new Archive_Zip($file);
1370 foreach (scandir($path) as $entry) {
1371 if (!in_array($entry, [
'.',
'..'])) {
1372 $files[] = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $entry;
1376 $zip->add($files, [
'remove_all_path' =>
true]);
1381 $file = $name.
'.tar.gz';
1382 require_once
'Archive/Tar.php';
1383 $zip =
new Archive_Tar($file,
'gz');
1384 $zip->_separator =
',';
1385 $zip->setIgnoreList(array($dir));
1386 $zip->createModify(rtrim($path, DIRECTORY_SEPARATOR),
'', $name);
1406 require_once
'workflow/Ego_Workflow.php';
1407 $workflow =
new Ego_Workflow($key);
1408 $source = $workflow->export();
1411 require_once
'base/template/Ego_Template.php';
1412 $template =
new Ego_Template($key);
1413 $source = $template->export();
1415 if (!empty($source)) {
1417 $output->setTemporary(
true);
1418 $output->download();
1432 private function getThumbnail($width, $height = 0, $pool =
'', $dir =
'', $params = []) {
1434 return $this->page->getThumbnail($width, $height, $pool, $dir, $params);
1456 private function getFilesize($file) {
1457 return (
int) @filesize($file);
static getDimensions($file)
createArchive($path, $type='tar')
convertImage($format, $reset=false)
error($image=false, $code=404)
static export($key, $type)
clearConvertedImages($format='')
__construct($source=null, $pool='', $dir='')
transform($width, $height, $modify=array())
pdf($name='', $temporary=true, $cookie=true, $return=1)
setCache($cache, $etag='')
static exec(String $command, Array $params=array(), &$output=null, &$return_var=null, $log=true)
static file_put_contents($filename, $data, $flags=0, $context=null)
static header($header, $replace=true)
static dateEncode($string)
static isDevMode($ignore=true)
static file_exists($file)
static mkdir($dir, $mode=0755, $recursive=true)
static file_get_contents($filename, $utf8=true, $context=null)
static copy($src, $dest, $except='', $useLinks=false, $noArchive=false, $preserveDate=false)
static byte_format($byte)