2018-10-17 23:48:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2022-09-26 15:22:26 +02:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2018-10-17 23:48:20 +02:00
|
|
|
*
|
2022-09-26 15:22:26 +02:00
|
|
|
* https://www.d3data.de
|
2018-10-17 23:48:20 +02:00
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2022-09-26 15:22:26 +02:00
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2018-10-17 23:48:20 +02:00
|
|
|
*/
|
|
|
|
|
2022-09-28 00:08:36 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-17 23:48:20 +02:00
|
|
|
namespace D3\Totp\Setup;
|
|
|
|
|
2022-09-28 00:08:36 +02:00
|
|
|
use OxidEsales\Eshop\Core\DatabaseProvider;
|
2018-10-17 23:48:20 +02:00
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
2022-09-30 00:06:20 +02:00
|
|
|
// @codeCoverageIgnoreStart
|
2018-10-17 23:48:20 +02:00
|
|
|
class Events
|
|
|
|
{
|
|
|
|
/**
|
2022-09-28 00:08:36 +02:00
|
|
|
* @return void
|
2018-10-17 23:48:20 +02:00
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
2022-09-28 00:08:36 +02:00
|
|
|
public static function onActivate(): void
|
2018-10-17 23:48:20 +02:00
|
|
|
{
|
2022-09-28 00:08:36 +02:00
|
|
|
self::addTotpTable();
|
|
|
|
self::addTotpBackupCodesTable();
|
|
|
|
self::addSeoItem1();
|
|
|
|
self::addSeoItem2();
|
2018-10-17 23:48:20 +02:00
|
|
|
}
|
|
|
|
|
2019-08-14 23:15:05 +02:00
|
|
|
/**
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
*/
|
2018-10-17 23:48:20 +02:00
|
|
|
public static function onDeactivate()
|
|
|
|
{
|
|
|
|
}
|
2022-09-28 00:08:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public static function addTotpTable(): void
|
|
|
|
{
|
|
|
|
$query = "CREATE TABLE IF NOT EXISTS `d3totp` (
|
|
|
|
`OXID` CHAR(32) NOT NULL ,
|
|
|
|
`OXUSERID` CHAR(32) NOT NULL ,
|
|
|
|
`USETOTP` TINYINT(1) NOT NULL DEFAULT 0,
|
|
|
|
`SEED` VARCHAR(256) NOT NULL ,
|
|
|
|
`OXTIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp',
|
|
|
|
PRIMARY KEY (`OXID`) ,
|
|
|
|
UNIQUE KEY `OXUSERID` (`OXUSERID`)
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='totp setting';";
|
|
|
|
|
|
|
|
DatabaseProvider::getDb()->execute( $query );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public static function addTotpBackupCodesTable(): void
|
|
|
|
{
|
|
|
|
$query = "CREATE TABLE IF NOT EXISTS `d3totp_backupcodes` (
|
|
|
|
`OXID` CHAR(32) NOT NULL ,
|
|
|
|
`OXUSERID` CHAR(32) NOT NULL COMMENT 'user id',
|
|
|
|
`BACKUPCODE` VARCHAR(64) NOT NULL COMMENT 'BackupCode',
|
|
|
|
`OXTIMESTAMP` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp',
|
|
|
|
PRIMARY KEY (`OXID`) ,
|
|
|
|
KEY `OXUSERID` (`OXUSERID`) ,
|
|
|
|
KEY `BACKUPCODE` (`BACKUPCODE`)
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='totp backup codes';";
|
|
|
|
|
|
|
|
DatabaseProvider::getDb()->execute( $query );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public static function addSeoItem1(): void
|
|
|
|
{
|
|
|
|
if (!DatabaseProvider::getDb()->getOne('SELECT 1 FROM oxseo WHERE oxident = "76282e134ad4e40a3578e121a6cb1f6a"')) {
|
|
|
|
$query = "INSERT INTO `oxseo`
|
|
|
|
(
|
|
|
|
`OXOBJECTID`, `OXIDENT`, `OXSHOPID`,
|
|
|
|
`OXLANG`, `OXSTDURL`, `OXSEOURL`,
|
|
|
|
`OXTYPE`, `OXFIXED`, `OXEXPIRED`,
|
|
|
|
`OXPARAMS`, `OXTIMESTAMP`
|
|
|
|
) VALUES (
|
|
|
|
'39f744f17e974988e515558698a29df4', '76282e134ad4e40a3578e121a6cb1f6a', 1,
|
|
|
|
1, 'index.php?cl=d3_account_totp', 'en/2-factor-authintication/',
|
|
|
|
'static', 0, 0,
|
|
|
|
'', NOW()
|
|
|
|
);";
|
|
|
|
|
|
|
|
DatabaseProvider::getDb()->execute( $query );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public static function addSeoItem2(): void
|
|
|
|
{
|
|
|
|
if (!DatabaseProvider::getDb()->getOne('SELECT 1 FROM oxseo WHERE oxident = "c1f8b5506e2b5d6ac184dcc5ebdfb591"')) {
|
|
|
|
$query = "INSERT INTO `oxseo`
|
|
|
|
(
|
|
|
|
`OXOBJECTID`, `OXIDENT`, `OXSHOPID`,
|
|
|
|
`OXLANG`, `OXSTDURL`, `OXSEOURL`,
|
|
|
|
`OXTYPE`, `OXFIXED`, `OXEXPIRED`,
|
|
|
|
`OXPARAMS`, `OXTIMESTAMP`
|
|
|
|
) VALUES (
|
|
|
|
'39f744f17e974988e515558698a29df4', 'c1f8b5506e2b5d6ac184dcc5ebdfb591', 1,
|
|
|
|
0, 'index.php?cl=d3_account_totp', '2-faktor-authentisierung/',
|
|
|
|
'static', 0, 0,
|
|
|
|
'', NOW()
|
|
|
|
);";
|
|
|
|
|
|
|
|
DatabaseProvider::getDb()->execute( $query );
|
|
|
|
}
|
|
|
|
}
|
2022-09-30 00:06:20 +02:00
|
|
|
}
|
|
|
|
// @codeCoverageIgnoreEnd
|