<?php
	require_once("../system.engine/system.core.php");
	
	$mPong = array();
	$a = &$mPong;
	$p = &$_POST;
	
	global $systemHandler;
	$systemExecution = $systemHandler->loadHandler("EXECUTION");
	$systemHash = $systemHandler->loadHandler("HASH");
	/* ### DO YOUR CODES ONLY FROM HERE ### */
	
	$mMail = $p["lostMail"];
	if($systemExecution->runQuery("SELECT COUNT(id) AS userCount FROM web_user WHERE mail = '%s'", $mMail)->fetch_object()->userCount > 0) {
		$mLostHash = $systemHandler->loadHandler("HASH")->hashString(time().$mMail.rand(9999, 99999));
		$systemExecution->runQuery("UPDATE web_user SET lost_hash = '%s' WHERE mail = '%s'", array($mLostHash, $mMail));
		$systemHandler->loadHandler("MAIL")->submitLostPassMail($systemExecution->runQuery("SELECT id FROM web_user WHERE mail = '%s'", $mMail)->fetch_object()->id);
		$a["isValid"] = true;
	} else $a["isValid"] = false;
	
	/* ### DO NOT CHANGE ANYTHING FROM HERE ### */
	header("Content-Type: application/json");
	echo json_encode($mPong);
?>