function images_tools_extrapage_imagestoolsresize($strPage, &$site) { if ($strPage != 'imagestoolsresize.php') { return false; } require SITE_PATH . 'core/lib/pimage.php'; if (!isset($_GET['img']) || !isset($_GET['width']) || !isset($_GET['height'])) { return false; } $strImgUrl = urldecode($_GET['img']); if (strstr($strImgUrl, '..') !== FALSE) { return false; } //check that image is a sub file of POLLEN MEDIAS directory if (!($oDirUpload = getFileObjectAndFind(MEDIAS_PATH))) { return false; } if (strstr($strImgUrl, $oDirUpload->getUrl()) === FALSE) { return false; } $strImgUrl = str_replace($oDirUpload->getUrl(), '', $strImgUrl); if (!($oImage = getFileObjectAndFind($oDirUpload->path . SLASH . str_replace('/', SLASH, $strImgUrl)))) { return false; } $iWidth = $_GET['width']; $iHeight = $_GET['height']; //generate the image resized, first copy the original image, then generate the resized image $oImageResize = new PImage(CACHE_DIR . 'thumbnails' . SLASH . $iWidth . 'x' . $iHeight . SLASH . $oImage->getRelativePath()); //create resized image if not exits if (!is_file($oImageResize->path)) { if (!is_dir($oImageResize->getParentPath())) { $oDir = new PDir($oImageResize->getParentPath()); if (!$oDir->mkdir()) { return false; } } if (!$oImage->Copy($oImageResize->getName(), $oImageResize->getParentPath())) { return false; } if (!$oImageResize->Resize($iWidth, $iHeight)) { return false; } } //at this point image must exists, if not return if (!is_file($oImageResize->path)) { return false; } //just set the header and read the image header('Content-type: image/' . $oImage->getExtension()); readfile($oImageResize->path); return true; }