if ($x - $sizeX < $y - $sizeY) { $newSizeX = $x; $newSizeY = $sizeY; } else { $newSizeX = $sizeX; $newSizeY = $y; } } else { $newSizeX = $x ? $x : round($y * $sizeX / $sizeY); $newSizeY = $y ? $y : round($x * $sizeY / $sizeX); } //$resizedImage = $pathInfo['filename'] .'-'. $newSizeX .'-'. $newSizeY .($crop ? '-c' : '').'.'. $pathInfo['extension']; //resized image path $resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $module . '/' . $location . '/' . $resizedImage; if ($image->resize($newSizeX, $newSizeY, $resizedImagepathFS, true, $crop)) { //Send cache headers header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($resizedImagepathFS)) . ' GMT'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT'); //30 days header("Cache-Control: must-revalidate"); header("Pragma: public"); //send resized image to browser CMS_file::downloadFile($resizedImagepathFS); } else { //send 404 headers header('HTTP/1.x 404 Not Found', true, 404); //send image 404 if (file_exists(PATH_REALROOT_FS . '/img/404.png')) { CMS_file::downloadFile(PATH_REALROOT_FS . '/img/404.png'); } }
<textarea style="width:100%;height:300px;">' . htmlspecialchars(var_export($exportDatas, true)) . '</textarea> </fielset>'; break; case 'xml': $content .= ' <br /><a name="exportDatas"></a> <fieldset> <legend>' . $cms_language->getMessage(MESSAGE_PAGE_EXPORTED_DATAS) . '</legend> <textarea style="width:100%;height:300px;">' . htmlspecialchars($exportDatas) . '</textarea> </fielset>'; break; case 'patch': //check archive if (file_exists($exportDatas)) { //send to browser CMS_file::downloadFile($exportDatas, false, true, 'application/x-compressed'); $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_FILE_ERROR) . "\n"; } else { $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_ARCHIVE_ERROR) . "\n"; } break; default: $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_UNKNOWN_FORMAT) . "\n"; break; } break; } if ($cms_message) { $dialog->setActionMessage($cms_message); } //draw content
//get object item id $itemID = ''; if (preg_match('#^r[0-9]+_[0-9]+_.*#', $pathinfo['basename'])) { $itemID = preg_replace('#^r([0-9]+)_[0-9]+_.*#', '\\1', $pathinfo['basename']); } if (sensitiveIO::isPositiveInteger($itemID)) { if (!is_object($cms_user)) { //no user => LOGIN header('Location: ' . PATH_FRONTEND_SPECIAL_LOGIN_WR . '?referer=' . base64_encode($_SERVER['REQUEST_URI'])); exit; } else { $public = preg_match('#.*/(edited|edition)$#', $pathinfo['dirname']) ? false : true; $item = CMS_poly_object_catalog::getObjectByID($itemID, false, $public); if (!$item || !is_object($item) || !$item->userHasClearance($cms_user, CLEARANCE_MODULE_VIEW, true)) { if ($cms_user->getLogin() == DEFAULT_USER_LOGIN) { //no rights and anonymous => LOGIN header('Location: ' . PATH_FRONTEND_SPECIAL_LOGIN_WR . '?referer=' . base64_encode($_SERVER['REQUEST_URI'])); } else { //no rights and logged => 403 header('Location: ' . PATH_FORBIDDEN_WR . '?referer=' . base64_encode($_SERVER['REQUEST_URI'])); } exit; } } } } } } //send file to browser CMS_file::downloadFile($scriptFilename);
/** * Send the current file for download (inline or attachment) * * @param boolean $inline : the file is sent inline (default) or as attachment * @param boolean $deleteFile : delete the sended file at end of download (default : false) * @param mixed $forceContentType : false to auto get the mime type to send, or string to force a mime type * @return void or false if error * @access public * @static */ function download($inline = true, $deleteFile = false, $forceContentType = false) { if (!$this->exists()) { $this->raiseError("Can't donwload file which does not exist"); return false; } return CMS_file::downloadFile($this->_name, $inline, $deleteFile, $forceContentType); }