Browse Source

Merge branch '1.9.x' of https://github.com/chamilo/chamilo-lms into 1.9.x

Cesar Perales 11 years ago
parent
commit
3e76b2dfa2
2 changed files with 10 additions and 8 deletions
  1. 7 6
      main/inc/lib/fileUpload.lib.php
  2. 3 2
      main/inc/lib/main_api.lib.php

+ 7 - 6
main/inc/lib/fileUpload.lib.php

@@ -611,8 +611,7 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
 	$zip_file = new PclZip($uploaded_file['tmp_name']);
 
 	// Check the zip content (real size and file extension)
-	if (file_exists($uploaded_file)) {
-
+	if (file_exists($uploaded_file['tmp_name'])) {
 		$zip_content_array = $zip_file->listContent();
 		$ok_scorm = false;
         $realFileSize = 0;
@@ -646,7 +645,7 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
 		}
 
 		// It happens on Linux that $upload_path sometimes doesn't start with '/'
-		if ($upload_path[0] != '/') {
+		if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') {
 			$upload_path = '/'.$upload_path;
 		}
 
@@ -670,14 +669,13 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
 			// PHP method - slower...
 			$save_dir = getcwd();
 			chdir($base_work_dir.$upload_path);
-			$unzippingState = $zip_file->extract();
+            $unzippingState = $zip_file->extract();
 			for ($j=0; $j < count($unzippingState); $j++) {
 				$state = $unzippingState[$j];
 
 				// Fix relative links in html files
 				$extension = strrchr($state['stored_filename'], '.');
 			}
-
 			if ($dir = @opendir($base_work_dir.$upload_path)) {
 				while ($file = readdir($dir)) {
 					if ($file != '.' && $file != '..') {
@@ -692,7 +690,10 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
 				}
 
 				closedir($dir);
-			}
+			} else {
+                error_log('Could not create directory '.$base_work_dir.$upload_path.' to unzip files');
+
+            }
 			chdir($save_dir); // Back to previous dir position
 		}
 	}

+ 3 - 2
main/inc/lib/main_api.lib.php

@@ -1325,9 +1325,10 @@ function api_get_cidreq($add_session_id = true, $add_group_id = true) {
  *
  * Now if the course_code is given, the returned array gives info about that
  * particular course, not specially the current one.
- * @todo    Same behaviour as api_get_user_info so that api_get_course_id becomes absolete too.
+ * @param string Course code
+ * @todo    Same behaviour as api_get_user_info so that api_get_course_id becomes obsolete too.
  */
-function api_get_course_info($course_code = null) {
+function api_get_course_info($course_code = null, $strict = false) {
     if (!empty($course_code)) {
         $course_code        = Database::escape_string($course_code);
         $course_table       = Database::get_main_table(TABLE_MAIN_COURSE);