Disable .htaccess, fix flash messages, fix php warnings, remove errorlog

pull/3878/head
Julio Montoya 5 years ago
parent d994797bae
commit 905a21037e
  1. 30
      main/admin/course_intro_pdf_import.php
  2. 8
      main/inc/lib/fileUpload.lib.php

@ -37,28 +37,17 @@ if (isset($_POST['formSent'])) {
);
} 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);
@ -101,7 +90,7 @@ Display::display_footer();
*
* @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 = '/')
{
@ -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;
@ -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 .
@ -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;
}

@ -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'))
);

Loading…
Cancel
Save