Ejemplo n.º 1
0
	static function AddNotification($key,$priority,$from_type,$from_id=0,$link_type=null,$link_id=null) {
			$DBHandle = DbConnect();
			$table = new Table("cc_notification", "*");
			$fields = " key_value , priority, from_type, from_id, link_type,link_id";
			$values = " '$key' , $priority,$from_type	,$from_id ,'$link_type',$link_id";
			$return = $table->Add_table($DBHandle, $values, $fields);
			return $return;
  	 }
Ejemplo n.º 2
0
 $useralias = $arr_card_alias[1];
 if (!is_numeric($addcredit)) {
     $addcredit = 0;
 }
 $passui_secret = MDP_NUMERIC(10);
 $FG_ADITION_SECOND_ADD_VALUE = "'{$cardnum}', '{$useralias}', '{$addcredit}', '{$choose_tariff}', 't', '{$gen_id}', '', '', '', '', '', '', '', '', {$choose_simultaccess}, '{$choose_currency}', {$choose_typepaid}, {$creditlimit}, {$enableexpire}, '{$expirationdate}', {$expiredays}, '{$passui_secret}', '{$runservice}','{$tag}'";
 if (DB_TYPE != "postgres") {
     $FG_ADITION_SECOND_ADD_VALUE .= ",now() ";
 }
 if (isset($sip)) {
     $FG_ADITION_SECOND_ADD_VALUE .= ", 1";
 }
 if (isset($iax)) {
     $FG_ADITION_SECOND_ADD_VALUE .= ", 1";
 }
 $id_cc_card = $instance_sub_table->Add_table($HD_Form->DBHandle, $FG_ADITION_SECOND_ADD_VALUE, null, null, $HD_Form->FG_TABLE_ID);
 // Insert data for sip_buddy
 if (isset($sip)) {
     $FG_QUERY_ADITION_SIP_IAX_VALUE = "'{$cardnum}', '{$cardnum}', '{$cardnum}', '{$amaflags}', '{$cardnum}', '{$context}', '{$dtmfmode}','{$host}', '{$type}', '{$cardnum}', '{$allow}', '" . $passui_secret . "', '{$id_cc_card}', '{$nat}', '{$qualify}'";
     $result_query1 = $instance_sip_table->Add_table($HD_Form->DBHandle, $FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null);
     $_SESSION["is_sip_iax_change"] = 1;
     $_SESSION["is_sip_changed"] = 1;
 }
 // Insert data for iax_buddy
 if (isset($iax)) {
     //$FG_QUERY_ADITION_SIP_IAX_VALUE = "'$cardnum', '$cardnum', '$cardnum', '$amaflag', '$cardnum', '$context', 'RFC2833','dynamic', 'friend', '$cardnum', 'g729,ulaw,alaw,gsm','".$passui_secret."'";
     $FG_QUERY_ADITION_SIP_IAX_VALUE = "'{$cardnum}', '{$cardnum}', '{$cardnum}', '{$amaflags}', '{$cardnum}', '{$context}', '{$dtmfmode}','{$host}', '{$type}', '{$cardnum}', '{$allow}', '" . $passui_secret . "', '{$id_cc_card}', '{$nat}', '{$qualify}'";
     $result_query2 = $instance_iax_table->Add_table($HD_Form->DBHandle, $FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null);
     $_SESSION["is_sip_iax_change"] = 1;
     $_SESSION["is_iax_changed"] = 1;
 }
 $instance_table = new Table("cc_invoice", $field_insert);
 if ($verbose_level >= 1) {
     echo "INSERT INVOICE : {$field_insert} =>\t{$value_insert} \n";
 }
 $id_invoice = $instance_table->Add_table($A2B->DBHandle, $value_insert, null, null, "id");
 if (!empty($id_invoice) && is_numeric($id_invoice)) {
     $description = "Subscription (" . $subscription['product_name'] . ")";
     $amount = $subscription['fee'];
     $vat = 0;
     $field_insert = "date, id_invoice, price, vat, description, id_ext, type_ext";
     $instance_table = new Table("cc_invoice_item", $field_insert);
     $value_insert = " '{$date}' , '{$id_invoice}', '{$amount}','{$vat}','{$description}','" . $subscription['card_subscription_id'] . "','SUBSCR'";
     if ($verbose_level >= 1) {
         echo "INSERT INVOICE ITEM : {$field_insert} =>\t{$value_insert} \n";
     }
     $instance_table->Add_table($A2B->DBHandle, $value_insert, null, null, "id");
 }
 $mail = new Mail(Mail::$TYPE_SUBSCRIPTION_UNPAID, $card['id']);
 $mail->replaceInEmail(Mail::$DAY_REMAINING_KEY, $billdaybefor_anniversary);
 $mail->replaceInEmail(Mail::$INVOICE_REF_KEY, $reference);
 $mail->replaceInEmail(Mail::$SUBSCRIPTION_FEE, $subscription['fee']);
 $mail->replaceInEmail(Mail::$SUBSCRIPTION_ID, $subscription['id']);
 $mail->replaceInEmail(Mail::$SUBSCRIPTION_LABEL, $subscription['product_name']);
 //insert charge
 $QUERY = "INSERT INTO cc_charge (id_cc_card, amount, chargetype, id_cc_card_subscription, invoiced_status, description) VALUES ('" . $card['id'] . "', '" . $subscription['fee'] . "', '3','" . $subscription['card_subscription_id'] . "',1, '" . $subscription['product_name'] . "')";
 if ($verbose_level >= 1) {
     echo "==> INSERT CHARGE QUERY: \t{$QUERY}\n";
 }
 $instance_table->SQLExec($A2B->DBHandle, $QUERY, 0);
 $QUERY = "UPDATE cc_card_subscription SET paid_status = 1 WHERE id=" . $subscription['card_subscription_id'];
 if ($verbose_level >= 1) {
     }
     $param_add_fields .= $FG_QUERY_ADITION_HIDDEN_FIELDS;
     if ($i > 0) {
         $param_add_value .= ", ";
     }
     $param_add_value .= $FG_QUERY_ADITION_HIDDEN_VALUE;
 }
 if ($FG_DEBUG == 1) {
     echo "<br><hr> {$param_add_fields}";
 }
 if ($FG_DEBUG == 1) {
     echo "<br><hr> {$param_add_value}";
 }
 $FG_TABLE_ID = "id";
 if ($VALID_SQL_REG_EXP) {
     $result_query = $instance_table->Add_table($DBHandle, $param_add_value, $param_add_fields, null, $FG_TABLE_ID);
 }
 if (!$result_query) {
     //--echo "<br><b>".$instance_table -> errstr."</b><br>";
     $findme = 'duplicate';
     $pos_find = strpos($instance_sub_table->errstr, $findme);
     // Note our use of ===.  Simply == would not work as expected
     // because the position of 'a' was the 0th (first) character.
     if ($pos_find === false) {
         //-- echo $instance_sub_table -> errstr;
     } else {
         //echo $FG_TEXT_ERROR_DUPLICATION;
         $alarm_db_error_duplication = true;
     }
 } else {
     if ($FG_ADITION_GO_EDITION == "yes") {
Ejemplo n.º 5
0
    function Update_Rates($security_key, $instance, $arr_rates)
    {
        $arr_check = $this->Check_KeyInstance($security_key, $instance);
		if ($arr_check[0] == 'ERROR') {
		    return $arr_check;
		}
		$id_group = $arr_check;
		
		
		$QUERY = "SELECT id_trunk FROM cc_trunk WHERE trunkcode = '$instance'";
		$result = $this->instance_table -> SQLExec ($this->DBHandle, $QUERY);
		if (!is_array($result))
		{
		    return array(false, "CANNOT LOAD THE TRUNK FOR THIS INSTANCE");
		}
		$id_trunk = $result[0][0];
		
		
		$QUERY = "SELECT id FROM cc_tariffplan WHERE tariffname = '$instance'";
		$result = $this->instance_table -> SQLExec ($this->DBHandle, $QUERY);
		if (!is_array($result))
		{
		    return array(false, "CANNOT LOAD THE RATECARD FOR THIS INSTANCE");
		}
		$id_ratecard = $result[0][0];
		
		
		// CHECK RATES VALIDITY
		if (!$this->check_rates_validity ($arr_rates)) {
		    return array(false, "ERROR RATES VALIDITY, LINE $nb_rates. ENSURE THAT ALL RATES HAVE A CORRECT FORMAT!");
		}
		
		// DELETE EXISTING RATES
		$DEL_QUERY = "DELETE FROM cc_ratecard WHERE idtariffplan=$id_ratecard";
	    $result_query = $this->DBHandle->Execute($DEL_QUERY);
	    
	    
		// REIMPORT RATES
		foreach ($arr_rates as $arr_rates_val) {
		    
		    $dialprefix = trim($arr_rates_val[0]);
		    $destination = trim($arr_rates_val[1]);
		    $buyrate = trim($arr_rates_val[2]);
		    $sellrate = trim($arr_rates_val[3]);
		    
		    // ADD PREFIX
		    $instance_table_prefix = new Table("cc_prefix");
		    $FG_ADITION_SECOND_ADD_FIELDS_PREFIX = 'prefix, destination';
		    
		    $FG_ADITION_SECOND_ADD_VALUE_PREFIX = "'" . intval($dialprefix) . "', '$destination'";
			$TT_QUERY_PREFIX = "INSERT INTO " . $FG_ADITION_SECOND_ADD_TABLE_PREFIX . " (" . $FG_ADITION_SECOND_ADD_FIELDS_PREFIX . ") values (" . $FG_ADITION_SECOND_ADD_VALUE_PREFIX . ") ";
			$instance_table_prefix -> Add_table ($this->DBHandle, $FG_ADITION_SECOND_ADD_VALUE_PREFIX, $FG_ADITION_SECOND_ADD_FIELDS_PREFIX);
			
			
			// ADD RATES
		    $FG_ADITION_SECOND_ADD_TABLE = 'cc_ratecard';
		    $FG_ADITION_SECOND_ADD_FIELDS = 'idtariffplan, id_trunk, dialprefix, destination, buyrate, rateinitial, startdate, stopdate';
		    
		    $startdate = date("Y-m-d H:i:s");
		    $stopdate_prefix = date("Y") + 30;
		    $stopdate_suffix = date("-m-d H:i:s");
		    
		    $FG_ADITION_SECOND_ADD_VALUE = "'$id_ratecard', '$id_trunk', '$dialprefix', '".intval($dialprefix)."', '$buyrate', '$sellrate', '$startdate', '$stopdate_prefix$stopdate_suffix'";
		    $TT_QUERY = "INSERT INTO " . $FG_ADITION_SECOND_ADD_TABLE . " (" . $FG_ADITION_SECOND_ADD_FIELDS . ") values (" . $FG_ADITION_SECOND_ADD_VALUE . ") ";
		    
		    $result_query = $this->DBHandle->Execute($TT_QUERY);
		    
		    if (!$result_query) {
		        return array(false, "ERROR RATES CREATION ($nb_to_import Rates imported)");
		    }
		    
		    $nb_to_import++;
		}
		
		
		return array(true, "RATES UPDATED ($nb_to_import Rates imported) - SUCCESS");
		
    }
Ejemplo n.º 6
0
                break;
            default:
                $rates_clauses .= " destination = '{$prefix}'";
                break;
        }
    }
    $QUERY = "SELECT {$id},id FROM cc_ratecard rc WHERE {$rates_clauses} GROUP BY destination";
    $table_rates->SQLExec($DBHandle, "INSERT IGNORE INTO cc_package_rate(package_id , rate_id) ({$QUERY})");
    Header("Location: A2B_package_manage_rates.php?id={$id}");
}
if (isset($addrate) && is_numeric($addrate)) {
    $DBHandle = DbConnect();
    $add_rate_table = new Table("cc_package_rate", "*");
    $fields = " package_id , rate_id";
    $values = " {$id} , {$addrate}";
    $add_rate_table->Add_table($DBHandle, $values, $fields);
    Header("Location: A2B_package_manage_rates.php?id={$id}");
}
if (isset($delrate) && is_numeric($delrate)) {
    $DBHandle = DbConnect();
    $del_rate_table = new Table("cc_package_rate", "*");
    $CLAUSE = " package_id = " . $id . " AND rate_id = {$delrate}";
    $del_rate_table->Delete_table($DBHandle, $CLAUSE);
    Header("Location: A2B_package_manage_rates.php?id={$id}");
}
if (isset($delallrate) && $delallrate) {
    $DBHandle = DbConnect();
    $del_rate_table = new Table("cc_package_rate", "*");
    $CLAUSE = " package_id = " . $id;
    $del_rate_table->Delete_table($DBHandle, $CLAUSE);
    Header("Location: A2B_package_manage_rates.php?id={$id}");
	
****************************************************************************/
set_time_limit(0);
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
include_once dirname(__FILE__) . "/../Class.Table.php";
include dirname(__FILE__) . "/../Class.A2Billing.php";
write_log(LOGFILE_CRONT_ARCHIVE_DATA, basename(__FILE__) . ' line:' . __LINE__ . "[#### ARCHIVING DATA BEGIN ####]");
if (!$A2B->DbConnect()) {
    echo "[Cannot connect to the database]\n";
    write_log(LOGFILE_CRONT_ARCHIVE_DATA, basename(__FILE__) . ' line:' . __LINE__ . "[Cannot connect to the database]");
    exit;
}
$A2B = new A2Billing();
$A2B->load_conf($agi, NULL, 0, $idconfig);
$instance_table = new Table();
$from_month = $A2B->config["backup"]['archive_data_x_month'];
if ($A2B->config["database"]['dbtype'] == "postgres") {
    $condition = "CURRENT_TIMESTAMP - interval '{$from_month} months' > starttime";
} else {
    $condition = "DATE_SUB(NOW(),INTERVAL {$from_month} MONTH) > starttime";
}
$value = "SELECT sessionid,uniqueid,username,nasipaddress,starttime,stoptime,sessiontime,calledstation,startdelay,stopdelay,terminatecause,usertariff,calledprovider,calledcountry,calledsub,calledrate,sessionbill,destination,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,buycost,id_card_package_offer,real_sessiontime FROM cc_call where {$condition}";
$func_fields = "sessionid,uniqueid,username,nasipaddress,starttime,stoptime,sessiontime,calledstation,startdelay,stopdelay,terminatecause,usertariff,calledprovider,calledcountry,calledsub,calledrate,sessionbill,destination,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,buycost,id_card_package_offer,real_sessiontime";
$func_table = 'cc_call_archive';
$id_name = "";
$subquery = true;
$result = $instance_table->Add_table($A2B->DBHandle, $value, $func_fields, $func_table, $id_name, $subquery);
$fun_table = "cc_call";
$result = $instance_table->Delete_table($A2B->DBHandle, $condition, $fun_table);
write_log(LOGFILE_CRONT_ARCHIVE_DATA, basename(__FILE__) . ' line:' . __LINE__ . "[#### ARCHIVING DATA END ####]");
Ejemplo n.º 8
0
    }
}
$paycur = $currencies_list[$getcur][2];

if (strtoupper($payment)=='PLUGNPAY') {
	$QUERY_FIELDS = "cardid, amount, vat, paymentmethod, cc_owner, cc_number, cc_expires, creationdate, cvv, credit_card_type, currency , item_id , item_type";
	$QUERY_VALUES = "'".$_SESSION["card_id"]."','$amount_string', '".$_SESSION["vat"]."', '$payment','$plugnpay_cc_owner','".substr($plugnpay_cc_number,0,4)."XXXXXXXXXXXX','".$plugnpay_cc_expires_month."-".$plugnpay_cc_expires_year."','$time_stamp', '$cvv', '$credit_card_type', '".BASE_CURRENCY."' , '$item_id', '$item_type'";
} else if(strtoupper($payment)=='IRIDIUM'){
	$QUERY_FIELDS = "cardid, amount, vat, paymentmethod, cc_owner, cc_number, cc_expires, creationdate, currency, item_id, item_type";
	$QUERY_VALUES = "'".$_SESSION["card_id"]."','$amount_string', '".$_SESSION["vat"]."', '$payment','$CardName','".substr($CardNumber,0,4)."XXXXXXXXXXXX','".$ExpiryDateMonth."-".$ExpiryDateYear."','$time_stamp', '".BASE_CURRENCY."' , '$item_id','$item_type'";
} else {
	$QUERY_FIELDS = "cardid, amount, vat, paymentmethod, cc_owner, cc_number, cc_expires, creationdate, currency, item_id, item_type";
    $QUERY_VALUES = "'".$_SESSION["card_id"]."','$amount_string', '".$_SESSION["vat"]."', '$payment','$authorizenet_cc_owner','".substr($authorizenet_cc_number,0,4)."XXXXXXXXXXXX','".$authorizenet_cc_expires_month."-".$authorizenet_cc_expires_year."','$time_stamp', '".$getcur."' , '$item_id','$item_type'";
}

$transaction_no = $paymentTable->Add_table ($HD_Form -> DBHandle, $QUERY_VALUES, $QUERY_FIELDS, 'cc_epayment_log', 'id');

$key = securitykey(EPAYMENT_TRANSACTION_KEY, $time_stamp."^".$transaction_no."^".$amount_string."^".$_SESSION["card_id"]."^".$item_id."^".$item_type);
if (empty($transaction_no)) {
	exit(gettext("No Transaction ID found"));
}

$HD_Form -> create_toppage ($form_action);

if (!isset($currencies_list[strtoupper($_SESSION['currency'])][2]) || !is_numeric($currencies_list[strtoupper($_SESSION['currency'])][2])) {
	$mycur = 1;
} else {
	$mycur = $currencies_list[strtoupper($_SESSION['currency'])][2]/$paycur;
	if ($payment == 'webmoney') {
		$getcur = $wm_purse_type;
		$two_currency=true;
Ejemplo n.º 9
0
 function Create_Card($security_key, $transaction_code, $account_number, $tariff, $uipass, $credit, $language, $activated, $status, $simultaccess, $currency, $runservice, $typepaid, $creditlimit, $enableexpire, $expirationdate, $expiredays, $lastname, $firstname, $address, $city, $state, $country, $zipcode, $phone, $fax, $callerid_list, $iax_friend, $sip_friend)
 {
     // The wrapper variables for security
     // $security_key = API_SECURITY_KEY;
     $logfile = SOAP_LOGFILE;
     $mysecurity_key = API_SECURITY_KEY;
     $mail_content = "[" . date("Y/m/d G:i:s", mktime()) . "] " . "SOAP API - Request asked: Create_Card [{$transaction_code}, {$account_number}, {$tariff}, {$uipass}, {$credit}, {$language}, {$activated}, {$simultaccess}, {$currency}, {$runservice}, {$typepaid}, {$creditlimit}, {$enableexpire}, {$expirationdate}, {$expiredays}, {$lastname}, {$firstname}, {$address}, {$city}, {$state}, {$country}, {$zipcode}, {$phone}, {$fax}, {$callerid_list}, {$iax_friend}, {$sip_friend}]";
     // CHECK SECURITY KEY
     if (md5($mysecurity_key) !== $security_key || strlen($security_key) == 0) {
         a2b_mail(EMAIL_ADMIN, "ALARM : API - CODE_ERROR SECURITY_KEY ", $mail_content);
         error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . " CODE_ERROR SECURITY_KEY" . "\n", 3, $logfile);
         sleep(2);
         return array($transaction_code, '', '', '', '', 'Error', 'KEY - BAD PARAMETER' . "{$security_key} - {$mysecurity_key}");
     }
     // Create new account
     $FG_ADITION_SECOND_ADD_TABLE = "cc_card";
     $FG_ADITION_SECOND_ADD_FIELDS = "username, useralias, credit, tariff, id_didgroup, activated, status, lastname, firstname, email, address, city, state, country, zipcode, phone, fax, userpass, simultaccess, currency, typepaid, creditlimit, language, runservice, enableexpire, expirationdate, expiredays, uipass, sip_buddy, iax_buddy";
     $arr_card_alias = gen_card_with_alias('cc_card', 1);
     $cardnum = $arr_card_alias[0];
     $useralias = $arr_card_alias[1];
     if ($uipass == '' || strlen($uipass) == 0) {
         $uipass = MDP_STRING();
     }
     // CHECK PARAMETERS LASTNAME ; FIRSTNAME ; ADDRESS ; ....
     if (!is_numeric($credit) || !is_numeric($creditlimit) || !is_numeric($expiredays) || $activated != 0 && $activated != 1 || $simultaccess != 0 && $simultaccess != 1 || $runservice != 0 && $runservice != 1 || strlen($lastname) > 40 || strlen($firstname) > 40 || strlen($address) > 100 || strlen($city) > 40 || strlen($state) > 40 || strlen($country) > 40 || strlen($zipcode) > 40 || strlen($phone) > 40 || strlen($email) > 60 || strlen($fax) > 40) {
         a2b_mail(EMAIL_ADMIN, "ALARM : API  - BAD PARAMETER ", $mail_content);
         error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . " - BAD PARAMETER " . "\n", 3, $logfile);
         return array($transaction_code, '', '', '', '', 'Error', 'BAD PARAMETER');
     } else {
         if ($expirationdate == '') {
             $expirationdate = "now()";
         } else {
             $expirationdate = "'{$expirationdate}'";
         }
         $DBHandle = DbConnect();
         $instance_sub_table = new Table($FG_ADITION_SECOND_ADD_TABLE, $FG_ADITION_SECOND_ADD_FIELDS);
         $FG_ADITION_SECOND_ADD_VALUE = "'{$cardnum}', '{$useralias}', '" . $credit . "', '" . $tariff . "', '0', '{$activated}', '{$status}', '{$lastname}', '{$firstname}', '{$email}', '{$address}', '{$city}', " . "'{$state}', '{$country}', '{$zipcode}', '{$phone}', '{$fax}', '{$cardnum}', " . $simultaccess . ", '" . $currency . "', '" . $typepaid . "','" . $creditlimit . "', '" . $language . "', '" . $runservice . "', '" . $enableexpire . "', {$expirationdate}, '{$expiredays}', '{$uipass}', '{$iax_friend}', '{$sip_friend}'";
         $result_query = $instance_sub_table->Add_table($DBHandle, $FG_ADITION_SECOND_ADD_VALUE, null, null, 'id');
         if ($result_query) {
             $id_cc_card = $result_query;
             if (strlen($callerid_list) > 1) {
                 $callerid_list = split(',', $callerid_list);
                 if (count($callerid_list) > 0) {
                     $k = 0;
                     foreach ($callerid_list as $mycallerid) {
                         $k++;
                         if (strlen($mycallerid) > 1) {
                             $QUERY = "SELECT * FROM cc_callerid WHERE cid='{$mycallerid}'";
                             $result = $instance_sub_table->SQLExec($DBHandle, $QUERY);
                             if (!is_array($result)) {
                                 $QUERY = "INSERT INTO cc_callerid (cid, id_cc_card) VALUES ('{$mycallerid}', '{$id_cc_card}')";
                                 $result = $instance_sub_table->SQLExec($DBHandle, $QUERY, 0);
                                 if ($result == false) {
                                     $callerid_result .= "|callerid{$k}-{$mycallerid}=NOK";
                                 } else {
                                     $callerid_result .= "|callerid{$k}-{$mycallerid}=OK";
                                 }
                             } else {
                                 $callerid_result .= "|callerid{$k}-{$mycallerid}=NOK";
                             }
                         }
                     }
                 }
             }
             //return array('transaction_code', 'account_number', 'card_number', $useralias, 'uipass', 'result', "IDCARD_CREATED=$id_cc_card"."$callerid_result");
             //|LASTQUERY=$QUERY
             // CHECK IF THERE IS A FRIEND TO CREATE
             if ($iax_friend || $sip_friend) {
                 // NEW ACCOUNT CREATED
                 $type = FRIEND_TYPE;
                 $allow = FRIEND_ALLOW;
                 $context = FRIEND_CONTEXT;
                 $nat = FRIEND_NAT;
                 $amaflags = FRIEND_AMAFLAGS;
                 $qualify = FRIEND_QUALIFY;
                 $host = FRIEND_HOST;
                 $dtmfmode = FRIEND_DTMFMODE;
                 $uipass = MDP_STRING();
                 $FG_QUERY_ADITION_SIP_IAX = 'name, type, username, accountcode, regexten, callerid, amaflags, secret, md5secret, nat, dtmfmode, qualify, canreinvite,disallow, allow, host, callgroup, context, defaultip, fromuser, fromdomain, insecure, language, mailbox, permit, deny, mask, pickupgroup, port,restrictcid, rtptimeout, rtpholdtimeout, musiconhold, regseconds, ipaddr, cancallforward';
                 // For IAX and SIP
                 $param_add_fields = "name, accountcode, regexten, amaflags, callerid, context, dtmfmode, host,  type, username, allow, secret";
                 $param_add_value = "'{$cardnum}', '{$cardnum}', '{$cardnum}', '{$amaflags}', '{$cardnum}', '{$context}', '{$dtmfmode}','{$host}', '{$type}', '{$cardnum}', '{$allow}', '" . $uipass . "', '{$id_cc_card}', '{$nat}', '{$qualify}'";
                 $list_names = explode(",", $FG_QUERY_ADITION_SIP_IAX);
                 $FG_TABLE_SIP_NAME = "cc_sip_buddies";
                 $FG_TABLE_IAX_NAME = "cc_iax_buddies";
                 for ($ki = 0; $ki < 2; $ki++) {
                     if ($ki == 0) {
                         if (!$sip_friend) {
                             continue;
                         }
                         $cfriend = 'sip';
                         $FG_TABLE_NAME = "cc_sip_buddies";
                         $buddyfile = BUDDY_SIP_FILE;
                     } else {
                         if (!$iax_friend) {
                             continue;
                         }
                         $cfriend = 'iax';
                         $FG_TABLE_NAME = "cc_iax_buddies";
                         $buddyfile = BUDDY_IAX_FILE;
                     }
                     // Insert Sip/Iax account info
                     if ($ki == 0 && $sip_friend || $ki == 1 && $iax_friend) {
                         $instance_table1 = new Table($FG_TABLE_NAME, $FG_QUERY_ADITION_SIP_IAX);
                         $result_query1 = $instance_table1->Add_table($DBHandle, $param_add_value, $param_add_fields, null, null);
                         $instance_table_friend = new Table($FG_TABLE_NAME, 'id, ' . $FG_QUERY_ADITION_SIP_IAX);
                         $list_friend = $instance_table_friend->Get_list($DBHandle, '', null, null, null, null);
                         $fd = fopen($buddyfile, "w");
                         if (!$fd) {
                             a2b_mail($email_alarm, "ALARM : SOAP-API  - Could not open buddy file '{$buddyfile}'", $mail_content);
                             error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . "[Could not open buddy file '{$buddyfile}'] - SOAP-API " . "\n", 3, $logfile);
                             return array($transaction_code, '', '', '', '', 'Error', 'SOAP-API  - Could not open buddy file $buddyfile');
                         } else {
                             foreach ($list_friend as $data) {
                                 $line = "\n\n[" . $data[1] . "]\n";
                                 if (fwrite($fd, $line) === FALSE) {
                                     error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . "[Impossible to write to the file ({$buddyfile})] - CODE_ERROR 8" . "\n", 3, $logfile);
                                     return array($transaction_code, '', '', '', '', 'Error', 'SOAP-API Impossible to write to the file ($buddyfile)');
                                 } else {
                                     for ($i = 1; $i < count($data) - 1; $i++) {
                                         if (strlen($data[$i + 1]) > 0) {
                                             if (trim($list_names[$i]) == 'allow') {
                                                 $codecs = explode(",", $data[$i + 1]);
                                                 $line = "";
                                                 foreach ($codecs as $value) {
                                                     $line .= trim($list_names[$i]) . '=' . $value . "\n";
                                                 }
                                             } else {
                                                 $line = trim($list_names[$i]) . '=' . $data[$i + 1] . "\n";
                                             }
                                             if (fwrite($fd, $line) === FALSE) {
                                                 error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . "[Impossible to write to the file ({$buddyfile})] - CODE_ERROR 8" . "\n", 3, $logfile);
                                                 return array($transaction_code, '', '', '', '', 'Error', 'SOAP-API ERROR : Card created in the DB but Impossible to write to the file ($buddyfile)');
                                             }
                                         }
                                     }
                                 }
                             }
                             fclose($fd);
                         }
                     }
                 }
                 // END OF FOR - KI
             }
             // END if ($iax_friend || $sip_friend)
             return array($transaction_code, $account_number, $cardnum, $useralias, $uipass, 'result=OK', "ID CARD_CREATED={$result_query}{$callerid_result}");
         } else {
             a2b_mail(EMAIL_ADMIN, "ALARM : SOAP-API (Add_table)", "{$FG_ADITION_SECOND_ADD_VALUE}\n\n" . $mail_content);
             error_log("[" . date("Y/m/d G:i:s", mktime()) . "] " . "[SOAP-API CODE_ERROR Add_table " . "\n", 3, $logfile);
             return array($transaction_code, '', '', '', '', 'Error', 'SOAP-API CODE_ERROR Add_table');
         }
     }
     // END - CHECK PARAMETERS LASTNAME ; FIRSTNAME ; ADDRESS ; ....
 }
Ejemplo n.º 10
0
function add_agi_confx($handle = null)
{
    if (empty($handle)) {
        $handle = DbConnect();
    }
    $instance_table = new Table();
    $config_group = array();
    $config_group = agi_confx_title();
    // calling function  to generate agi-conf(title_number)
    $group_title = $config_group[0];
    $config_group_id = $config_group[1];
    $description = $config_group[2];
    $base_group_title = 'agi-conf' . $config_group[3];
    $value = "'{$group_title}', '{$description}'";
    $func_fields = "group_title, group_description";
    $func_table = 'cc_config_group';
    $id_name = "id";
    $inserted_id = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name);
    $value = "SELECT config_title, config_key, config_value, config_description, config_valuetype, '{$group_title}', config_listvalues FROM cc_config WHERE config_group_title = '{$base_group_title}'";
    $func_fields = "config_title, config_key, config_value, config_description, config_valuetype, config_group_title, config_listvalues";
    $func_table = 'cc_config';
    $id_name = "";
    $subquery = true;
    $result = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name, $subquery);
    return $group_title;
}
Ejemplo n.º 11
0
	function insert_voip_config ($sip, $iax, $id_card, $accountnumber, $passui_secret, $useralias, $language)
	{
	    $who_id = '';
	    if (!isset ($sip))
	        $sip = 0;
	    
	    if (!isset ($iax))
	        $iax = 0;
        
	    // SIP / IAX FRIENDS TABLE
	    $FG_TABLE_SIP_NAME = "cc_sip_buddies";
	    $FG_TABLE_IAX_NAME = "cc_iax_buddies";
	
	    if ((isset ($sip)) || (isset ($iax))) {
	    	
	    	$type = FRIEND_TYPE;
		    $allow = str_replace(' ', '', FRIEND_ALLOW);
		    $context = FRIEND_CONTEXT;
		    $nat = FRIEND_NAT;
		    $amaflags = FRIEND_AMAFLAGS;
		    $qualify = FRIEND_QUALIFY;
		    $host = FRIEND_HOST;
		    $dtmfmode = FRIEND_DTMFMODE;
		    
		    if (!USE_REALTIME) {
				if(($sip == 1) && ($iax == 1))
					$key = "sip_iax_changed";
				elseif ($sip == 1)
					$key = "sip_changed";
				elseif ($iax == 1)
					$key = "iax_changed";
				
				//check who
				if (isset($_SESSION["user_type"]) && $_SESSION["user_type"]=="ADMIN") {
				    $who = Notification::$ADMIN;
				    $who_id = $_SESSION['admin_id'];
				} elseif (isset($_SESSION["user_type"]) && $_SESSION["user_type"]=="AGENT") {
				    $who = Notification::$AGENT;
				    $who_id = $_SESSION['agent_id'];
				} else {
				    $who=Notification::$UNKNOWN;
				    $id=-1;
				}
				NotificationsDAO::AddNotification($key, Notification::$HIGH, $who, $who_id);
			}
	    }
	    
	    // Insert data for sip_buddy
		if ($sip) {
			
			$FG_QUERY_ADITION_SIP_FIELDS = "name, accountcode, regexten, amaflags, callerid, context, dtmfmode, host, type, defaultuser, allow, secret, id_cc_card, nat, qualify, language, rtptimeout, rtpholdtimeout, rtpkeepalive, allowtransfer";
		    $instance_sip_table = new Table($FG_TABLE_SIP_NAME, $FG_QUERY_ADITION_SIP_FIELDS);
		    
			$FG_QUERY_ADITION_SIP_IAX_VALUE = "'$useralias', '$accountnumber', '', '$amaflags', '', '$context', '$dtmfmode','$host', '$type', ".
			                                    "'$useralias', '$allow', '$passui_secret', '$id_card', '$nat', '$qualify', '$language', '60', '300', '30', 'yes'";
			$result_query1 = $instance_sip_table->Add_table($this->DBHandler, $FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null);
			if (USE_REALTIME) {
				$_SESSION["is_sip_iax_change"] = 1;
				$_SESSION["is_sip_changed"] = 1;
			}
		}
		
		// Insert data for iax_buddy
		if ($iax) {
			
			$FG_QUERY_ADITION_IAX_FIELDS = "name, accountcode, regexten, amaflags, callerid, context, host, type, username, allow, secret, id_cc_card, qualify";
		    $instance_iax_table = new Table($FG_TABLE_IAX_NAME, $FG_QUERY_ADITION_IAX_FIELDS);
		    
			$FG_QUERY_ADITION_SIP_IAX_VALUE = "'$accountnumber', '$accountnumber', '$accountnumber', '$amaflags', '', '$context', '$host', '$type', ".
			                                   "'$accountnumber', '$allow', '$passui_secret', '$id_card', '$qualify'";
			$result_query2 = $instance_iax_table->Add_table($this->DBHandler, $FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null);
			if (USE_REALTIME) {
				$_SESSION["is_sip_iax_change"] = 1;
				$_SESSION["is_iax_changed"] = 1;
			}
		}
	
	}
Ejemplo n.º 12
0
 public function insertReceiptItem($desc, $price)
 {
     $DBHandle = DbConnect();
     $instance_sub_table = new Table("cc_receipt_item", "*");
     $QUERY_FIELDS = 'id_receipt, description,price';
     $QUERY_VALUES = "'{$this->id}', '{$desc}','{$price}'";
     $return = $instance_sub_table->Add_table($DBHandle, $QUERY_VALUES, $QUERY_FIELDS, 'cc_receipt_item', 'id');
 }
Ejemplo n.º 13
0
 public function insertComment($desc, $creator, $creator_type)
 {
     $DBHandle = DbConnect();
     $instance_sub_table = new Table("cc_ticket_comment", "*");
     $QUERY_FIELDS = 'id_ticket, description,creator, creator_type';
     $QUERY_VALUES = "'{$this->id}', '{$desc}','{$creator}', '{$creator_type}'";
     switch ($creator_type) {
         case 0:
             $QUERY_FIELDS .= " ,viewed_cust ";
             $QUERY_VALUES .= " ,'0'";
             break;
         case 1:
             $QUERY_FIELDS .= " ,viewed_admin ";
             $QUERY_VALUES .= " ,'0'";
             break;
         case 2:
             $QUERY_FIELDS .= " ,viewed_agent ";
             $QUERY_VALUES .= " ,'0'";
             break;
     }
     $return = $instance_sub_table->Add_table($DBHandle, $QUERY_VALUES, $QUERY_FIELDS, 'cc_ticket_comment', 'id');
     switch ($creator_type) {
         case 0:
             $instance_sub_table = new Table("cc_card", "lastname, firstname");
             $QUERY = " id = " . $creator;
             $subreturn = null;
             $subreturn = $instance_sub_table->Get_list($DBHandle, $QUERY, 0);
             $subvalue = $subreturn[0];
             if (!is_null($subvalue)) {
                 $owner_comment = $subvalue["lastname"] . " " . $subvalue["firstname"];
             }
             break;
         case 1:
             $instance_sub_table = new Table("cc_ui_authen", "*");
             $QUERY = " userid = " . $creator;
             $subreturn = null;
             $subreturn = $instance_sub_table->Get_list($DBHandle, $QUERY, 0);
             $subvalue = $subreturn[0];
             if (!is_null($subvalue)) {
                 $owner_comment = "(ADMINISTRATOR) " . $subvalue["login"];
             }
             break;
         case 2:
             $instance_sub_table = new Table("cc_agent", "lastname, firstname,login");
             $QUERY = " id = " . $creator;
             $subreturn = null;
             $subreturn = $instance_sub_table->Get_list($DBHandle, $QUERY, 0);
             $subvalue = $subreturn[0];
             if (!is_null($subvalue)) {
                 $owner_comment = "(AGENT) " . $subvalue["login"] . " - " . $subvalue["firstname"] . " " . $subvalue["lastname"];
             }
             break;
     }
     $owner = $this->creator_login . " (" . $this->creator_firstname . " " . $this->creator_lastname . ")";
     try {
         $mail = new Mail(Mail::$TYPE_TICKET_MODIFY, null, $this->creator_language);
         $mail->replaceInEmail(Mail::$TICKET_OWNER_KEY, $owner);
         $mail->replaceInEmail(Mail::$TICKET_NUMBER_KEY, $this->id);
         $mail->replaceInEmail(Mail::$TICKET_DESCRIPTION_KEY, $this->description);
         $mail->replaceInEmail(Mail::$TICKET_PRIORITY_KEY, Ticket::DisplayPriority($this->priority));
         $mail->replaceInEmail(Mail::$TICKET_STATUS_KEY, Ticket::getStatusDisplay($this->status));
         $mail->replaceInEmail(Mail::$TICKET_TITLE_KEY, $this->title);
         $mail->replaceInEmail(Mail::$TICKET_COMMENT_DESCRIPTION_KEY, $desc);
         $mail->replaceInEmail(Mail::$TICKET_COMMENT_CREATOR_KEY, $owner_comment);
         $mail->send($this->creator_email);
     } catch (A2bMailException $e) {
         $error_msg = $e->getMessage();
     }
     try {
         $mail = new Mail(Mail::$TYPE_TICKET_MODIFY, null, $this->supportbox_language);
         $mail->replaceInEmail(Mail::$TICKET_OWNER_KEY, $owner);
         $mail->replaceInEmail(Mail::$TICKET_NUMBER_KEY, $this->id);
         $mail->replaceInEmail(Mail::$TICKET_DESCRIPTION_KEY, $this->description);
         $mail->replaceInEmail(Mail::$TICKET_PRIORITY_KEY, Ticket::DisplayPriority($this->priority));
         $mail->replaceInEmail(Mail::$TICKET_STATUS_KEY, Ticket::getStatusDisplay($this->status));
         $mail->replaceInEmail(Mail::$TICKET_TITLE_KEY, $this->title);
         $mail->replaceInEmail(Mail::$TICKET_COMMENT_DESCRIPTION_KEY, $desc);
         $mail->replaceInEmail(Mail::$TICKET_COMMENT_CREATOR_KEY, $owner_comment);
         $mail->send($this->supportbox_email);
     } catch (A2bMailException $e) {
         $error_msg = $e->getMessage();
     }
 }
Ejemplo n.º 14
0
}
$DBHandle = DbConnect();

if (!empty($action)) {
	switch ($action) {
		case 'add' :
			$DBHandle = DbConnect();
			$instance_table = new Table("cc_message_agent","COUNT(*)");
			$clause="id_agent = $id";
			$result=$instance_table -> Get_list($DBHandle, $clause);
			if(is_array($result) && sizeof($result)>0){
			    $count = $result[0][0];
			    $fields="id_agent,type,message,order_display,logo";
			    if(empty($logo))$logo=0;
			    $values="$id,$type,'".addslashes($_POST['message'])."',$count,$logo";
			    $return=$instance_table->Add_table($DBHandle, $values, $fields);
			    if($return)$result_param ="success";
			    else $result_param ="faild";
			    header("Location: A2B_agent_home.php?" . "id=" . $id . "&result=$result_param");
			    die();
			}
			header("Location: A2B_agent_home.php?" . "id=" . $id . "&result=faild");
			die();
			break;
		case 'askedit' :
			if(is_numeric($id_msg)){
			    $DBHandle = DbConnect();
			    $clause = "id = $id_msg";
			    $instance_table = new Table("cc_message_agent","*");
			    $result=$instance_table -> Get_list($DBHandle, $clause);
			    if(is_array($result) && sizeof($result)>0){
    if (!empty($id) && is_numeric($id)) {
        $instance_table_remittance = new Table("cc_remittance_request", "*");
        $param_update_remittance = "status = '1'";
        $clause_update_remittance = " id ='{$id}'";
        $instance_table_remittance->Update_table($DBHandle, $param_update_remittance, $clause_update_remittance, $func_table = null);
        // load
        $result = $instance_table_remittance->Get_list($DBHandle, $clause_update_remittance);
        $type = $result[0]['type'];
        $agent_id = $result[0]['id_agent'];
        $credit = $result[0]['amount'];
        if ($type == 0) {
            // insert refill
            $field_insert = " credit, agent_id, description";
            $value_insert = "'" . $credit . "', '{$agent_id}', '" . gettext('REFILL BY REMITTANCE REQUEST') . "'";
            $instance_sub_table = new Table("cc_logrefill_agent", $field_insert);
            $instance_sub_table->Add_table($DBHandle, $value_insert, null, null, 'id');
            //REFILL... UPDATE AGENT
            $instance_table_agent = new Table("cc_agent");
            $param_update_agent = "credit = credit + '" . $credit . "' , com_balance = com_balance - {$credit} ";
            $clause_update_agent = " id='{$agent_id}'";
            $instance_table_agent->Update_table($DBHandle, $param_update_agent, $clause_update_agent, $func_table = null);
        } else {
            //UPDATE AGENT
            $instance_table_agent = new Table("cc_agent");
            $param_update_agent = " com_balance = com_balance - {$credit} ";
            $clause_update_agent = " id='{$agent_id}'";
            $instance_table_agent->Update_table($DBHandle, $param_update_agent, $clause_update_agent, $func_table = null);
        }
    }
    die;
}
Ejemplo n.º 16
0
	static public function create_agent_refill()
	{
		global $A2B;
		$FormHandler = FormHandler::GetInstance();
		$processed = $FormHandler->getProcessed();
		
		if ($processed['added_refill']==1) {
			$id_payment = $FormHandler -> RESULT_QUERY;
			
			//CREATE REFILL
			$field_insert = "date, credit, agent_id ,refill_type, description";
			$date = $processed['date'];
			$credit = $processed['payment'];
			$agent_id = $processed['agent_id'];
			$refill_type= $processed['payment_type'];
			$description = $processed['description'];
			$value_insert = " '$date' , '$credit', '$agent_id','$refill_type', '$description' ";
			$instance_sub_table = new Table("cc_logrefill_agent", $field_insert);
			$id_refill = $instance_sub_table -> Add_table ($FormHandler->DBHandle, $value_insert, null, null,"id");	
			
			//REFILL AGENT .. UPADTE AGENT
			$instance_table_agent = new Table("cc_agent");
			$param_update_agent = "credit = credit + '".$credit."'";
			$clause_update_agent = " id='$agent_id'";
			$instance_table_agent -> Update_table ($FormHandler->DBHandle, $param_update_agent, $clause_update_agent, $func_table = null);
			
			//LINK THE REFILL TO THE PAYMENT .. UPADTE PAYMENT
			$instance_table_pay = new Table("cc_logpayment_agent");
			$param_update_pay = "id_logrefill = '".$id_refill."'";
			$clause_update_pay = " id ='$id_payment'";
			$instance_table_pay-> Update_table ($FormHandler->DBHandle, $param_update_pay, $clause_update_pay, $func_table = null);
		}
	}
Ejemplo n.º 17
0
$FG_TABLE_CLAUSE = "id_agent = ".$_SESSION['agent_id'];

$list_group = $instance_table_group -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, "id", "ASC", null, null, null, null);

$disabled =false;




if($task=="generate" && !empty($tariffplan) && !empty($group)){
	$code = gen_card('cc_agent_signup',10,'code');
	$table_signup = new Table('cc_agent_signup');
	$fields = "code,id_agent,id_tariffgroup,id_group";
	$values =  "'$code','".$_SESSION['agent_id']."', '$tariffplan','$group'";
	$result_insert = $table_signup -> Add_table($DBHandle,$values,$fields);
	if($result_insert)$URL = $A2B->config['signup']['urlcustomerinterface']."signup.php?key=$code";
}



?>
<?php
$smarty->display('main.tpl');

?>
<script type="text/javascript">
<!--


function submit_form(form){
Ejemplo n.º 18
0
                }
                die;
            } else {
                echo "false";
                die;
            }
            break;
        default:
            die;
            break;
    }
    $DBHandle = DbConnect();
    $table = new Table("cc_notification_admin", "*");
    $fields = "id_notification, id_admin, viewed";
    $values = " {$id} , " . $_SESSION['admin_id'] . ",1 ";
    $return = $table->Add_table($DBHandle, $values, $fields);
    if ($return) {
        echo "true";
    } else {
        echo "false";
    }
    die;
}
if (empty($page)) {
    $page = 1;
}
$DBHandle = DbConnect();
// #### HEADER SECTION
$smarty->display('main__vt.tpl');
if (!VT_DEMO) {
    echo $CC_help_notifications;
    if ($amount_rounded < $threshold_cur) {
        $err_msg = gettext("Invalid amount, is higher than the threshold to authorize a remittance");
    }
    if ($amount_rounded > $commision_bal_cur) {
        $err_msg = gettext("Invalid amount, is higher than your commission Accrued");
    }
    if ($action == "add" && empty($err_msg)) {
        if ($remittance_type == "BANK") {
            $type = 1;
        } else {
            $type = 0;
        }
        $table_remittance = new Table("cc_remittance_request");
        $fields = "id_agent,amount,type";
        $values = $_SESSION['agent_id'] . ",'{$amount_gobal_cur}',{$type}";
        $id = $table_remittance->Add_table($DBHandle_max, $values, $fields, "cc_remittance_request", "id");
        if (is_numeric($id) && $id > 0) {
            $insert = true;
        } else {
            $insert = false;
        }
        NotificationsDAO::AddNotification("remittance_added_agent", Notification::$MEDIUM, Notification::$AGENT, $_SESSION['agent_id'], Notification::$LINK_REMITTANCE, $id);
    }
}
?>

<table style="width:90%;margin:0 auto;" align="center">
<tr>
    <td align="center">
        <table width="80%" align="center" class="tablebackgroundcamel">
        <tr>
Ejemplo n.º 20
0
function archive_data($condition, $entity = "")
{
    if (empty($condition)) {
        return 0;
        exit;
    }
    $handle = DbConnect();
    $instance_table = new Table();
    if (!empty($entity)) {
        if ($entity == "card") {
            $value = "SELECT id, creationdate, firstusedate, expirationdate, enableexpire, expiredays, username, useralias, uipass, credit, tariff, id_didgroup, activated, status, lastname, firstname, address, city, state, country, zipcode, phone, email,fax, inuse, simultaccess, currency, lastuse,nbused, typepaid, creditlimit, voipcall, sip_buddy, iax_buddy, language, redial, runservice, nbservice, id_campaign, num_trials_done, callback, vat, servicelastrun, initialbalance, invoiceday,autorefill, loginkey, activatedbyuser, mac_addr, id_timezone, tag, template_invoice, template_outstanding FROM cc_card {$condition}";
            $func_fields = "id, creationdate, firstusedate, expirationdate, enableexpire, expiredays, username, useralias, uipass, credit, tariff, id_didgroup, activated, status, lastname, firstname, address, city, state, country, zipcode, phone, email,fax, inuse, simultaccess, currency, lastuse,nbused, typepaid, creditlimit, voipcall, sip_buddy, iax_buddy, language, redial, runservice, nbservice, id_campaign, num_trials_done, callback, vat, servicelastrun, initialbalance, invoiceday,autorefill, loginkey, activatedbyuser, mac_addr, id_timezone, tag, template_invoice, template_outstanding";
            $func_table = 'cc_card_archive';
            $id_name = "";
            $subquery = true;
            $result = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name, $subquery);
            $fun_table = "cc_card";
            if (strpos($condition, 'WHERE') > 0) {
                $condition = str_replace("WHERE", "", $condition);
            }
            $result = $instance_table->Delete_table($handle, $condition, $fun_table);
        } else {
            if ($entity == "call") {
                $value = "SELECT id, sessionid,uniqueid,username,nasipaddress,starttime,stoptime,sessiontime,calledstation,startdelay,stopdelay,terminatecause,usertariff,calledprovider,calledcountry,calledsub,calledrate,sessionbill,destination,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,buycost,id_card_package_offer,real_sessiontime FROM cc_call {$condition}";
                $func_fields = "id, sessionid,uniqueid,username,nasipaddress,starttime,stoptime,sessiontime,calledstation,startdelay,stopdelay,terminatecause,usertariff,calledprovider,calledcountry,calledsub,calledrate,sessionbill,destination,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,buycost,id_card_package_offer,real_sessiontime";
                $func_table = 'cc_call_archive';
                $id_name = "";
                $subquery = true;
                $result = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name, $subquery);
                if (strpos($condition, 'WHERE') > 0) {
                    $condition = str_replace("WHERE", "", $condition);
                }
                $fun_table = "cc_call";
                $result = $instance_table->Delete_table($handle, $condition, $fun_table);
            }
        }
    }
    return 1;
}
Ejemplo n.º 21
0
    $instance_table->Add_table($DBHandle, $value_insert, null, null, "id");
}
//link payment to this invoice
$table_payment_invoice = new Table("cc_invoice_payment", "*");
$fields = " id_invoice , id_payment";
$values = " {$id_invoice}, {$id_payment}\t";
$table_payment_invoice->Add_table($DBHandle, $values, $fields);
//END INVOICE
//Agent commision
// test if this card have a agent
$table_transaction = new Table();
$result_agent = $table_transaction->SQLExec($DBHandle, "SELECT cc_card_group.id_agent FROM cc_card LEFT JOIN cc_card_group ON cc_card_group.id = cc_card.id_group WHERE cc_card.id = {$id}");
if (is_array($result_agent) && !is_null($result_agent[0]['id_agent']) && $result_agent[0]['id_agent'] > 0) {
    //test if the agent exist and get its commission
    $id_agent = $result_agent[0]['id_agent'];
    $agent_table = new Table("cc_agent", "commission");
    $agent_clause = "id = " . $id_agent;
    $result_agent = $agent_table->Get_list($DBHandle, $agent_clause);
    if (is_array($result_agent) && is_numeric($result_agent[0]['commission']) && $result_agent[0]['commission'] > 0) {
        $field_insert = "id_payment, id_card, amount,description,id_agent";
        $commission = ceil($amount_paid * $result_agent[0]['commission'] / 100 * 100) / 100;
        $description_commission = gettext("AUTOMATICALY GENERATED COMMISSION!");
        $description_commission .= "\nID CARD : " . $id;
        $description_commission .= "\nID PAYMENT : " . $id_payment;
        $description_commission .= "\nPAYMENT AMOUNT: " . $amount_paid;
        $description_commission .= "\nCOMMISSION APPLIED: " . $result_agent[0]['commission'];
        $value_insert = "'" . $id_payment . "', '{$id}', '{$commission}','{$description_commission}','{$id_agent}'";
        $commission_table = new Table("cc_agent_commission", $field_insert);
        $id_commission = $commission_table->Add_table($DBHandle, $value_insert, null, null, "id");
    }
}
	
	if (!is_null($FG_QUERY_ADITION_HIDDEN_FIELDS) && $FG_QUERY_ADITION_HIDDEN_FIELDS!=""){
		
		if ($i>0) $param_add_fields .= ", ";		
		$param_add_fields .= $FG_QUERY_ADITION_HIDDEN_FIELDS;
		if ($i>0) $param_add_value .= ", ";
		$param_add_value  .= $FG_QUERY_ADITION_HIDDEN_VALUE;
		
	}
	
	
	if ($FG_DEBUG == 1)  echo "<br><hr> $param_add_fields";	
	if ($FG_DEBUG == 1)  echo "<br><hr> $param_add_value";	
	
	$FG_TABLE_ID = "id";
	if ($VALID_SQL_REG_EXP) $result_query=$instance_table -> Add_table ($DBHandle, $param_add_value, $param_add_fields, null, $FG_TABLE_ID);
	if (!$result_query ){
		
			//--echo "<br><b>".$instance_table -> errstr."</b><br>";				
			$findme   = 'duplicate';
			$pos_find = strpos($instance_sub_table -> errstr, $findme);	
					
			// Note our use of ===.  Simply == would not work as expected
			// because the position of 'a' was the 0th (first) character.

			if ($pos_find === false) {		
				//-- echo $instance_sub_table -> errstr;	
			}else{
				//echo $FG_TEXT_ERROR_DUPLICATION;
				$alarm_db_error_duplication = true;				
			}
Ejemplo n.º 23
0
include './form_data/FG_var_ticket.inc';
include './lib/customer.smarty.php';
if (!has_rights(ACX_SUPPORT)) {
    Header("HTTP/1.0 401 Unauthorized");
    Header("Location: PP_error.php?c=accessdenied");
    die;
}
getpost_ifset(array('title', 'description', 'priority', 'component'));
$HD_Form->setDBHandler(DbConnect());
$HD_Form->init();
// ADD TICKET
if ((strlen($description) > 0 || strlen($title) > 0) && is_numeric($priority) && is_numeric($component)) {
    $fields = "creator,title, description, id_component, priority, viewed_cust";
    $ticket_table = new Table('cc_ticket', $fields);
    $values = "'" . $_SESSION["card_id"] . "', '" . $title . "', '" . $description . "', '" . $component . "', '" . $priority . "' ,'0'";
    $id_ticket = $ticket_table->Add_table($HD_Form->DBHandle, $values, null, null, "id");
    NotificationsDAO::AddNotification("ticket_added_cust", Notification::$LOW, Notification::$CUST, $_SESSION['card_id'], Notification::$LINK_TICKET_CUST, $id_ticket);
    $table_card = new Table("cc_card", "firstname, lastname, language, email");
    $card_clause = "id = " . $_SESSION["card_id"];
    $result = $table_card->Get_list($HD_Form->DBHandle, $card_clause);
    $owner = $_SESSION["pr_login"] . " (" . $result[0]['firstname'] . " " . $result[0]['lastname'] . ")";
    try {
        $mail = new Mail(Mail::$TYPE_TICKET_NEW, null, $result[0]['language']);
        $mail->replaceInEmail(Mail::$TICKET_OWNER_KEY, $owner);
        $mail->replaceInEmail(Mail::$TICKET_NUMBER_KEY, $id_ticket);
        $mail->replaceInEmail(Mail::$TICKET_DESCRIPTION_KEY, $description);
        $mail->replaceInEmail(Mail::$TICKET_PRIORITY_KEY, Ticket::DisplayPriority($priority));
        $mail->replaceInEmail(Mail::$TICKET_STATUS_KEY, "NEW");
        $mail->replaceInEmail(Mail::$TICKET_TITLE_KEY, $title);
        $mail->send($result[0]['email']);
    } catch (A2bMailException $e) {
Ejemplo n.º 24
0
function archive_data($condition, $entity = "")
{
    $handle = DbConnect();
    $instance_table = new Table();
    if (!empty($entity)) {
        if ($entity == "card") {
            $func_fields = "id, creationdate, firstusedate, expirationdate, enableexpire, expiredays, username, useralias, uipass, credit, tariff, id_didgroup, activated, status, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, inuse, simultaccess, currency, lastuse, nbused, typepaid, creditlimit, voipcall, sip_buddy, iax_buddy, language, redial, runservice, nbservice, id_campaign, num_trials_done, vat, servicelastrun, initialbalance, invoiceday, autorefill, loginkey, mac_addr, id_timezone, tag, voicemail_permitted, voicemail_activated, last_notification, email_notification, notify_email, credit_notification, id_group, company_name, company_website, VAT_RN, traffic, traffic_target, discount, restriction";
            $value = "SELECT {$func_fields} FROM cc_card {$condition}";
            $func_table = 'cc_card_archive';
            $id_name = "";
            $subquery = true;
            $result = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name, $subquery);
            $fun_table = "cc_card";
            if (strpos($condition, 'WHERE') > 0) {
                $condition = str_replace("WHERE", "", $condition);
            }
            $result = $instance_table->Delete_table($handle, $condition, $fun_table);
        } else {
            if ($entity == "call") {
                $value = "SELECT id, sessionid,uniqueid,card_id,nasipaddress,starttime,stoptime,sessiontime,calledstation,sessionbill,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,id_card_package_offer,real_sessiontime FROM cc_call {$condition}";
                $func_fields = "id, sessionid,uniqueid,card_id,nasipaddress,starttime,stoptime,sessiontime,calledstation,sessionbill,id_tariffgroup,id_tariffplan,id_ratecard,id_trunk,sipiax,src,id_did,buyrate,id_card_package_offer,real_sessiontime";
                $func_table = 'cc_call_archive';
                $id_name = "";
                $subquery = true;
                $result = $instance_table->Add_table($handle, $value, $func_fields, $func_table, $id_name, $subquery);
                if (strpos($condition, 'WHERE') > 0) {
                    $condition = str_replace("WHERE", "", $condition);
                }
                $fun_table = "cc_call";
                $result = $instance_table->Delete_table($handle, $condition, $fun_table);
            }
        }
    }
    return 1;
}
Ejemplo n.º 25
0
        $arr_card_alias = gen_card_with_alias("cc_card", 0, $cardnumberlenght_list);
        $accountnumber = $arr_card_alias[0];
        $useralias = $arr_card_alias[1];
        if (!is_numeric($addcredit)) {
            $addcredit = 0;
        }
        $passui_secret = MDP_NUMERIC(5) . MDP_STRING(10) . MDP_NUMERIC(5);
        $FG_ADITION_SECOND_ADD_VALUE = "'{$accountnumber}', '{$useralias}', '{$addcredit}', '{$choose_tariff}', 't', '{$gen_id}', '', '', '', '', '', '{$id_country}', '', '', {$choose_simultaccess}, '{$choose_currency}', " . "{$choose_typepaid}, {$creditlimit}, {$enableexpire}, '{$expirationdate}', {$expiredays}, '{$passui_secret}', '{$runservice}', '{$tag}', '{$id_group}', '{$discount}', '{$id_seria}', " . "'{$id_didgroup}', {$sip_buddy}, {$iax_buddy}, '{$vat}'";
        if (DB_TYPE != "postgres") {
            $FG_ADITION_SECOND_ADD_VALUE .= ", now() ";
        }
        $id_cc_card = $instance_sub_table->Add_table($HD_Form->DBHandle, $FG_ADITION_SECOND_ADD_VALUE, null, null, $HD_Form->FG_TABLE_ID);
        //create refill for each cards
        if ($addcredit > 0) {
            $value_insert_refill = "'{$addcredit}', '{$id_cc_card}', '{$description_refill}' ";
            $instance_refill_table->Add_table($HD_Form->DBHandle, $value_insert_refill, null, null);
        }
        $instance_realtime->insert_voip_config($sip, $iax, $id_cc_card, $accountnumber, $passui_secret);
    }
    // Save Sip accounts to file
    if (isset($sip)) {
        $instance_realtime->create_trunk_config_file('sip');
    }
    // Save IAX accounts to file
    if (isset($iax)) {
        $instance_realtime->create_trunk_config_file('iax');
    }
}
if (!isset($_SESSION["IDfilter"])) {
    $_SESSION["IDfilter"] = 'NODEFINED';
}
Ejemplo n.º 26
0
$HD_Form->FG_OTHER_BUTTON2 = false;
$HD_Form->FG_FILTER_APPLY = false;
$HD_Form->FG_LIST_ADDING_BUTTON1 = false;
$HD_Form->FG_LIST_ADDING_BUTTON2 = false;
$nbvoucher = $choose_list;
if ($nbvoucher > 0) {
    check_demo_mode();
    $FG_ADITION_SECOND_ADD_TABLE = "cc_voucher";
    $FG_ADITION_SECOND_ADD_FIELDS = "voucher, credit, activated, tag, currency, expirationdate";
    $instance_sub_table = new Table($FG_ADITION_SECOND_ADD_TABLE, $FG_ADITION_SECOND_ADD_FIELDS);
    $gen_id = time();
    $_SESSION["IDfilter"] = $tag_list;
    for ($k = 0; $k < $nbvoucher; $k++) {
        $vouchernum = generate_unique_value($FG_ADITION_SECOND_ADD_TABLE, LEN_VOUCHER, 'voucher');
        $FG_ADITION_SECOND_ADD_VALUE = "'{$vouchernum}', '{$addcredit}', 't', '{$tag_list}', '{$choose_currency}', '{$expirationdate}'";
        $result_query = $instance_sub_table->Add_table($HD_Form->DBHandle, $FG_ADITION_SECOND_ADD_VALUE, null, null);
    }
}
if (!isset($_SESSION["IDfilter"])) {
    $_SESSION["IDfilter"] = 'NODEFINED';
}
$HD_Form->FG_TABLE_CLAUSE = "tag='" . $_SESSION["IDfilter"] . "'";
$HD_Form->init();
if ($id != "" || !is_null($id)) {
    $HD_Form->FG_EDITION_CLAUSE = str_replace("%id", "{$id}", $HD_Form->FG_EDITION_CLAUSE);
}
if (!isset($form_action)) {
    $form_action = "list";
}
//ask-add
if (!isset($action)) {
 /**
  * Function to add_content
  * @public
  */
 function perform_add_content($sub_action, $id)
 {
     $processed = $this->getProcessed();
     $table_split = preg_split("/:/", $this->FG_TABLE_EDITION[$sub_action][14]);
     $instance_sub_table = new Table($table_split[0], $table_split[1] . ", " . $table_split[5]);
     if (is_array($processed[$table_split[1]])) {
         foreach ($processed[$table_split[1]] as $value) {
             if (empty($table_split[12]) || preg_match('/' . $this->FG_regular[$table_split[12]][0] . '/', $value)) {
                 // RESPECT REGULAR EXPRESSION
                 $result_query = $instance_sub_table->Add_table($this->DBHandle, "'" . addslashes(trim($value)) . "', '" . addslashes(trim($id)) . "'", null, null);
                 if (!$result_query) {
                     $findme = 'duplicate';
                     $pos_find = strpos($instance_sub_table->errstr, $findme);
                     if ($pos_find === false) {
                         echo $instance_sub_table->errstr;
                     } else {
                         $alarm_db_error_duplication = true;
                     }
                 }
             }
         }
     } else {
         $value = $processed[$table_split[1]];
         if (empty($table_split[12]) || preg_match('/' . $this->FG_regular[$table_split[12]][0] . '/', $value)) {
             // RESPECT REGULAR EXPRESSION
             $result_query = $instance_sub_table->Add_table($this->DBHandle, "'" . addslashes(trim($value)) . "', '" . addslashes(trim($id)) . "'", null, null);
             if (!$result_query) {
                 $findme = 'duplicate';
                 $pos_find = strpos($instance_sub_table->errstr, $findme);
                 if ($pos_find === false) {
                     echo $instance_sub_table->errstr;
                 } else {
                     $alarm_db_error_duplication = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
    echo "CREATE TRUNK : {$nb_db_trunk} <br><br>\n\n";
}
// -----------------------------------
// CREATE CALLPLAN
// -----------------------------------
$id_callplan_list = array();
for ($i = 0; $i < $nb_callplan; $i++) {
    if ($verbose > 1) {
        echo "CREATE CALLPLAN : {$i}\n";
    }
    $id_name = intval(microtime(true) * 10000) + rand(100000000, 999999999);
    $QUERY_FIELDS = "iduser ,idtariffplan ,tariffgroupname ,lcrtype ,creationdate ,removeinterprefix ,id_cc_package_offer";
    $QUERY_VALUES = "'0', '0', 'CALLPLAN : {$id_name}', '0',NOW() , '0', '-1'";
    $QUERY_ID = "id";
    $QUERY_TABLE = "cc_tariffgroup";
    $id_tmp = $instance_table->Add_table($A2B->DBHandle, $QUERY_VALUES, $QUERY_FIELDS, $QUERY_TABLE, $QUERY_ID);
    $id_callplan_list[$i] = $id_tmp;
}
$instance_callplan = new Table("cc_tariffgroup", "id");
$id_callplan_list = $instance_callplan->Get_list($A2B->DBHandle, null, null, null, null, null, 1000, 1);
$nb_db_callplan = sizeof($id_callplan_list);
if ($verbose > 0) {
    echo "CREATE CALLPLAN : " . $nb_db_callplan . " <br><br>\n\n";
}
// -----------------------------------
// CREATE RATECARD
// -----------------------------------
$id_ratecards_list = array();
for ($i = 0; $i < $nb_ratecard; $i++) {
    if ($verbose > 1) {
        echo "CREATE RATECARD : {$i}\n";
Ejemplo n.º 29
0
    $filename = basename($path);
    $len = filesize($path);
    header("content-type: application/stream");
    header("content-length: " . $len);
    header("content-disposition: attachment; filename=" . $filename);
    $fp = fopen($path, "r");
    fpassthru($fp);
    exit;
}
if ($form_action == "upload") {
    $uploaddir = BACKUP_PATH . '/';
    $uploadfile = $uploaddir . basename($_FILES['databasebackup']['name']);
    if (move_uploaded_file($_FILES['databasebackup']['tmp_name'], $uploadfile)) {
        $instance_table_backup = new Table($HD_Form->FG_TABLE_NAME, 'id, name, path, creationdate');
        $param_add_value = "'','Custom" . date("Ymd-His") . "','" . $uploadfile . "',now()";
        $result_query = $instance_table_backup->Add_table($HD_Form->DBHandle, $param_add_value, null, null, null);
        if (isset($FG_GO_LINK_AFTER_UPLOAD)) {
            Header("Location: {$FG_GO_LINK_AFTER_UPLOAD}");
            exit;
        }
    } else {
        $error_upload = gettext("Error uploading file");
    }
}
$list = $HD_Form->perform_action($form_action);
// #### HEADER SECTION
$smarty->display('main.tpl');
// #### HELP SECTION
echo $CC_help_database_restore;
// #### TOP SECTION PAGE
$HD_Form->create_toppage($form_action);
Ejemplo n.º 30
0
if ($id > 0) {
    $addcredit = $transaction_data[0][2];
    $instance_table = new Table("cc_agent", "");
    $param_update .= " credit = credit + '" . $amount_without_vat . "'";
    $FG_EDITION_CLAUSE = " id='{$id}'";
    $instance_table->Update_table($DBHandle, $param_update, $FG_EDITION_CLAUSE, $func_table = null);
    write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " Update_table cc_card : {$param_update} - CLAUSE : {$FG_EDITION_CLAUSE}");
    $field_insert = "date, credit, agent_id, description";
    $value_insert = "'{$nowDate}', '" . $amount_without_vat . "', '{$id}', '" . $transaction_data[0][4] . "'";
    $instance_sub_table = new Table("cc_logrefill_agent", $field_insert);
    $id_logrefill = $instance_sub_table->Add_table($DBHandle, $value_insert, null, null, 'id');
    write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " Add_table cc_logrefill : {$field_insert} - VALUES {$value_insert}");
    $field_insert = "date, payment, agent_id, id_logrefill, description";
    $value_insert = "'{$nowDate}', '" . $amount_paid . "', '{$id}', '{$id_logrefill}', '" . $transaction_data[0][4] . "'";
    $instance_sub_table = new Table("cc_logpayment_agent", $field_insert);
    $id_payment = $instance_sub_table->Add_table($DBHandle, $value_insert, null, null, "id");
    write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "-transactionID={$transactionID}" . " Add_table cc_logpayment : {$field_insert} - VALUES {$value_insert}");
}
$_SESSION["p_amount"] = null;
$_SESSION["p_cardexp"] = null;
$_SESSION["p_cardno"] = null;
$_SESSION["p_cardtype"] = null;
$_SESSION["p_module"] = null;
$_SESSION["p_module"] = null;
//Update the Transaction Status to 1 (Proceed 1)
$QUERY = "UPDATE cc_epayment_log_agent SET status=1, transaction_detail='" . addslashes($transaction_detail) . "' WHERE id = " . $transactionID;
$paymentTable->SQLExec($DBHandle_max, $QUERY);
write_log(LOGFILE_EPAYMENT, basename(__FILE__) . ' line:' . __LINE__ . "- QUERY = {$QUERY}");
switch ($orderStatus) {
    case -2:
        $statusmessage = "Failed";