Author Topic: Problem with download > 50 MB  (Read 10090 times)

0 Members and 1 Guest are viewing this topic.

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Problem with download > 50 MB
« on: June 30, 2006, 05:00:04 PM »
Ich hab ein problem.Meine mp3 files sind grosser als 50mb.Wenn man si downloaden muchte funkcionirt der download aber nicht :( Ich hab in dem forum verschiedene varianten gesehen ,wie man das reparieren konte .....aber auch da habe ich nichts gefunden.Kont ihr mir irgentwie helfen?

viele grusse
   
« Last Edit: July 01, 2006, 11:16:47 AM by kai »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #2 on: July 02, 2006, 01:10:16 PM »
ich hab's ausprobiert .......aber  .........der download get bis zu max 9mb...(50mb -original datei).....dann hort es auf.  (bei den files die kleiner sind als 9mb funktionirt es ok) ........die datei die runtergeladen wurde ist dan nicht spielbar ...meine server konf: apache 1.3.34  php 5.1.4

viele grusse


Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #3 on: July 02, 2006, 01:15:14 PM »
<?php

$main_template = 0;

$nozip = 1;
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');

$user_access = get_permission();

function get_remote_file($url) {
  $file_data = "";
  $url = @parse_url($url);
  if (isset($url['path']) && isset($url['scheme']) && eregi("http", $url['scheme'])) {
    $url['port'] = (!isset($url['port'])) ? 80 : $url['port'];
    if ($fsock = @fsockopen($url['host'], $url['port'], $errno, $errstr)) {
      @fputs($fsock, "GET ".$url['path']." HTTP/1.1\r\n");
      @fputs($fsock, "HOST: ".$url['host']."\r\n");
      @fputs($fsock, "Connection: close\r\n\r\n");
      $file_data = "";
      while (!@feof($fsock)) {
        $file_data .= @fread($fsock, 100000);
      }
      @fclose($fsock);
      if (preg_match("/Content-Length\: ([0-9]+)[^\/ \n]/i", $file_data, $regs)) {
        $file_data = substr($file_data, strlen($file_data) - $regs[1], $regs[1]);
      }
    }
  }
  return (!empty($file_data)) ? $file_data : 0;
}

function get_file_data($file_path, $size = 0) {
  if ($size)
  {
    if (!file_exists($file_path) || !$size = filesize($file_path)) return false;
    return $size;
  }
  global $script_url;
  ob_start();
  return file_get_contents($file_path);
  @ob_implicit_flush(0);
  @readfile($file_path);
  $file_data = ob_get_contents();
  ob_end_clean();
  if (!empty($file_data)) {
    return $file_data;
  }
  elseif (is_remote_file($file_path)) {
    $file_data = get_remote_file($file_path);
  }
  else {
    if (!file_exists($file_path)) {
      $file_path = preg_replace("/\/{2,}/", "/", get_document_root()."/".$file_path);
    }
    if (file_exists($file_path)) {
      $file_size = @filesize($file_path);
      $fp = @fopen($file_path, "rb");
      if ($fp) {
        $file_data = @fread($fp, $file_size);
        @fclose($fp);
      }
    }
  }
  if (empty($file_data)) {
    if (ereg("^\/", $file_path)) {
      preg_match("/^(http:\/\/[^\/]+)/i", $script_url, $regs);
      $script_url = $regs[1];
    }
    $file_data = get_remote_file($script_url."/".$file_path);
  }
  return (!empty($file_data)) ? $file_data : 0;
}

$file = array();

if ($action == "lightbox") {
  if (empty($user_info['lightbox_image_ids']) || !function_exists("gzcompress") || !function_exists("crc32")) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
  $image_ids = array();
  $sql = "SELECT image_id, cat_id, image_media_file, image_download_url
          FROM 4images_images
          WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_download", "NOTIN").")";
  $result = $site_db->query($sql);

  if ($result) {
    include(ROOT_PATH."includes/zip.php");
    $zipfile = new zipfile();
    $file_added = 0;
    while ($image_row = $site_db->fetch_array($result)) {
      if (!empty($image_row['image_download_url'])) {
        if (is_remote_file($image_row['image_download_url']) || is_local_file($image_row['image_download_url'])) {
          $file_path = $image_row['image_download_url'];
          $file_name = basename($image_row['image_download_url']);
        }
      }
      elseif (is_remote($image_row['image_media_file'])) {
        $file_path = $image_row['image_media_file'];
        $file_name = basename($image_row['image_media_file']);
      }
      else {
        $file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
        $file_name = $image_row['image_media_file'];
      }

      if (!empty($file_path)) {
        @set_time_limit(120);
        if (!$file_data = get_file_data($file_path)) {
          continue;
        }
        $zipfile->add_file($file_data, $file_name);
        $file_added = 1;
        unset($file_data);
        $image_ids[] = $image_row['image_id'];
      }
    }

    if ($file_added) {
      if ($user_info['user_level'] != ADMIN) {
        $sql = "UPDATE 4images_images
                SET image_downloads = image_downloads + 1
                WHERE image_id IN (".trim(implode(", ", $image_ids)).")";
        $site_db->query($sql);
      }

      @set_time_limit(120);
      $file['file_name'] = time().".zip";
      $file['file_data'] = $zipfile->file();
      #$file['file_size'] = strlen($file['file_data']);
    }
    else {
      header("Location: ".$site_sess->url($url, "&"));
      exit;
    }
  }
}
elseif ($image_id) {
  if (isset($HTTP_GET_VARS['size']) || isset($HTTP_POST_VARS['size'])) {
    $size = (isset($HTTP_GET_VARS['size'])) ? intval($HTTP_GET_VARS['size']) : intval($HTTP_POST_VARS['size']);
  }
  else {
    $size = 0;
  }

  $sql = "SELECT cat_id, user_id, image_media_file, image_download_url, image_downloads
          FROM 4images_images
          WHERE image_id = $image_id AND image_active = 1";
  $image_row = $site_db->query_firstrow($sql);

  if (!check_permission("auth_download", $image_row['cat_id']) || !$image_row) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $remote_url = 0;
  if (!empty($image_row['image_download_url'])) {
    if (is_remote_file($image_row['image_download_url']) || is_local_file($image_row['image_download_url'])) {
      ereg("(.+)\.(.+)", basename($image_row['image_download_url']), $regs);
      $file_name = $regs[1];
      $file_extension = $regs[2];

      $file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
      $file['file_path'] = dirname($image_row['image_download_url'])."/".$file['file_name'];
    }
    else {
      $file['file_path'] = $image_row['image_download_url'];
      $remote_url = 1;
    }
  }
  elseif (is_remote_file($image_row['image_media_file'])) {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file_name = $regs[1];
    $file_extension = $regs[2];

    $file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
    $file['file_path'] = dirname($image_row['image_media_file'])."/".$file['file_name'];
  }
  else {
    ereg("(.+)\.(.+)", basename($image_row['image_media_file']), $regs);
    $file_name = $regs[1];
    $file_extension = $regs[2];

    $file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
    $file['file_path'] = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".$file['file_name'];
  }

  if ($user_info['user_level'] != ADMIN) {
    $sql = "UPDATE 4images_images
            SET image_downloads = image_downloads + 1
            WHERE image_id = $image_id";
    $site_db->query($sql);
  }

  if (!empty($file['file_path'])) {
    @set_time_limit(120);
    if ($remote_url) {
      header("Location: ".$file['file_path']);
      exit;
    }
    elseif (!$file['file_size'] = get_file_data($file['file_path'], 1)) {
      ?>
     <script language="JavaScript" type="text/javascript">
     <!--
     function beginDownload() {
       idl = -1;
       idl = location.search.indexOf("idl=n");
       if (idl < 0) document.write('<iframe height="0" width="0" src="<?php echo $file['file_path']; ?>"></iframe>');
     }
     window.onLoad=beginDownload();
     //-->
     </script>
     <noscript>
        <iframe height="0" width="0" src="<?php echo $file['file_path']; ?>"></iframe>
     </noscript>

      <?php
      exit;
    }


    if ($action == "zip" && !eregi("\.zip$", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) {
     $file['file_data'] = get_file_data($file['file_path']);
      include(ROOT_PATH."includes/zip.php");
      $zipfile = new zipfile();
      $zipfile->add_file($file['file_data'], $file['file_name']);

      $file['file_data'] = $zipfile->file();
      $file['file_name'] = get_file_name($file['file_name']).".zip";
    }
    #$file['file_size'] = strlen($file['file_data']);
  }
  else {
    echo $lang['download_error']."\n<!-- EMPTY FILE PATH //-->";
    exit;
  }
}
else {
  echo $lang['download_error']."\n<!-- NO ACTION SPECIFIED //-->";
  exit;
}

#if (!empty($file['file_data'])) {
  if (get_user_os() == "MAC") {
    header("Content-Type: application/x-unknown\n");
    header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
  }
  elseif (get_browser_info() == "MSIE") {
    $disposition = (!eregi("\.zip$", $file['file_name']) && $action != "zip" && $action != "lightbox") ? 'attachment' : 'inline';
    header("Content-Disposition: $disposition; filename=\"".$file['file_name']."\"\n");
    header("Content-Type: application/x-ms-download\n");
  }
  elseif (get_browser_info() == "OPERA") {
    header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
    header("Content-Type: application/octetstream\n");
  }
  else {
    header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
    header("Content-Type: application/octet-stream\n");
  }
  header("Content-Length: ".$file['file_size']."\n\n");
if (!empty($file['file_data'])) {
  echo $file['file_data'];
}
else
{
  if ($handle = @fopen($file['file_path'], "rb"))
  {
    while (!feof($handle))
    {
      print fread($handle, 512000);
      @ob_flush();
      @flush();
    }
    fclose($handle);
  }
}
exit;
?>

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #4 on: July 11, 2006, 01:49:42 PM »
any solution ?

Offline honda2000

  • 4images Guru
  • *******
  • Posts: 3.263
    • View Profile
    • Wir machen Internet!
Re: Problem with download > 50 MB
« Reply #5 on: July 11, 2006, 08:06:12 PM »
du hast dir die Frage doch schon so gut wie selbst beantwortet!

dein SERVER > Hoster oder wenn dann DU bei einem Root-Server lässt dateien in der GRöße nicht zu, bzw. dauert der upload so lange, das die Verbindung abgebrochen wird, weil einfach die Zeit überschritten ist

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #6 on: July 12, 2006, 06:46:33 PM »
Man muss diese zeile             
Code: [Select]
@set_time_limit(120);  also 2 min andern ins  zbs.--------->?
Code: [Select]
@set_time_limit(3600);?     dann geht der download.
Aber es gibt da noch ein problem, werend  ich das file downloade,blokiert es alles(ich kann mich nicht durch die seite navigieren;4images ist wie blokiert->der download blokiert alles).

was konnte dass werursachen?

viele grusse
« Last Edit: July 18, 2006, 01:27:31 PM by kai »

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #7 on: July 14, 2006, 01:21:18 PM »
when downloading a picture from my site (4images 1.7.2) the site is not browsable until the download completes.Is there a chance that i could download the picture/s and browse my site at the same time (not that the download blocks everthing )?

any solutions ?
i use the code posted before

thnx

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Problem with download > 50 MB
« Reply #8 on: July 14, 2006, 02:54:50 PM »
when downloading a picture from my site (4images 1.7.2) the site is not browsable until the download completes.Is there a chance that i could download the picture/s and browse my site at the same time (not that the download blocks everthing )?

any solutions ?
i use the code posted before

thnx
http://www.4homepages.de/forum/index.php?topic=12013.msg67048#msg67048
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline max18

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Problem with download > 50 MB
« Reply #9 on: July 14, 2006, 04:57:32 PM »
thnx