2018-01-25 11:30:17 +01:00
|
|
|
<?php
|
|
|
|
|
2018-02-23 11:06:24 +01:00
|
|
|
namespace D3\Devhelper\Modules\Application\Controller;
|
|
|
|
|
2018-01-25 11:30:17 +01:00
|
|
|
// .../?cl=thankyou[&d3orderid=23]
|
2018-02-23 12:30:57 +01:00
|
|
|
use D3\Devhelper\Modules\Application\Model\d3_dev_d3inquiry;
|
|
|
|
use D3\Devhelper\Modules\Application\Model\d3_dev_oxorder;
|
|
|
|
use OxidEsales\Eshop\Application\Model\Order;
|
|
|
|
use OxidEsales\Eshop\Application\Model\User;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\UserException;
|
2018-01-25 11:30:17 +01:00
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2018-02-23 12:30:57 +01:00
|
|
|
use OxidEsales\Eshop\Core\Request;
|
2018-01-25 11:30:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This Software is the property of Data Development and is protected
|
|
|
|
* by copyright law - it is NOT Freeware.
|
|
|
|
*
|
|
|
|
* Any unauthorized use of this software without a valid license
|
|
|
|
* is a violation of the license agreement and will be prosecuted by
|
|
|
|
* civil and criminal law.
|
|
|
|
*
|
|
|
|
* http://www.shopmodule.com
|
|
|
|
*
|
|
|
|
* @copyright © D³ Data Development, Thomas Dartsch
|
2018-02-23 12:30:57 +01:00
|
|
|
* @author D³ Data Development - Daniel Seifert <info@shopmodule.com>
|
2018-01-25 11:30:17 +01:00
|
|
|
* @link http://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
class d3_dev_thankyou extends d3_dev_thankyou_parent
|
|
|
|
{
|
|
|
|
/**
|
2018-02-23 12:30:57 +01:00
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2018-01-25 11:30:17 +01:00
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$sSessChallenge = Registry::getSession()->getVariable('sess_challenge');
|
|
|
|
|
|
|
|
parent::init();
|
|
|
|
|
|
|
|
Registry::getSession()->setVariable('sess_challenge', $sSessChallenge);
|
|
|
|
|
2018-02-23 12:30:57 +01:00
|
|
|
if (Registry::get(Request::class)->getRequestEscapedParameter("d3dev")
|
|
|
|
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
|
2018-01-25 11:30:17 +01:00
|
|
|
&& Registry::getConfig()->getConfigParam('blD3DevShowThankyou')
|
|
|
|
) {
|
|
|
|
$this->_d3authenticate();
|
|
|
|
$oOrder = $this->d3GetLastOrder();
|
|
|
|
$oBasket = $oOrder->d3DevGetOrderBasket();
|
|
|
|
$this->_oBasket = $oBasket;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function _d3authenticate ()
|
|
|
|
{
|
|
|
|
try {
|
2018-02-23 12:30:57 +01:00
|
|
|
$sUser = Registry::get(Request::class)->getRequestEscapedParameter( 'usr');
|
|
|
|
$sPassword = Registry::get(Request::class)->getRequestEscapedParameter('pwd');
|
2018-01-25 11:30:17 +01:00
|
|
|
|
|
|
|
if ( !$sUser || !$sPassword ) {
|
|
|
|
$sUser = $_SERVER[ 'PHP_AUTH_USER' ];
|
|
|
|
$sPassword = $_SERVER[ 'PHP_AUTH_PW' ];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$sUser || !$sPassword ) {
|
|
|
|
$sHttpAuthorization = $_REQUEST[ 'HTTP_AUTHORIZATION' ];
|
|
|
|
if ( $sHttpAuthorization ) {
|
|
|
|
$sUser = null;
|
|
|
|
$sPassword = null;
|
|
|
|
$aHttpAuthorization = explode( ' ', $sHttpAuthorization );
|
|
|
|
if ( is_array( $aHttpAuthorization ) && count( $aHttpAuthorization ) >= 2 && strtolower( $aHttpAuthorization[ 0 ] ) == 'basic' ) {
|
|
|
|
$sBasicAuthorization = base64_decode( $aHttpAuthorization[ 1 ] );
|
|
|
|
$aBasicAuthorization = explode( ':', $sBasicAuthorization );
|
|
|
|
if ( is_array( $aBasicAuthorization ) && count( $aBasicAuthorization ) >= 2 ) {
|
|
|
|
$sUser = $aBasicAuthorization[ 0 ];
|
|
|
|
$sPassword = $aBasicAuthorization[ 1 ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-23 12:30:57 +01:00
|
|
|
/** @var User $oUser */
|
|
|
|
$oUser = oxNew(User::class);
|
2018-01-25 11:30:17 +01:00
|
|
|
if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) {
|
2018-02-23 12:30:57 +01:00
|
|
|
/** @var UserException $oEx */
|
|
|
|
$oEx = oxNew(UserException::class, 'EXCEPTION_USER_NOVALIDLOGIN');
|
2018-01-25 11:30:17 +01:00
|
|
|
throw $oEx;
|
|
|
|
}
|
|
|
|
}
|
2018-02-23 12:30:57 +01:00
|
|
|
catch ( \Exception $oEx ) {
|
2018-01-25 11:30:17 +01:00
|
|
|
$oShop = Registry::getConfig()->getActiveShop();
|
2018-02-23 12:30:57 +01:00
|
|
|
header( 'WWW-Authenticate: Basic realm="{' . $oShop->getFieldData('oxname') . '"' );
|
2018-01-25 11:30:17 +01:00
|
|
|
header( 'HTTP/1.0 401 Unauthorized' );
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool|d3_dev_oxorder
|
2018-02-23 12:30:57 +01:00
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2018-01-25 11:30:17 +01:00
|
|
|
*/
|
|
|
|
public function d3GetLastOrder()
|
|
|
|
{
|
2018-02-23 12:30:57 +01:00
|
|
|
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
|
2018-01-25 11:30:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var d3_dev_oxorder $oOrder */
|
2018-02-23 12:30:57 +01:00
|
|
|
$oOrder = oxNew(Order::class);
|
2018-01-25 11:30:17 +01:00
|
|
|
$oOrder->d3getLastOrder();
|
|
|
|
|
|
|
|
return $oOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool|d3_dev_d3inquiry
|
2018-02-23 12:30:57 +01:00
|
|
|
* @throws DatabaseConnectionException
|
2018-01-25 11:30:17 +01:00
|
|
|
*/
|
|
|
|
public function d3GetLastInquiry()
|
|
|
|
{
|
2018-02-23 12:30:57 +01:00
|
|
|
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
|
2018-01-25 11:30:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var d3_dev_d3inquiry $oInquiry */
|
|
|
|
$oInquiry = oxNew('d3inquiry');
|
|
|
|
$oInquiry->d3getLastInquiry();
|
|
|
|
|
|
|
|
return $oInquiry;
|
|
|
|
}
|
|
|
|
}
|