Selaa lähdekoodia

Minor - format code

Julio Montoya 11 vuotta sitten
vanhempi
commit
2dbfbe9d3a
2 muutettua tiedostoa jossa 40 lisäystä ja 39 poistoa
  1. 35 36
      main/document/download.php
  2. 5 3
      main/newscorm/lp_view.php

+ 35 - 36
main/document/download.php

@@ -29,7 +29,7 @@ $doc_url = str_replace(' ', '+', $doc_url);
 
 $doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url); //echo $doc_url;
 
-if (strpos($doc_url,'../') OR strpos($doc_url,'/..')) {
+if (strpos($doc_url, '../') OR strpos($doc_url, '/..')) {
    $doc_url = '';
 }
 
@@ -42,31 +42,31 @@ $refer_script = strrchr($_SERVER["HTTP_REFERER"], '/');
 $sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 
 if (substr($refer_script, 0, 15) == '/fillsurvey.php') {
-	$invitation = substr(strstr($refer_script, 'invitationcode='), 15);
-	$course = strstr($refer_script, 'course=');
-	$course = substr($course, 7, strpos($course, '&') - 7);
-	include '../survey/survey.download.inc.php';
-	$_course = check_download_survey($course, $invitation, $doc_url);
-	$_course['path'] = $_course['directory'];
+    $invitation = substr(strstr($refer_script, 'invitationcode='), 15);
+    $course = strstr($refer_script, 'course=');
+    $course = substr($course, 7, strpos($course, '&') - 7);
+    include '../survey/survey.download.inc.php';
+    $_course = check_download_survey($course, $invitation, $doc_url);
+    $_course['path'] = $_course['directory'];
 } else {
-	// If the rewrite rule asks for a directory, we redirect to the document explorer
-	if (is_dir($sys_course_path.$doc_url)) {
-		// Remove last slash if present
-		// mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
-		while ($doc_url{$dul = strlen($doc_url) - 1} == '/') {
-			$doc_url = substr($doc_url, 0, $dul);
-		}
-		// Group folder?
-		$gid_req = ($_GET['gidReq']) ? '&gidReq='.Security::remove_XSS($_GET['gidReq']) : '';
-		// Create the path
-		$document_explorer = api_get_path(WEB_CODE_PATH).'document/document.php?curdirpath='.urlencode($doc_url).'&cidReq='.Security::remove_XSS($_GET['cidReq']).$gid_req;
-		// Redirect
-		header('Location: '.$document_explorer);
-	}	
+    // If the rewrite rule asks for a directory, we redirect to the document explorer
+    if (is_dir($sys_course_path.$doc_url)) {
+        // Remove last slash if present
+        // mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
+        while ($doc_url{$dul = strlen($doc_url) - 1} == '/') {
+            $doc_url = substr($doc_url, 0, $dul);
+        }
+        // Group folder?
+        $gid_req = ($_GET['gidReq']) ? '&gidReq='.Security::remove_XSS($_GET['gidReq']) : '';
+        // Create the path
+        $document_explorer = api_get_path(WEB_CODE_PATH).'document/document.php?curdirpath='.urlencode($doc_url).'&cidReq='.Security::remove_XSS($_GET['cidReq']).$gid_req;
+        // Redirect
+        header('Location: '.$document_explorer);
+    }
 }
 
-        
-//Fixes swf upload problem in chamilo 1.8.x. When uploading a file with 
+
+//Fixes swf upload problem in chamilo 1.8.x. When uploading a file with
 //the character "-" the filename was changed from "-" to "_" in the DB for no reason
 $path_info = pathinfo($doc_url);
 
@@ -79,28 +79,27 @@ if (isset($path_info['extension']) && $path_info['extension'] == 'swf') {
     }
 }
 
-
 if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
-    $full_file_name = $sys_course_path.$doc_url;    
+    $full_file_name = $sys_course_path.$doc_url;
     if ($fix_file_name) {
         $doc_url = $fixed_url;
     }
     // Check visibility of document and paths
     $is_visible = DocumentManager::is_visible($doc_url, $_course, api_get_session_id());
-    
-	//Documents' slideshow thumbnails
-	//correct $is_visible used in below and ??. Now the students can view the thumbnails too
-	if ( preg_match('/\.thumbs\/\./',  $doc_url)){ 
-		$doc_url_thumbs = str_replace('.thumbs/.', '', $doc_url);
-		$is_visible = DocumentManager::is_visible($doc_url_thumbs, $_course, api_get_session_id());
-	}
-	
+
+    //Document's slideshow thumbnails
+    //correct $is_visible used in below and ??. Now the students can view the thumbnails too
+    if (preg_match('/\.thumbs\/\./', $doc_url)) {
+        $doc_url_thumbs = str_replace('.thumbs/.', '', $doc_url);
+        $is_visible = DocumentManager::is_visible($doc_url_thumbs, $_course, api_get_session_id());
+    }
+
     if (!api_is_allowed_to_edit() && !$is_visible) {
-    	Display::display_error_message(get_lang('ProtectedDocument'));//api_not_allowed backbutton won't work.
-    	exit; // You shouldn't be here anyway.
+        Display::display_error_message(get_lang('ProtectedDocument'));//api_not_allowed backbutton won't work.
+        exit; // You shouldn't be here anyway.
     }
     // Launch event
-	event_download($doc_url);
+    event_download($doc_url);
     DocumentManager::file_send_for_download($full_file_name);
 }
 exit;

+ 5 - 3
main/newscorm/lp_view.php

@@ -55,7 +55,9 @@ if (empty($_SESSION['oLP'])) {
 
 $debug = 0;
 
-if ($debug) { error_log('------ Entering lp_view.php -------'); }
+if ($debug) {
+    error_log('------ Entering lp_view.php -------');
+}
 
 $_SESSION['oLP']->error = '';
 $lp_item_id = $_SESSION['oLP']->get_current_item_id();
@@ -175,7 +177,7 @@ if (!isset($src)) {
             $htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
             $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($prereq_check === true) {
-                $src = $_SESSION['oLP']->get_link('http',$lp_item_id, $get_toc_list);
+                $src = $_SESSION['oLP']->get_link('http', $lp_item_id, $get_toc_list);
                 $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
             } else {
                 $src = 'blank.php?error=prerequisites';
@@ -187,7 +189,7 @@ if (!isset($src)) {
             $htmlHeadXtra[] = '<script src="'.$_SESSION['oLP']->get_js_lib().'" type="text/javascript" language="javascript"></script>';
             $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($prereq_check === true) {
-                $src = $_SESSION['oLP']->get_link('http',$lp_item_id, $get_toc_list);
+                $src = $_SESSION['oLP']->get_link('http', $lp_item_id, $get_toc_list);
                 $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
             } else {
                 $src = 'blank.php';