<?php

	# mark core  v1.0
    # author Drk in
	# date 24.10.19 	

	# core

	require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );

	$SIGN = md5(FREE_ID_ADS.':'.$_REQUEST['AMOUNT'].':'.FREE_KEY_ADS.':'.$_REQUEST['MERCHANT_ORDER_ID']);

	if ($SIGN == $_REQUEST['SIGN']):

	if(cache_ads::ch($_REQUEST['MERCHANT_ORDER_ID']) == true):
		
	$ads = cache_ads::get($_REQUEST['MERCHANT_ORDER_ID']);
	
	if ($ads['price'] == $_REQUEST['AMOUNT']):

	$time_end = time() + 86400 * $ads['day'];	

	DB :: $dbh -> query("UPDATE ads SET time_pay = ?,time_end = ? WHERE id = ? LIMIT 1;", array(time(),$time_end,$ads['id']));		

	cache_ads::save($ads['id']);		

	die('YES');   	

	# error
	
	else: die('ERROR PRICE');  endif;	
	else: die('ERROR PAY');  endif;
	else: die('ERROR SIGN');  endif;
?>