<?php

/*$data = '4
5
3
6
0
6
7
3
24
160
6
5
16
9
24
0
24
8
6
24
0
5
6
16
7
0
0
9';

$exploded = explode("\n",$data);
echo "<pre>";print_r($exploded);
echo "<br/>";
echo "SUM = ".array_sum($exploded)." Hrs";
exit;*/
/*try{
    $x = 10;
}catch (\Exception $e){

}*/

//echo($x);

$result = '21DOCA21@GMAIL.COM
21ELNGHO21@GMAIL.COM
21FEME21@GMAIL.COM
21sahkho21@gmail.com
AAEG2121@GMAIL.COM
aliahmadi1944@gmail.com
lvf815@gmail.com
mahingan88@gmail.com
mellymoy236@gmail.com
pulido.agustin89@gmail.com
sam2cici@gmail.com
YOURWAYOUTBAILBOND@ATT.NET';

$exploded = explode("\n",$result);
$sql = "SELECT * FROM `creditreportsetups` WHERE `credit_report_company_type` = 3";
$string = "";
if(!empty($exploded)){
    foreach ($exploded as $exp){
        if(!empty($exp)){
            if(!empty($string)){
                $string .= ",'".$exp."'";
            }else{
                $string = "'".$exp."'";
            }
        }
    }
}

$sql = $sql." AND credit_report_company_username IN (".$string.")";
echo $sql;exit;
echo "<pre>";print_r($exploded);
exit;
function testXmlQuery($security_key,$constraints)
{
    // transactionFields has all of the fields we want to validate
    // in the transaction tag in the XML output
    $transactionFields = array(
        'transaction_id',
        'partial_payment_id',
        'partial_payment_balance',
        'platform_id',
        'transaction_type',
        'condition',
        'order_id',
        'authorization_code',
        'ponumber',
        'order_description',

        'first_name',
        'last_name',
        'address_1',
        'address_2',
        'company',
        'city',
        'state',
        'postal_code',
        'country',
        'email',
        'phone',
        'fax',
        'cell_phone',
        'customertaxid',
        'customerid',
        'website',

        'shipping_first_name',
        'shipping_last_name',
        'shipping_address_1',
        'shipping_address_2',
        'shipping_company',
        'shipping_city',
        'shipping_state',
        'shipping_postal_code',
        'shipping_country',
        'shipping_email',
        'shipping_carrier',
        'tracking_number',
        'shipping_date',
        'shipping',
        'shipping_phone',

        'cc_number',
        'cc_hash',
        'cc_exp',
        'cavv',
        'cavv_result',
        'xid',
        'eci',
        'avs_response',
        'csc_response',
        'cardholder_auth',
        'cc_start_date',
        'cc_issue_number',
        'check_account',
        'check_hash',
        'check_aba',
        'check_name',
        'account_holder_type',
        'account_type',
        'sec_code',
        'drivers_license_number',
        'drivers_license_state',
        'drivers_license_dob',
        'social_security_number',

        'processor_id',
        'tax',
        'currency',
        'surcharge',
        'tip',

        'card_balance',
        'card_available_balance',
        'entry_mode',
        'cc_bin',
        'cc_type'
    );

    // actionFields is used to validate the XML tags in the
    // action element
    $actionFields = array(
        'amount',
        'action_type',
        'date',
        'success',
        'ip_address',
        'source',
        'api_method',
        'username',
        'response_text',
        'batch_id',
        'processor_batch_id',
        'response_code',
        'processor_response_text',
        'processor_response_code',
        'device_license_number',
        'device_nickname'
    );

    $mycurl=curl_init();
    $postStr='security_key='.$security_key.$constraints;
    $url="https://secure.networkmerchants.com/api/query.php?". $postStr;
    curl_setopt($mycurl, CURLOPT_URL, $url);
    curl_setopt($mycurl, CURLOPT_RETURNTRANSFER, 1);
    $responseXML=curl_exec($mycurl);
    curl_close($mycurl);

    $testXmlSimple= new SimpleXMLElement($responseXML);

    if (!isset($testXmlSimple->transaction)) {
        throw new Exception('No transactions returned');
    }

    $transNum = 1;
    foreach($testXmlSimple->transaction as $transaction) {
        foreach ($transactionFields as $xmlField) {
            if (!isset($transaction->{$xmlField}[0])){
                throw new Exception('Error in transaction_id:'. $transaction->transaction_id[0] .' id  Transaction tag is missing  field ' . $xmlField);
            }
        }
        if (!isset ($transaction->action)) {
            throw new Exception('Error, Action tag is missing from transaction_id '. $transaction->transaction_id[0]);
        }

        $actionNum = 1;
        foreach ($transaction->action as $action){
            foreach ($actionFields as $xmlField){
                if (!isset($action->{$xmlField}[0])){
                    throw new Exception('Error with transaction_id'.$transaction->transaction_id[0].'
                                        Action number '. $actionNum . ' Action tag is missing field ' . $xmlField);
                }
            }
            $actionNum++;
        }
        $transNum++;
    }

    return $testXmlSimple;
}

try {

    $constraints = "&action_type=sale&order_id=167155443665318";
    $result = testXmlQuery('BeErzh5W79nA2cfr5McWWtqXm65fwYFF',$constraints);
    //print "Success.\n";
    echo "<pre>";
    print_r(json_decode(json_encode($result),true));
    exit;

} catch (Exception $e) {

    echo $e->getMessage();

}



?>








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































