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

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

$request = safedArray($_REQUEST);

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

unset($request['ik_sign']);

ksort($request, SORT_STRING);

array_push($request, $cabinet_config['payment']['interkassa']['key']);

$signString = implode(':', $request);

$generate = base64_encode(md5($signString, true));

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

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

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

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

$db->query("INSERT INTO `cabinet_pay_logs` VALUES (NULL, '{$request['ik_x_login']}', '{$request['ik_am']}', '{$request['ik_pm_no']}', '{$request['ik_sign']}')");

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