12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
-
- header('Content-Type: application/json');
-
- $url = realpath("./../server/json/ProductCode.json");
- $json = file_get_contents($url);
- $json = json_decode($json);
-
- $productcode = str_replace("/", ".", $_GET["ProductCode"]);
- $productarray = explode(".", $productcode);
-
-
- if($_GET["ProductCode"] == ""){
- echo json_encode (json_decode ("{}"));
- return;
- }
- if(isset($_GET["Semantic"])){
- $fixwerte = 6;
- for($i = 0; $i < $fixwerte; ++$i){
- if(isset($productarray[$i])){
- $asocarray[$json->pattern[$i]->abk] = $productarray[$i];
- }
- else{
- $asocarray[$json->pattern[$i]->abk] = "";
- }
- }
-
- //Search which abk can be linked to the patternpart
- for($i = $fixwerte; $i < count($productarray); ++$i){
- foreach($json->pattern as $node){
- foreach($node->types as $type){
- if($productarray[$i] == $type && $type != "*"){
- $asocarray[$node->abk] = $productarray[$i];
- }
- }
- }
- }
- }
- else{
- $i = 0;
- foreach($json->pattern as $node){
- if(isset($productarray[$i])){
- $asocarray[$node->abk] = $productarray[$i];
- }
- ++$i;
- }
-
- }
-
-
- echo json_encode($asocarray);
- ?>
|