devhelper/copy_this/modules/d3/d3dev/controllers/d3dev.php

113 lines
4.2 KiB
PHP
Raw Normal View History

2015-12-16 17:44:47 +01:00
<?php
/**
* 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 <EFBFBD> D<EFBFBD> Data Development, Thomas Dartsch
* @author D<EFBFBD> Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
class d3dev extends oxUBase
{
2017-11-21 16:35:36 +01:00
public function init()
{
$this->_authenticate();
parent::init();
}
protected function _authenticate ()
{
$oConfig = oxRegistry::getConfig();
try {
$sUser = $oConfig->getRequestParameter( 'usr' );
$sPassword = $oConfig->getRequestParameter( 'pwd' );
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 ];
}
}
}
}
/** @var oxUser $oUser */
$oUser = oxNew( 'oxuser' );
if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) {
$oEx = oxNew( 'oxuserexception' );
$oEx->setMessage( 'EXCEPTION_USER_NOVALIDLOGIN' );
throw $oEx;
}
}
catch ( Exception $oEx ) {
$oShop = $oConfig->getActiveShop();
header( 'WWW-Authenticate: Basic realm="' . $oShop->oxshops__oxname->value . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
exit( 1 );
}
}
2015-12-16 17:44:47 +01:00
public function showOrderMailContent()
{
2017-11-17 12:38:46 +01:00
header('Content-type: text/html; charset='.oxRegistry::getLang()->translateString('charset'));
2015-12-16 17:44:47 +01:00
if (oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value
|| false == oxRegistry::getConfig()->getConfigParam('blD3DevShowOrderMailsInBrowser')
) {
oxRegistry::getUtils()->redirect(oxRegistry::getConfig()->getShopUrl().'index.php?cl=start');
}
$sTpl = oxRegistry::getConfig()->getRequestParameter('type');
/** @var d3_dev_thankyou $oThankyou */
$oThankyou = oxNew('thankyou');
$oOrder = $oThankyou->d3GetLastOrder();
/** @var d3_dev_oxemail $oEmail */
$oEmail = oxNew('oxemail');
echo $oEmail->d3GetOrderMailContent($oOrder, $sTpl);
die();
}
public function showInquiryMailContent()
{
if (oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value
|| false == oxRegistry::getConfig()->getConfigParam('blD3DevShowOrderMailsInBrowser')
) {
oxRegistry::getUtils()->redirect(oxRegistry::getConfig()->getShopUrl().'index.php?cl=start');
}
$sTpl = oxRegistry::getConfig()->getRequestParameter('type');
/** @var d3_dev_thankyou $oThankyou */
$oThankyou = oxNew('thankyou');
$oOrder = $oThankyou->d3GetLastInquiry();
/** @var d3_dev_oxemail $oEmail */
$oEmail = oxNew('oxemail');
echo $oEmail->d3GetInquiryMailContent($oOrder, $sTpl);
die();
}
}