Update music_on_hold.php

Fix the global upload and handling for mixed case upload to lower case.
This commit is contained in:
FusionPBX 2016-07-03 20:36:06 -06:00 committed by GitHub
parent c35bb365de
commit 76ffe78adb
1 changed files with 14 additions and 14 deletions

View File

@ -115,7 +115,7 @@
//determine name & scope //determine name & scope
if ($_POST['name_new'] != '') { if ($_POST['name_new'] != '') {
if (permission_exists('music_on_hold_global_add')) { $stream_scope = $_POST['scope']; } else { $stream_scope = 'local'; } if (permission_exists('music_on_hold_global_add')) { $stream_scope = $_POST['scope']; } else { $stream_scope = 'local'; }
$stream_name_only = strtolower($_POST['name_new']); $stream_name = strtolower($_POST['name_new']);
if (is_numeric($_POST['rate'])) { $stream_rate = $_POST['rate']; } else { $stream_rate = ''; } if (is_numeric($_POST['rate'])) { $stream_rate = $_POST['rate']; } else { $stream_rate = ''; }
} }
else { else {
@ -138,7 +138,7 @@
//set the scope //set the scope
if (strlen($stream_domain_uuid) == 0) { if (strlen($stream_domain_uuid) == 0) {
$stream_scope = "public"; $stream_scope = "global";
} }
else { else {
$stream_scope = "local"; $stream_scope = "local";
@ -148,7 +148,6 @@
break; break;
} }
} }
$stream_name_only = $stream_name;
} }
//get remaining values //get remaining values
@ -166,12 +165,14 @@
$_SESSION['message'] = $text['message-unsupported_file_type']; $_SESSION['message'] = $text['message-unsupported_file_type'];
} }
else if ($has_permission) { else if ($has_permission) {
//strip slashes, replace spaces //strip slashes, replace spaces
$slashes = array("/", "\\"); $slashes = array("/", "\\");
$stream_name_only = str_replace($slashes, '', $stream_name_only); $stream_name = str_replace($slashes, '', $stream_name);
$stream_name_only = str_replace(' ', '_', $stream_name_only); $stream_name = str_replace(' ', '_', $stream_name);
$stream_file_name = str_replace($slashes, '', $stream_file_name); $stream_file_name = str_replace($slashes, '', $stream_file_name);
$stream_file_name = str_replace(' ', '-', $stream_file_name); $stream_file_name = str_replace(' ', '-', $stream_file_name);
$stream_file_name = strtolower($stream_file_name);
//detect auto rate //detect auto rate
if ($stream_rate == 'auto') { if ($stream_rate == 'auto') {
$stream_rate = ''; $stream_rate = '';
@ -185,7 +186,7 @@
//define default path //define default path
$stream_path = path_join($_SESSION['switch']['sounds']['dir'], 'music', $stream_path = path_join($_SESSION['switch']['sounds']['dir'], 'music',
(($stream_scope == 'global') ? 'global' : $_SESSION['domain_name']), (($stream_scope == 'global') ? 'global' : $_SESSION['domain_name']),
$stream_name_only, $path_rate $stream_name, $path_rate
); );
//find whether the path already exists //find whether the path already exists
$stream_new_name = true; $stream_new_name = true;
@ -199,12 +200,11 @@
} }
//set the variables //set the variables
$music_on_hold_name = $stream_name_only; $stream_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $stream_path);
$music_on_hold_path = str_replace('$${sounds_dir}', $_SESSION['switch']['sounds']['dir'], $stream_path);
//begin query //begin query
if ($stream_new_name) { if ($stream_new_name) {
$music_on_hold_uuid = uuid(); $stream_uuid = uuid();
$sql = "insert into v_music_on_hold "; $sql = "insert into v_music_on_hold ";
$sql .= "( "; $sql .= "( ";
$sql .= "music_on_hold_uuid, "; $sql .= "music_on_hold_uuid, ";
@ -221,10 +221,10 @@
$sql .= "music_on_hold_chime_max "; $sql .= "music_on_hold_chime_max ";
$sql .= ") "; $sql .= ") ";
$sql .= "values ( "; $sql .= "values ( ";
$sql .= "'".$music_on_hold_uuid."',"; $sql .= "'".$stream_uuid."',";
$sql .= (($stream_scope == 'global') ? 'null' : "'".$domain_uuid."'").", "; $sql .= (($stream_scope == 'global') ? 'null' : "'".$domain_uuid."'").", ";
$sql .= "'".check_str($music_on_hold_name)."', "; $sql .= "'".check_str($stream_name)."', ";
$sql .= "'".check_str($music_on_hold_path)."', "; $sql .= "'".check_str($stream_path)."', ";
if (strlen($stream_rate) == 0) { if (strlen($stream_rate) == 0) {
$sql .= "null, "; $sql .= "null, ";
} }
@ -506,8 +506,8 @@
$stream_scope = $row['domain_uuid']; $stream_scope = $row['domain_uuid'];
if (!$stream_scope) $stream_scope = '_global_'; if (!$stream_scope) $stream_scope = '_global_';
$tmp = explode('/', $row['music_on_hold_name']); // $tmp = explode('/', $row['music_on_hold_name']);
$stream_name_only = $tmp[0]; // $stream_name = $tmp[0];
$stream_rate = $row['music_on_hold_rate']; $stream_rate = $row['music_on_hold_rate'];
//add vertical space //add vertical space