Author Topic: Modifying Headers when user clicks download link  (Read 1079 times)

andrewdalaniz

  • Newbie
  • Posts: 2
Modifying Headers when user clicks download link
« on: March 08, 2011, 10:01:22 pm »
I am hosting my podcasts on Amazon S3, and prior to version 2.0 I modified the download link url to point to a download.php file I created and passed the podcast url as a parameter.  The download.php file modified the host headers so that IE downloaded the file instead of trying to play it in the browser.  The code was as follows:
Code: [Select]
<?php
$url
=$_GET[&#39;url&#39;];
header(&#39;Content-disposition: attachment; filename=&#39;.$url);
header(&#39;Content-type: application/octet-stream&#39;);
readfile($url);
?>

The code that previously populated the url of the DOWNLOAD_LINK looked like this:
Code: [Select]
if( $GeneralSettings['podcast_link'] == 1 )
{
if( $player_links )
$player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
$player_links .= "<a href=\"download.php?url={$EpisodeData['url']}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a>".PHP_EOL;
}
else if( $GeneralSettings['podcast_link'] == 2 )
{
if( $player_links )
$player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
$player_links .= "<a href=\"download.php?url={$EpisodeData['url']}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EpisodeData['size']).") ".PHP_EOL;
}
else if( $GeneralSettings['podcast_link'] == 3 )
{
if( $player_links )
$player_links .= ' '. POWERPRESS_LINK_SEPARATOR .' ';
if( $EpisodeData['duration'] && ltrim($EpisodeData['duration'], '0:') != '' )
$player_links .= "<a href=\"download.php?url={$EpisodeData['url']}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (". htmlspecialchars(POWERPRESS_DURATION_TEXT) .": " . powerpress_readable_duration($EpisodeData['duration']) ." &#8212; ".powerpress_byte_size($EpisodeData['size']).")".PHP_EOL;
else
$player_links .= "<a href=\"download.php?url={$EpisodeData['url']}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($EpisodeData['size']).")".PHP_EOL;

}

I have been unable to determine how to perform the same tasks in version 2.0 because the content generation for the download link doesn't look the same.  Does anyone know how to to perform these tasks in version 2.0?

angelo

  • CIO, RawVoice
  • Administrator
  • Hero Member
  • *****
  • Posts: 4483
Re: Modifying Headers when user clicks download link
« Reply #1 on: March 09, 2011, 08:39:01 am »
The settings are still the same, just there is a bug in 2.0 related to that talked about on this thread: http://forum.blubrry.com/index.php/topic,2626.msg6523.html#msg6523

This will be fixed in 2.0.1 release.