<?php include_once '../settings/autoload.php'; $msql = SafeMySQL::getInstance(); $orderID = AF::get($_GET, 'order_id'); $status = AF::get($_GET, 'status', 'inprogress'); // inprogress, submitted, unknown, new if ($orderID) { Order::finalizeOrder($orderID); die; } while ($orderID = getOrderID()) { Order::finalizeOrder($orderID); } function getOrderID() { global $msql, $status; try { // Open transaction $msql->query("START TRANSACTION"); // Select attempt $sql = "SELECT `attempt_id`, `order_id`, `status`\n FROM `attempts`\n WHERE `status`=?s\n AND `attempt_type` = 'debit'\n AND `updated` < DATE_SUB(NOW(), INTERVAL 10 MINUTE)\n LIMIT 1"; $result = $msql->getRow($sql, $status); $attemptID = isset($result['attempt_id']) && $result['attempt_id'] ? $result['attempt_id'] : null; $orderID = isset($result['order_id']) && $result['order_id'] ? $result['order_id'] : null; // Update selected attempt if ($attemptID) { $sql = "UPDATE `attempts` SET `updated`=NOW() WHERE `attempt_id`=?i"; $msql->query($sql, $attemptID); } // Close transaction
{ # PHPmailer instanse $mail = new PHPMailer(); # General settings email $mail->CharSet = 'UTF-8'; $mail->setFrom("robot@{$cfg['domain']}", $cfg['title']); $mail->addReplyTo("support@{$cfg['domain']}"); $mail->isHTML(true); $mail->Subject = "Заявка #{$orderID}"; $mail->Body = getMessage($cfg, $query, $orderID); return $mail; } # --- Send email $cfg = json_decode(file_get_contents($PATH . '/config.json'), true); $query = getDataOfQuery(); if ($query) { $orderID = getOrderID(); foreach ($cfg['emails'] as $email) { $mail = getMailInstanse($cfg, $query, $orderID); $mail->addAddress($email); if ($mail->send()) { echo $STATUS_CODES['HTTP_200']; } else { echo $STATUS_CODES['HTTP_500']; exit; } } } else { echo $STATUS_CODES['HTTP_400']; exit; }
if (empty($_SESSION)) { echo ' <ul class="nav navbar-nav navbar-right"> <li><a href="registration.php">Sign up</a></li> <li><a id="sign_in_affix" href="javascript:;">Log in</a></li> </ul> '; include "login_affix.php"; } else { $acc_id = $_SESSION['account_id']; echo ' <ul class="nav navbar-nav navbar-right"> <li><p>Welcome, '; echo $_SESSION['nick']; //Ak ma user order v stave processing tak sa zobrazule tooltip if (getOrderID($_SESSION['account_id']) == 0) { $var = 'Shopping cart is empty'; } else { $var = getTooltip($_SESSION['account_id']); } echo '</p></li> <li data-toggle="tooltip" title="' . $var . '" data-placement="bottom"> <a href="orders.php"><i class="glyphicon glyphicon-shopping-cart"></i></a> </li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" role="button"><i class="glyphicon glyphicon-user"></i> <i class="caret"></i></a> <ul class="dropdown-menu" role="menu"> <li><a href="personal.php?acc_id=' . $acc_id . '"><span class="glyphicon glyphicon-pencil"></span> Edit profile</a></li> <li><a href="history.php"><span class="glyphicon glyphicon-tag"></span> History of orders</a></li> <li><a href="accounts/logout.php"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
return $orderID; } function getSignature($Shop_IDP, $Order_IDP, $Subtotal_P, $MeanType, $EMoneyType, $Lifetime, $Customer_IDP, $Card_IDP, $IData, $PT_Code, $password) { $str = $Shop_IDP . "&" . $Order_IDP . "&" . $Subtotal_P . "&" . $MeanType . "&" . $EMoneyType . "&" . $Lifetime . "&" . $Customer_IDP . "&" . $Card_IDP . "&" . $IData . "&" . $PT_Code . "&" . $password; print $str; $Signature = strtoupper(md5(md5($Shop_IDP) . "&" . md5($Order_IDP) . "&" . md5($Subtotal_P) . "&" . md5($MeanType) . "&" . md5($EMoneyType) . "&" . md5($Lifetime) . "&" . md5($Customer_IDP) . "&" . md5($Card_IDP) . "&" . md5($IData) . "&" . md5($PT_Code) . "&" . md5($password))); return $Signature; } // Инициализация параметров для формы платежа // Параметры могут извлекаться из БД или из других хранилищ данных, либо содержаться $Shop_IDP = $systemOptions[$systemName . '_shop_IDP']; // идентификатор точки продажи $Lifetime = $systemOptions[$systemName . '_Lifetime']; // время жизни формы оплаты в секундах $Order_ID = getOrderID(); // Сумма для оплаты и идентификатор зарегистрированного пользователя могу храниться в $Customer_IDP = $user['uid']; $Email = $user['email']; $phone = $user['phone']; // Адреса возврата после успешной и неуспешной оплат покупателями $URL_RETURN_OK = $systemOptions[$systemName . '_URL_RETURN_OK']; $URL_RETURN_NO = $systemOptions[$systemName . '_URL_RETURN_NO']; $password = $systemOptions[$systemName . '_password']; // пароль из ЛК Uniteller $EMoneyType = $systemOptions[$systemName . '_EMoneyType']; $MeanType = $systemOptions[$systemName . '_MeanType']; // Подпись для формы, вместо неиспользуемых параметров передаются пустые строки //$EMoneyType = ''; $Signature = getSignature($Shop_IDP, $Order_ID, $amount, $MeanType, $EMoneyType, $Lifetime, $Customer_IDP, "", "", "", $password); ?>