• [MOD] Alternate directory for download files. 5 0 5 1
Currently:  

Author Topic: [MOD] Alternate directory for download files.  (Read 223555 times)

0 Members and 2 Guests are viewing this topic.

Rembrandt

  • Guest
Re: [MOD] Alternate directory for download files.
« Reply #120 on: April 18, 2009, 08:38:55 PM »
also anscheinend bin ich zublöd dafür....

ich lade die Bilder hoch per ftp.... und dann was mach ich dann?  geh ich auf Bilder einschecken und dann??

? erstelle ich Thumbnail manuell
? und dann autoimage resize?
jaaaa... du gehst auf neue bilder checken stellt dort alles ein und der rest geht automatisch, dazu brauchst du vanos checkimages.php von hier aus dem forum.

mfg Andi

Offline CarstenM

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #121 on: April 18, 2009, 11:03:00 PM »
müsst man halt dabei schreiben das man die bracuht....

wo finde ich diese den?

Offline dp

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #122 on: October 07, 2009, 04:57:30 PM »
Hi,

just tested with v1. 7. 7 on Mobile Server.  Worked without any Problem.

Thank you very much for sharing this!

Offline dp

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #123 on: October 09, 2009, 05:03:35 PM »
Hi,

I'm trying to expand this mods functionality to have more than one download-directory (with different picture-sizes therein) and let the user choose via selction-formular which size to download on the details-page.    

My approach seemed quiet simple to me: just use a variable instead of the phrase "/download" where the download-path is defined and assign the name of the choosen download-directory to this variable via the formular.    
Unfortunately this failed because I could not succeed to declare the variable as global, so that it is accessible from other parts of the script.     So the main question for me is at the moment: How can I define a variable as global and accessible for the whole script?

I asked this Question in another thread 4homepages.  de/forum/index.  php?topic=26033.  0  and V@no thankfully gave me some answers, but at least I couldn't solve the problem so I follow the advice to post the problem here and give more details.  
As you see, I'm just a beginner in php but very experienced in other scripts like vb and in html and css, too.    

Here is what I did:
in includes/funktions.    php I modified the original mod


    $check_handle 
"check_".    $image_type.    "_type";
//-----------------------------------------------
//-- MOD Alternative Download Directory ---------
//    $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;
// Download file block insert BEGIN
    
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";
        echo 
$path;                                   
        break;
	
  default:
	
    if( 
$cat_id )
	
      
$path THUMB_PATH.    "/".    $cat_id;
	
	
else
	
	
  
$path THUMB_TEMP_PATH;
	
    break;
	
}
	
$path .    = "/".    $file_name;
// Download file block insert END
    
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 ""); // Download file :: V@no big mod


to


        $path 
MEDIA_PATH.    "/".    $cat_id.   $dp_download_folder;     // changing the original phrase "/download" to a varibale


where $dp_download_folder is the variable for the download-directory and should contain e.    g.     "/download" or any other directory with different size of the picture.    
This Variable I declared as global at top of the function:


function get_file_path($file_name ""$image_type "media"$cat_id 0$in_admin 0$return_icon 1$check_remote CHECK_REMOTE_FILES) {
    global 
$dp_download_folder;


When I assign $dp_download_folder = "/med", e.    g.     at the top of global.    php, the download-button at the details-page will succesfully download from this directory.    

I now set up a form in details.    html of my template wich should choose the picture-size and set $dp_download_folder

Code: [Select]
(.  .  .  )
<?php
if (isset( $_POST['dp_picsize'] ))
{
$dp_download_folder $_POST['dp_picsize'];
}
?>

<!-- download_folder_form -->
<div id="dp_select_download">
  <form id="select_download_folder" method="post" name="dp_download_directory" action="<?php echo $_SERVER['PHP_SELF']; ?>?image_id={image_id}">
    <select name="dp_picsize" onchange="if (this.  options[this.  selectedIndex].  value != 0){ forms['jumpbox'].  submit() }" class="dp_picsize_select">
      <option value="/med">Bildgröße wählen</option>
      <option value="/med">----------------</option>
      <option value="/med">800 Pixel</option>
      <option value="/download">Originalgröße</option>
    </select>
    <input type="image" src="{template_url}/images/hintergrund_submit_suche.  gif" name="dp_download" id="submitbutton" />
  </form>
</div>
<!-- END download_folder_form -->
(.  .  .  )

Selecting "800 Pixel" in the form will set $dp_download_folder to "/med" (I checked this with echo $dp_download_folder), but this variable is still local and not identical with global $dp_download_folder, wich still has no value.

[EDIT by V@no]
I didn't change anything, just hit save button. For some reason the forum doesn't display properly php code until I save it...
« Last Edit: October 10, 2009, 03:30:05 AM by V@no »

Offline honda2000

  • 4images Guru
  • *******
  • Posts: 3.263
    • View Profile
    • Wir machen Internet!
Re: [MOD] Alternate directory for download files.
« Reply #124 on: February 02, 2010, 04:31:12 PM »
Hat jemenad dem MOD für 1.7.7 zusammenhängen, funtionierend??

Offline viadata

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #125 on: February 14, 2010, 06:47:24 PM »
Hallo Zusammen,

ich habe den MOD eingebaut. Kann nun die "big" Bilder aus dem Big Verzeichnis laden.

3 Probleme:

- Die Bildauflösung zeigt nun die Werte des Bildes der Detail Ansicht, wärend die Dateigröße vom Big Bild angezeigt wird.
- Das Big Bild wird in einem neuen Browserfenster geladen, ich wollte das als Download
- Über den Leuchtkasten geht der Download nicht. Es wird nur ein neues weißes Browserfenster angezeigt.

Hat jemand einen Tip, wo ich suchen muss?

Danke

Holger

Offline ***elvis***

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #126 on: April 16, 2010, 06:58:36 PM »
...
- Das Big Bild wird in einem neuen Browserfenster geladen, ich wollte das als Download
- Über den Leuchtkasten geht der Download nicht. Es wird nur ein neues weißes Browserfenster angezeigt....

Das wäre natürlich nicht so gut. Mir geht es auch ausschließlich darum das so hinzubekommen, das bei klick auf Download-Button / Zip oder  Leuchtkasten immer die Datei aus dem Bigfile Ordner genommen wird.

DANKE
« Last Edit: April 18, 2010, 01:11:55 PM by ***elvis*** »

Offline ***elvis***

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #127 on: April 18, 2010, 01:19:25 PM »
Ich hab mir die Nacht um die Ohren geschlagen ...

EDIT

Gelöst, jetzt läuft es DANKE
« Last Edit: April 18, 2010, 03:35:27 PM by ***elvis*** »

Offline dp

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #128 on: June 08, 2010, 04:39:19 PM »
Ich hab mir die Nacht um die Ohren geschlagen ...

EDIT

Gelöst, jetzt läuft es DANKE

Hallo elvis,

ich fände es schön, wenn du die Lösung ebenfalls hier posten könntest, Danke!

Offline ***elvis***

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #129 on: June 08, 2010, 05:15:05 PM »
Quote
Hallo elvis, ich fände es schön, wenn du die Lösung ebenfalls hier posten könntest, Danke!

Ist zwar schon ne weile her wo ich das gemacht habe, bzw. seit dem habe ich so viele Änderungen vorgenommen, aber ich meine ich hab nur ein Fehler beim einbau des MOD´s gemacht.

Rembrandt

  • Guest
Re: [MOD] Alternate directory for download files.
« Reply #130 on: June 26, 2010, 04:01:59 PM »
Code Update, This Mod is Supported by 4images V1.7.8 and Higher
For older 4images Version e.g. 1.7.7  supported by @V@nos checkimages: [MOD] Check new images in ALL categories v2.11 (updated 22-04-2006)

the Alternative folder you can either "download" or "big" call.
in the details.html can you see the original size and original resolution.
add in the Lightbox, you can download the original files.


1.) search in includes/functions.php:

  $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;

and replace:

//$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;
//####################################### Alternate Download Start ##################################################
  
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 ""); // Download file :: V@no big mod
//####################################### Alternate Download END ####################################################

1.2) search:

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);
    }
  }

and replace:

/* 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);
    }
  } */
//####################################### Alternate Download Start ##################################################
  
$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;
      
$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);
  }
  
//####################################### Alternate Download END ####################################################

1.3) search:

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

insert below:

//############################################ Alternate Download Start ########################################
    
"download_image_file_size" => $download_file_size,
    
"lang_original_size" => $lang['original_size'], 
    
"lang_original_resolution" => $lang['original_resolution'],
//############################################ Alternate Download END ##########################################

1.4) search:

$height 
$image_info[1];

insert below:

//############################################### Alternate Download Start #####################################
        
$download_width_height $width_height;
        
$download_width $width;
        
$download_height $height;
      }
      
$big_file MEDIA_PATH.(($cat_id != 0) ? "/".$cat_id "")."/"."big"."/".$media_file_name;
      
$download_file MEDIA_PATH.(($cat_id != 0) ? "/".$cat_id "")."/"."download"."/".$media_file_name;
	

      if (
file_exists($big_file)){
        
$bild $big_file;
      }
      elseif (
file_exists($download_file)){
        
$bild $download_file;
      }
      else{
        
$bild $src;
      }
      if (
in_array(strtolower($file_extension), array('gif','jpg','jpeg','png','swf')) && $image_info = @getimagesize($bild$info)) {
//############################################### Alternate Download End #######################################

1.5) search:

$site_template
->register_vars(array(
      
"media_src" => $media_src,
      
"media_icon" => $media_icon,
      
"image_name" => format_text($image_name2),
      
"width_height" => $width_height,
      
"width" => $width,
      
"height" => $height,
      
"iptc_info" => $iptc_info,
      
"exif_info" => $exif_info
    
));

and replace:

//###################################### Alternate Download Start ##############################################   
      //$download_file_src = get_file_path($media_file_name, "download", $cat_id, 0, 1);
      
$src_download = (!file_exists($bild) && file_exists(preg_replace("/\/{2,}/""/"get_document_root()."/".$bild))) ? preg_replace("/\/{2,}/""/"get_document_root()."/".$bild) : $bild;
      if (
$temp = @getimagesize($src_download$bild)) {
        
$download_width_height " ".$temp[3];
        
$download_width = (isset($temp[0]))? $temp[0]:"";
        
$download_height $temp[1];
      }
//####################################### Alternate Download END ###############################################
    
$site_template->register_vars(array(
      
"media_src" => $media_src,
      
"media_icon" => $media_icon,
      
"image_name" => format_text($image_name2),
      
"width_height" => $width_height,
      
"width" => $width,
      
"height" => $height,
//###################################### Alternate Download Start ##############################################      
      
"download_width" => $download_width,
      
"download_height" => $download_height,
//###################################### Alternate Download END ################################################      
      
"iptc_info" => $iptc_info,
      
"exif_info" => $exif_info
    
));

1.6) search:

?>

insert above:

//###################################### Alternate Download Start ############################################
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)) ? 0

function 
check_local_download($local_media_file) { 
  global 
$config
  return (
preg_match("#^((\.)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is"$local_media_file)) ? 0

function 
check_download_type($file_name) { 
  global 
$config
  return (
in_array(get_file_extension($file_name), $config['allowed_mediatypes_array'])) ? 0
}
//###################################### Alternate Download End ###############################################


2.) search in root/download.php:

$file_path 
MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];

and replace:

//  $file_path = MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'];
//###################################### Alternate Download Start ##############################################
  
$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'];
  }
//###################################### Alternate Download End ##############################################

2.1.) search:

$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'];

and replace:

//  $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'];
//########################################## Alternate Download Start ##############################################    
  
$media_file_download = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/download/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/download/".$file['file_name'];
  
$media_file_big = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/big/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/big/".$file['file_name'];
  
$media_file = (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 (
file_exists($media_file_download)){
    
$file['file_path'] = $media_file_download;
  }
  elseif(
file_exists($media_file_big)){
    
$file['file_path'] = $media_file_big;
  }
  elseif(
file_exists($media_file)){
    
$file['file_path'] = $media_file;
  } 
//########################################### Alternate Download End ##############################################    


3.) search in lang/english/main.php:

?>

insert above:

//-----------------------------------------------------
//--- Alternate Download ------------------------------
//-----------------------------------------------------
$lang['original_size'] = "Originalsize:"
$lang['original_resolution'] = "Originalresolution:";

for lang/deutsch/main.php:

//-----------------------------------------------------
//--- Alternate Download ------------------------------
//-----------------------------------------------------
$lang['original_size'] = "Originalgröße:"
$lang['original_resolution'] = "Originalauflösung:";


4.) search in your/templates/details.html:
Code: [Select]
                         <tr>
                            <td valign="top" class="row1"><b>{lang_file_size}</b></td>
                            <td valign="top" class="row1">{image_file_size}</td>
                          </tr>
insert below:
Code: [Select]

                          <tr>
                            <td valign="top" class="row1"><b>{lang_original_size}</b></td>
                            <td valign="top" class="row1">{download_image_file_size}</td>
                          </tr>                        
                          <tr>
                            <td valign="top" class="row1"><b>{lang_original_resolution}</b></td>
                            <td valign="top" class="row1">{download_width}&nbsp;x&nbsp;{download_height}&nbsp;Pixel</td>
                          </tr>

Option 1.) Show original image in new window by clicking on image

search in the code (step 1.4)
 if (in_array(strtolower($file_extension), array('gif','jpg','jpeg','png','swf')) && $image_info = @getimagesize($bild$info)) {
insert above:
$site_template->register_vars("show_big"$bild);

search in the code (step 1.5)
"download_width" => $download_width,
      
"download_height" => $download_height,

insert below:
"big_width" => $download_width+36,
       
"big_height" => $download_height+36,




search in your Templates/details.html:
Code: [Select]
{image}and replace:
Code: [Select]
<a href ="{show_big}" onclick="void(window.open(this.href,this.target,'top=100,left=200,width={big_width},height={big_height},toolbar=no, directories=no, resizable=yes,menubar=no,locationbar=no,scrollbars=auto'));return false;">{image}</a>

now you can by clicking on image show original image in new window.

mfg Andi
« Last Edit: February 24, 2011, 05:55:03 PM by Rembrandt »

Offline 1001Musik

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #131 on: February 24, 2011, 06:08:39 PM »
Hallo,
ich habe die ganzen Dateien abgeändert wie von Rembrandt beschrieben (danke dafür) ohne Option 1.  Ich möchte die Original Datei nur zum Download haben. Angezeigt soll diese nicht. Ich hoffe das geht mit diesem Mod?

Habe dann ein paar Bilder per ftp in einen Kategorie Ordner geladen. Dann auf Nach neuen Bildern checken und abgewartet. Als alles fertig war, werden mir im Frontend immer noch die kleinen Bilder (also nicht Original) als Download angeboten. Habe ich etwas vergessen oder falsch gemacht. Müssen die Bilder ev. in einen speziellen Ordner?

Würde mich freuen, wenn mir jemand weiter helfen würde.

Rembrandt

  • Guest
Re: [MOD] Alternate directory for download files.
« Reply #132 on: February 24, 2011, 06:18:49 PM »
.... Dann auf Nach neuen Bildern checken und abgewartet. ....
nach dem du bei "Neue Bilder Checken" auf den button "neue bilder checken" geklickt hast, mußt du:
Automatisch verkleinern:    Ein
Originalbild speichern: Ja
einstellen, dann wird dein Großes Originalbild in den ordner "big" verschoben von wo es dann mittels diesen mod herruntergeladen werden kann.

mfg Andi

Offline 1001Musik

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #133 on: February 25, 2011, 03:54:23 PM »
Danke Dir, nun funktioniert es.

Offline heffernan

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] Alternate directory for download files.
« Reply #134 on: April 09, 2011, 12:00:34 PM »
habe ich gemacht bis zu dem Punkt wo steht:

Code: [Select]
Option 1.) Show original image in new window by clicking on image

search in the code (step 1.4)
PHP Code:  [Select]  [Expand]  [Hide line numbers]

In welcher Datei denn ????

Ich muss doch nur diese Anleitung durchgehen oder muss ich da noch andere Mods oder sonstwa sinstallieren?

Gibt es das nicht als fertiges Plugin???