After removing domain name from the default recordings dir path need to add the domain name every where the recordings directory is currently used.

This commit is contained in:
markjcrane
2015-12-06 13:37:35 -07:00
parent 37d4f52dc8
commit ff8b838b5e
32 changed files with 92 additions and 105 deletions
+12 -12
View File
@@ -49,7 +49,7 @@ require_once "resources/check_auth.php";
if ($_GET['a'] == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) {
session_cache_limiter('public');
if ($_GET['type'] = "rec") {
$path = $_SESSION['switch']['recordings']['dir'];
$path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'];
//if from recordings, get recording details from db
$recording_uuid = check_str($_GET['id']); //recordings
@@ -115,7 +115,7 @@ require_once "resources/check_auth.php";
if ($_POST['submit'] == $text['button-upload'] && $_POST['type'] == 'rec' && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
$recording_filename = str_replace(" ", "_", $_FILES['ulfile']['name']);
$recording_filename = str_replace("'", "", $recording_filename);
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$recording_filename);
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename);
$_SESSION['message'] = $text['message-uploaded'].": ".htmlentities($recording_filename);
@@ -146,9 +146,9 @@ require_once "resources/check_auth.php";
$array_base64_exists[$row['recording_uuid']] = ($row['recording_base64'] != '') ? true : false;
//if not base64, convert back to local files and remove base64 from db
if ($_SESSION['recordings']['storage_type']['text'] != 'base64' && $row['recording_base64'] != '') {
if (!file_exists($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename'])) {
if (!file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row['recording_filename'])) {
$recording_decoded = base64_decode($row['recording_base64']);
file_put_contents($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename'], $recording_decoded);
file_put_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row['recording_filename'], $recording_decoded);
$sql = "update v_recordings set recording_base64 = null where domain_uuid = '".$domain_uuid."' and recording_uuid = '".$row['recording_uuid']."' ";
$db->exec(check_sql($sql));
unset($sql);
@@ -158,10 +158,10 @@ require_once "resources/check_auth.php";
unset ($prep_statement);
//add recordings to the database
if (is_dir($_SESSION['switch']['recordings']['dir'].'/')) {
if ($dh = opendir($_SESSION['switch']['recordings']['dir'].'/')) {
if (is_dir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/')) {
if ($dh = opendir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/')) {
while (($recording_filename = readdir($dh)) !== false) {
if (filetype($_SESSION['switch']['recordings']['dir']."/".$recording_filename) == "file") {
if (filetype($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename) == "file") {
if (!in_array($recording_filename, $array_recordings)) {
//file not found in db, add it
@@ -187,7 +187,7 @@ require_once "resources/check_auth.php";
$sql .= "'".$recording_name."', ";
$sql .= "'".$recording_description."' ";
if ($_SESSION['recordings']['storage_type']['text'] == 'base64') {
$recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename));
$recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename));
$sql .= ", '".$recording_base64."' ";
}
$sql .= ")";
@@ -199,7 +199,7 @@ require_once "resources/check_auth.php";
if ($_SESSION['recordings']['storage_type']['text'] == 'base64') {
$found_recording_uuid = array_search($recording_filename, $array_recordings);
if (!$array_base64_exists[$found_recording_uuid]) {
$recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename));
$recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename));
$sql = "update v_recordings set ";
$sql .= "recording_base64 = '".$recording_base64."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
@@ -211,8 +211,8 @@ require_once "resources/check_auth.php";
}
//if base64, remove local file
if ($_SESSION['recordings']['storage_type']['text'] == 'base64' && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename)) {
@unlink($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename);
if ($_SESSION['recordings']['storage_type']['text'] == 'base64' && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename)) {
@unlink($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename);
}
}
@@ -307,7 +307,7 @@ require_once "resources/check_auth.php";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['recording_name']."</td>\n";
if ($_SESSION['recordings']['storage_type']['text'] != 'base64') {
echo " <td valign='top' class='".$row_style[$c]."'>".$row['recording_filename']."</td>\n";
$tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename']);
$tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row['recording_filename']);
$tmp_filesize = byte_convert($tmp_filesize);
echo " <td class='".$row_style[$c]."' style='text-align: center;'>".$tmp_filesize."</td>\n";
}