@ini_set('gd.jpeg_ignore_warning', 1);
$this->attachment = $attachment;
$this->attachmentData = $attachment->Data;
$this->attachRepo = $this->getAttachmentRepo();
$this->_options = \XF::options();
$this->font = \XF::getRootDirectory() . $this->font;
if(!empty($this->_options['watermarkerType']['font_path']))
{
$this->font = \XF::getRootDirectory() . $this->_options['watermarkerType']['font_path'];
}
if(!$this->_options['watermarkerType']['enabled_image'] && !$this->_options['watermarkerType']['enabled_text'])
{
return false;
}
$this->outputImage = $this->attachmentData->getAbstractedWatermarkerDataPath();
if(\XF::fs()->has($this->outputImage))
{
$simpleCache = \XF::app()->simpleCache();
$lastSettingsChange = $simpleCache->getValue('X0815\Watermarker', 'lastSettingsChange');
$fileAge = \XF::fs()->getTimestamp($this->outputImage);
if(
\XF::options()->watermarkerCacheRefresh != 0 &&
($fileAge >= $lastSettingsChange) &&
($fileAge > \XF::$time - (\XF::options()->watermarkerCacheRefresh * 86400))
)
{
$this->status = true;
}
}
$tempFile = \XF\Util\File::getTempFile();
$stream = \XF::fs()->readStream($this->attachmentData->getAbstractedDataPath());
@file_put_contents($tempFile, $stream, FILE_APPEND | LOCK_EX);
$this->inputImage = $tempFile;
if($this->status)
{
return false;
}