3
« on: February 16, 2003, 04:16:46 PM »
Hallo Jan,
der download funktioniert nicht mehr.
Wo möglich ist die Ursache ein update der Serververwaltungssoftware Confixx ligt of Confixx Pro.
Ich benutze eine von dir modifizierte download.php für Mac user der Version 1.6
Nachdem monatelang alles wunderbar funktioniert hat habe ich nun das Problem ( denke es hat was mit confixx zu tun ) das zwar im Leuchtkasten der download startet aber nach einiger Zeit im Broswer nur eine weisse Seite zu sehen ist und nichts passiert.
Im Verzeichnis download liegen die gepackte Dateien aber der download startet nicht auch werden die alten Dateien in dem Verzeichnis nicht gelöscht.
Hast du ne Idee warum das auf einmal nicht mehr funktioniert ??
Vielen Dank
MaxMeier
Ps. hier nochmal die download.php von dir:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: download.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.6.1 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) f?r weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
// Start Configuration
define("DOWNLOAD_TMP_PATH", "download/"); // with trailing slash
define("DOWNLOAD_ZIP_TYPE", 1); // 1 = zip, 2 = tar, 3 = tar.gz
// End Configuration
$nozip = 1;
$main_template = 0;
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, 1000);
}
@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) {
global $script_url;
ob_start();
@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;
}
function copy_file_data($src, $dest) {
global $script_url;
$ok = 0;
if (is_remote_file($src)) {
if ($file_data = get_remote_file($src)) {
@umask(0111);
$fp = @fopen($dest, "w");
$ok = @fwrite($fp, $file_data);
@fclose($fp);
}
}
else {
if (!file_exists($src)) {
$src = preg_replace("/\/{2,}/", "/", get_document_root()."/".$src);
}
if (file_exists($src)) {
$ok = @copy($src, $dest);
}
}
if (!$ok) {
if (ereg("^\/", $src)) {
preg_match("/^(http:\/\/[^\/]+)/i", $script_url, $regs);
$script_url = $regs[1];
}
if ($file_data = get_remote_file($script_url."/".$src)) {
@umask(0111);
$fp = @fopen($dest, "w");
$ok = @fwrite($fp, $file_data);
@fclose($fp);
}
}
return (file_exists($dest)) ? 1 : 0;
}
function remove_tmp_folder($path) {
$ok = 1;
if (@is_dir($path)) {
$handle = opendir($path);
while ($file = @readdir($handle)) {
if ($file != "." && $file != "..") {
$ok = (!remove_tmp_folder($path."/".$file)) ? 0 : $ok;
}
}
closedir($handle);
$ok = (@rmdir($path)) ? $ok : 0;
}
else {
$ok = (@unlink($path)) ? $ok : 0;
}
return $ok;
}
function create_tmp_folder($tmp_path, $mode = 0777) {
$path = $tmp_path."lightbox".substr(md5(uniqid(microtime())), 0, 8);
if (@is_dir($path)) {
remove_tmp_folder($path);
}
else {
$oldumask = umask(0);
$result = mkdir($path, $mode);
umask($oldumask);
if (!@is_dir($path) || !$result) {
$result = mkdir($path, 0755);
@chmod($path, $mode);
}
return ($result) ? $path : 0;
}
}
$file = array();
// Remove old files
$path = (DOWNLOAD_TMP_PATH == "") ? "./" : DOWNLOAD_TMP_PATH."/";
$handle = opendir($path);
while ($file = @readdir($handle)) {
if (@is_file($path.$file) && preg_match("/(\.[zip|gz|tar]+)$/i", $file)) {
@unlink($path.$file);
}
}
if ($action == "lightbox") {
if (empty($user_info['lightbox_image_ids']) || !function_exists("gzcompress") || !function_exists("crc32")) {
header("Location: ".$site_sess->url($url, "&"));
exit;
}
$cat_id_sql = 0;
foreach ($cat_cache as $key => $val) {
if (check_permission("auth_download", $key)) {
$cat_id_sql .= ", ".$key;
}
}
$image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
$sql = "SELECT cat_id, image_media_file, image_download_url
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id IN ($cat_id_sql)";
$result = $site_db->query($sql);
if ($result) {
$file_added = 0;
$tmp_lightbox_path = create_tmp_folder(DOWNLOAD_TMP_PATH);
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)) {
if (!@is_dir($tmp_lightbox_path)) {
break;
}
if (copy_file_data($file_path, $tmp_lightbox_path."/".$file_name)) {
$file_added = 1;
}
}
}
if ($file_added) {
$src = $tmp_lightbox_path."/*";
if (DOWNLOAD_ZIP_TYPE == 1) {
$file['file_name'] = time().".zip";
$dest = DOWNLOAD_TMP_PATH.$file['file_name'];
exec("zip $dest $src");
}
else {
$file['file_name'] = time().".tar";
$dest = DOWNLOAD_TMP_PATH.$file['file_name'];
exec("tar -cvf $dest $src");
if (DOWNLOAD_ZIP_TYPE == 3) {
exec("gzip $dest");
$file['file_name'] .= ".gz";
$dest .= ".gz";
}
}
//$file['file_data'] = get_file_data($dest);
//$file['file_size'] = strlen($file['file_data']);
remove_tmp_folder($tmp_lightbox_path);
if (file_exists($dest)) {
header("Location: $dest");
//@unlink($dest);
exit;
}
}
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 ".IMAGES_TABLE."
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 ".IMAGES_TABLE."
SET image_downloads = image_downloads + 1
WHERE image_id = $image_id";
$site_db->query($sql);
}
if (!empty($file['file_path'])) {
if ($remote_url) {
header("Location: ".$file['file_path']);
exit;
}
if ($action == "zip" && !eregi("\.zip$", $file['file_name'])) {
if (copy_file_data($file['file_path'], DOWNLOAD_TMP_PATH.$file['file_name'])) {
$src = DOWNLOAD_TMP_PATH.$file['file_name'];
if (DOWNLOAD_ZIP_TYPE == 1) {
$file['file_name'] = get_file_name($file['file_name']).".zip";
$dest = DOWNLOAD_TMP_PATH.$file['file_name'];
exec("zip $dest $src");
}
else {
$file['file_name'] = get_file_name($file['file_name']).".tar";
$dest = DOWNLOAD_TMP_PATH.$file['file_name'];
exec("tar -cvf $dest $src");
if (DOWNLOAD_ZIP_TYPE == 3) {
exec("gzip $dest");
$file['file_name'] .= ".gz";
$dest .= ".gz";
}
}
if (file_exists($src)) {
unlink($src);
}
if (file_exists($dest)) {
//$file['file_data'] = get_file_data($dest);
header("Location: $dest");
//@unlink($dest);
exit;
}
else {
echo $lang['download_error']."\n<!-- COULD NOT CREATE ZIP FILE //-->";
exit;
}
}
else {
echo $lang['download_error']."\n<!-- COULD NOT COPY FILE //-->";
exit;
}
}
elseif (!$file['file_data'] = get_file_data($file['file_path'])) {
?>
<script language="javascript" type="text/javascript">
<!--
window.open('<?php echo $file['file_path']; ?>','imagewindow','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
// -->
</script>
<meta http-equiv="Refresh" content="0; URL=<?php echo $site_sess->url($url, "&"); ?>">
<?php
echo $lang['download_error']."\n<!-- NO FILE DATA / FILE NOT FOUND //-->";
exit;
}
$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") {
if (eregi("\.zip$", $file['file_name'])) {
$type = "zip";
}
elseif (eregi("\.gz$", $file['file_name'])) {
$type = "gzip";
}
elseif (eregi("\.tar$", $file['file_name'])) {
$type = "x-tar";
}
else {
$type = "x-unknown";
}
header("Content-Type: application/".$type."\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");
echo $file['file_data'];
}
exit;
?>