diff --git a/favicon.ico b/images/favicon.ico similarity index 100% rename from favicon.ico rename to images/favicon.ico diff --git a/inc/functions.php b/inc/functions.php index 9d9af57..ea11a9f 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2,6 +2,8 @@ require_once 'settings.php'; +define(TMP_FOLDER, 'tmp/'); + function getPage($sPath, $asVars, $sType) { $bSavePage = Settings::DEBUG; @@ -9,7 +11,7 @@ function getPage($sPath, $asVars, $sType) { $asFileIds = array_filter($asVars); unset($asFileIds['_']); - $sFileName = $sPath.'.'.implode('.', $asFileIds).'.log'; + $sFileName = TMP_FOLDER.$sPath.'.'.implode('.', $asFileIds).'.log'; } if(!$bSavePage || !file_exists($sFileName) || date('dmY', filemtime($sFileName))!=date('dmY')) { @@ -45,10 +47,11 @@ function setPageMime($sType='html') if($sType!='html' && array_key_exists($sType, $asMainTypes)) header('Content-type: '.$asMainTypes[$sType].'/'.$sType); } -function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt) +function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt, $bForce=false) { - $sOutPath = 'images/'.$iFilmId.'_'.$sSize.'.'.$sImageExt; - if(!file_exists($sOutPath)) + $sOutPath = TMP_FOLDER.$iFilmId.'_'.$sSize.'.'.$sImageExt; + $bFileExist = file_exists($sOutPath); + if(!$bFileExist || $bForce) { $oImage = call_user_func('imagecreatefrom'.$sImageExt, $sinPath); $iImageX = imagesx($oImage); @@ -117,6 +120,10 @@ function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt) //Copy the content, excluding the border imagecopy($oCropImage, $oImage, 0, 0, $iLeft, $iTop, imagesx($oCropImage), imagesy($oCropImage)); + //Remove existing image + if($bFileExist) unlink($sOutPath); + + //Store image call_user_func_array('image'.$sImageExt, array($oCropImage, $sOutPath)); } diff --git a/index.php b/index.php index dd69948..a3c2ab6 100755 --- a/index.php +++ b/index.php @@ -12,7 +12,7 @@ switch($sAction) $sResult = getPage($asData['path'], $asData['vars'], $sType); break; case 'get_poster': - $sResult = getTrimImage($asData['id'], $asData['size'], $asData['url'], $sType); + $sResult = getTrimImage($asData['id'], $asData['size'], $asData['url'], $sType, $asData['force']); break; default: $sResult = file_get_contents('masks/index.html'); diff --git a/masks/index.html b/masks/index.html index 490141f..5c88693 100755 --- a/masks/index.html +++ b/masks/index.html @@ -4,8 +4,8 @@ - - + + diff --git a/script/ugc.js b/script/ugc.js index 0e03829..6622f9c 100755 --- a/script/ugc.js +++ b/script/ugc.js @@ -103,7 +103,12 @@ function Film(oSettings) this._anchor = $('
', {'class':'title'}) .append($('', {'class':'name', 'target':'_blank', 'href':this.consts.ugc_url+'film.html?id='+this.id()}) diff --git a/tmp/11000_medium.jpeg b/tmp/11000_medium.jpeg new file mode 100644 index 0000000..b104259 Binary files /dev/null and b/tmp/11000_medium.jpeg differ