MOD: Alternate directory for download files

MODs (& more) applied to 4images image gallery.<br>
.:: Preferred language(s): all<br>
.:: Permissions: Registered
Post Reply
User avatar
geohei
Site Admin
Posts: 3388
Joined: Tuesday, 19.11.2002 07:56
Location: Luxembourg
Contact:

MOD: Alternate directory for download files

Post by geohei »

Date of modification:
17.11.2005

Link:
http://www.4homepages.de/forum/index.php?topic=7499.0

Modified files:
./download.php
./includes/functions.php
./templates/x_images/details.html
./details.php
./lang/english/main.php
./lang/deutsch/main.php

./download.php
Locate:

Code: Select all

    $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'];
Change it to:

Code: Select all

    $temp = get_file_path($file['file_name'], "download", $image_row['cat_id'], 0, 1);
    if( !file_exists($temp) )
      $temp = (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'];
      $file['file_path'] = $temp;
Locate:

Code: Select all

        $file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
Replace with:

Code: Select all

        $file_path = MEDIA_PATH."/".$image_row['cat_id']."/download/".$image_row['image_media_file'];
        if( !file_exists($file_path) )
          $file_path = MEDIA_PATH."/".$image_row['cat_id']."/big/".$image_row['image_media_file'];
        if( !file_exists($file_path) )
          $file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
./includes/functions.php
Locate:

Code: Select all

  $file_size = "n/a";
  if (!is_remote($image_row['image_media_file'])) {
    if ($file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'])) {
      $file_size = format_file_size($file_size);
    }
  }
  elseif ($detailed_view) {
    $file_size = get_remote_file_size($image_row['image_media_file']);
  }
Replace with:

Code: Select all

  $file_size = "n/a";
  $download_file_size = "n/a";  // Download file
  if (!is_remote($image_row['image_media_file'])) {
    if ($file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'])) {
      $download_file_size = $file_size;  // Download file
      $file_size = format_file_size($file_size);
    }
    if( file_exists(MEDIA_PATH."/".$image_row['cat_id']."/download/".$image_row['image_media_file']) )
      $download_file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/download/".$image_row['image_media_file']);
    elseif( file_exists(MEDIA_PATH."/".$image_row['cat_id']."/big/".$image_row['image_media_file']) )
      $download_file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/big/".$image_row['image_media_file']);
      $download_file_size = format_file_size($download_file_size);
  }
  elseif ($detailed_view) {
    $file_size = get_remote_file_size($image_row['image_media_file']);
  }
Locate:

Code: Select all

    "url_download" => $site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']),
Add after:

Code: Select all

    "download_image_file_size" => $download_file_size,
Locate:

Code: Select all

if ($image_info = @getimagesize($src, $info)) {
  $width_height = " ".$image_info[3];
  $width = $image_info[0];
  $height = $image_info[1];
Add after:

Code: Select all

  $download_width_height = $width_height;
  $download_width = $width;
  $download_height = $height;
Locate:

Code: Select all

  else {
    $check_handle = "check_".$image_type."_type";
    $path = (($image_type == "media") ? (($cat_id) ? MEDIA_PATH."/".$cat_id : MEDIA_TEMP_PATH) : (($cat_id) ? THUMB_PATH."/".$cat_id : THUMB_TEMP_PATH))."/".$file_name;
    return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : $return_code;
  }
Replace with:

Code: Select all

  else {
    $check_handle = "check_".$image_type."_type";
    switch( $image_type ) {
      case "media":
        if( $cat_id )
          $path = MEDIA_PATH."/".$cat_id;
        else
	  $path = MEDIA_TEMP_PATH;
        break;
      case "big":
        $path = MEDIA_PATH."/".$cat_id."/big";
        break;
      case "download":
        $path = MEDIA_PATH."/".$cat_id."/download";
        break;
      default:
        if( $cat_id )
          $path = THUMB_PATH."/".$cat_id;
	else
	  $path = THUMB_TEMP_PATH;
        break;
    }
    $path .= "/".$file_name;
    return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : (($image_type != "big" && $image_type != "download") ? $return_code : "");
  }
Locate:

Code: Select all

    $site_template->register_vars(array(
      "media_src" => $media_src,
      "media_icon" => $media_icon,
      "image_name" => $image_name,
      "width_height" => $width_height,
      "width" => $width,
      "height" => $height,
      "iptc_info" => $iptc_info
    ));
Replace with:

Code: Select all

    $download_file_src = get_file_path($media_file_name, "download", $cat_id, 0, 1);
    $src_download = (!file_exists($download_file_src) && file_exists(preg_replace("/\/{2,}/", "/", get_document_root()."/".$download_file_src))) ? preg_replace("/\/{2,}/", "/", get_document_root()."/".$download_file_src) : $download_file_src;
    if ($temp = @getimagesize($src_download)) {
      $download_width_height = " ".$temp[3];
      $download_width = $temp[0];
      $download_height = $temp[1];
    }

    $site_template->register_vars(array(
      "media_src" => $media_src,
      "media_icon" => $media_icon,
      "image_name" => $image_name,
      "width_height" => $width_height,
      "width" => $width,
      "height" => $height,
      "download_width" => $download_width, // Download file
      "download_height" => $download_height, // Download file
      "iptc_info" => $iptc_info
    ));
Locate the very last line:

Code: Select all

?>
Replace with:

Code: Select all

function check_remote_download($remote_media_file) { 
  global $config; 
  return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $remote_media_file)) ? 1 : 0; 
} 
function check_local_download($local_media_file) { 
  global $config; 
  return (preg_match("#^((\.)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $local_media_file)) ? 1 : 0; 
} 
function check_download_type($file_name) { 
  global $config; 

  return (in_array(get_file_extension($file_name), $config['allowed_mediatypes_array'])) ? 1 : 0; 
}
?>
Backup: geoheiIM_1.7.1_20050818_0.tgz

./templates/x_images/details.html
Locate:

Code: Select all

<tr> 
  <td valign="top" class="cat2"><b>{lang_added_by}</b></td>
  <td valign="top" class="cat2">{user_name_link}</td>
</tr>
Replace with:

Code: Select all

<tr> 
  <td valign="top" class="cat2"><b>{lang_download_file_size}</b></td>
  <td valign="top" class="cat2">{download_image_file_size} [{download_width}x{download_height}]</td>
</tr>
<tr> 
  <td valign="top" class="cat1"><b>{lang_added_by}</b></td>
  <td valign="top" class="cat1">{user_name_link}</td>
</tr>
./details.php
Locate:

Code: Select all

"lang_file_size" => $lang['file_size']
Replace with:

Code: Select all

"lang_file_size" => $lang['file_size'],
"lang_download_file_size" => $lang['download_file_size']
./lang/english/main.php
Locate:

Code: Select all

$lang['file_size'] = "File size:";
Add after:

Code: Select all

$lang['download_file_size'] = "Download file size [resolution]:";
./lang/deutsch/main.php
Locate:

Code: Select all

$lang['file_size'] = "File size:";
Add after:

Code: Select all

$lang['download_file_size'] = "Download Dateigr&ouml;&szlig;e [Auflösung]:";
Backup: geoheiIM_1.7.1_20051117_0.tgz
Image
Post Reply