1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
<?php
MainFactory::load_class('AdminHttpViewController');
class ShopKeyController extends AdminHttpViewController
{
protected $db;
protected $languageTextManager;
public function __construct(HttpContextReaderInterface $httpContextReader,
HttpResponseProcessorInterface $httpResponseProcessor,
ContentViewInterface $contentView)
{
parent::__construct($httpContextReader, $httpResponseProcessor, $contentView);
$gxCoreLoader = MainFactory::create('GXCoreLoader', MainFactory::create('GXCoreLoaderSettings'));
$this->db = $gxCoreLoader->getDatabaseQueryBuilder();
$this->languageTextManager = MainFactory::create('LanguageTextManager', 'shop_key', $_SESSION['languages_id']);
}
public function actionDefault()
{
$shopKey = $this->_getShopKey();
$shopKeyData = $this->_getShopKeyData($shopKey);
$shopKeyRequestLink = 'http://www.gambio.de/0n7hb';
$pageTitle = $this->languageTextManager->get_text('page_title');
$this->contentView->set_template_dir(DIR_FS_ADMIN . 'html/content/');
$html = $this->_render('shop_key.html', array(
'shop_key' => $shopKey,
'shop_key_data' => $shopKeyData,
'shop_key_request_link' => $shopKeyRequestLink
));
return MainFactory::create('AdminPageHttpControllerResponse', $pageTitle, $html, null, array('shop_key'));
}
public function actionStore()
{
$this->_store(trim($this->_getPostData('GAMBIO_SHOP_KEY')));
$url = xtc_href_link('admin.php', 'do=ShopKey');
return MainFactory::create('RedirectHttpControllerResponse', $url);
}
public function actionDestroy()
{
$this->_store('');
$url = xtc_href_link('admin.php', 'do=ShopKey');
return MainFactory::create('RedirectHttpControllerResponse', $url);
}
protected function _getShopKey()
{
$shopKeyResult = $this->db->select('configuration_value')
->from('configuration')
->where('configuration_key', 'GAMBIO_SHOP_KEY')
->get();
$shopKey = $shopKeyResult->row();
$shopKey = $shopKey->configuration_value;
return $shopKey;
}
protected function _getShopKeyData($p_shopKey)
{
include DIR_FS_CATALOG . '/release_info.php';
$shopKeyData = 'shop_version=' . $gx_version . "\n";
$shopKeyData .= 'shop_url=' . HTTP_SERVER . DIR_WS_CATALOG . "\n";
$shopKeyData .= 'shop_key=' . (string)$p_shopKey . "\n";
$shopKeyData .= 'language=' . $_SESSION['language_code'] . "\n";
$shopKeyData .= 'server_path=' . rtrim(DIR_FS_CATALOG, '/') . "\n";
return $shopKeyData;
}
protected function _store($p_shopKey)
{
$this->db->set('configuration_value', $p_shopKey);
$this->db->where('configuration_key', 'GAMBIO_SHOP_KEY');
$this->db->update('configuration');
$coo_cache = DataCache::get_instance();
$coo_cache->clear_cache_by_tag('ADMIN');
$this->db->set('gm_value', 1);
$this->db->set('gm_key', 'CHECK_SHOP_KEY');
$this->db->where('gm_key', 'CHECK_SHOP_KEY');
$this->db->replace('gm_configuration');
}
}