Skip to content
Permalink
Browse files Browse the repository at this point in the history
Disable .htaccess, fix flash messages, fix php warnings, remove errorlog
  • Loading branch information
jmontoyaa committed May 20, 2021
1 parent d994797 commit 905a210
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 13 additions & 17 deletions main/admin/course_intro_pdf_import.php
Expand Up @@ -37,28 +37,17 @@
);
} else {
$errors = import_pdfs($subDir);
if (count($errors) == 0) {
error_log('Course intros imported successfully in '.__FILE__.', line '.__LINE__);
}
}
}
}

if (count($errors) != 0) {
if (!empty($errors)) {
$error_message = '<ul>';
foreach ($errors as $index => $error_course) {
$error_message .= '<li>'.get_lang('Course').': '.$error_course['Title'].' ('.$error_course['Code'].')</li>';
}
$error_message .= '</ul>';
Display::addFlash(Display::return_message($error_message, 'normal', false));
} elseif (isset($_POST['formSent'])) {
Display::addFlash(
Display::return_message(
get_lang('CourseIntroductionsAllImportedSuccessfully'),
'confirmation',
false
)
);
}

Display::display_header($tool_name);
Expand Down Expand Up @@ -101,7 +90,7 @@
*
* @param string $subDir The subdirectory in which to put the files in each course
*
* @return array List of possible errors found
* @return bool|array List of possible errors found
*/
function import_pdfs($subDir = '/')
{
Expand All @@ -112,9 +101,7 @@ function import_pdfs($subDir = '/')
@mkdir($baseDir.$uploadPath);
}
if (!unzip_uploaded_file($_FILES['import_file'], $uploadPath, $baseDir, 1024 * 1024 * 1024)) {
error_log('Could not unzip uploaded file in '.__FILE__.', line '.__LINE__);

return $errors;
return false;
}
$list = scandir($baseDir.$uploadPath);
$i = 0;
Expand Down Expand Up @@ -174,7 +161,6 @@ function import_pdfs($subDir = '/')
$course_description->insert();
}
} else {
error_log($parts[0].' is not a course, apparently');
$errors[] = ['Line' => 0, 'Code' => $parts[0], 'Title' => $parts[0].' - '.get_lang('CodeDoesNotExists')];
}
$i++; //found at least one entry that is not a dir or a .
Expand All @@ -183,5 +169,15 @@ function import_pdfs($subDir = '/')
$errors[] = ['Line' => 0, 'Code' => '.', 'Title' => get_lang('NoPDFFoundAtRoot')];
}

if (empty($errors)) {
Display::addFlash(
Display::return_message(
get_lang('CourseIntroductionsAllImportedSuccessfully'),
'confirmation',
false
)
);
}

return $errors;
}
8 changes: 6 additions & 2 deletions main/inc/lib/fileUpload.lib.php
Expand Up @@ -1013,8 +1013,12 @@ function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_
$zip_content_array = $zip_file->listContent();
$ok_scorm = false;
$realFileSize = 0;
foreach ($zip_content_array as &$this_content) {
if (preg_match('~.(php.*|phtml)$~i', $this_content['filename'])) {
$ok_plantyn_scorm1 = false;
$ok_plantyn_scorm2 = false;
$ok_plantyn_scorm3 = false;
$ok_aicc_scorm = false;
foreach ($zip_content_array as $this_content) {
if (preg_match('~.(php.*|phtml|phar|htaccess)$~i', $this_content['filename'])) {
Display::addFlash(
Display::return_message(get_lang('ZipNoPhp'))
);
Expand Down

0 comments on commit 905a210

Please sign in to comment.