<?php
/**
* @copyright Copyright (c) 2015 Christopher W. Olsen <cwolsen@uBixStudios.com>
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* @package VoIP
* @subpackage VoIP Dial Plan
* @version $Id: $
*/
/* Main include info */
ini_set ( 'include_path', $_SERVER ['DOCUMENT_ROOT'] . "/include/" );
include ("config.php");
$ubF->session->Validate_JSON ( 'A_V_', 1 );
switch ( $form_data ['req'] ) {
case 'dialplan_dynDID' :
$query = "SELECT * FROM dialplan WHERE context = 'dyn-did' AND exten = '+1" . $form_data ['exten'] . "' ORDER BY priority";
$result = $ubF->DB ['voip']->query ( $query );
while ( $qData = $result->fetch_assoc () ) {
$rows [] = $qData;
}
$ubF->json_return ( 1, 'Success', json_encode ( $rows ) );
break;
case 'dialplan_pubList' :
if ( !isset ( $form_data ['account_number'] ) ) { // && ! preg_match ( '/\d{2}-\d{5}-\d{3}/', $form_data ['account_number'] )) {
$ubF->json_return ( 0, "Invalid Account" );
}
else {
$query = "SELECT exten,label FROM voip_dialplan_info WHERE account_number = '" . $form_data ['account_number'] . "' AND dp_type = 'pub' ORDER by label";
$result = $ubF->DB ['main']->query ( $query );
$rows = Array ();
if ( $result !== false && $result->num_rows > 0 ) {
while ( $qData = $result->fetch_assoc () ) {
$rows [] = array (
'Desc' => $qData ['label'],
'ID' => $qData ['exten']
);
}
}
else {
$rows [] = Array (
'Desc' => 'No Available Dial Plans',
'ID' => 0
);
}
$ubF->json_return ( 1, 'Success', $rows );
}
break;
case 'dialplan_list' :
if ( isset ( $form_data ['account_number'] ) && ($form_data ['account_number'] != "") )
$query = "SELECT * FROM voip_dialplan where account_number = '" . $form_data ['account_number'] . "'";
else
$query = "SELECT * FROM voip_dialplan";
$result = $ubF->DB ['main']->query ( $query );
while ( $qData = $result->fetch_assoc () )
$rows [] = array(
$qData['account_number'],
$qData['label'],
0,
0,
0,
0,
0
);
$ubF->json_return ( 1, 'Success', $rows );
break;
default :
$ubF->json_return ( 0, "Invalid Command" );
break;
}
print (json_encode ( $json_data )) ;
?>