Ejemplo n.º 1
0
        }
        $msg_error .= gettext("- EXPIRATION DAY inserted is invalid, it must respect the date format YYYY-MM-DD HH:MM:SS (time is optional) !");
    }
    if (!is_numeric($nb_to_create) || $nb_to_create < 1) {
        $nb_error++;
        $number_error = true;
        if (!empty($msg_error)) {
            $msg_error .= "<br/>";
        }
        $msg_error .= gettext("- Choose the number of customers that you want generate!");
    }
}
$nbcard = $nb_to_create;
if ($nbcard > 0 && $action == "generate" && $nb_error == 0) {
    check_demo_mode();
    $instance_realtime = new Realtime();
    $FG_ADITION_SECOND_ADD_TABLE = "cc_card";
    $FG_ADITION_SECOND_ADD_FIELDS = "username, useralias, credit, tariff, activated, lastname, firstname, email, address, city, state, country, zipcode, phone, simultaccess, currency, typepaid, " . "creditlimit, enableexpire, expirationdate, expiredays, uipass, runservice, tag,id_group, discount, id_seria, id_didgroup, sip_buddy, iax_buddy, vat";
    if (DB_TYPE != "postgres") {
        $FG_ADITION_SECOND_ADD_FIELDS .= ",creationdate ";
    }
    $instance_sub_table = new Table($FG_ADITION_SECOND_ADD_TABLE, $FG_ADITION_SECOND_ADD_FIELDS);
    $gen_id = time();
    $_SESSION["IDfilter"] = $gen_id;
    $sip_buddy = $iax_buddy = 0;
    if (isset($sip) && $sip == 1) {
        $sip_buddy = 1;
    }
    if (isset($iax) && $iax == 1) {
        $iax_buddy = 1;
    }
Ejemplo n.º 2
0
    function Create_Customer($security_key, $instance, $id_callplan, $id_didgroup, $units, $accountnumber_len, $balance, $activated, $status,  $simultaccess, $currency, $typepaid, $sip, $iax,  $language, $voicemail_enabled, $country)
    {
        $arr_check = $this->Check_KeyInstance($security_key, $instance);
		if ($arr_check[0] == 'ERROR') {
		    return $arr_check;
		}
		$id_group = $arr_check[0];
		
		if (!is_numeric($id_callplan)) {
		    return array("ERROR", "NO ID_CALLPLAN PROVIDED");
		}
		
		if ($accountnumber_len < 2 || $accountnumber_len > 40) {
		    return array("ERROR", "WRONG ACCOUNT NUMBER LENGTH - $accountnumber_len");
		}
		
		if (strlen($country)==3)
			$country = strtoupper($country);
		else 
			$country = 'USA';
		
		if (strlen($language)==2)
			$language = strtolower($language);
		else
			$language = 'en';
		
		if ($activated)
			$activated = 't';
	    else
	        $activated = 'f';
		
		$instance_realtime = new Realtime();
        
	    $FG_ADITION_SECOND_ADD_TABLE = "cc_card";
	    $FG_ADITION_SECOND_ADD_FIELDS = "username, useralias, credit, tariff, country, language, activated, simultaccess, currency, typepaid, uipass, id_group, id_didgroup, sip_buddy, iax_buddy";

	    if (DB_TYPE != "postgres") {
		    $FG_ADITION_SECOND_ADD_FIELDS .= ",creationdate ";
	    }
	
	    $instance_sub_table = new Table($FG_ADITION_SECOND_ADD_TABLE, $FG_ADITION_SECOND_ADD_FIELDS);
	    
	    $sip_buddy = $iax_buddy = 0;
	    
	    if (isset ($sip) && $sip == 1)
            $sip_buddy = 1;
        
        if (isset ($iax) && $iax == 1)
            $iax_buddy = 1;
        
	    //initialize refill parameter
	    $description_refill = gettext("CREATION CARD REFILL");
	    $field_insert_refill = "credit, card_id, description";
	    $instance_refill_table = new Table("cc_logrefill", $field_insert_refill);
        $arr_account = array();
        
	    for ($k = 0; $k < $units; $k++) {
		    $arr_card_alias = gen_card_with_alias("cc_card", 0, $accountnumber_len);
		    $accountnumber = $arr_card_alias[0];
		    $useralias = $arr_card_alias[1];
		    if (!is_numeric($balance))
			    $balance = 0;
		    $passui_secret = MDP_NUMERIC(10);
		
		    $FG_ADITION_SECOND_ADD_VALUE = "'$accountnumber', '$useralias', '$balance', '$id_callplan', '$country', '$language', '$activated', ".
		                         " $simultaccess, '$currency', $typepaid, '$passui_secret', '$id_group', '$id_didgroup', $sip_buddy, $iax_buddy";
            
		    if (DB_TYPE != "postgres")
			    $FG_ADITION_SECOND_ADD_VALUE .= ", now() ";
		    
		    $id_cc_card = $instance_sub_table->Add_table($this->DBHandle, $FG_ADITION_SECOND_ADD_VALUE, null, null, 'id');
		    
		    if (!$id_cc_card) {
		        return array(false, "ERROR CREATING ACCOUNT (".$k." Accounts created)");
		    }
		    
		    $arr_account[] = array ($accountnumber, $id_cc_card);
		    
		    // create refill for card
		    if ($balance > 0) {
			    $value_insert_refill = "'$balance', '$id_cc_card', '$description_refill' ";
			    $instance_refill_table->Add_table($this->DBHandle, $value_insert_refill, null, null);
		    }
            
		    $instance_realtime -> insert_voip_config ($sip_buddy, $iax_buddy, $id_cc_card, $accountnumber, $passui_secret, $useralias, $language);
	    }
	    
	    // Save Sip accounts to file
	    $instance_realtime -> create_trunk_config_file ('sip');
	    
	    // Save IAX accounts to file
	    $instance_realtime -> create_trunk_config_file ('iax');
	    
	    
		return array(serialize($arr_account), "Create_Customer SUCCESS - ".$k." ACCOUNTS CREATED");
    }
Ejemplo n.º 3
0
$URL = 'http://ortc-developers.realtime.co/server/2.1';
$AK = 'YOUR_APPLICATION_KEY';
// your realtime.co application key
$PK = 'YOUR_APPLICATION_PRIVATE_KEY';
// your realtime.co private key
$TK = 'YOUR_AUTHENTICATION_TOKEN';
// token: could be randomly generated in the session
$CH = 'MyChannel';
//channel
$ttl = 180;
$isAuthRequired = false;
$result = false;
/* -------------------- */
/*        END           */
/* -------------------- */
// ORTC auth
// on a live usage we would already have the auth token authorized and stored in a php session
// Since a developer appkey does not require authentication the following code is optional
if (!array_key_exists('ortc_token', $_SESSION)) {
    $_SESSION['ortc_token'] = $TK;
}
$rt = new Realtime($URL, $AK, $PK, $TK);
if ($isAuthRequired) {
    $result = $rt->auth(array($CH => 'w'), $ttl);
    //post authentication permissions. w -> write; r -> read
    echo 'authentication status ' . ($result ? 'success' : 'failed') . '<br/>';
}
if ($result || !$isAuthRequired) {
    $result = $rt->send($CH, "Sending message from php API", $response);
    echo ' send status ' . ($result ? 'success' : 'failed') . '<br/>';
}
Ejemplo n.º 4
0
	/**
     * Function to edit the fields
     * @public
     */
	static public function create_sipiax_friends()
	{
		global $A2B;
		$FormHandler = FormHandler::GetInstance();
		$processed = $FormHandler->getProcessed();
		$id = $FormHandler -> RESULT_QUERY; // DEFINED BEFORE FG_ADDITIONAL_FUNCTION_AFTER_ADD		
		$sip = stripslashes($processed['sip_buddy']);
		$iax = stripslashes($processed['iax_buddy']);
		$language = stripslashes($processed['language']);
		
		// $FormHandler -> FG_QUERY_EXTRA_HIDDED - username, useralias, uipass, loginkey
		if (strlen($FormHandler -> FG_QUERY_EXTRA_HIDDED[0])>0) {
			$username 	= $FormHandler -> FG_QUERY_EXTRA_HIDDED[0];
			$uipass 	= $FormHandler -> FG_QUERY_EXTRA_HIDDED[2];
			$useralias 	= $FormHandler -> FG_QUERY_EXTRA_HIDDED[1];
		} else {
			$username 	= $processed['username'];
			$uipass 	= $processed['uipass'];
			$useralias 	= $processed['useralias'];
		}
		
		$instance_realtime = new Realtime();
		
		$instance_realtime -> insert_voip_config ($sip, $iax, $id, $username, $uipass, $useralias, $language);
		
		// Save info in table and in sip file
		if ($sip == 1) {
			$instance_realtime -> create_trunk_config_file ('sip');
		}
		
		// Save info in table and in iax file
		if ($iax == 1) {
			$instance_realtime -> create_trunk_config_file ('iax');
		}
	}
Ejemplo n.º 5
0
		} elseif ( $atmenu == "iaxfriend" ) {
			$res = $as->Command('iax2 reload');
		} else {
			$res = $as->Command('sip reload');
			$res = $as->Command('iax2 reload');
		}
		$actiondone=1;
		
		// && DISCONNECTING	
		$as->disconnect();
	} else {
		$error_msg= "</br><center><b><font color=red>".gettext("Cannot connect to the asterisk manager!<br>Please check your manager configuration.")."</font></b></center>";		
	}
} else {
	
	$instance_realtime = new Realtime();
	
	if ( $atmenu == "sipfriend" ) {
		
		$buddyfile = BUDDY_SIP_FILE;
		$instance_realtime -> create_trunk_config_file ('sip');
		
		$_SESSION["is_sip_changed"]=0;
		if ($_SESSION["is_iax_changed"]==0) {
			$_SESSION["is_sip_iax_change"]=0;			
		}
	} else {
		
		$buddyfile = BUDDY_IAX_FILE;
		$instance_realtime -> create_trunk_config_file ('iax');