<?php
$pjs = file_get_contents("package.json");
$arPack = json_decode($pjs,1);

if(!empty($_REQUEST["v"]) && $_REQUEST["v"] != $arPack["version"]){
	$prodPath = "prod/".$arPack["version"].'/';
	$arFiles = [];
	foreach(scandir($prodPath) as $file){
		if(strlen($file)>3){
			$arFiles[] = $file;
		}
	}
	echo json_encode(["version"=>$arPack["version"], "path"=>$prodPath, "files"=>$arFiles]);
	
}
die();
// echo (!empty($arPack["version"])) ? $arPack["version"] : '';
// preg_match("/\"version\"\:\s\"([\d\.]{1,}[\d\.]{1,}[\d\.]{1,})\"/",$pjs,$mtch);
// echo (!empty($mtch[1])) ? $mtch[1] : "";
?>