id; if($loginId === null){ die('Error while authenticate'); } //check if the user has authorisation for this picture $access = Frontend_CategoryManager::isUserAuthorised($id, $loginId); if(!$access){ die('You don\'t have access to this picture'); } /* disabled for now... => bah oauis trous du cul de merde plus lent que ca tu meurt quoi... faut pas pousser les gars... //load login watermark $pictures = Frontend_ModuleFileManager::getItemFiles('login', $loginId, 'picture'); if(!empty($pictures)){ list($watermarkLogin) = $pictures; } if($login->watermark){ //$cacheBaseDirectory = realpath('classes/thirdParty/phpthumb/soap-cache/'); $cacheBaseDirectory = '/srv/cache/catwalkpictures.com/soap/'; $requestUri = $_SERVER['REQUEST_URI']; }else{*/ //$cacheBaseDirectory = realpath('classes/thirdParty/phpthumb/secure-cache/'); $cacheBaseDirectory = '/srv/cache/hyeres/web/'; $requestUri = '/secure-image,' . $id . ',' . $zoneId; $requestUri .= strrchr($_SERVER['REQUEST_URI'], '/'); //} //$ex = "/[^/]*/(.*)"; //$matches = preg_split($ex, $_SERVER['REQUEST_URI']); //basic authentification }else{ $zoneId = $_GET['zoneId']; if (!isset($_SESSION['login.id']) || empty($_SESSION['login.id'])) { $_SESSION['login.id']=6; } require_once(ROOT . '/inc/classes/customer/frontend/loginManager.php'); $loginManager = Frontend_loginManager::getInstance(); // disconnect the whatsnew user if needed /*if($loginManager->isAuthenticated()){ if($_SESSION['login.id'] == 558 && $_SERVER['REQUEST_URI'] != '/whatsnew,en,20,4,1.html'){ die($_SERVER['REQUEST_URI'] . 'hello'); $loginManager->disconnectWhatsNewUser(); } }*/ //&& $_SERVER['REMOTE_ADDR'] != '91.199.4.130' && $_SERVER['REMOTE_ADDR'] != '176.31.131.165' if(!$loginManager->isAuthenticated() && !isset($_SESSION[BACKEND_USER_ID_SESSION_KEY]) && $_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR'] ){ // not a website user, not a backend user, not a local server script die('Error login'); } // Load the websiteId to set the good cache path $pictureWebsiteId = Frontend_ModuleFileManager::loadPictureWebsiteId($id); if ($pictureWebsiteId == 2){ $cacheBaseDirectory = realpath('/srv/cache/hyeres/web/'); //$cacheBaseDirectory = realpath('classes/thirdParty/phpthumb/secure-cache/'); } else { $cacheBaseDirectory = realpath('/srv/cache/planetpictures.eu/web/'); //$cacheBaseDirectory = realpath('classes/thirdParty/phpthumb/secure-cache/'); } $requestUri = $_SERVER['REQUEST_URI']; } $originalCacheFileExtension = strrchr($requestUri, '.'); $cache = frontend_ModuleFileManager::loadCacheInfo($requestUri, $cacheBaseDirectory); $cacheFilename = $cache->cacheFilename; $cacheFolder = $cache->cacheFolder; // checking for cached file //$timestamp = (int)Frontend_ModuleFileManager::loadModuleFileTimestamp($id); //$timestamp <= filemtime($cacheFilename) // && $zoneId != 9 //var_dump($cacheFilename); die(); if (@is_file($cacheFilename)) { $cacheFileModifiedTime = filemtime($cacheFilename); // checkin for MODIFIED_SINCE http header header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cacheFileModifiedTime) . ' GMT'); if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && @$_SERVER['SERVER_PROTOCOL'] && ($cacheFileModifiedTime == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))) { header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified'); die(); } $mimeTypes = array( '.gif' => 'image/gif', '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.png' => 'image/png' ); // outputting cached file header('Content-Type: ' . $mimeTypes[$originalCacheFileExtension]); header('Content-Length: '. filesize($cacheFilename)); header('Cache-Control: maxage=345600'); header('Expires: ' . date('D, d M Y H:i:s', (time()+345600)) . ' GMT+0200'); @readfile($cacheFilename); die(); } /* $to = 'mat@xt-creations.fr'; $subject = 'passage generation live aws...'; $message = $timestamp.' <= '.filemtime($cacheFilename).' '.$cacheFilename; $headers = 'From: bug@catwalkpictures.com' . "\r\n" . 'Reply-To: bug@catwalkpictures.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers, '-f bug@catwalkpictures.com'); */ // checking for externally set filename $filename = null; if (isset($_imageResizerFilename)) { $filename = $_imageResizerFilename; } // loading module file objects if (is_null($filename)) { $moduleFile = frontend_ModuleFileManager::loadModuleFile($id); if (is_null($moduleFile)) { die('/moduleFile/'); } $filename = $moduleFile->filename; } $moduleFileZone = frontend_ModuleFileManager::loadModuleFileZone($zoneId); if (is_null($moduleFileZone)) { die('/moduleFileZone/'); } if(!isset($loginId)){ $loginId = null; } //var_dump($moduleFile->awsRelativeFilename); die(); require_once(ROOT . '/inc/classes/customer/frontend/remoteThumbnailer.php'); $remoteThumbnailer = new remoteThumbnailer(); $remoteThumbnailSettings = new remoteThumbnailSettings( $moduleFile->awsRelativeFilename, $moduleFileZone->width, $moduleFileZone->height, $moduleFileZone->crop, $moduleFileZone->jpegQuality, $loginId); $remoteThumbnailer->receiver = 'http://hyeresthumbs.catwalkarchives.com/resize.php'; $remoteThumbnailer->challenge = 'aezpuiarpizeurpazrfazerazerazrazerazer'; //$startTime = microtime(true); $remoteThumbnailer->getThumbnail($remoteThumbnailSettings); //$totalTime = microtime(true) - $startTime; //file_put_contents('/tmp/awsRequestTime', $totalTime); $pictureRawData = $remoteThumbnailer->getRawData(); // caching file if (!file_exists($cacheFolder)) { mkdir($cacheFolder, 0755, true); } if ((file_exists($cacheFilename) && is_writable($cacheFilename)) || is_writable($cacheFolder)) { file_put_contents($cacheFilename , $pictureRawData); if(@filesize($cacheFilename) == 0){ @unlink($cacheFilename); } } $remoteThumbnailer->showThumbnail(); ?>