If the extension or dialplan xml directories are disabled or don't exist don't add sub directories.

This commit is contained in:
Mark Crane
2012-07-08 11:26:37 +00:00
parent e44426ee1a
commit f2db211c44
4 changed files with 26 additions and 16 deletions
+17 -13
View File
@@ -48,23 +48,27 @@
} }
//if the public directory doesn't exist then create it //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 multiple domains then make sure that the dialplan/public/domain_name.xml file exists
if (count($_SESSION["domains"]) > 1) { if (count($_SESSION["domains"]) > 1) {
//make sure the public directory and xml file exist //make sure the public directory and xml file exist
if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) {
mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'],0777,true); 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)) { $file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml";
$fout = fopen($file,"w"); if (!file_exists($file)) {
$xml = "<include>\n"; $fout = fopen($file,"w");
$xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$_SESSION['domains'][$domain_uuid]['domain_name']."/*.xml\"/>\n"; $xml = "<include>\n";
$xml .= "</include>\n"; $xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$_SESSION['domains'][$domain_uuid]['domain_name']."/*.xml\"/>\n";
fwrite($fout, $xml); $xml .= "</include>\n";
fclose($fout); fwrite($fout, $xml);
unset($xml,$file); fclose($fout);
unset($xml,$file);
}
} }
} }
+3 -1
View File
@@ -25,6 +25,8 @@
*/ */
//if the extensions dir doesn't exist then create it //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); }
}
?> ?>
+3 -1
View File
@@ -25,6 +25,8 @@
*/ */
//if the recordings directory doesn't exist then create it //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); }
}
?> ?>
+3 -1
View File
@@ -27,7 +27,9 @@
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
//if the resource scripts resource directory does not exist then create it //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 //get odbc information
$sql = "select count(*) as num_rows from v_databases "; $sql = "select count(*) as num_rows from v_databases ";