Example #1
0
         case 'aicc':
             require_once 'aicc.class.php';
             $oAICC = new aicc();
             $config_dir = $oAICC->import_package($_FILES['user_file']);
             if (!empty($config_dir)) {
                 $oAICC->parse_config_files($config_dir);
                 $oAICC->import_aicc(api_get_course_id());
             }
             $oAICC->set_proximity($proximity);
             $oAICC->set_maker($maker);
             $oAICC->set_jslib('aicc_api.php');
             break;
         case 'oogie':
             require_once 'openoffice_presentation.class.php';
             $take_slide_name = empty($_POST['take_slide_name']) ? false : true;
             $o_ppt = new OpenofficePresentation($take_slide_name);
             $first_item_id = $o_ppt->convert_document($_FILES['user_file']);
             break;
         case 'woogie':
             require_once 'openoffice_text.class.php';
             $split_steps = empty($_POST['split_steps']) || $_POST['split_steps'] == 'per_page' ? 'per_page' : 'per_chapter';
             $o_doc = new OpenofficeText($split_steps);
             $first_item_id = $o_doc->convert_document($_FILES['user_file']);
             break;
         case '':
         default:
             throw new \Exception(get_lang('ScormUnknownPackageFormat'));
     }
 } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
     // end if is_uploaded_file
     // If file name given to get in /upload/, try importing this way.
Example #2
0
     /*==== extension extraction ====*/
     $file_name = strrpos($newPath, '.') > 0 ? substr($newPath, 0, strrpos($newPath, '.')) : $newPath;
     $file_extension = strrpos($newPath, '.') > 0 ? substr($newPath, strrpos($newPath, '.'), 10) : '';
     if ($debug > 0) {
         error_log(strrpos($newPath, '.'));
     }
     if ($debug > 0) {
         error_log($file_extension);
     }
     /*==== conversion if needed ====*/
     if (!in_array(strtolower($file_extension), $image_extension)) {
         if ($debug > 0) {
             error_log("converting: " . $file_extension);
         }
         $take_slide_name = false;
         $o_ppt = new OpenofficePresentation($take_slide_name);
         $o_ppt->set_slide_size(640, 480);
         $o_ppt->convert_document($_FILES['Filedata'], 'add_docs_to_visio');
     }
     echo '<html><body><script language="javascript">setTimeout(1000,window.close());</script></body></html>';
 } else {
     if ($action == "service") {
         /*==== List files ====*/
         if ($debug > 0) {
             error_log("sending file list", 0);
         }
         $subaction = $_REQUEST["subaction"];
         $is_manager = CourseManager::get_user_in_course_status($user_id, $cidReq) == COURSEMANAGER;
         if ($subaction == "list") {
             // FIXME: check security around $_REQUEST["cwd"]
             $cwd = $_REQUEST["cwd"];
Example #3
0
 case 'convertToPdf':
     // PDF format as target by default
     $formatTarget = $_REQUEST['formatTarget'] ? strtolower(Security::remove_XSS($_REQUEST['formatTarget'])) : 'pdf';
     $formatType = $_REQUEST['formatType'] ? strtolower(Security::remove_XSS($_REQUEST['formatType'])) : 'text';
     // Get the document data from the ID
     $document_info = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, $session_id);
     $file = $sys_course_path . $courseInfo['directory'] . '/document' . $document_info['path'];
     $fileInfo = pathinfo($file);
     if ($fileInfo['extension'] == $formatTarget) {
         Display::addFlash(Display::return_message(get_lang('ConversionToSameFileFormat'), 'warning'));
     } elseif (!in_array($fileInfo['extension'], DocumentManager::getJodconverterExtensionList('from', $formatType)) || !in_array($formatTarget, DocumentManager::getJodconverterExtensionList('to', $formatType))) {
         Display::addFlash(Display::return_message(get_lang('FileFormatNotSupported'), 'warning'));
     } else {
         $convertedFile = $fileInfo['dirname'] . DIRECTORY_SEPARATOR . $fileInfo['filename'] . '_from_' . $fileInfo['extension'] . '.' . $formatTarget;
         $convertedTitle = $document_info['title'];
         $obj = new OpenofficePresentation(true);
         if (file_exists($convertedFile)) {
             Display::addFlash(Display::return_message(get_lang('FileExists'), 'error'));
         } else {
             $result = $obj->convertCopyDocument($file, $convertedFile, $convertedTitle);
             if (empty($result)) {
                 Display::addFlash(Display::return_message(get_lang('CopyFailed'), 'error'));
             } else {
                 $cidReq = Security::remove_XSS($_GET['cidReq']);
                 $id_session = api_get_session_id();
                 $gidReq = Security::remove_XSS($_GET['gidReq']);
                 $file_link = Display::url(get_lang('SeeFile'), api_get_path(WEB_CODE_PATH) . 'document/showinframes.php?' . 'cidReq=' . $cidReq . '&id_session=' . $id_session . '&' . 'gidReq=' . $gidReq . '&id=' . current($result));
                 Display::addFlash(Display::return_message(get_lang('CopyMade') . ' ' . $file_link, 'confirmation', false));
             }
         }
     }