<commit_before><?php
class Vps_Util_PayPal_Ipn
{
    public function dispatch($logModel = 'Vps_Util_PayPal_Ipn_LogModel')
    {
        $url = '';
        if (isset($_SERVER['REDIRECT_URL'])) {
            $url = $_SERVER['REDIRECT_URL'];
        }
        if ($url != '/paypal_ipn') return;

        if (Vps_Setup::getConfigSection()=='production' || !isset($_GET['dontValidate'])) {

            $req = 'cmd=_notify-validate';

            foreach ($_POST as $key => $value) {
                if(get_magic_quotes_gpc() == 1) {
                    $value = stripslashes($value);
                }
                $value = urlencode($value);
                $req .= "&$key=$value";
            }

            // Post back to PayPal to validate
            $header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
            $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
            $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
            if (isset($_POST['test_ipn']) && $_POST['test_ipn']) {
                $domain = 'www.sandbox.paypal.com';
            } else {
                $domain = 'www.paypal.com';
            }
            $fp = fsockopen($domain, 80);
            if (!$fp) {
                throw new Vps_Exception("Http error in Ipn validation");
            }
            fputs($fp, $header . $req);
            while (!feof($fp)) {
                $res = fgets ($fp, 1024);
            }
        } else {
            $res = 'VERIFIED';
        }

        if (strcmp($res, "VERIFIED") == 0) {
            // TODO:
            // Check the payment_status is Completed
            // Check that txn_id has not been previously processed
            // Check that receiver_email is your Primary PayPal email
            // Check that payment_amount/payment_currency are correct
            // Process payment
            //mail('<EMAIL>', "Live-VERIFIED IPN", print_r($_POST, true));

            $m = Vps_Model_Abstract::getInstance($logModel);
            $row = $m->createRow();
            foreach ($_REQUEST as $key => $value) {
                $row->$key = $value;
            }
            $row->save();

        } else if (strcmp ($res, "INVALID") == 0) {
            throw new Vps_Exception("Ipn validation received INVALID $domain");
        } else {
            throw new Vps_Exception("Ipn validation received something strange: $res");
        }

        echo 'OK';
        exit;
    }
}<commit_msg>daten von paypal sind nicht utf8, muessen wir konvertieren<commit_after><?php
class Vps_Util_PayPal_Ipn
{
    public function dispatch($logModel = 'Vps_Util_PayPal_Ipn_LogModel')
    {
        $url = '';
        if (isset($_SERVER['REDIRECT_URL'])) {
            $url = $_SERVER['REDIRECT_URL'];
        }
        if ($url != '/paypal_ipn') return;

        if (Vps_Setup::getConfigSection()=='production' || !isset($_GET['dontValidate'])) {

            $req = 'cmd=_notify-validate';

            foreach ($_POST as $key => $value) {
                if(get_magic_quotes_gpc() == 1) {
                    $value = stripslashes($value);
                }
                $value = urlencode($value);
                $req .= "&$key=$value";
            }

            // Post back to PayPal to validate
            $header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
            $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
            $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
            if (isset($_POST['test_ipn']) && $_POST['test_ipn']) {
                $domain = 'www.sandbox.paypal.com';
            } else {
                $domain = 'www.paypal.com';
            }
            $fp = fsockopen($domain, 80);
            if (!$fp) {
                throw new Vps_Exception("Http error in Ipn validation");
            }
            fputs($fp, $header . $req);
            while (!feof($fp)) {
                $res = fgets ($fp, 1024);
            }
        } else {
            $res = 'VERIFIED';
        }

        if (strcmp($res, "VERIFIED") == 0) {
            // TODO:
            // Check the payment_status is Completed
            // Check that txn_id has not been previously processed
            // Check that receiver_email is your Primary PayPal email
            // Check that payment_amount/payment_currency are correct
            // Process payment
            //mail('<EMAIL>', "Live-VERIFIED IPN", print_r($_POST, true));

            $m = Vps_Model_Abstract::getInstance($logModel);
            $row = $m->createRow();
            foreach ($_REQUEST as $key => $value) {
                $row->$key = utf8_encode($value);
            }
            $row->save();

        } else if (strcmp ($res, "INVALID") == 0) {
            throw new Vps_Exception("Ipn validation received INVALID $domain");
        } else {
            throw new Vps_Exception("Ipn validation received something strange: $res");
        }

        echo 'OK';
        exit;
    }
}
{'fraction_non_alphanumeric': 0.145304312777106, 'fraction_numerical': 0.0048367593712212815, 'mean_word_length': 1.5970695970695972, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3478529', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1426, 'n_words': 324}