@@ -1068,48 +1068,34 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
1068
1068
}
1069
1069
1070
1070
/* Uncompressing phase */
1071
-
1072
- /*
1073
- The first version, using OS unzip, is not used anymore
1074
- because it does not return enough information.
1075
- We need to process each individual file in the zip archive to
1076
- - add it to the database
1077
- - parse & change relative html links
1078
- */
1079
- if (PHP_OS == 'Linux ' && !get_cfg_var ('safe_mode ' ) && false ) { // *** UGent, changed by OC ***
1080
- // Shell Method - if this is possible, it gains some speed
1081
- exec ("unzip -d \"" .$ base_work_dir .$ upload_path ."/ \"" .$ uploaded_file ['name ' ]." " .$ uploaded_file ['tmp_name ' ]);
1082
- } else {
1083
- // PHP method - slower...
1084
- $ save_dir = getcwd ();
1085
- chdir ($ base_work_dir .$ upload_path );
1086
- $ unzippingState = $ zip_file ->extract ();
1087
- for ($ j = 0 ; $ j < count ($ unzippingState ); $ j ++) {
1088
- $ state = $ unzippingState [$ j ];
1089
-
1090
- // Fix relative links in html files
1091
- $ extension = strrchr ($ state ['stored_filename ' ], '. ' );
1092
- }
1093
- if ($ dir = @opendir ($ base_work_dir .$ upload_path )) {
1094
- while ($ file = readdir ($ dir )) {
1095
- if ($ file != '. ' && $ file != '.. ' ) {
1096
- $ filetype = 'file ' ;
1097
- if (is_dir ($ base_work_dir .$ upload_path .'/ ' .$ file )) {
1098
- $ filetype = 'folder ' ;
1099
- }
1100
-
1101
- $ safe_file = api_replace_dangerous_char ($ file );
1102
- @rename ($ base_work_dir .$ upload_path .'/ ' .$ file , $ base_work_dir .$ upload_path .'/ ' .$ safe_file );
1103
- set_default_settings ($ upload_path , $ safe_file , $ filetype );
1071
+ $ save_dir = getcwd ();
1072
+ chdir ($ base_work_dir .$ upload_path );
1073
+ $ unzippingState = $ zip_file ->extract ();
1074
+ for ($ j = 0 ; $ j < count ($ unzippingState ); $ j ++) {
1075
+ $ state = $ unzippingState [$ j ];
1076
+ // Fix relative links in html files
1077
+ $ extension = strrchr ($ state ['stored_filename ' ], '. ' );
1078
+ }
1079
+ if ($ dir = @opendir ($ base_work_dir .$ upload_path )) {
1080
+ while ($ file = readdir ($ dir )) {
1081
+ if ($ file != '. ' && $ file != '.. ' ) {
1082
+ $ filetype = 'file ' ;
1083
+ if (is_dir ($ base_work_dir .$ upload_path .'/ ' .$ file )) {
1084
+ $ filetype = 'folder ' ;
1104
1085
}
1105
- }
1106
1086
1107
- closedir ($ dir );
1108
- } else {
1109
- error_log ('Could not create directory ' .$ base_work_dir .$ upload_path .' to unzip files ' );
1087
+ $ safe_file = api_replace_dangerous_char ($ file );
1088
+ @rename ($ base_work_dir .$ upload_path .'/ ' .$ file , $ base_work_dir .$ upload_path .'/ ' .$ safe_file );
1089
+ set_default_settings ($ upload_path , $ safe_file , $ filetype );
1090
+ }
1110
1091
}
1111
- chdir ($ save_dir ); // Back to previous dir position
1092
+
1093
+ closedir ($ dir );
1094
+ } else {
1095
+ error_log ('Could not create directory ' .$ base_work_dir .$ upload_path .' to unzip files ' );
1112
1096
}
1097
+ chdir ($ save_dir ); // Back to previous dir position
1098
+
1113
1099
}
1114
1100
1115
1101
return true ;
0 commit comments