<commit_before>#!/usr/bin/php -q
<?php   
/***************************************************************************
 *
 * a2billing.php : PHP A2Billing Core
 * Written for PHP 4.x & PHP 5.X versions.
 *
 * A2Billing -- Asterisk billing solution.
 * Copyright (C) 2004, 2007 <NAME> <areski _atl_ gmail com>
 *
 * See http://www.asterisk2billing.org for more information about
 * the A2Billing project. 
 * Please submit bug reports, patches, etc to <areski _atl_ gmail com>
 *
 * This software is released under the terms of the GNU Lesser General Public License v2.1
 * A copy of which is available from http://www.gnu.org/copyleft/lesser.html
 *
 ****************************************************************************/

declare(ticks = 1);
if (function_exists('pcntl_signal')) {
	pcntl_signal(SIGHUP,  SIG_IGN);
}

error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
	
include_once (dirname(__FILE__)."/libs_a2billing/db_php_lib/Class.Table.php");
include (dirname(__FILE__)."/libs_a2billing/Class.A2Billing.php");
include (dirname(__FILE__)."/libs_a2billing/Class.RateEngine.php");   
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi.php");
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi-asmanager.php");
include (dirname(__FILE__)."/libs_a2billing/Misc.php");

$charge_callback=0;
$G_startime = time();
$agi_date = "Release : no date";
$agi_version = "Asterisk2Billing - Version 1.4 - Trunk";

if ($argc > 1 && ($argv[1] == '--version' || $argv[1] == '-v'))
{
	echo "A2Billing - Version $agi_version - $agi_date\n";
	exit;
}


/********** 	 CREATE THE AGI INSTANCE + ANSWER THE CALL		**********/
$agi = new AGI();


if ($argc > 1 && is_numeric($argv[1]) && $argv[1] >= 0){
	$idconfig = $argv[1];
}else{
	$idconfig = 1;
}



if ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'did')			$mode = 'did';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'callback')		$mode = 'callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'cid-callback')	$mode = 'cid-callback';	
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'all-callback')	$mode = 'all-callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'predictivedialer')	$mode = 'predictivedialer';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'voucher')	$mode = 'voucher';
else $mode = 'standard';

// get the area code for the cid-callback & all-callback
if ($argc > 3 && strlen($argv[3]) > 0) $caller_areacode = $argv[3];


$A2B = new A2Billing();
$A2B -> load_conf($agi, NULL, 0, $idconfig);
$A2B -> mode = $mode;



$A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "IDCONFIG : $idconfig");
$A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "MODE : $mode");


$A2B -> CC_TESTING = isset($A2B->agiconfig['debugshell']) && $A2B->agiconfig['debugshell'];	
//$A2B -> CC_TESTING = true;

define ("DB_TYPE", isset($A2B->config["database"]['dbtype'])?$A2B->config["database"]['dbtype']:null); 	
	
// TEST DID
// if ($A2B -> CC_TESTING) $mode = 'did';

//-- Print header
$A2B -> debug( VERBOSE , $agi, __FILE__, __LINE__, 'AGI Request:');
$A2B -> debug( VERBOSE , $agi, __FILE__, __LINE__, print_r($agi->request, true));


/* GET THE AGI PARAMETER */
$A2B -> get_agi_request_parameter ($agi);

//$A2B -> accountcode = '2222222222';

if (!$A2B -> DbConnect()){						
	$agi-> stream_file('prepaid-final', '#');
	exit;					
}

$instance_table = new Table();
$A2B -> set_instance_table ($instance_table);
	

//GET CURRENCIES FROM DATABASE 

$QUERY =  "SELECT id,currency,name,value from cc_currencies order by id";
$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);
<commit_msg>UPDATE : write log - AGI Request<commit_after>#!/usr/bin/php -q
<?php   
/***************************************************************************
 *
 * a2billing.php : PHP A2Billing Core
 * Written for PHP 4.x & PHP 5.X versions.
 *
 * A2Billing -- Asterisk billing solution.
 * Copyright (C) 2004, 2007 <NAME> <areski _atl_ gmail com>
 *
 * See http://www.asterisk2billing.org for more information about
 * the A2Billing project. 
 * Please submit bug reports, patches, etc to <areski _atl_ gmail com>
 *
 * This software is released under the terms of the GNU Lesser General Public License v2.1
 * A copy of which is available from http://www.gnu.org/copyleft/lesser.html
 *
 ****************************************************************************/

declare(ticks = 1);
if (function_exists('pcntl_signal')) {
	pcntl_signal(SIGHUP,  SIG_IGN);
}

error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
	
include_once (dirname(__FILE__)."/libs_a2billing/db_php_lib/Class.Table.php");
include (dirname(__FILE__)."/libs_a2billing/Class.A2Billing.php");
include (dirname(__FILE__)."/libs_a2billing/Class.RateEngine.php");   
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi.php");
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi-asmanager.php");
include (dirname(__FILE__)."/libs_a2billing/Misc.php");

$charge_callback=0;
$G_startime = time();
$agi_date = "Release : no date";
$agi_version = "Asterisk2Billing - Version 1.4 - Trunk";

if ($argc > 1 && ($argv[1] == '--version' || $argv[1] == '-v'))
{
	echo "A2Billing - Version $agi_version - $agi_date\n";
	exit;
}


/********** 	 CREATE THE AGI INSTANCE + ANSWER THE CALL		**********/
$agi = new AGI();


if ($argc > 1 && is_numeric($argv[1]) && $argv[1] >= 0){
	$idconfig = $argv[1];
}else{
	$idconfig = 1;
}



if ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'did')			$mode = 'did';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'callback')		$mode = 'callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'cid-callback')	$mode = 'cid-callback';	
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'all-callback')	$mode = 'all-callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'predictivedialer')	$mode = 'predictivedialer';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'voucher')	$mode = 'voucher';
else $mode = 'standard';

// get the area code for the cid-callback & all-callback
if ($argc > 3 && strlen($argv[3]) > 0) $caller_areacode = $argv[3];


$A2B = new A2Billing();
$A2B -> load_conf($agi, NULL, 0, $idconfig);
$A2B -> mode = $mode;



$A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "IDCONFIG : $idconfig");
$A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "MODE : $mode");


$A2B -> CC_TESTING = isset($A2B->agiconfig['debugshell']) && $A2B->agiconfig['debugshell'];	
//$A2B -> CC_TESTING = true;

define ("DB_TYPE", isset($A2B->config["database"]['dbtype'])?$A2B->config["database"]['dbtype']:null); 	
	
// TEST DID
// if ($A2B -> CC_TESTING) $mode = 'did';

//-- Print header
$A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "AGI Request:\n".print_r($agi->request, true));


/* GET THE AGI PARAMETER */
$A2B -> get_agi_request_parameter ($agi);

//$A2B -> accountcode = '2222222222';

if (!$A2B -> DbConnect()){						
	$agi-> stream_file('prepaid-final', '#');
	exit;					
}

$instance_table = new Table();
$A2B -> set_instance_table ($instance_table);
	

//GET CURRENCIES FROM DATABASE 

$QUERY =  "SELECT id,currency,name,value from cc_currencies order by id";
$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);

{'fraction_non_alphanumeric': 0.23572996706915478, 'fraction_numerical': 0.028677277716794732, 'mean_word_length': 4.637277648878577, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4596085', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2714, 'n_words': 624}