mirror of
https://git.d3data.de/3rdParty/captcha-module.git
synced 2025-01-31 07:18:40 +01:00
Merge branch 'minimal_port-OXDEV-338'
This commit is contained in:
commit
c219debfd6
24
CHANGELOG.md
Normal file
24
CHANGELOG.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Change Log for OE Tags Module
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
- Adapted the module to be compatible with OXID eShop 6.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/OXIDprojects/captcha-module/compare/HEAD...HEAD
|
@ -3,6 +3,8 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||
|
||||
/**
|
||||
* Class handling CAPTCHA image
|
||||
* This class requires utility file utils/verificationimg.php as image generator
|
||||
@ -76,7 +78,7 @@ class oeCaptcha extends oxSuperCfg
|
||||
$hashArray[$hash] = array($textHash => $time);
|
||||
$session->setVariable('captchaHashes', $hashArray);
|
||||
} else {
|
||||
$database = oxDb::getDb();
|
||||
$database = DatabaseProvider::getDb();
|
||||
$query = "insert into oecaptcha (oxhash, oxtime) values (" .
|
||||
$database->quote($textHash) . ", " . $database->quote($time) . ")";
|
||||
$database->execute($query);
|
||||
@ -110,10 +112,14 @@ class oeCaptcha extends oxSuperCfg
|
||||
*/
|
||||
public function getImageUrl()
|
||||
{
|
||||
$url = $this->getConfig()->getCurrentShopUrl() . 'modules/oe/captcha/core/utils/verificationimg.php?e_mac=';
|
||||
$key = $this->getConfig()->getConfigParam('oecaptchakey');
|
||||
$key = empty($key) ? null : $key;
|
||||
$url .= oxRegistry::getUtils()->strMan($this->getText(), $key);
|
||||
$config = \OxidEsales\Eshop\Core\Registry::getConfig();
|
||||
$url = $config->getCurrentShopUrl() . 'modules/oe/captcha/core/utils/verificationimg.php?e_mac=';
|
||||
$key = $config->getConfigParam('oecaptchakey');
|
||||
|
||||
$key = $key ? $key : $config->getConfigParam('sConfigKey');
|
||||
|
||||
$encryptor = new \OxidEsales\Eshop\Core\Encryptor();
|
||||
$url .= $encryptor->encrypt($this->getText(), $key);
|
||||
|
||||
return $url;
|
||||
}
|
||||
@ -213,7 +219,7 @@ class oeCaptcha extends oxSuperCfg
|
||||
*/
|
||||
protected function passFromDb($macHash, $hash, $time)
|
||||
{
|
||||
$database = oxDb::getDb();
|
||||
$database = DatabaseProvider::getDb();
|
||||
$where = "where oxid = " . $database->quote($macHash) . " and oxhash = " . $database->quote($hash);
|
||||
$query = "select 1 from oecaptcha " . $where;
|
||||
$pass = (bool) $database->getOne($query, false, false);
|
||||
|
@ -3,6 +3,7 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||
|
||||
/**
|
||||
* Class defines what module does on Shop events.
|
||||
@ -24,8 +25,7 @@ class oeCaptchaEvents
|
||||
"KEY `OXTIME` (`OXTIME`) " .
|
||||
") ENGINE=MEMORY AUTO_INCREMENT=1 COMMENT 'If session is not available, this is where captcha information is stored';";
|
||||
|
||||
oxDb::getDb()->execute($query);
|
||||
|
||||
DatabaseProvider::getDb()->execute($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ class oeCaptchaEvents
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS `oecaptcha`";
|
||||
|
||||
oxDb::getDb()->execute($query);
|
||||
DatabaseProvider::getDb()->execute($query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,8 +62,6 @@ if (!function_exists('generateVerificationImg')) {
|
||||
|
||||
if (!function_exists('strRem')) {
|
||||
|
||||
require_once getShopBasePath() . '/core/oxdecryptor.php';
|
||||
|
||||
/**
|
||||
* OXID specific string manipulation method
|
||||
*
|
||||
@ -73,10 +71,10 @@ if (!function_exists('strRem')) {
|
||||
*/
|
||||
function strRem($value)
|
||||
{
|
||||
$decryptor = new oxDecryptor;
|
||||
|
||||
$key = oxRegistry::getConfig()->getConfigParam('oecaptchakey');
|
||||
$decryptor = new \OxidEsales\Eshop\Core\Decryptor();
|
||||
$config = oxRegistry::getConfig();
|
||||
|
||||
$key = $config->getConfigParam('oecaptchakey');
|
||||
if (empty($key)) {
|
||||
$key = getOxConfKey();
|
||||
}
|
||||
@ -94,10 +92,9 @@ if (!function_exists('getOxConfKey')) {
|
||||
*/
|
||||
function getOxConfKey()
|
||||
{
|
||||
$fileName = getShopBasePath() . '/core/oxconfk.php';
|
||||
$configFile = new oxConfigFile($fileName);
|
||||
|
||||
return $configFile->getVar("sConfigKey");
|
||||
$config = oxRegistry::getConfig();
|
||||
$configKey = $config->getConfigParam('sConfigKey') ?: \OxidEsales\Eshop\Core\Config::DEFAULT_CONFIG_KEY;
|
||||
return $configKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
10
metadata.php
10
metadata.php
@ -33,7 +33,7 @@ $aModule = array(
|
||||
'en' => 'OXID eSales Simple Captcha Module',
|
||||
),
|
||||
'thumbnail' => 'out/pictures/picture.png',
|
||||
'version' => '1.0.0',
|
||||
'version' => '2.0.0',
|
||||
'author' => 'OXID eSales AG',
|
||||
'url' => 'http://www.oxid-esales.com/',
|
||||
'email' => '',
|
||||
@ -49,10 +49,10 @@ $aModule = array(
|
||||
),
|
||||
'templates' => array(),
|
||||
'blocks' => array(
|
||||
array('template' => 'form/contact.tpl', 'block'=>'captcha_form', 'file'=>'/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/invite.tpl', 'block'=>'captcha_form', 'file'=>'/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/pricealarm.tpl', 'block'=>'captcha_form', 'file'=>'/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/suggest.tpl', 'block'=>'captcha_form', 'file'=>'/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/contact.tpl', 'block'=>'captcha_form', 'file'=>'/application/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/privatesales/invite.tpl', 'block'=>'captcha_form', 'file'=>'/application/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/pricealarm.tpl', 'block'=>'captcha_form', 'file'=>'/application/views/blocks/captcha_form.tpl'),
|
||||
array('template' => 'form/suggest.tpl', 'block'=>'captcha_form', 'file'=>'/application/views/blocks/captcha_form.tpl'),
|
||||
),
|
||||
'settings' => array(
|
||||
array('group' => 'main', 'name' => 'oecaptchakey', 'type' => 'str', 'value' => ''),
|
||||
|
30
tests/phpunit.xml
Normal file
30
tests/phpunit.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<phpunit backupGlobals="true"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap.php"
|
||||
cacheTokens="true"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
forceCoversAnnotation="false"
|
||||
mapTestClassNameToCoveredClassName="false"
|
||||
printerClass="PHPUnit_TextUI_ResultPrinter"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
|
||||
verbose="false">
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">../tests</directory>
|
||||
<directory suffix=".php">../translations</directory>
|
||||
<directory suffix=".php">../views</directory>
|
||||
<file>../metadata.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -3,7 +3,9 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
abstract class CaptchaTestCase extends OxidTestCase
|
||||
use OxidEsales\EshopCommunity\Core\DatabaseProvider;
|
||||
|
||||
abstract class CaptchaTestCase extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Fixture set up.
|
||||
@ -23,7 +25,7 @@ abstract class CaptchaTestCase extends OxidTestCase
|
||||
) ENGINE=MEMORY AUTO_INCREMENT=1 COMMENT 'If session is not available, this is where captcha information is stored';
|
||||
";
|
||||
|
||||
oxDb::getDb()->execute($query);
|
||||
DatabaseProvider::getDb()->execute($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +34,7 @@ abstract class CaptchaTestCase extends OxidTestCase
|
||||
protected function tearDown()
|
||||
{
|
||||
$query = "DROP TABLE `oecaptcha`";
|
||||
oxDb::getDb()->execute($query);
|
||||
DatabaseProvider::getDb()->execute($query);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../CaptchaTestCase.php';
|
||||
|
||||
class oeCaptchaWArticleDetailsTest extends CaptchaTestCase
|
||||
{
|
||||
public function testGetCaptcha()
|
||||
{
|
||||
$articleDetails = oxNew('oxwarticledetails');
|
||||
$captcha = $articleDetails->getCaptcha();
|
||||
$this->assertInstanceOf("oeCaptcha", $captcha);
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\EshopCommunity\Core\DatabaseProvider;
|
||||
|
||||
require_once __DIR__ . '/../CaptchaTestCase.php';
|
||||
|
||||
class Unit_Core_oecaptchaEventsTest extends CaptchaTestCase
|
||||
@ -15,7 +17,7 @@ class Unit_Core_oecaptchaEventsTest extends CaptchaTestCase
|
||||
parent::setUp();
|
||||
|
||||
//Drop captcha table
|
||||
oxDb::getDB()->execute("DROP TABLE IF EXISTS `oecaptcha`");
|
||||
DatabaseProvider::getDB()->execute("DROP TABLE IF EXISTS `oecaptcha`");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,8 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\EshopCommunity\Core\DatabaseProvider;
|
||||
|
||||
require_once __DIR__ . '/../CaptchaTestCase.php';
|
||||
|
||||
class Unit_Core_oecaptchaTest extends CaptchaTestCase
|
||||
@ -50,7 +52,10 @@ class Unit_Core_oecaptchaTest extends CaptchaTestCase
|
||||
$captcha->expects($this->once())->method('getSession')->will($this->returnValue($session));
|
||||
|
||||
$hash = $captcha->getHash('test');
|
||||
$this->assertEquals(oxDb::getDb()->getOne('select LAST_INSERT_ID()', false, false), $hash);
|
||||
$this->assertEquals(DatabaseProvider::getDb()->getOne(
|
||||
'select LAST_INSERT_ID()',
|
||||
false
|
||||
), $hash);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +83,7 @@ class Unit_Core_oecaptchaTest extends CaptchaTestCase
|
||||
*/
|
||||
public function testGetImageUrl()
|
||||
{
|
||||
$this->setConfigParam('oecaptchakey', 'someTestCaptchaKey');
|
||||
$this->getConfig()->setConfigParam("oecaptchakey", 'someTestCaptchaKey');
|
||||
$this->captcha->setNonPublicVar('text', 'test1');
|
||||
$expected = $this->getConfig()->getShopUrl() . 'modules/oe/captcha/core/utils/verificationimg.php?e_mac=ox_MAsbCBYgVBoQ';
|
||||
|
||||
@ -90,7 +95,7 @@ class Unit_Core_oecaptchaTest extends CaptchaTestCase
|
||||
*/
|
||||
public function testGetImageUrlFallbackKey()
|
||||
{
|
||||
$this->setConfigParam('oecaptchakey', '');
|
||||
$this->getConfig()->setConfigParam("oecaptchakey", '');
|
||||
$this->captcha->setNonPublicVar('text', 'test1');
|
||||
|
||||
$expected = $this->getConfig()->getShopUrl() . 'modules/oe/captcha/core/utils/verificationimg.php?e_mac=ox_MB4FUUYlYlld';
|
||||
@ -127,7 +132,10 @@ class Unit_Core_oecaptchaTest extends CaptchaTestCase
|
||||
$captcha->setSession($session);
|
||||
|
||||
$captcha->getHash('3at8u');
|
||||
$hash = oxDb::getDb()->getOne('select LAST_INSERT_ID()', false, false);
|
||||
$hash = DatabaseProvider::getDb()->getOne(
|
||||
'select LAST_INSERT_ID()',
|
||||
false
|
||||
);
|
||||
$this->assertTrue($captcha->pass('3at8u', $hash));
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\EshopCommunity\Core\DatabaseProvider;
|
||||
|
||||
require_once __DIR__ . '/../CaptchaTestCase.php';
|
||||
|
||||
class Unit_pricealarmTest extends CaptchaTestCase
|
||||
@ -33,7 +35,7 @@ class Unit_pricealarmTest extends CaptchaTestCase
|
||||
$this->assertEquals(2, $priceAlarm->getNonPublicVar('_iPriceAlarmStatus'));
|
||||
|
||||
$query = 'select count(oxid) from oxpricealarm';
|
||||
$this->assertEquals(0, oxDb::getDb()->getOne($query));
|
||||
$this->assertEquals(0, DatabaseProvider::getDb()->getOne($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +52,7 @@ class Unit_pricealarmTest extends CaptchaTestCase
|
||||
$this->assertEquals(0, $priceAlarm->getNonPublicVar('_iPriceAlarmStatus'));
|
||||
|
||||
$query = 'select count(oxid) from oxpricealarm';
|
||||
$this->assertEquals(0, oxDb::getDb()->getOne($query));
|
||||
$this->assertEquals(0, DatabaseProvider::getDb()->getOne($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +77,7 @@ class Unit_pricealarmTest extends CaptchaTestCase
|
||||
$this->assertEquals(999, $priceAlarm->getNonPublicVar('_iPriceAlarmStatus'));
|
||||
|
||||
$query = 'select * from oxpricealarm';
|
||||
$alarm = oxDb::getDb(oxDB::FETCH_MODE_ASSOC)->getRow($query);
|
||||
$alarm = DatabaseProvider::getDb(oxDB::FETCH_MODE_ASSOC)->getRow($query);
|
||||
|
||||
$this->assertEquals($parameters['email'], $alarm['OXEMAIL']);
|
||||
$this->assertEquals($parameters['aid'], $alarm['OXARTID']);
|
||||
@ -103,7 +105,7 @@ class Unit_pricealarmTest extends CaptchaTestCase
|
||||
$priceAlarm->addme();
|
||||
|
||||
$query = 'select oxlang from oxpricealarm';
|
||||
$language = oxDb::getDb(oxDB::FETCH_MODE_ASSOC)->getOne($query);
|
||||
$language = DatabaseProvider::getDb(oxDB::FETCH_MODE_ASSOC)->getOne($query);
|
||||
|
||||
$this->assertEquals(1, $language);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
||||
*/
|
||||
|
||||
use OxidEsales\EshopCommunity\Core\DatabaseProvider;
|
||||
|
||||
require_once __DIR__ . '/../CaptchaTestCase.php';
|
||||
|
||||
class Unit_suggestTest extends CaptchaTestCase
|
||||
@ -15,10 +17,10 @@ class Unit_suggestTest extends CaptchaTestCase
|
||||
protected function tearDown()
|
||||
{
|
||||
$sDelete = "delete from oxrecommlists where oxid like 'testlist%'";
|
||||
oxDb::getDB()->execute($sDelete);
|
||||
DatabaseProvider::getDB()->execute($sDelete);
|
||||
|
||||
$sDelete = "delete from oxobject2list where oxlistid like 'testlist%'";
|
||||
oxDb::getDB()->execute($sDelete);
|
||||
DatabaseProvider::getDB()->execute($sDelete);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user