diff --git a/app/providers/app_config.php b/app/providers/app_config.php new file mode 100644 index 0000000000..5e13d53c06 --- /dev/null +++ b/app/providers/app_config.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/app/providers/app_languages.php b/app/providers/app_languages.php new file mode 100644 index 0000000000..9edbda0fa9 --- /dev/null +++ b/app/providers/app_languages.php @@ -0,0 +1,303 @@ + \ No newline at end of file diff --git a/app/providers/app_menu.php b/app/providers/app_menu.php new file mode 100644 index 0000000000..433fefd483 --- /dev/null +++ b/app/providers/app_menu.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/app/providers/provider_delete.php b/app/providers/provider_delete.php new file mode 100755 index 0000000000..d5f781d13d --- /dev/null +++ b/app/providers/provider_delete.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + include "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('dialplan_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the provider + if (isset($_GET["provider"])) { + $provider = new providers; + $reports->domain_uuid = $_SESSION['domain_uuid']; + $provider->delete($_GET["provider"]); + } + +//clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + +//set the add message + messages::add($text['message-delete']); + +//redirect the user + header("Location: index.php"); + return; + +?> \ No newline at end of file diff --git a/app/providers/provider_setup.php b/app/providers/provider_setup.php new file mode 100755 index 0000000000..acae2119c0 --- /dev/null +++ b/app/providers/provider_setup.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + include "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('dialplan_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the provider + if (isset($_GET["provider"])) { + $provider = new providers; + $reports->domain_uuid = $_SESSION['domain_uuid']; + $provider->setup($_GET["provider"]); + } + +//clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + +//set the add message + messages::add($text['message-add']); + +//redirect the user + header("Location: index.php"); + return; + +?> \ No newline at end of file diff --git a/app/providers/providers.php b/app/providers/providers.php new file mode 100755 index 0000000000..c88a9fb4b9 --- /dev/null +++ b/app/providers/providers.php @@ -0,0 +1,162 @@ + + Portions created by the Initial Developer are Copyright (C) 2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + include "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('dialplan_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the provider + if (isset($_REQUEST["provider"])) { + $provider = check_str($_REQUEST["provider"]); + switch ($provider) { + case 'voicetel': + break; + case 'skyetel': + break; + default: + $provider = ''; + } + echo $provider; + exit; + } + +//skyetel installed + $sql = "select gateway_uuid from v_gateways "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $gateways = $prep_statement->fetchAll(); + $skyetel_installed = false; + $voicetel_installed = false; + foreach ($gateways as $row) { + if ($row['gateway_uuid'] === "22245a48-552c-463a-a723-ce01ebbd69a2") { + $skyetel_installed = true; + } + if ($row['gateway_uuid'] === "d61be0f0-3a4c-434a-b9f6-4fef15e1a634") { + $voicetel_installed = true; + } + } + +?> + +
+
+ ".$text['title-providers']."\n"; + echo "
\n"; + echo $text['description-providers']."\n"; + ?> +
+
+

+ + +
+
+


+ +
+
+
+
+ VoiceTel\n"; + echo "
\n"; + echo "".$text['label-region']."
\n"; + echo $text['label-region_voicetel']."\n"; + echo "

\n"; + echo "".$text['label-about']."
\n"; + echo $text['label-about_voicetel']."\n"; + echo "

\n"; + echo "".$text['label-features']."
\n"; + echo $text['label-features_voicetel']."\n"; + echo "

\n"; + echo "\n"; + echo "\n"; + if (!$voicetel_installed) { + echo "\n"; + } + else { + echo "\n"; + } + ?> +
+ +
+




+ + +
+
+

+ +
+
+
+
+ Skyetel\n"; + echo "
\n"; + echo "".$text['label-region']."
\n"; + echo $text['label-region_skyetel']."\n"; + echo "

\n"; + echo "".$text['label-about']."
\n"; + echo $text['label-about_skyetel']."\n"; + echo "

\n"; + echo "".$text['label-features']."
\n"; + echo $text['label-features_skyetel']."\n"; + echo "

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (!$skyetel_installed) { + echo "\n"; + } + else { + echo "\n"; + } + ?> +
+
+ +


+ + \ No newline at end of file diff --git a/app/providers/resources/classes/providers.php b/app/providers/resources/classes/providers.php new file mode 100644 index 0000000000..9ff21f6c6b --- /dev/null +++ b/app/providers/resources/classes/providers.php @@ -0,0 +1,565 @@ +2 + Portions created by the Initial Developer are Copyright (C) 2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + +/** + * providers class provides methods for providing an overview + * + * @method boolean add + */ +if (!class_exists('providers')) { + class providers { + + //define variables + public $db; + public $debug; + public $domain_uuid; + public $array; + + /** + * Called when the object is created + */ + public function __construct() { + //connect to the database if not connected + if (!$this->db) { + require_once "resources/classes/database.php"; + $database = new database; + $database->connect(); + $this->db = $database->db; + } + } + + /** + * Called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + if (isset($this)) foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * nodes array + */ + public function nodes($provider) { + + //build the skyetel node array + if ($provider == 'skyetel') { + $x = 0; + $nodes[$x]['uuid'] = 'af26484f-03a1-4f93-857b-b8cef1ac28f5'; + $nodes[$x]['cidr'] = '52.41.52.34/32'; + $nodes[$x]['description'] = 'Skyetel - North West'; + $x++; + $nodes[$x]['uuid'] = '87eb7803-9b96-41d3-ac5a-42ed3f213777'; + $nodes[$x]['cidr'] = '52.8.201.128/32'; + $nodes[$x]['description'] = 'Skyetel - South West'; + $x++; + $nodes[$x]['uuid'] = 'cf61ab01-1465-4eca-9152-2e6fd4a02073'; + $nodes[$x]['cidr'] = '52.60.138.31/32'; + $nodes[$x]['description'] = 'Skyetel - North East'; + $x++; + $nodes[$x]['uuid'] = 'b43ebeef-c214-492b-8f22-4bfc6b647668'; + $nodes[$x]['cidr'] = '50.17.48.216/32'; + $nodes[$x]['description'] = 'Skyetel - South East'; + $x++; + $nodes[$x]['uuid'] = '28615834-4517-4515-b474-5ca54ee958fc'; + $nodes[$x]['cidr'] = '35.156.192.164/32'; + $nodes[$x]['description'] = 'Skyetel - Europe'; + } + + //build the voicetel node array + if ($provider == 'voicetel') { + $x = 0; + $nodes[$x]['uuid'] = 'dae9ab41-73c1-4792-bfdb-eccbedeebac9'; + $nodes[$x]['cidr'] = '199.101.184.146/32'; + $nodes[$x]['description'] = 'VoiceTel'; + $x++; + $nodes[$x]['uuid'] = '3167d47d-0679-4336-b4c4-be68cdc28e5b'; + $nodes[$x]['cidr'] = '162.243.249.135/32'; + $nodes[$x]['description'] = 'VoiceTel'; + $x++; + $nodes[$x]['uuid'] = 'e3d2e9b8-5807-4175-9ffc-57480ac94f83'; + $nodes[$x]['cidr'] = '192.254.76.222/32'; + $nodes[$x]['description'] = 'VoiceTel'; + $x++; + $nodes[$x]['uuid'] = 'a1d70666-ab25-425a-9884-60530f4dd8b7'; + $nodes[$x]['cidr'] = '162.243.156.185/32'; + $nodes[$x]['description'] = 'VoiceTel'; + $x++; + $nodes[$x]['uuid'] = '0bf5450f-c23b-4139-9e89-884bd0972912'; + $nodes[$x]['cidr'] = '94.75.246.200/32'; + $nodes[$x]['description'] = 'VoiceTel'; + $x++; + $nodes[$x]['uuid'] = '181dcaf8-f990-4869-90e3-97de7d2daa5a'; + $nodes[$x]['cidr'] = '204.77.3.60/32'; + $nodes[$x]['description'] = 'VoiceTel'; + } + + //return the array + return $nodes; + } + + /** + * gateways array + */ + public function gateways($provider) { + + //build the array + if ($provider == 'skyetel') { + $x=0; + $gateways[$x]['uuid'] = '22245a48-552c-463a-a723-ce01ebbd69a2'; + $gateways[$x]['name'] = 'term.skyetel.com'; + $gateways[$x]['proxy'] = 'term.skyetel.com'; + $gateways[$x]['username'] = 'username'; + $gateways[$x]['password'] = 'password'; + $gateways[$x]['register'] = 'false'; + $x++; + $gateways[$x]['uuid'] = 'b171ba70-06a5-4560-82be-596ed9d00041'; + $gateways[$x]['name'] = 'skyetel.34'; + $gateways[$x]['proxy'] = '52.41.52.34'; + $gateways[$x]['username'] = 'username'; + $gateways[$x]['password'] = 'password'; + $gateways[$x]['register'] = 'false'; + $x++; + $gateways[$x]['uuid'] = '4864ac6e-9e50-4fff-8381-2c508f8912b5'; + $gateways[$x]['name'] = 'skyetel.128'; + $gateways[$x]['proxy'] = '52.8.201.128'; + $gateways[$x]['username'] = 'username'; + $gateways[$x]['password'] = 'password'; + $gateways[$x]['register'] = 'false'; + $x++; + $gateways[$x]['uuid'] = '5553606b-e543-4427-bb63-ebed16001937'; + $gateways[$x]['name'] = 'skyetel.216'; + $gateways[$x]['proxy'] = '50.17.48.216'; + $gateways[$x]['username'] = 'username'; + $gateways[$x]['password'] = 'password'; + $gateways[$x]['register'] = 'false'; + $x++; + } + if ($provider == 'voicetel') { + //build the array + $x=0; + $gateways[$x]['uuid'] = 'd61be0f0-3a4c-434a-b9f6-4fef15e1a634'; + $gateways[$x]['name'] = 'voicetel'; + $gateways[$x]['proxy'] = 'sbc.voicetel.com'; + $gateways[$x]['username'] = 'username'; + $gateways[$x]['password'] = 'password'; + $gateways[$x]['register'] = 'true'; + $x++; + } + + //return the array + return $gateways; + } + + /** + * setup the provider + */ + public function setup($provider) { + + //validate the provider + switch ($provider) { + case 'voicetel': + break; + case 'skyetel': + break; + default: + $provider = ''; + } + + //get the domains access control uuid + $sql = "select access_control_uuid from v_access_controls "; + $sql .= "where access_control_name = 'domains'; "; + if ($this->debug) { + echo $sql."
\n"; + } + $prep_statement = $this->db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_ASSOC); + $access_control_uuid = $result['access_control_uuid']; + } + unset($prep_statement); + + //get the existing nodes + $sql = "select * from v_access_control_nodes "; + $sql .= "where access_control_uuid = '".$access_control_uuid."' "; + $sql .= "and node_cidr <> '' "; + if ($this->debug) { + echo $sql."
\n"; + } + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $access_control_nodes = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + //echo "
\n";
+					//print_r($access_control_nodes);
+					//echo "
\n"; + } + + //get the existing nodes + $sql = "select * from v_sip_profiles "; + $sql .= "where sip_profile_enabled = 'true' "; + $sql .= "order by sip_profile_name asc "; + $sql .= "limit 1; "; + if ($this->debug) { + echo $sql."
\n"; + } + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_ASSOC); + $sip_profile_name = $result['sip_profile_name']; + } + + //get the nodes array + $nodes = $this->nodes($provider); + + //add gateways + $x = 0; + foreach ($nodes as $row) { + $array['access_control_nodes'][$x]['access_control_node_uuid'] = $row['uuid']; + $array['access_control_nodes'][$x]['access_control_uuid'] = $access_control_uuid; + $array['access_control_nodes'][$x]['node_type'] = 'allow'; + $array['access_control_nodes'][$x]['node_cidr'] = $row['cidr']; + $array['access_control_nodes'][$x]['node_description']= $row['description']; + $x++; + } + + //get the gateways array + $gateways = $this->gateways($provider); + + //gateways array + if ($provider == 'skyetel') { + //dialplan settings + $dialplan_expression = '^\+?1?(\d{10})$'; + $dialplan_prefix = '1'; + } + if ($provider == 'voicetel') { + //dialplan settings + $dialplan_expression = '^\+?1?(\d{10})$'; + $dialplan_prefix = '1'; + } + + //add gateways + $x = 0; + foreach ($gateways as $row) { + $array['gateways'][$x]['gateway_uuid'] = $row['uuid']; + $array['gateways'][$x]['gateway'] = $row['name']; + $array['gateways'][$x]['username'] = $row['username']; + $array['gateways'][$x]['password'] = $row['password']; + $array['gateways'][$x]['proxy'] = $row['proxy']; + $array['gateways'][$x]['register'] = $row['register']; + $array['gateways'][$x]['retry_seconds'] = '30'; + $array['gateways'][$x]['ping'] = '90'; + $array['gateways'][$x]['expire_seconds'] = '800'; + $array['gateways'][$x]['context'] = 'public'; + $array['gateways'][$x]['profile'] = $sip_profile_name; + $array['gateways'][$x]['enabled'] = 'true'; + $array['gateways'][$x]['description'] = ''; + $x++; + } + + //set the dialplan variables + if ($provider == 'skyetel') { $dialplan_uuid = '777bf012-9746-4ccb-a7cc-95c1714f15fe'; } + if ($provider == 'voicetel') { $dialplan_uuid = '513e3710-1cbd-48da-b8f1-792eae471d3a'; } + $app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'; + $dialplan_name = $provider; + $dialplan_order = '100'; + $dialplan_continue = 'false'; + $dialplan_context = '${domain_name}'; + $dialplan_enabled = 'true'; + $dialplan_description = '10-11 digits'; + + //add outbound routes + $x = 0; + //$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['app_uuid'] = $app_uuid; + $array['dialplans'][$x]['dialplan_name'] = $dialplan_name; + $array['dialplans'][$x]['dialplan_order'] = $dialplan_order; + $array['dialplans'][$x]['dialplan_continue'] = $dialplan_continue; + $array['dialplans'][$x]['dialplan_context'] = $dialplan_context; + $array['dialplans'][$x]['dialplan_enabled'] = $dialplan_enabled; + $array['dialplans'][$x]['dialplan_description'] = $dialplan_description; + $y = 0; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'condition'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = '${user_exists}'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'false'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'condition'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'destination_number'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $dialplan_expression; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'sip_h_X-accountcode=${accountcode}'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'call_direction=outbound'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'unset'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'call_timeout'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'hangup_after_bridge=true'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_name=${outbound_caller_id_name}'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'effective_caller_id_number=${outbound_caller_id_number}'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'inherit_codec=true'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'ignore_display_updates=true'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'callee_id_number=$1'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'set'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'continue_on_fail=true'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + + foreach ($gateways as $row) { + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); + $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = 'action'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = 'bridge'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = 'sofia/gateway/'.$row['uuid'].'/'.$dialplan_prefix.'$1'; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $y * 10; + $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; + $y++; + } + + //save to the data + $database = new database; + $database->app_name = 'outbound_routes'; + $database->app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'; + $database->save($array); + $message = $database->message; + + //debug + //echo "
\n";
+				//print_r($array);
+				//echo "
\n";
+				//exit;
+
+			//update the dialplan xml
+				$dialplans = new dialplan;
+				$dialplans->source = "details";
+				$dialplans->destination = "database";
+				$dialplans->uuid = $dialplan_uuid;
+				$dialplans->xml();
+
+			//clear the cache
+				$cache = new cache;
+				$cache->delete("configuration:acl.conf");
+				$cache->delete("configuration:sofia.conf:".$sip_profile_hostname);
+
+			//create the event socket connection
+				$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+
+			//get the hostname
+				if ($fp) {  $sip_profile_hostname = event_socket_request($fp, 'api switchname'); }
+
+			//reload acl and rescan the sip profile
+				if ($fp) { event_socket_request($fp, "api reloadacl"); }
+				if ($fp) { event_socket_request($fp, "api sofia profile ".$sip_profile_name." rescan"); }
+		}
+
+		/**
+		 * delete the provider
+		 */
+		public function delete($provider) {
+
+			//validate the provider
+				switch ($provider) {
+					case 'voicetel':
+						break;
+					case 'skyetel': 
+						break;
+					default: 
+						$provider = '';
+				}
+
+			//set the dialplan_uuid
+				if ($provider == 'skyetel') { $dialplan_uuid = '777bf012-9746-4ccb-a7cc-95c1714f15fe'; }
+				if ($provider == 'voicetel') { $dialplan_uuid = '513e3710-1cbd-48da-b8f1-792eae471d3a'; }
+
+			//delete child data
+				$sql = "delete from v_dialplan_details ";
+				$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
+				$this->db->query($sql);
+				unset($sql);
+
+			//delete parent data
+				$sql = "delete from v_dialplans ";
+				$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
+				$this->db->query($sql);
+				unset($sql);
+
+			//get the nodes array
+				$nodes = $this->nodes($provider);
+
+			//delete each node
+				foreach ($nodes as $row) {
+					$sql = "delete from v_access_control_nodes ";
+					$sql .= "where access_control_node_uuid = '".$row['uuid']."'; ";
+					$this->db->query($sql);
+					unset($sql);
+				}
+
+			//get the gateways array
+				$gateways = $this->gateways($provider);
+
+			//get the existing nodes
+				$sql = "select * from v_sip_profiles ";
+				$sql .= "where sip_profile_enabled = 'true' ";
+				$sql .= "order by sip_profile_name asc ";
+				$sql .= "limit 1; ";
+				if ($this->debug) {
+					echo $sql."
\n"; + } + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_ASSOC); + $sip_profile_name = $result['sip_profile_name']; + } + + //create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + + //delete each gateway + foreach ($gateways as $row) { + //stop the gateway + if ($fp) { event_socket_request($fp, "api sofia profile ".$sip_profile_name." killgw ".$row['uuid']); } + + //delete the gateway + $sql = "delete from v_gateways "; + $sql .= "where gateway_uuid = '".$row['uuid']."'; "; + $this->db->query($sql); + unset($sql); + } + + //clear the cache + $cache = new cache; + $cache->delete("configuration:acl.conf"); + $cache->delete("configuration:sofia.conf:".$sip_profile_hostname); + + //get the hostname + if ($fp) { $sip_profile_hostname = event_socket_request($fp, 'api switchname'); } + + //reload acl and rescan the sip profile + if ($fp) { event_socket_request($fp, "api reloadacl"); } + if ($fp) { event_socket_request($fp, "api sofia profile ".$sip_profile_name." rescan"); } + } + + } //end scripts class +} + +/* +//example use + $provider = new providers; + $reports->domain_uuid = $_SESSION['domain_uuid']; + $provider->setup(); +*/ + +?> \ No newline at end of file diff --git a/app/providers/resources/images/logo_voicetel.png b/app/providers/resources/images/logo_voicetel.png new file mode 100755 index 0000000000..1e5cbfe28e Binary files /dev/null and b/app/providers/resources/images/logo_voicetel.png differ diff --git a/app/providers/resources/images/skyetel-logo.png b/app/providers/resources/images/skyetel-logo.png new file mode 100644 index 0000000000..7f277609a0 Binary files /dev/null and b/app/providers/resources/images/skyetel-logo.png differ diff --git a/app/providers/root.php b/app/providers/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/providers/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?> \ No newline at end of file