checkParamter(); //dumpvar($this->processRequest()); //echo __METHOD__ . " " . __LINE__ . "
" . PHP_EOL; #dumpvar($this->prepareFromTansport($this->prepareDataForTansport($this->processRequest()))); #echo __METHOD__ . " " . __LINE__ . "
" . PHP_EOL; //die(); echo $this->prepareDataForTansport($this->processRequest()); } /** * @throws DatabaseErrorException * @throws DatabaseConnectionException */ public function processRequest() { $Parameter = $this->getParameter(); switch ($Parameter['FNC']) { case 'getShopData': return $this->getShopData($Parameter); break; case 'getOrder': return $this->getOrder($Parameter); break; case 'getOrderArticles': return $this->getOrderArticles($Parameter); break; case 'getArticle': return $this->getArticle($Parameter); break; case 'getDeliveryData': return $this->getDeliveryData($Parameter); break; case 'getPaymentData': return $this->getPaymentData($Parameter); break; case 'getCountry': return $this->getCountry($Parameter); break; } } /** * @throws DatabaseErrorException * @throws DatabaseConnectionException */ public function getShopData(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxshops'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = <<getRow($sQuery,[$OXID]); unset($result['OXSERIAL']); unset($result['OXSMTP']); unset($result['OXSMTPUSER']); unset($result['OXSMTPPWD']); return $result; } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException */ public function getOrder(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxorder'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE OXID= ?"; return $Db->getRow($sQuery,[$OXID]); } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ public function getOrderArticles(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxorderarticles'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE oxorderid = ? AND OXAMOUNT > 0 AND OXSTORNO = 0 ORDER BY oxartid, oxselvariant, oxpersparam"; return $Db->getAll($sQuery,[$OXID]); } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ public function getArticle(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxarticles'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE OXID= ?"; return $Db->getAll($sQuery,[$OXID]); } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ public function getDeliveryData(array $aParameter) { $OXID = $aParameter['OXID']; if(!$OXID) { $OXID = 'oxidstandard'; } $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxdeliveryset'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE OXID= ?"; return $Db->getRow($sQuery,[$OXID]); } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ public function getPaymentData(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxpayments'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE OXID= ?"; return $Db->getAll($sQuery,[$OXID]); } /** * @param array $aParameter * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ public function getCountry(array $aParameter) { $OXID = $aParameter['OXID']; $sTable = Registry::get(TableViewNameGenerator::class)->getViewName('oxcountry'); $Db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); $sQuery = "SELECT * FROM ".$sTable." WHERE OXID= ?"; return $Db->getAll($sQuery,[$OXID]); } public function checkParamter() { // todo check accesstoken //fnc //oxid // $this->getParameter(); } public function getParameter() { return array( 'SecureID' => $_GET['ID'], 'FNC' => $_GET['FNC'], 'OXID' => $_GET['OXID'], ); } /** * @param array $Data * @return string */ public function prepareDataForTansport(array $Data): string { return base64_encode(json_encode($Data)); } /** * @param string $Data * @return array */ public function prepareFromTansport(string $Data): array { return (array)json_decode(base64_decode($Data)); } } $Connect = new connect(); $Connect->init();