コード例 #1
0
ファイル: document.php プロジェクト: rhertzog/lcs
     $uploadImgFileNb = sizeof($_FILES['imgFile']);
     if ($uploadImgFileNb > 0) {
         // Try to create  a directory to store the image files
         $_REQUEST['relatedFile'] = secure_file_path($_REQUEST['relatedFile']);
         $imgDirectory = $_REQUEST['relatedFile'] . '_files';
         $imgDirectory = create_unexisting_directory($baseWorkDir . $imgDirectory);
         // set the makeInvisible command param appearing later in the script
         $mkInvisibl = str_replace($baseWorkDir, '', $imgDirectory);
         // move the uploaded image files into the corresponding image directory
         // Try to create  a directory to store the image files
         $newImgPathList = move_uploaded_file_collection_into_directory($_FILES['imgFile'], $imgDirectory);
         if (!empty($newImgPathList)) {
             $newImgPathList = array_map('rawurlencode', $newImgPathList);
             // rawurlencode() does too much. We don't need to replace '/' by '%2F'
             $newImgPathList = str_replace('%2F', '/', $newImgPathList);
             replace_img_path_in_html_file($_REQUEST['imgFilePath'], $newImgPathList, $baseWorkDir . $_REQUEST['relatedFile']);
         }
     }
     // end if ($uploadImgFileNb > 0)
 }
 // end if ($submitImage)
 /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
                          CREATE DOCUMENT
   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
 /*------------------------------------------------------------------------
                         CREATE DOCUMENT : STEP 2
   ------------------------------------------------------------------------*/
 if ('exMkHtml' == $cmd) {
     $fileName = replace_dangerous_char(trim($_REQUEST['fileName']));
     $cwd = secure_file_path($cwd);
     if (!empty($fileName)) {
コード例 #2
0
    }
}
//missing images are submitted
if (isset($_POST['submit_image'])) {
    $number_of_uploaded_images = count($_FILES['img_file']['name']);
    //if images are uploaded
    if ($number_of_uploaded_images > 0) {
        //we could also create a function for this, I'm not sure...
        //create a directory for the missing files
        $img_directory = str_replace('.', '_', $_POST['related_file'] . "_files");
        $folderData = create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $img_directory);
        $missing_files_dir = $folderData['path'];
        //put the uploaded files in the new directory and get the paths
        $paths_to_replace_in_file = move_uploaded_file_collection_into_directory($_course, $_FILES['img_file'], $base_work_dir, $missing_files_dir, $_user['user_id'], $to_group_id, $to_user_id, $max_filled_space);
        //open the html file and replace the paths
        replace_img_path_in_html_file($_POST['img_file_path'], $paths_to_replace_in_file, $base_work_dir . $_POST['related_file']);
        //update parent folders
        item_property_update_on_folder($_course, $_POST['curdirpath'], $_user['user_id']);
    }
}
//they want to create a directory
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
    $added_slash = $path == '/' ? '' : '/';
    $dir_name = $path . $added_slash . api_replace_dangerous_char($_POST['dirname']);
    $created_dir = create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $dir_name, $_POST['dirname']);
    if ($created_dir) {
        Display::display_normal_message(get_lang('DirCr'));
        $path = $created_dir;
    } else {
        display_error(get_lang('CannotCreateDir'));
    }