<?php
define('DATALIFEENGINE', true);

require_once @$_SERVER['DOCUMENT_ROOT'] . '/cabinet/config.php';

$request = safedArray($_REQUEST);

$generate = md5($request['OutSum'].':'.$request['InvId'].':'.$cabinet_config['payment']['robokassa']['pass2'].':shp_login='.$request['shp_login']);

(!checkArray($request)) ? die('Error REQUEST-data') : '';

(strtoupper($generate) != $request['SignatureValue']) ? die('Error Signature-data') : '';

$operation = $db->super_query("SELECT * FROM `cabinet_pay_logs` WHERE `name`='{$request['shp_login']}' AND `operation_id`='{$request['InvId']}'");

($operation) ? die('Error duble operation!') : '';

$db->query("INSERT INTO `cabinet_logs` (`name`, `description`, `price`, `date`) VALUES ('{$request['shp_login']}', 'Пополнение баланса', '{$request['OutSum']}', '". time() ."')");

$db->query("INSERT INTO `cabinet_pay_logs` VALUES (NULL, '{$request['shp_login']}', '{$request['OutSum']}', '{$request['InvId']}', '{$generate}')");

$db->query("UPDATE `dle_users` SET `balance`=`balance`+'{$request['OutSum']}' WHERE `name`='{$request['shp_login']}'");

die('OK'.$request['InvId']);
?>