add addTimestampToFilePath function

This commit is contained in:
2018-10-09 20:12:06 +02:00
parent ba2bd72b87
commit 3d2bacf380

View File

@@ -3,7 +3,7 @@
/**
* Main Class
* @author franzz
* @version 2.2
* @version 2.3
*/
abstract class Main extends PhpObject
{
@@ -90,6 +90,17 @@ abstract class Main extends PhpObject
$this->setMasks();
}
public function addTimestampToFilePath($sFile)
{
//Remove timestamp
$sFilePath = preg_replace('/(.*)\?[\d]{14}$/', '$1', $sFile);
//Remove base URL
$sLocalPath = str_replace($this->asContext['serv_name'], '', $sFilePath);
return file_exists($sLocalPath)?$sFilePath.'?'.date("YmdHis", filemtime($sLocalPath)):$sFile;
}
public function addUncaughtError($sError)
{
$this->addError('Uncaught errors:'."\n".$sError);
@@ -155,7 +166,7 @@ abstract class Main extends PhpObject
public static function getJsonResult($bSuccess, $sDesc, $asVars=array())
{
header('Content-type: application/json');
return json_encode(array('result'=>$bSuccess?self::SUCCESS:self::ERROR, 'desc'=>ToolBox::mb_ucwords($sDesc), 'data'=>$asVars));
return json_encode(array('result'=>$bSuccess?self::SUCCESS:self::ERROR, 'desc'=>$sDesc, 'data'=>$asVars));
}
}