From f2db211c443c64f9a49b93af45a662f9104cc8a4 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sun, 8 Jul 2012 11:26:37 +0000 Subject: [PATCH] If the extension or dialplan xml directories are disabled or don't exist don't add sub directories. --- app/dialplan_inbound/app_defaults.php | 30 +++++++++++++++------------ app/extensions/app_defaults.php | 4 +++- app/recordings/app_defaults.php | 4 +++- core/upgrade/app_defaults.php | 4 +++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/dialplan_inbound/app_defaults.php b/app/dialplan_inbound/app_defaults.php index 93c598d04a..4c00f35a16 100644 --- a/app/dialplan_inbound/app_defaults.php +++ b/app/dialplan_inbound/app_defaults.php @@ -48,23 +48,27 @@ } //if the public directory doesn't exist then create it - if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public',0777,true); } + if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public',0777,true); } + } //if multiple domains then make sure that the dialplan/public/domain_name.xml file exists if (count($_SESSION["domains"]) > 1) { //make sure the public directory and xml file exist - if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { - mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'],0777,true); - } - $file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml"; - if (!file_exists($file)) { - $fout = fopen($file,"w"); - $xml = "\n"; - $xml .= " \n"; - $xml .= "\n"; - fwrite($fout, $xml); - fclose($fout); - unset($xml,$file); + if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { + mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'],0777,true); + } + $file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml"; + if (!file_exists($file)) { + $fout = fopen($file,"w"); + $xml = "\n"; + $xml .= " \n"; + $xml .= "\n"; + fwrite($fout, $xml); + fclose($fout); + unset($xml,$file); + } } } diff --git a/app/extensions/app_defaults.php b/app/extensions/app_defaults.php index 11c064c110..bced9d90e7 100644 --- a/app/extensions/app_defaults.php +++ b/app/extensions/app_defaults.php @@ -25,6 +25,8 @@ */ //if the extensions dir doesn't exist then create it - if (!is_dir($_SESSION['switch']['extensions']['dir'])) { mkdir($_SESSION['switch']['extensions']['dir'],0777,true); } + if (strlen($_SESSION['switch']['extensions']['dir']) > 0) { + if (!is_dir($_SESSION['switch']['extensions']['dir'])) { mkdir($_SESSION['switch']['extensions']['dir'],0777,true); } + } ?> \ No newline at end of file diff --git a/app/recordings/app_defaults.php b/app/recordings/app_defaults.php index 36abb0f07b..b7e1c0af6c 100644 --- a/app/recordings/app_defaults.php +++ b/app/recordings/app_defaults.php @@ -25,6 +25,8 @@ */ //if the recordings directory doesn't exist then create it - if (!is_readable($_SESSION['switch']['recordings']['dir'])) { mkdir($_SESSION['switch']['recordings']['dir'],0777,true); } + if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + if (!is_readable($_SESSION['switch']['recordings']['dir'])) { mkdir($_SESSION['switch']['recordings']['dir'],0777,true); } + } ?> \ No newline at end of file diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php index d8bd4092d6..e984b4af1b 100644 --- a/core/upgrade/app_defaults.php +++ b/core/upgrade/app_defaults.php @@ -27,7 +27,9 @@ if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { //if the resource scripts resource directory does not exist then create it - if (!is_dir($_SESSION['switch']['scripts']['dir']."/resources")) { mkdir($_SESSION['switch']['scripts']['dir']."/resources",0755,true); } + if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { + if (!is_dir($_SESSION['switch']['scripts']['dir']."/resources")) { mkdir($_SESSION['switch']['scripts']['dir']."/resources",0755,true); } + } //get odbc information $sql = "select count(*) as num_rows from v_databases ";