2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2014-04-15 08:55:48 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2014
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//only run the following code if the directory exists
|
2016-07-01 21:02:31 +02:00
|
|
|
/*
|
2012-06-04 16:58:40 +02:00
|
|
|
if (is_dir($_SESSION['switch']['dialplan']['dir'])) {
|
|
|
|
|
//write the dialplan/default.xml if it does not exist
|
2014-04-13 06:45:05 +02:00
|
|
|
//set the path
|
2014-10-23 20:03:33 +02:00
|
|
|
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')) {
|
|
|
|
|
$path = "/usr/share/examples/fusionpbx/resources/templates/conf";
|
2014-04-13 06:45:05 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2014-04-15 08:22:17 +02:00
|
|
|
$path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/conf';
|
2014-04-13 06:45:05 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//get the contents of the dialplan/default.xml
|
2014-04-15 08:22:17 +02:00
|
|
|
$file_default_path = $path.'/dialplan/default.xml';
|
2012-06-04 16:58:40 +02:00
|
|
|
$file_default_contents = file_get_contents($file_default_path);
|
|
|
|
|
|
|
|
|
|
//prepare the file contents and the path
|
|
|
|
|
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
|
2014-05-03 02:49:11 +02:00
|
|
|
$file_default_contents = str_replace("{v_domain}", $context, $file_default_contents);
|
2012-06-04 16:58:40 +02:00
|
|
|
//set the file path
|
2014-05-03 02:49:11 +02:00
|
|
|
$file_path = $_SESSION['switch']['conf']['dir'].'/dialplan/'.$context.'.xml';
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//write the default dialplan
|
2014-05-03 02:49:11 +02:00
|
|
|
if (!file_exists($file_path)) {
|
2014-04-15 08:55:48 +02:00
|
|
|
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissions are set correctly.');
|
|
|
|
|
fwrite($fh, $file_default_contents);
|
|
|
|
|
fclose($fh);
|
|
|
|
|
}
|
2012-07-09 11:05:35 +02:00
|
|
|
}
|
2016-07-01 21:02:31 +02:00
|
|
|
*/
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2012-07-09 11:05:35 +02:00
|
|
|
//get the $apps array from the installed apps from the core and mod directories
|
2014-01-19 14:09:17 +01:00
|
|
|
if ($domains_processed == 1) {
|
2016-07-02 00:49:12 +02:00
|
|
|
//get the array of xml files
|
|
|
|
|
$xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml");
|
|
|
|
|
|
|
|
|
|
//dialplan class
|
|
|
|
|
$dialplan = new dialplan;
|
|
|
|
|
|
|
|
|
|
//process the xml files
|
|
|
|
|
foreach ($xml_list as &$xml_file) {
|
|
|
|
|
//get and parse the xml
|
|
|
|
|
$xml_string = file_get_contents($xml_file);
|
|
|
|
|
//get the order number prefix from the file name
|
|
|
|
|
$name_array = explode('_', basename($xml_file));
|
|
|
|
|
if (is_numeric($name_array[0])) {
|
|
|
|
|
$dialplan_order = $name_array[0];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$dialplan_order = 0;
|
|
|
|
|
}
|
|
|
|
|
$dialplan->dialplan_order = $dialplan_order;
|
|
|
|
|
if ($display_type == "text") {
|
|
|
|
|
$dialplan->display_type = 'text';
|
|
|
|
|
}
|
|
|
|
|
$dialplan->xml = $xml_string;
|
|
|
|
|
$dialplan->import();
|
|
|
|
|
}
|
2016-07-24 21:45:03 +02:00
|
|
|
|
|
|
|
|
//update the dialplan order
|
|
|
|
|
$sql = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup';\n";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
$sql = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen';\n";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
$sql = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension';\n";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
unset($sql);
|
2014-01-19 14:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-20 09:19:30 +02:00
|
|
|
//add not found dialplan to inbound routes
|
2014-08-16 20:22:36 +02:00
|
|
|
/*
|
2014-05-20 09:19:30 +02:00
|
|
|
if ($domains_processed == 1) {
|
2014-07-24 01:06:14 +02:00
|
|
|
if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
|
|
|
|
|
$sql = "select count(*) as num_rows from v_dialplans ";
|
|
|
|
|
$sql .= "where dialplan_uuid = 'ea5339de-1982-46ca-9695-c35176165314' ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if ($row['num_rows'] == 0) {
|
|
|
|
|
$sql = "INSERT INTO v_dialplans ";
|
|
|
|
|
$sql .= "(dialplan_uuid, app_uuid, dialplan_context, dialplan_name, dialplan_continue, dialplan_order, dialplan_enabled) ";
|
|
|
|
|
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', 'public', 'not-found', 'false', '999', 'false');";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO v_dialplan_details ";
|
|
|
|
|
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
|
|
|
|
|
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', '8a21744d-b381-4cb0-9930-55b776e4e461', 'condition', 'context', 'public', '10');";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO v_dialplan_details ";
|
|
|
|
|
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
|
|
|
|
|
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'e391530c-4078-4b49-bc11-bda4a23ad566', 'action', 'log', '[inbound routes] 404 not found \${sip_network_ip}', '20');";
|
|
|
|
|
$db->query($sql);
|
|
|
|
|
unset($sql);
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement);
|
2014-05-20 09:19:30 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-16 20:22:36 +02:00
|
|
|
*/
|
2016-07-01 22:35:45 +02:00
|
|
|
?>
|