"; // phpinfo(32); exit; $file = __DIR__ . "/" . ($_GET['_route_']??'') . ".php"; // echo $file ; exit; if( is_file($file) ) $templ = file_get_contents( $file ); else $templ = file_get_contents( __DIR__ . "/index-ua.php" ); if( preg_match("/ru$/", $_GET['_route_'] ) ){ $lang_ = ''; $lang = 'ru-ru'; $templ = str_replace( "", "" . "", $templ ); }else{ $templ = str_replace( "", "" . "", $templ ); $lang_ = 'ua/'; $lang = 'ua-uk'; } $templ = str_replace( "", '' . file_get_contents( __DIR__ . "/preloader.php" ) . "", $templ ); $products = []; if( preg_match_all("/\[product_id:(\d+):name\]/", $templ, $r/*, PREG_SET_ORDER*/ ) )$products = $r[1]; // print_r( $products ); $opts = [ 'http' =>[ 'method' => 'PUT', 'header' => 'Content-type: application/json; charset=UTF-8' . "\r\n", 'content' => json_encode( [ 'ids' => $products, "route" => "product/search/byid", "_lang_" => $lang ] ), ], 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ]; // print_r( $opts ); $context = stream_context_create($opts); $result = json_decode( file_get_contents('https://enjee.ua/ua/', false, $context), true )['response']['products']??[]; // print_r( error_get_last() ); exit; // print_r( $result ); exit; foreach( $result as $product_info ){ // echo "/\[product_id:{$product_info['product_id']}:name\]/" . "\n\n"; if( !$product_info['special'] ){ $product_info['special'] = $product_info['price']; $product_info['price'] += 100; // $product_info['price'] *= 1.35; } $product_info['price'] = (int)round( $product_info['price'] ); $product_info['special'] = (int)round( $product_info['special'] ); $product_info['sale'] = $product_info['price'] - $product_info['special']; $templ = preg_replace([ "/\[product_id:{$product_info['product_id']}:name\]/", "/\[product_id:{$product_info['product_id']}:price-special\]/", "/\[product_id:{$product_info['product_id']}:price\]/", "/\[product_id:{$product_info['product_id']}:special\]/", "/\[product_id:{$product_info['product_id']}:sale\]/", ], [ $product_info['name'], $product_info['special'] ? $product_info['special'] : $product_info['price'], $product_info['price'], $product_info['special'], $product_info['sale'] ], $templ ); } echo $templ;