<?php 

	if (Session::get("tipo_usuario") != "2"){ show_403();}
	if ($_SERVER["REQUEST_METHOD"] == "POST") {
		import_file(DIR_LIBRARIES."functions.php");
		
		$p = filter_input(INPUT_POST, "p", FILTER_SANITIZE_STRING);
		
		$codigo = urlencode(encrypt_encode_url($p."@".Session::get("id_usuario")));

		$link = (isset($_SERVER["HTTPS"]) ? "https" : "http")."://".$_SERVER["HTTP_HOST"].URL_BASE."/produtos-promocionais/?p=".$codigo;

		echo json_encode(["link" => $link]);
	}
	else{
		show_403();
	}

?>