/**
  * Delete Expired Captcha Images for specific website
  *
  * @param \Magento\Captcha\Helper\Data $helper
  * @param \Magento\Store\Model\Website|null $website
  * @param \Magento\Store\Model\Store|null $store
  * @return void
  */
 protected function _deleteExpiredImagesForWebsite(\Magento\Captcha\Helper\Data $helper, \Magento\Store\Model\Website $website = null, \Magento\Store\Model\Store $store = null)
 {
     $expire = time() - $helper->getConfig('timeout', $store) * 60;
     $imageDirectory = $this->_mediaDirectory->getRelativePath($helper->getImgDir($website));
     foreach ($this->_mediaDirectory->read($imageDirectory) as $filePath) {
         if ($this->_mediaDirectory->isFile($filePath) && pathinfo($filePath, PATHINFO_EXTENSION) == 'png' && $this->_mediaDirectory->stat($filePath)['mtime'] < $expire) {
             $this->_mediaDirectory->delete($filePath);
         }
     }
 }
Example #2
0
 /**
  * Return content of backup file
  *
  * @return string
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function &getFile()
 {
     if (!$this->exists()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.'));
     }
     return $this->varDirectory->read($this->_getFilePath());
 }