/**
  * 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);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Retrieve list of forms where captcha must be shown
  *
  * For frontend this list is based on current website
  *
  * @return array
  */
 protected function _getTargetForms()
 {
     $formsString = (string) $this->_captchaData->getConfig('forms');
     return explode(',', $formsString);
 }
Exemplo n.º 3
0
 /**
  * @covers \Magento\Captcha\Helper\Data::getConfig
  */
 public function testGetConfigNode()
 {
     $this->configMock->expects($this->once())->method('getValue')->with('customer/captcha/enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue('1'));
     $this->helper->getConfig('enable');
 }