<?php
$mrh_pass2  = "pass2-robokassa"; //pass-robokassa #2
if ($_POST['shp_username']!="" ) {
$out_summ = $_POST["OutSum"];
$inv_id = $_POST['InvId'];
$shp_item = $_POST["shp_item"];
$shp_note = $_POST["shp_note"];
$shp_username = $_POST["shp_username"];
$crc = $_POST["SignatureValue"];
$crc = strtoupper($crc);
$my_crc = strtoupper(md5("$out_summ:$inv_id:$mrh_pass2:shp_item=$shp_item:shp_note=$shp_note:shp_username=$shp_username"));
if ($my_crc !=$crc)
{ $errorString = 'Invalid Signature';
return false;
}else{ include('./library/config.php');
mysql_connect($config['db']['host'], $config['db']['username'], $config['db']['password']) or die("Ошибка подключения к базе");
mysql_select_db($config['db']['dbname']) or die("База не найдена");
mysql_query("SET NAMES UTF8");
$shp_item = mysql_real_escape_string($_POST['shp_item']);
$name = mysql_real_escape_string($_POST['shp_username']);
$shp_note = mysql_real_escape_string($_POST['shp_note']);
$price = mysql_real_escape_string($_POST['OutSum']);
$querys = mysql_query("SELECT *  FROM `robodn_goal` WHERE `goal_id` = $inv_id");
$dow = mysql_fetch_array($querys);
$usnm = $dow['donated'];
$usnote = $dow['goal'];
$usum = $dow['summm'];
$ugoal = $dow['goal_id'];
$data=time();
if($usnm AND $usnote AND $usum) {
$db = mysql_query("INSERT INTO `robodn_donation` (`donation_id`, `note`, `user_id`, `username`, `amount`, `donation_date`) VALUES ('$ugoal', '$usnote','$shp_item','$shp_username','$usum', '$data')") or die ("Invalid query");
}}}else{ $startTime = microtime(true);
$fileDir = dirname(__FILE__);
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$deps = new XenForo_Dependencies_Public();
$deps->preLoadData();
$response = new Zend_Controller_Response_Http();
$processor = new XenForo_UserUpgradeProcessor_RoboKassa();
$processor->initCallbackHandling(new Zend_Controller_Request_Http());
$logExtra = array();
try
{
if (!$processor->validateRequest($logMessage))
{
$logType = 'error';
$response->setHttpResponseCode(500);
}else if (!$processor->validatePreConditions($logMessage,$mrh_pass2)){
$logType = 'error';
}else{
list($logType, $logMessage) = $processor->processTransaction();
}}
catch (Exception $e)
{
$response->setHttpResponseCode(500);
XenForo_Error::logException($e);
$logType = 'error';
$logMessage = 'Exception: ' . $e->getMessage();
$logExtra['_e'] = $e;
}
$processor->log($logType, $logMessage, $logExtra);
$response->setBody(htmlspecialchars($logMessage));
$response->sendResponse();
}