コード例 #1
0
    Display::display_header($nameTools, 'Dropbox');
    Display::display_error_message(get_lang('YouAreNotAllowedToDownloadThisFile'));
    Display::display_footer();
    exit;
} else {
    /*      DOWNLOAD THE FILE */
    // the user is allowed to download the file
    $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][] = intval($_GET['id']);
    $work = new Dropbox_Work($_GET['id']);
    $path = dropbox_cnf('sysPath') . '/' . $work->filename;
    //path to file as stored on server
    if (!Security::check_abs_path($path, dropbox_cnf('sysPath') . '/')) {
        exit;
    }
    $file = $work->title;
    $mimetype = DocumentManager::file_get_mime_type(true);
    $fileinfo = pathinfo($file);
    $extension = $fileinfo['extension'];
    if (!empty($extension) && isset($mimetype[$extension]) && $_GET['action'] != 'download') {
        // give hint to browser about filetype
        header('Content-type: ' . $mimetype[$extension] . "\n");
    } else {
        //no information about filetype: force a download dialog window in browser
        header("Content-type: application/octet-stream\n");
    }
    header('Content-Disposition: attachment; filename=' . $file);
    /**
     * Note that if you use these two headers from a previous example:
     * header('Cache-Control: no-cache, must-revalidate');
     * header('Pragma: no-cache');
     * before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it.
コード例 #2
0
/**
 * Script to find a document with a specific title or path in all courses
 */
/**
 * Code init - comment die() call to enable
 */
die;
require '../../inc/global.inc.php';
require_once '../../inc/lib/course.lib.php';
require_once '../../inc/lib/document.lib.php';
if (empty($_GET['doc'])) {
    echo "To add a document name to search, add ?doc=abc to the URL\n";
} else {
    echo "Received param " . $_GET['doc'] . "<br />\n";
}
$allowed_mime_types = DocumentManager::file_get_mime_type(true);
$allowed_extensions = array('doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'xls', 'xlsx', 'odt', 'odp', 'ods', 'pdf', 'txt', 'rtf', 'msg', 'csv', 'html', 'htm');
$courses_list = CourseManager::get_courses_list();
// Simulating empty specific fields (this is necessary for indexing)
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
$specific_fields_values = array();
foreach ($specific_fields as $sf) {
    $specific_fields_values[$sf['code']] = '';
}
$td = Database::get_course_table(TABLE_DOCUMENT);
foreach ($courses_list as $course) {
    $course_dir = $course['directory'] . '/document';
    $title = Database::escape_string($_GET['doc']);
    $sql = "SELECT id, path, session_id FROM {$td} WHERE c_id = " . $course['id'] . " AND path LIKE '%{$title}%' or title LIKE '%{$title}%'";
    $res = Database::query($sql);
コード例 #3
0
 function mime_content_type($filename)
 {
     return DocumentManager::file_get_mime_type((string) $filename);
 }
コード例 #4
0
 function mdo_add_breadcrump_nav()
 {
     global $interbreadcrumb, $langFormats;
     $regs = array();
     // for use with ereg()
     $docurl = api_get_self();
     // should be .../main/xxx/yyy.php
     if (ereg('^(.+[^/\\.]+)/[^/\\.]+/[^/\\.]+.[^/\\.]+$', $docurl, $regs)) {
         $docurl = $regs[1] . '/document/document.php';
     }
     $interbreadcrumb[] = array('url' => $docurl, "name" => get_lang('MdCallingTool'));
     if ($docpath = $this->mdo_path) {
         $docpath = substr($docpath, 0, strrpos($docpath, '/'));
         if (strlen($docpath) > 1) {
             $interbreadcrumb[] = array('url' => $docurl . '?curdirpath=' . urlencode($docpath) . ($this->mdo_group ? '&gidReq=' . $this->mdo_group : ''), "name" => htmlspecialchars(substr($docpath, strrpos($docpath, '/') + 1)));
         }
     }
     // Complete assoclist $langFormats from mime types
     require_once api_get_path(LIBRARY_PATH) . 'xht.lib.php';
     require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
     $sep = $langFormats[0] ? $langFormats[0] : ":";
     $arrFormats = xht_explode_assoclist($langFormats);
     foreach (DocumentManager::file_get_mime_type(TRUE) as $format) {
         if (!isset($arrFormats[$format])) {
             $langFormats .= ",, " . $format . $sep . $format;
         }
     }
     if (!isset($arrFormats["inode/directory"])) {
         $langFormats .= ",, inode/directory" . $sep . "inode/directory";
     }
     if (substr($langFormats, 0, 3) == ",, ") {
         $langFormats = $sep . substr($langFormats, 3);
     }
 }