Файл: RootPanel 1.7.0 FreeCode/RootPanel 1.7.0 FreeCode/online_paypal.php
Строк: 76
<?
$full_home_path = dirname(__FILE__);
require_once($full_home_path."/_rootload.php");
$input = '';
$post_string = '';
foreach ($_POST as $field=>$value) { 
    $input .= $field." ".$value."n";
    $post_string .= $field.'='.urlencode(htmlDecode($value)).'&'; 
}
$post_string.="cmd=_notify-validate";
$input = "Входящие параметры:nn$input";
if (getenv("REQUEST_METHOD") != "POST") {
    mconnect();
    $manager_email=GetSetting('manager_email');
    $msg = "С IP-адреса $ip произошло обращение к скрипту online_paypal.php по GET-протоколу.nnБудьте внимательны, т.к. возможно кто-то пытается взломать систему.nn$inputnn--nRootPanel";
    $subject = "Возможная попытка взлома билинга [PayPal]";
    $admEmails=GetAdminEmailsWhereTrueParam("senderror");
    if (count($admEmails) > 0) {
        WriteMailLog($subject,$msg);
    }
    while (list($i,$em) = @each($admEmails)) {
        sendmail($em,'',$manager_email,$subject,$msg);
    }
    mclose();
    exit; 
}
if ($business) {
    mconnect();
    EnableLanguages();
    $bill = GetBillById(intval($item_number));
    if (!$item_number) { $error_msg = "Отсутствует номер счета биллинг-системы."; }
    else if (!$bill->id) { $error_msg = "Счет # $BILL_ID не найден."; }
    else if ($payment_gross != $bill->merchantmoney) { $error_msg = "Неправильная сумма оплаты."; }
    else if ($business != GetSetting("paypal")) { $error_msg = "Неправильный e-mail продавца."; }
    else if ($receiver_email != GetSetting("paypal")) { $error_msg = "Неправильный e-mail получателя платежа."; }
    else if ($payment_status != "Completed") { $error_msg = "Неправильный статус платежа."; }
    else {
        $fp = curl_init(); 
        curl_setopt($fp, CURLOPT_URL, "https://www.paypal.com/cgi-bin/webscr");
#        curl_setopt($fp, CURLOPT_URL, "https://www.sandbox.paypal.com/cgi-bin/webscr");
        curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($fp, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($fp, CURL_HTTP_VERSION_1_1, 1);
        curl_setopt($fp, CURLOPT_POST, 1);
        curl_setopt($fp, CURLOPT_POSTFIELDS, $post_string);
        curl_setopt($fp, CURLOPT_FAILONERROR, 0); 
        curl_setopt($fp, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($fp, CURLOPT_TIMEOUT, 120);
        $result = curl_exec($fp);
        curl_close($fp);  
        if (preg_match("/VERIFIED/ui",$result)) {
            MakeBillPayed($bill->id,1,"PayPal ($payer_email)");
            mclose();
            exit;
        }
    }
    $manager_email=GetSetting('manager_email');
    $msg = "Автоматическая оплата через PayPal отклонена биллинг-системой по причине:nn$error_msgnn$inputnnIP: $ipnn--nRootPanel";
    $subject = "Ошибка автоматической оплаты [PayPal]";
    $admEmails=GetAdminEmailsWhereTrueParam("senderror");
    if (count($admEmails) > 0) {
        WriteMailLog($subject,$msg);
    }
    while (list($i,$em) = @each($admEmails)) {
        sendmail($em,'',$manager_email,$subject,$msg);
    }
    mclose();
}
?>