diff --git a/main/document/record_audio.php b/main/document/record_audio.php index 4086a2beb6..5827aaba22 100755 --- a/main/document/record_audio.php +++ b/main/document/record_audio.php @@ -43,10 +43,10 @@ if (empty($document_data)) { //make some vars $wamidir = $dir; -if ($wamidir === "/") { +if ($wamidir === '/') { $wamidir = ''; } -$wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/"; +$wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir.'/'; $groupId = api_get_group_id(); $is_allowed_to_edit = api_is_allowed_to_edit(null, true); @@ -55,7 +55,7 @@ if (strstr($dir, '..')) { $dir = '/'; } -if ($dir[0] == '.') { +if ($dir[0] === '.') { $dir = substr($dir, 1); } @@ -63,7 +63,7 @@ if ($dir[0] !== '/') { $dir = '/'.$dir; } -if ($dir[strlen($dir) - 1] != '/') { +if ($dir[strlen($dir) - 1] !== '/') { $dir .= '/'; } diff --git a/main/document/webcam_clip.php b/main/document/webcam_clip.php index 118740d6ec..40b706bd19 100755 --- a/main/document/webcam_clip.php +++ b/main/document/webcam_clip.php @@ -1,4 +1,5 @@ "../group/group_space.php?".api_get_cidreq(), - "name" => get_lang('GroupSpace'), + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), + 'name' => get_lang('GroupSpace').' '.$groupProperties['name'], ]; - $noPHP_SELF = true; - $group = GroupManager::get_group_properties($groupId); - $path = explode('/', $dir); - if ('/'.$path[1] != $group['directory']) { - api_not_allowed(true); - } } $interbreadcrumb[] = [ - "url" => "./document.php?id=".$documentId."&".api_get_cidreq(), - "name" => get_lang('Documents'), + 'url' => "./document.php?id=".$documentId."&".api_get_cidreq(), + 'name' => get_lang('Documents'), ]; if (!api_is_allowed_in_course()) { @@ -106,18 +104,8 @@ if (!($isAllowedToEdit || $groupRights || $isMySharedFolder)) { api_not_allowed(true); } -/* Header */ Event::event_access_tool(TOOL_DOCUMENT); -$displayDir = $dir; -if (isset($group)) { - $displayDir = explode('/', $dir); - unset($displayDir[0]); - unset($displayDir[1]); - $displayDir = implode('/', $displayDir); -} - -// Interbreadcrumb for the current directory root path $counter = 0; if (isset($documentData['parents'])) { foreach ($documentData['parents'] as $documentSubData) { @@ -155,10 +143,7 @@ $template = new Template($nameTools); $template->assign('webcam_dir', $webcamdir); $template->assign('user_id', $userId); $template->assign('filename', 'video_clip.jpg'); - -$layout = $template->get_template('document/webcam.tpl'); -$content = $template->fetch($layout); - +$content = $template->fetch($template->get_template('document/webcam.tpl')); $template->assign('header', get_lang('TakeYourPhotos')); $template->assign('actions', $actions); $template->assign('content', $content); diff --git a/main/document/webcam_receiver.php b/main/document/webcam_receiver.php index e53f4810bd..1eb61911fb 100755 --- a/main/document/webcam_receiver.php +++ b/main/document/webcam_receiver.php @@ -34,24 +34,23 @@ $webcamname = addslashes(trim($webcamname)); $webcamname = api_replace_dangerous_char($webcamname); $webcamname = disable_dangerous_file($webcamname); $webcamdir = Security::remove_XSS($webcamdir); - +$courseInfo = api_get_course_info(); //security extension $ext = explode('.', $webcamname); -$ext = strtolower($ext[sizeof($ext) - 1]); +$ext = strtolower($ext[count($ext) - 1]); -if ($ext != 'jpg') { - die(); +if ($ext !== 'jpg') { + exit; } //Do not use here check Fileinfo method because return: text/plain //CHECK THIS BEFORE COMMIT - -$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; +$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; $saveDir = $dirBaseDocuments.$webcamdir; $current_session_id = api_get_session_id(); $groupId = api_get_group_id(); $groupInfo = GroupManager::get_group_properties($groupId); -//Avoid duplicates +// Avoid duplicates. $webcamname_to_save = $webcamname; $title_to_save = str_replace('_', ' ', $webcamname); $webcamname_noex = basename($webcamname, ".jpg"); @@ -77,24 +76,24 @@ if (!$content) { //add document to database $doc_id = add_document( - $_course, + $courseInfo, $webcamdir.'/'.$webcamname_to_save, 'file', filesize($documentPath), $title_to_save ); api_item_property_update( - $_course, + $courseInfo, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', - $_user['user_id'], + api_get_user_id(), $groupInfo, null, null, null, $current_session_id ); -/// + $url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']).'/'.$documentPath; echo get_lang('ClipSent'); diff --git a/main/template/default/document/webcam.tpl b/main/template/default/document/webcam.tpl index 3453ffed91..e498c48c89 100644 --- a/main/template/default/document/webcam.tpl +++ b/main/template/default/document/webcam.tpl @@ -33,7 +33,7 @@