2016-01-19 15:30:55 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
|
|
|
*/
|
|
|
|
|
2017-11-10 13:36:09 +01:00
|
|
|
use OxidEsales\Eshop\Core\DatabaseProvider;
|
2016-01-19 15:30:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class defines what module does on Shop events.
|
|
|
|
*/
|
|
|
|
class oeCaptchaEvents
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Add table oecaptcha.
|
|
|
|
*/
|
|
|
|
public static function addCaptchaTable()
|
|
|
|
{
|
|
|
|
$query = "CREATE TABLE IF NOT EXISTS `oecaptcha` (" .
|
|
|
|
"`OXID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Captcha id'," .
|
|
|
|
"`OXHASH` char(32) NOT NULL default '' COMMENT 'Hash'," .
|
|
|
|
"`OXTIME` int(11) NOT NULL COMMENT 'Validation time'," .
|
|
|
|
"`OXTIMESTAMP` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT 'Timestamp'," .
|
|
|
|
"PRIMARY KEY (`OXID`), " .
|
|
|
|
"KEY `OXID` (`OXID`,`OXHASH`), " .
|
|
|
|
"KEY `OXTIME` (`OXTIME`) " .
|
|
|
|
") ENGINE=MEMORY AUTO_INCREMENT=1 COMMENT 'If session is not available, this is where captcha information is stored';";
|
|
|
|
|
2017-11-10 13:36:09 +01:00
|
|
|
DatabaseProvider::getDb()->execute($query);
|
2016-01-19 15:30:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove table oecaptcha.
|
|
|
|
* NOTE: table oecaptcha contains temporary data if any and can be
|
|
|
|
* removed without side effects on module deactivation
|
|
|
|
*/
|
|
|
|
public static function removeCaptchaTable()
|
|
|
|
{
|
|
|
|
$query = "DROP TABLE IF EXISTS `oecaptcha`";
|
|
|
|
|
2017-11-10 13:36:09 +01:00
|
|
|
DatabaseProvider::getDb()->execute($query);
|
2016-01-19 15:30:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute action on activate event
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
|
|
|
public static function onActivate()
|
|
|
|
{
|
|
|
|
self::addCaptchaTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute action on deactivate event
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
|
|
|
public static function onDeactivate()
|
|
|
|
{
|
|
|
|
self::removeCaptchaTable();
|
|
|
|
}
|
|
|
|
}
|