mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Use FreeSWITCH to run mkdir so it inherits its own user and group permissions.
This commit is contained in:
@@ -217,7 +217,7 @@ else {
|
||||
echo " <a href='javascript:void(0);' onclick=\"send_cmd('calls_exec.php?cmd='+get_park_cmd(escape('$uuid'), '".$tmp_domain."'));\">".$text['label-park']."</a> \n";
|
||||
//record start/stop
|
||||
$tmp_dir = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d");
|
||||
mkdir($tmp_dir, 02770, true);
|
||||
event_socket_mkdir($tmp_dir);
|
||||
$tmp_file = $tmp_dir."/".$uuid.".wav";
|
||||
if (file_exists($tmp_file)) {
|
||||
//stop
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
//if the public directory doesn't exist then create it
|
||||
if ($domains_processed == 1) {
|
||||
if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public',02770,true); }
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { event_socket_mkdir($_SESSION['switch']['dialplan']['dir'].'/public'); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
//make sure the public directory and xml file exist
|
||||
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'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name']);
|
||||
}
|
||||
$file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml";
|
||||
if (!file_exists($file)) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
//if the extensions dir doesn't exist then create it
|
||||
if ($domains_processed == 1) {
|
||||
if (strlen($_SESSION['switch']['extensions']['dir']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['extensions']['dir'])) { mkdir($_SESSION['switch']['extensions']['dir'],02770,true); }
|
||||
if (!is_dir($_SESSION['switch']['extensions']['dir'])) { event_socket_mkdir($_SESSION['switch']['extensions']['dir']); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ if (!class_exists('extension')) {
|
||||
$xml .= " </user>\n";
|
||||
|
||||
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
|
||||
mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context']);
|
||||
}
|
||||
if (strlen($extension) > 0) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
|
||||
|
||||
@@ -64,19 +64,19 @@ else {
|
||||
|
||||
//make sure the directories exist
|
||||
if (!is_dir($_SESSION['switch']['storage']['dir'])) {
|
||||
mkdir($_SESSION['switch']['storage']['dir'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['storage']['dir']);
|
||||
}
|
||||
if (!is_dir($fax_dir.'/'.$fax_extension)) {
|
||||
mkdir($fax_dir.'/'.$fax_extension,02770,true);
|
||||
event_socket_mkdir($fax_dir.'/'.$fax_extension);
|
||||
}
|
||||
if (!is_dir($dir_fax_inbox)) {
|
||||
mkdir($dir_fax_inbox,02770,true);
|
||||
event_socket_mkdir($dir_fax_inbox);
|
||||
}
|
||||
if (!is_dir($dir_fax_sent)) {
|
||||
mkdir($dir_fax_sent,02770,true);
|
||||
event_socket_mkdir($dir_fax_sent);
|
||||
}
|
||||
if (!is_dir($dir_fax_temp)) {
|
||||
mkdir($dir_fax_temp,02770,true);
|
||||
event_socket_mkdir($dir_fax_temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,19 +145,19 @@ else {
|
||||
|
||||
//make sure the directories exist
|
||||
if (!is_dir($_SESSION['switch']['storage']['dir'])) {
|
||||
mkdir($_SESSION['switch']['storage']['dir'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['storage']['dir']);
|
||||
}
|
||||
if (!is_dir($fax_dir.'/'.$fax_extension)) {
|
||||
mkdir($fax_dir.'/'.$fax_extension,02770,true);
|
||||
event_socket_mkdir($fax_dir.'/'.$fax_extension);
|
||||
}
|
||||
if (!is_dir($dir_fax_inbox)) {
|
||||
mkdir($dir_fax_inbox,02770,true);
|
||||
event_socket_mkdir($dir_fax_inbox);
|
||||
}
|
||||
if (!is_dir($dir_fax_sent)) {
|
||||
mkdir($dir_fax_sent,02770,true);
|
||||
event_socket_mkdir($dir_fax_sent);
|
||||
}
|
||||
if (!is_dir($dir_fax_temp)) {
|
||||
mkdir($dir_fax_temp,02770,true);
|
||||
event_socket_mkdir($dir_fax_temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,25 +206,25 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){
|
||||
|
||||
//make sure the directories exist
|
||||
if (!is_dir($_SESSION['switch']['storage']['dir'])) {
|
||||
mkdir($_SESSION['switch']['storage']['dir'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['storage']['dir']);
|
||||
}
|
||||
if (!is_dir($_SESSION['switch']['storage']['dir'].'/fax')) {
|
||||
mkdir($_SESSION['switch']['storage']['dir'].'/fax',02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['storage']['dir'].'/fax');
|
||||
}
|
||||
if (!is_dir($_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'])) {
|
||||
mkdir($_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']);
|
||||
}
|
||||
if (!is_dir($fax_dir.'/'.$fax_extension)) {
|
||||
mkdir($fax_dir.'/'.$fax_extension,02770,true);
|
||||
event_socket_mkdir($fax_dir.'/'.$fax_extension);
|
||||
}
|
||||
if (!is_dir($dir_fax_inbox)) {
|
||||
mkdir($dir_fax_inbox,02770,true);
|
||||
event_socket_mkdir($dir_fax_inbox);
|
||||
}
|
||||
if (!is_dir($dir_fax_sent)) {
|
||||
mkdir($dir_fax_sent,02770,true);
|
||||
event_socket_mkdir($dir_fax_sent);
|
||||
}
|
||||
if (!is_dir($dir_fax_temp)) {
|
||||
mkdir($dir_fax_temp,02770,true);
|
||||
event_socket_mkdir($dir_fax_temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
}
|
||||
//check target folder, move uploaded file
|
||||
if (!is_dir($moh_path)) {
|
||||
mkdir($moh_path, 02770, true);
|
||||
event_socket_mkdir($moh_path);
|
||||
}
|
||||
if (is_dir($moh_path)) {
|
||||
if (copy($moh_file_name_temp, $moh_path.'/'.$moh_file_name)) {
|
||||
|
||||
@@ -69,7 +69,7 @@ if ($domains_processed == 1) {
|
||||
foreach ($conf_lang_folders as $conf_lang_folder) {
|
||||
//create phrases folder, if necessary
|
||||
if (!file_exists($conf_lang_folder."/phrases/")) {
|
||||
mkdir($conf_lang_folder."/phrases/", 02770);
|
||||
event_socket_mkdir($conf_lang_folder."/phrases/");
|
||||
}
|
||||
//parse language, open xml file
|
||||
$conf_lang = substr($conf_lang_folder, -2);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
//if the recordings directory doesn't exist then create it
|
||||
if (strlen($_SESSION['switch']['recordings']['dir']."/".$domain_name) > 0) {
|
||||
if (!is_readable($_SESSION['switch']['recordings']['dir']."/".$domain_name)) { mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name,02770,true); }
|
||||
if (!is_readable($_SESSION['switch']['recordings']['dir']."/".$domain_name)) { event_socket_mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name,02770,true); }
|
||||
}
|
||||
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
@@ -155,7 +155,7 @@ require_once "resources/check_auth.php";
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) == 0 && !file_exists($v_greeting_dir.'/'.$file_name)) {
|
||||
//move the uploaded greeting
|
||||
mkdir($v_greeting_dir, 02770, true);
|
||||
event_socket_mkdir($v_greeting_dir);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $v_greeting_dir.'/'.$file_name);
|
||||
//set newly uploaded greeting as active greeting for voicemail box
|
||||
$sql = "update v_voicemails ";
|
||||
|
||||
@@ -42,7 +42,7 @@ if ($domains_processed == 1) {
|
||||
foreach ($voicemails as $row) {
|
||||
$path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$row['domain_name'].'/'.$row['voicemail_id'];
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path, 02770, true);
|
||||
event_socket_mkdir($path);
|
||||
}
|
||||
}
|
||||
unset ($prep_statement, $sql);
|
||||
|
||||
@@ -399,7 +399,7 @@ if (!class_exists('xml_cdr')) {
|
||||
catch(PDOException $e) {
|
||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
|
||||
if(!file_exists($tmp_dir)) {
|
||||
mkdir($tmp_dir, 02770, true);
|
||||
event_socket_mkdir($tmp_dir);
|
||||
}
|
||||
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
||||
$tmp_file = $uuid.'.xml';
|
||||
@@ -426,7 +426,7 @@ if (!class_exists('xml_cdr')) {
|
||||
$tmp_day = date("d", $tmp_time);
|
||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
|
||||
if(!file_exists($tmp_dir)) {
|
||||
mkdir($tmp_dir, 02770, true);
|
||||
event_socket_mkdir($tmp_dir);
|
||||
}
|
||||
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
||||
$tmp_file = $uuid.'.xml';
|
||||
|
||||
@@ -445,7 +445,7 @@
|
||||
catch(PDOException $e) {
|
||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/';
|
||||
if(!file_exists($tmp_dir)) {
|
||||
mkdir($tmp_dir, 02770, true);
|
||||
event_socket_mkdir($tmp_dir);
|
||||
}
|
||||
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
||||
$tmp_file = $uuid.'.xml';
|
||||
@@ -472,7 +472,7 @@
|
||||
$tmp_day = date("d", $tmp_time);
|
||||
$tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
|
||||
if(!file_exists($tmp_dir)) {
|
||||
mkdir($tmp_dir, 02770, true);
|
||||
event_socket_mkdir($tmp_dir);
|
||||
}
|
||||
if ($_SESSION['cdr']['format']['text'] == "xml") {
|
||||
$tmp_file = $uuid.'.xml';
|
||||
|
||||
@@ -1956,4 +1956,28 @@ function number_pad($number,$n) {
|
||||
}
|
||||
}
|
||||
|
||||
function event_socket_mkdir($dir) {
|
||||
//if the handle does not exist create it
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
//send the mkdir command to freeswitch
|
||||
if ($fp) {
|
||||
//send the api command to check if the module exists
|
||||
$switch_cmd = "system mkdir -p '$dir'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
unset($switch_cmd);
|
||||
if (trim($switch_result) == "-ERR no reply") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -942,12 +942,12 @@ function save_dialplan_xml() {
|
||||
$dialplan_filename = $dialplan_order."_v_".$dialplan_name.".xml";
|
||||
if (strlen($row['dialplan_context']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']);
|
||||
}
|
||||
if ($row['dialplan_context'] == "public") {
|
||||
if (count($_SESSION['domains']) > 1 && strlen($row['domain_uuid']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name']);
|
||||
}
|
||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."/".$dialplan_filename, $tmp);
|
||||
}
|
||||
@@ -957,7 +957,7 @@ function save_dialplan_xml() {
|
||||
}
|
||||
else {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']);
|
||||
}
|
||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']."/".$dialplan_filename, $tmp);
|
||||
}
|
||||
@@ -1334,7 +1334,7 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
|
||||
// make profile dir if needed
|
||||
$profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles";
|
||||
if (!is_readable($profile_dir)) { mkdir($profile_dir,02770,true); }
|
||||
if (!is_readable($profile_dir)) { event_socket_mkdir($profile_dir); }
|
||||
|
||||
//get the global variables
|
||||
global $domain_uuid;
|
||||
@@ -1399,7 +1399,7 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
}
|
||||
|
||||
//if the directory does not exist then create it
|
||||
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { mkdir($profile_dir.'/'.$sip_profile_name,02770,true); }
|
||||
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { event_socket_mkdir($profile_dir.'/'.$sip_profile_name); }
|
||||
|
||||
} //end foreach
|
||||
unset($sql, $result, $row_count);
|
||||
|
||||
Reference in New Issue
Block a user