Esempio n. 1
0
function get_rss_enclosure($file_name, $image_type, $cat_id)
{
    if (!get_file_path($file_name, $image_type, $cat_id, 0, 0)) {
        return array();
    }
    $file = get_file_path($file_name, $image_type, $cat_id, 0, 1);
    $url = get_file_url($file_name, $image_type, $cat_id);
    return array('url' => $url, 'length' => @filesize($file), 'type' => get_mime_content_type($file));
}
Esempio n. 2
0
     exit_error($Language->getText('global', 'error'), $Language->getText('docman_admin_index', 'error_nodocgroup'));
 }
 if (!$title || !$description) {
     exit_missing_param();
 }
 //Page security - checks someone isnt updating a doc
 //that isnt theirs.
 $query = "select dd.docid " . "from doc_data dd, doc_groups dg " . "where dd.doc_group = dg.doc_group " . "and dg.group_id = " . $group_id . " " . "and dd.docid = '" . $docid . "'";
 $result = db_query($query);
 if (db_numrows($result) == 1) {
     // Upload the document if needed
     if ($upload_instead) {
         $fileName = $_FILES['uploaded_data']['name'];
         $tmpName = $_FILES['uploaded_data']['tmp_name'];
         $fileSize = $_FILES['uploaded_data']['size'];
         $fileType = get_mime_content_type($_FILES['uploaded_data']['tmp_name'], $_FILES['uploaded_data']['name']);
         //echo " filesize=".$fileSize;
         $fp = fopen($tmpName, 'r');
         $data = addslashes(fread($fp, filesize($tmpName)));
         fclose($fp);
         //echo "strlen(data) =".strlen($data);
         if ($fileSize <= 0 || $fileSize >= $sys_max_size_upload) {
             //too big or small
             exit_error($Language->getText('global', 'error'), $Language->getText('docman_new', 'error_size', array($sys_max_size_upload)));
         } else {
             //size is fine
             $feedback .= $Language->getText('docman_admin_index', 'feedback_doc_uploaded');
         }
     }
     if ($upload_instead) {
         // Upload file
Esempio n. 3
0
 if (ini_get('zlib.output_compression')) {
     ini_set('zlib.output_compression', 'Off');
 }
 // Content description
 header('Content-Description: File Transfer');
 // Content disposition
 if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") > 0) {
     header('Content-Disposition: attachment; filename="' . urlencode($release->filename) . '"');
 } else {
     header('Content-Disposition: attachment; filename*=UTF-8\'\'' . urlencode($release->filename));
 }
 // Content type
 $content_type = dc_header_content_type();
 if ($content_type == DC_HEADER_CONTENT_TYPE) {
     // Send MIME type of current file
     header('Content-Type: ' . get_mime_content_type(dc_file_location() . $release->filename));
 } else {
     // Override content type with header setting
     header('Content-Type: ' . $content_type);
 }
 // Transfer encoding
 header('Content-Transfer-Encoding: binary');
 // Content length
 header('Content-Length: ' . filesize(dc_file_location() . $release->filename));
 // Cache handling
 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 header('Pragma: public');
 header('Expires: 0');
 // Stream file
 ob_clean();
 flush();
Esempio n. 4
0
 /**
  * Sets the content of a file object to that in
  * the given source file
  *
  * @param File $file
  * @param string $sourceFile
  */
 public function setFile(File $file, $sourceFile)
 {
     if (!$this->getConnection()) {
         return null;
     }
     ini_set('memory_limit', '64M');
     $node = $this->nodeFromFile($file);
     if (!$node) {
         return;
     }
     $content = new ContentData($node, NamespaceMap::getFullName("cm_content"));
     $mimeType = get_mime_content_type($sourceFile);
     $sourceContent = file_get_contents($sourceFile);
     $content->setContent($sourceContent);
     $content->setMimetype($mimeType);
     $node->cm_content = $content;
     $this->alfresco->save();
 }
Esempio n. 5
0
 /**
  * Streams the content for a given file
  *
  * @param File $file
  */
 public function streamFile(File $file)
 {
     $filename = $this->getFullFilename($file);
     $filetype = get_mime_content_type($filename);
     // just raw stream the file
     header("Content-type: {$filetype}");
     header("Content-Disposition: inline; filename=\"{$file->filename}\";");
     $size = filesize($filename);
     if ($size) {
         header("Content-Length: " . $size);
     }
     readfile($filename);
     exit;
 }
Esempio n. 6
0
/**
 * Sends headers to download file when download code was entered successfully
 */
function dc_send_download_headers()
{
    global $wpdb;
    // Only continue if lease is provided as a query parameter
    if (isset($_GET['lease'])) {
        // Get details for code and release
        $release = $wpdb->get_row($wpdb->prepare("SELECT r.*, c.ID as code, c.code_prefix, c.code_suffix FROM " . dc_tbl_releases() . " r INNER JOIN " . dc_tbl_codes() . " c ON c.release = r.ID WHERE MD5(CONCAT('wp-dl-hash',c.ID)) = %s", array($_GET['lease'])));
        // Get # of downloads with this code
        $downloads = $wpdb->get_row($wpdb->prepare("SELECT COUNT(*) AS downloads FROM " . dc_tbl_downloads() . " WHERE code= %s", array($release->code)));
        // Start download if maximum of allowed downloads is not reached
        if ($downloads->downloads < $release->allowed_downloads) {
            // Get current IP
            $IP = $_SERVER['REMOTE_ADDR'];
            // Insert download in downloads table
            $wpdb->insert(dc_tbl_downloads(), array('code' => $release->code, 'IP' => $IP), array('%d', '%s'));
            // If Apache's xsendfile is enabled (must be installed and working on server side)
            if (dc_xsendfile_enabled()) {
                header('X-Sendfile: ' . dc_file_location() . $release->filename);
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename=\\"' . urlencode($release->filename) . '\\"');
                exit;
            }
            // Increase timeout for slow connections
            set_time_limit(0);
            // Deactivate output compression (required for IE, otherwise Content-Disposition is ignored)
            if (ini_get('zlib.output_compression')) {
                ini_set('zlib.output_compression', 'Off');
            }
            // Content description
            header('Content-Description: File Transfer');
            // Content disposition
            if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") > 0) {
                header('Content-Disposition: attachment; filename="' . urlencode($release->filename) . '"');
            } else {
                header('Content-Disposition: attachment; filename*=UTF-8\'\'' . urlencode($release->filename));
            }
            // Content type
            $content_type = dc_header_content_type();
            if ($content_type == DC_HEADER_CONTENT_TYPE) {
                // Send MIME type of current file
                header('Content-Type: ' . get_mime_content_type(dc_file_location() . $release->filename));
            } else {
                // Override content type with header setting
                header('Content-Type: ' . $content_type);
            }
            // Transfer encoding
            header('Content-Transfer-Encoding: binary');
            // Content length
            header('Content-Length: ' . filesize(dc_file_location() . $release->filename));
            // Cache handling
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Expires: 0');
            // Stream file
            ob_clean();
            flush();
            $handle = fopen(dc_file_location() . $release->filename, 'rb');
            $chunksize = 1 * (1024 * 1024);
            $buffer = '';
            if ($handle === false) {
                exit;
            }
            while (!feof($handle)) {
                $buffer = fread($handle, $chunksize);
                echo $buffer;
                flush();
            }
            // Close file
            fclose($handle);
            // Exit
            exit;
        }
    }
}