<commit_before><?php
/**
 * BoxBilling
 *
 * @copyright BoxBilling, Inc (http://www.boxbilling.com)
 * @license   Apache-2.0
 *
 * Copyright BoxBilling, Inc
 * This source file is subject to the Apache-2.0 License that is bundled
 * with this source code in the file LICENSE
 */

require_once dirname(__FILE__) . '/bb-load.php';
$di = include dirname(__FILE__) . '/bb-di.php';
$di['translate']();

$bb_invoice_id = null;
if(isset($_GET['bb_invoice_id'])) {
    $bb_invoice_id = $_GET['bb_invoice_id'];
}
if(isset($_POST['bb_invoice_id'])) {
    $bb_invoice_id = $_POST['bb_invoice_id'];
}

$bb_gateway_id = null;
if(isset($_GET['bb_gateway_id'])) {
    $bb_gateway_id = $_GET['bb_gateway_id'];
}
if(isset($_POST['bb_invoice_id'])) {
    $bb_gateway_id = $_POST['bb_gateway_id'];
}

$ipn = array(
    'skip_validation'       =>  true,
    'bb_invoice_id'         =>  $bb_invoice_id,
    'bb_gateway_id'         =>  $bb_gateway_id,
    'get'                   =>  $_GET,
    'post'                  =>  $_POST,
    'server'                =>  $_SERVER,
    'http_raw_post_data'    =>  file_get_contents("php://input"),
);

try {
    $service = $di['mod_service']('invoice', 'transaction');
    $output = $service->createAndProcess($ipn);
    $res = array('result'=>$output, 'error'=>null);
} catch(Exception $e) {
    $res = array('result'=>null, 'error'=> array('message' => $e->getMessage()));
    $output = false;
}

// print transaction output if available
if(!is_bool($output)) {
    print $output;
    exit;
}

// redirect to invoice if gateways requires
if(isset($_GET['bb_redirect']) && isset($_GET['bb_invoice_hash'])) {
    $url = $di['url']->get('invoice/'.$_GET['bb_invoice_hash']);
    header("Location: $url");
    exit;
} else {
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json; charset=utf-8');<commit_msg>bb-ipn $_POST param fixed<commit_after><?php
/**
 * BoxBilling
 *
 * @copyright BoxBilling, Inc (http://www.boxbilling.com)
 * @license   Apache-2.0
 *
 * Copyright BoxBilling, Inc
 * This source file is subject to the Apache-2.0 License that is bundled
 * with this source code in the file LICENSE
 */

require_once dirname(__FILE__) . '/bb-load.php';
$di = include dirname(__FILE__) . '/bb-di.php';
$di['translate']();

$bb_invoice_id = null;
if(isset($_GET['bb_invoice_id'])) {
    $bb_invoice_id = $_GET['bb_invoice_id'];
}
if(isset($_POST['bb_invoice_id'])) {
    $bb_invoice_id = $_POST['bb_invoice_id'];
}

$bb_gateway_id = null;
if(isset($_GET['bb_gateway_id'])) {
    $bb_gateway_id = $_GET['bb_gateway_id'];
}
if(isset($_POST['bb_gateway_id'])) {
    $bb_gateway_id = $_POST['bb_gateway_id'];
}

$ipn = array(
    'skip_validation'       =>  true,
    'bb_invoice_id'         =>  $bb_invoice_id,
    'bb_gateway_id'         =>  $bb_gateway_id,
    'get'                   =>  $_GET,
    'post'                  =>  $_POST,
    'server'                =>  $_SERVER,
    'http_raw_post_data'    =>  file_get_contents("php://input"),
);

try {
    $service = $di['mod_service']('invoice', 'transaction');
    $output = $service->createAndProcess($ipn);
    $res = array('result'=>$output, 'error'=>null);
} catch(Exception $e) {
    $res = array('result'=>null, 'error'=> array('message' => $e->getMessage()));
    $output = false;
}

// print transaction output if available
if(!is_bool($output)) {
    print $output;
    exit;
}

// redirect to invoice if gateways requires
if(isset($_GET['bb_redirect']) && isset($_GET['bb_invoice_hash'])) {
    $url = $di['url']->link('invoice/'.$_GET['bb_invoice_hash']);
    var_dump($url);exit;
    header("Location: $url");
    exit;
} else {
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json; charset=utf-8');
{'fraction_non_alphanumeric': 0.18914050437467833, 'fraction_numerical': 0.008749356664951106, 'mean_word_length': 3.683132530120482, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2679820', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1395, 'n_words': 253}