image refresher
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user