PowerPress Podcasting plugin by Blubrry - Version 0.3.2

Version Description

Download this release

Release Info

Developer amandato
Plugin Icon 128x128 PowerPress Podcasting plugin by Blubrry
Version 0.3.2
Comparing to
See all releases

Code changes from version 0.3.1 to 0.3.2

Files changed (4) hide show
  1. mp3info.class.php +84 -1
  2. powerpress.php +2 -1
  3. powerpressadmin.php +13 -17
  4. readme.txt +4 -1
mp3info.class.php CHANGED
@@ -80,7 +80,17 @@
80
  Start the download and get the headers, handles the redirect if there are any
81
  */
82
  function Download($url, $RedirectCount = 0)
83
- {
 
 
 
 
 
 
 
 
 
 
84
  if( $RedirectCount > $this->m_RedirectLimit )
85
  {
86
  $this->SetError( 'Download exceeded redirect limit of '.$this->m_RedirectLimit .'.' );
@@ -191,6 +201,79 @@
191
  return false;
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  /*
195
  Get the MP3 information
196
  */
80
  Start the download and get the headers, handles the redirect if there are any
81
  */
82
  function Download($url, $RedirectCount = 0)
83
+ {
84
+ if( !ini_get( 'allow_url_fopen' ) && !function_exists( 'curl_init' ) )
85
+ {
86
+ $this->SetError('Server must either have php.ini allow_url_fopen enabled or PHP CURL library loaded in order to continue.');
87
+ return false;
88
+ }
89
+
90
+ if( !ini_get( 'allow_url_fopen' ) )
91
+ return $this->DownloadAlt($url);
92
+
93
+ // The following code relies on fopen_url capability.
94
  if( $RedirectCount > $this->m_RedirectLimit )
95
  {
96
  $this->SetError( 'Download exceeded redirect limit of '.$this->m_RedirectLimit .'.' );
201
  return false;
202
  }
203
 
204
+ /*
205
+ Alternative method (curl) for downloading portion of a media file
206
+ */
207
+ function DownloadAlt($url)
208
+ {
209
+ $curl = curl_init();
210
+ // First, get the content-length...
211
+ curl_setopt($curl, CURLOPT_URL, $url);
212
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
213
+ curl_setopt($curl, CURLOPT_HEADER, true); // header will be at output
214
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request
215
+ curl_setopt($curl, CURLOPT_NOBODY, true );
216
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
217
+ curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
218
+ $Headers = curl_exec($curl);
219
+ $ContentLength = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
220
+ $HttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
221
+
222
+ if( $HttpCode != 200 )
223
+ {
224
+ switch( $HttpCode )
225
+ {
226
+ case 301:
227
+ case 302:
228
+ case 307: {
229
+ $this->SetError( 'Download exceeded redirect limit of '.$this->m_RedirectLimit .'.' );
230
+ }; break;
231
+ default: {
232
+ $this->SetError( 'HTTP error '. $HttpCode .'.' );
233
+ }; break;
234
+ }
235
+ return false;
236
+ }
237
+
238
+ // Next get the first chunk of the file...
239
+ curl_setopt($curl, CURLOPT_URL, $url);
240
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
241
+ curl_setopt($curl, CURLOPT_HEADER, false); // header will be at output
242
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); // HTTP request
243
+ curl_setopt($curl, CURLOPT_NOBODY, false );
244
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
245
+ curl_setopt($curl, CURLOPT_MAXREDIRS, $this->m_RedirectLimit);
246
+ curl_setopt($curl, CURLOPT_RANGE, "0-{$this->m_DownloadBytesLimit}");
247
+ $Content = curl_exec($curl);
248
+ curl_close($curl);
249
+
250
+ if( $Content )
251
+ {
252
+ global $TempFile;
253
+ if( function_exists('get_temp_dir') ) // If wordpress function is available, lets use it
254
+ $TempFile = tempnam(get_temp_dir(), 'wp_powerpress');
255
+ else // otherwise use the default path
256
+ $TempFile = tempnam('/tmp', 'wp_powerpress');
257
+
258
+ if( $TempFile === false )
259
+ {
260
+ $this->SetError('Unable to save media information to temporary directory.');
261
+ return false;
262
+ }
263
+
264
+ $fp = fopen( $TempFile, 'w' );
265
+ fwrite($fp, $Content);
266
+ fclose($fp);
267
+
268
+ if( $ContentLength )
269
+ $this->m_ContentLength = $ContentLength;
270
+ return $TempFile;
271
+ }
272
+
273
+ $this->SetError('Unable to download media.');
274
+ return false;
275
+ }
276
+
277
  /*
278
  Get the MP3 information
279
  */
powerpress.php CHANGED
@@ -3,10 +3,11 @@
3
  Plugin Name: Blubrry Powerpress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry Powerpress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
- Version: 0.3.0
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
 
10
  2008-10-02 - v0.3.1: iTunes subtitle, keywords and summary values now properly escape html special characters such as &nbsp; added define for adding itunes:new-feed-url tag, added define to display player for legacy Podpress episodes only.
11
  2008-09-24 - v0.3.0: Added important feeds list in feed settings, logic to prevent stats redirect duplication and added podcast only feed.
12
  2008-09-17 - v0.2.1: Fixed itunes:subtitle bug, itunes:summary is now enabled by default, add ending trailing slash to media url if missing, and copy blubrry keyword from podpress fix.
3
  Plugin Name: Blubrry Powerpress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry Powerpress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
+ Version: 0.3.2
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
10
+ 2008-10-05 - v0.3.2: Added alternative logic for those who host their blogs on servers with allow_url_fopen turned off.
11
  2008-10-02 - v0.3.1: iTunes subtitle, keywords and summary values now properly escape html special characters such as &nbsp; added define for adding itunes:new-feed-url tag, added define to display player for legacy Podpress episodes only.
12
  2008-09-24 - v0.3.0: Added important feeds list in feed settings, logic to prevent stats redirect duplication and added podcast only feed.
13
  2008-09-17 - v0.2.1: Fixed itunes:subtitle bug, itunes:summary is now enabled by default, add ending trailing slash to media url if missing, and copy blubrry keyword from podpress fix.
powerpressadmin.php CHANGED
@@ -962,23 +962,19 @@ while( list($value,$desc) = each($explicit) )
962
  'https://www.itunes.com/podcast?id=',
963
  'http://www.itunes.com/podcast?id='),
964
  'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $iTunes_url);
965
-
966
- $fp = fopen($ping_url, 'rb');
967
- if( $fp )
968
- {
969
- $tempdata = '';
970
- while( !feof($fp) )
971
- $tempdata .= fread($fp, 8192);
972
- fclose($fp);
973
- if( stristr($tempdata, 'No Podcast Found') )
974
- return array('error'=>true, 'content'=>'No Podcast Found from iTunes ping request');
975
-
976
- // Parse the data into something readable
977
- $results = trim( str_replace('Podcast Ping Received', '', strip_tags($tempdata) ) );
978
- list($null, $FeedURL, $null, $null, $null, $PodcastID) = split("\n", $results );
979
 
980
- return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
981
- }
982
- return array('error'=>true, 'content'=>'Unable to connect to iTunes ping server.');
 
 
983
  }
984
  ?>
962
  'https://www.itunes.com/podcast?id=',
963
  'http://www.itunes.com/podcast?id='),
964
  'https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast?id=', $iTunes_url);
965
+
966
+ $tempdata = wp_remote_fopen($ping_url);
967
+
968
+ if( $tempdata == false )
969
+ return array('error'=>true, 'content'=>'Unable to connect to iTunes ping server.');
970
+
971
+ if( stristr($tempdata, 'No Podcast Found') )
972
+ return array('error'=>true, 'content'=>'No Podcast Found from iTunes ping request');
 
 
 
 
 
 
973
 
974
+ // Parse the data into something readable
975
+ $results = trim( str_replace('Podcast Ping Received', '', strip_tags($tempdata) ) );
976
+ list($null, $FeedURL, $null, $null, $null, $PodcastID) = split("\n", $results );
977
+
978
+ return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
979
  }
980
  ?>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Angelo Mandato, Blubrry.com
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss
4
  Requires at least: 2.5.0
5
  Tested up to: 2.6.2
6
- Stable tag: 0.3.1
7
 
8
  Add podcasting support to your blog.
9
 
@@ -62,5 +62,8 @@ New features: Added important feeds list in feed settings, logic to prevent stat
62
  0.3.1 released on 10/02/2008
63
  Fixed bug and added enhancements: iTunes subtitle, keywords and summary values now properly escape html special characters such as &nbsp; added define for adding itunes:new-feed-url tag, added define to display player for legacy Podpress episodes only.
64
 
 
 
 
65
  == Feedback ==
66
  http://www.blubrry.com/powerpress/
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss
4
  Requires at least: 2.5.0
5
  Tested up to: 2.6.2
6
+ Stable tag: 0.3.2
7
 
8
  Add podcasting support to your blog.
9
 
62
  0.3.1 released on 10/02/2008
63
  Fixed bug and added enhancements: iTunes subtitle, keywords and summary values now properly escape html special characters such as &nbsp; added define for adding itunes:new-feed-url tag, added define to display player for legacy Podpress episodes only.
64
 
65
+ 0.3.2 released on 10/05/2008
66
+ Added alternative logic for those who host their blogs on servers with allow_url_fopen turned off.
67
+
68
  == Feedback ==
69
  http://www.blubrry.com/powerpress/