PageRenderTime 58ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wordpress/wp-content/plugins/podpress/podpress_admin_functions.php

https://github.com/bill742/verbalbrew
PHP | 1827 lines | 1470 code | 180 blank | 177 comment | 197 complexity | 5a32a37b6f22d792643183234526e853 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0, AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /*
  3. License:
  4. ==============================================================================
  5. Copyright 2006 Dan Kuykendall (email : dan@kuykendall.org)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-107 USA
  17. */
  18. function podPress_isAuthorized($needed = '##NOTSET##', $justChecking = false) {
  19. GLOBAL $user_level, $podPress;
  20. if($needed == '##NOTSET##') {
  21. $needed = $podPress->requiredadminrights;
  22. }
  23. if (function_exists('current_user_can')) {
  24. $result = current_user_can($needed);
  25. } else {
  26. $result = $user_level > 5;
  27. }
  28. if(!$justChecking && !$result) {
  29. die(__('Access Denied', 'podpress'));
  30. }
  31. return $result;
  32. }
  33. //this is crap
  34. function podPress_getCapName($cap) {
  35. return ucwords(str_replace('_', ' ', $cap));
  36. }
  37. function podPress_DirectoriesPreview($context) {
  38. echo ' <fieldset class="options">'."\n";
  39. echo ' <legend class="podpress_directorypreview_legend">'.__('Directory Preview', 'podpress').'</legend> <a href="javascript:void(null);" id="podpress_showhide_directory_preview" class="podpress_showhide_element" onclick="podpress_showhide_adv(\'podpress_DirectoryPreviewDisplay\', true, this.id);">[ '.__('Show', 'podpress').' ]</a>';
  40. echo ' <div id="podpress_DirectoryPreviewDisplay" style="display:none;">'."\n";
  41. echo ' <a href="javascript:void(null);" onclick="javascript: podPressShowDirectoryPreview(\'iTunes\');"><img src="'.podPress_url().'images/directoryPreview_iTunes_logo.png" border="0" alt="iTunes preview" /></a> &nbsp;';
  42. /// YAHOO! Podcast is shutdown since 2007 - see, http://en.wikipedia.org/wiki/Yahoo!_Podcasts
  43. //echo ' <a href="javascript:void(null);" onclick="javascript: podPressShowDirectoryPreview(\'Yahoo\');"><img src="'.podPress_url().'images/directoryPreview_yahoo_logo.png" border="0" alt="Yahoo preview" /></a> &nbsp;';
  44. echo ' <a href="javascript:void(null);" onclick="javascript: podPressShowDirectoryPreview(\'PodcastAlley\');"><img src="'.podPress_url().'images/directoryPreview_PCA_logo.png" border="0" alt="PodcastAlley preview" /></a>';
  45. echo ' <a href="javascript:void(null);" onclick="javascript: podPressShowDirectoryPreview(\'PodcastReady\');"><img src="'.podPress_url().'images/directoryPreview_PodcastReady_logo.png" border="0" alt="PodcastAlley preview" /></a>';
  46. echo ' <a href="javascript:void(null);" onclick="javascript: podPressShowDirectoryPreview(\'Blubrry\');"><img src="'.podPress_url().'images/directoryPreview_Blubrry_logo.jpg" border="0" alt="Blubrry preview" /></a>';
  47. echo ' '."\n";
  48. echo ' <div id="iTunesPreviewDisplay" style="border: 0;">'."\n";
  49. echo ' <div style="width: 100%; text-align: center;"><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewGenre?id=26" target="_new">Visit this directory</a> / <a href="https://phobos.apple.com/WebObjects/MZFinance.woa/wa/publishPodcast" target="_new">Submit to this directory</a></div>'."\n";
  50. echo ' <table width="100%" cellspacing="2" cellpadding="5" class="editform" style="background-color:#8CA9CB;">'."\n";
  51. echo ' <tr valign="top">'."\n";
  52. echo ' <td colspan="3">'."\n";
  53. echo ' <b><font size="+1"><span id="iTunesBlognamePreview"></span></font></b><br/>'."\n";
  54. echo ' </td>'."\n";
  55. echo ' </tr>'."\n";
  56. echo ' <tr valign="top">'."\n";
  57. echo ' <td width="1%">'."\n";
  58. echo ' <img id="iTunesPreviewImage" width="175" height="175" alt="Podcast Image" src=""/>'."\n";
  59. echo ' </td>'."\n";
  60. echo ' <td align="left">'."\n";
  61. echo ' <span id="itunesAuthorPreview" style="font-weight: bold;"></span><br/><br/>'."\n";
  62. echo ' <span style="font-size: small;">'."\n";
  63. echo ' Category: <span id="itunesCategoryPreview"></span><br/>'."\n";
  64. echo ' Language: <span id="iTunesRssLanguagePreview">English</span><br/>'."\n";
  65. echo ' Total: n episodes<br/><br/>'."\n";
  66. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_subscribebutton.png" border="0" alt="iTunesSubscriptions" /> '."\n";
  67. echo ' </span>'."\n";
  68. echo ' </td>'."\n";
  69. echo ' <td rowspan="3" width="1%">'."\n";
  70. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_seeallpodcasts.png" border="0" alt="iTunesSeeAllPodcasts" /> '."\n";
  71. echo ' <br/><br/>'."\n";
  72. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_alsosubcribedto.png" border="0" alt="iTunesAlsoSubscribeTo" /> '."\n";
  73. echo ' </td>'."\n";
  74. echo ' </tr>'."\n";
  75. echo ' <tr valign="top">'."\n";
  76. echo ' <td colspan="2">'."\n";
  77. echo ' <b><font size="+1" color="#163B6A">Podcast Description</font></b><br/><br/>'."\n";
  78. echo ' <span id="itunesDescriptionPreview" style="font-size: small;"></span>'."\n";
  79. echo ' </td>'."\n";
  80. echo ' </tr>'."\n";
  81. echo ' <tr valign="top">'."\n";
  82. echo ' <td colspan="2" bgcolor="#8DAACC">'."\n";
  83. echo ' <table width="100%" bgcolor="#8DAACC">'."\n";
  84. echo ' <tr>'."\n";
  85. echo ' <td align="left">'."\n";
  86. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_l_reviews.png" border="0" alt="iTunesReviews" /> '."\n";
  87. echo ' </td>'."\n";
  88. echo ' <td align="right">'."\n";
  89. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_r_reviews.png" border="0" alt="iTunesReviews" /> '."\n";
  90. echo ' </td>'."\n";
  91. echo ' </tr>'."\n";
  92. echo ' </table>'."\n";
  93. echo ' </td>'."\n";
  94. echo ' </tr>'."\n";
  95. echo ' </table>'."\n";
  96. echo ' </div>'."\n";
  97. echo ' <div id="YahooPreviewDisplay" style="display: none;">'."\n";
  98. echo ' <div style="width: 100%; text-align: center;"><a href="http://podcasts.yahoo.com/" target="_new">Visit this directory</a> / <a href="http://podcasts.yahoo.com/publish" target="_new">Submit to this directory</a></div>'."\n";
  99. echo ' <div style="width: 100%; border: 1px solid grey;">'."\n";
  100. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0">'."\n";
  101. echo ' <tr valign="top">'."\n";
  102. echo ' <td colspan="3">'."\n";
  103. echo ' <b><font size="+1" color="#669900">Series Information: <span id="YahooBlognamePreview"></span></font></b><br/><br/>'."\n";
  104. echo ' </td>'."\n";
  105. echo ' </tr>'."\n";
  106. echo ' <tr valign="top">'."\n";
  107. echo ' <td width="1%" rowspan="2">'."\n";
  108. echo ' <img id="YahooPreviewImage" width="175" height="175" alt="Podcast Image" src=""/><br/><br/>'."\n";
  109. echo ' <img src="'.podPress_url().'images/directoryPreview_yahoo_buttons.png" border="0" alt="YahooButtons" /> '."\n";
  110. echo ' </td>'."\n";
  111. echo ' <td colspan="2">'."\n";
  112. echo ' <span id="YahooDescriptionPreview" style="font-size: small;"></span>'."\n";
  113. echo ' </td>'."\n";
  114. echo ' </tr>'."\n";
  115. echo ' <tr valign="top">'."\n";
  116. echo ' <td align="left">'."\n";
  117. echo ' <font size="+1" color="#669900">Details</font><br/>'."\n";
  118. echo ' Episodes: N<br/>'."\n";
  119. echo ' Web Site: <font color="#2597D6">'.get_option('siteurl').'</font><br/>'."\n";
  120. echo ' RSS: <span id="YahooFeedURLPreview" style="color: #2597D6;"></span><br/>'."\n";
  121. echo ' Author: <span id="YahooAuthorPreview"></span><br/>'."\n";
  122. echo ' Language: <span id="YahooRssLanguagePreview">English</span><br/>'."\n";
  123. echo ' Copyright: --<br/>'."\n";
  124. echo ' Published: whatever date<br/>'."\n";
  125. echo ' </td>'."\n";
  126. echo ' <td align="left">'."\n";
  127. echo ' <font size="+1" color="#669900">Ratings</font><br/>'."\n";
  128. echo ' Be the first to rate!<br/><br/>'."\n";
  129. echo ' <b>Rate it:</b><br/>'."\n";
  130. echo ' <img src="'.podPress_url().'images/directoryPreview_yahoo_stars.png" border="0" alt="YahooStars" /> '."\n";
  131. echo ' <br/><font color="#2597D6">Write a Review</font><br/>'."\n";
  132. echo ' </td>'."\n";
  133. echo ' </tr>'."\n";
  134. echo ' </table>'."\n";
  135. echo ' </div>'."\n";
  136. echo ' </div>'."\n";
  137. echo ' <div id="PodcastAlleyPreviewDisplay" style="display: none; border: 0;">'."\n";
  138. echo ' <div style="width: 100%; text-align: center;"><a href="http://www.podcastalley.com/" target="_new">Visit this directory</a> / <a href="http://www.podcastalley.com/add_a_podcast.php" target="_new">Submit to this directory</a></div>'."\n";
  139. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFFFFF;">'."\n";
  140. echo ' <tr valign="top">'."\n";
  141. echo ' <td width="5%">'."\n";
  142. echo ' <img src="'.podPress_url().'images/directoryPreview_PCA_left.png" border="0" alt="PCA Left" /> '."\n";
  143. echo ' </td>'."\n";
  144. echo ' <td width="90%">'."\n";
  145. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#F2F2F2;">'."\n";
  146. echo ' <tr valign="top">'."\n";
  147. echo ' <td class="podPress_statscell" valign="top" width="140">'."\n";
  148. echo ' <table class="podPress_statstable" width="100%" border="0" cellspacing="0" cellpadding="0">'."\n";
  149. echo ' <tr>'."\n";
  150. echo ' <td class="podPress_statshead">Podcast Stats</td>'."\n";
  151. echo ' </tr>'."\n";
  152. echo ' <tr>'."\n";
  153. echo ' <td class="podPress_linkscell">'."\n";
  154. echo ' <p><span class="podPress_captionstats">GENRE: </span> <span id="PCACategoryPreview"></span><br/>'."\n";
  155. echo ' <span class="podPress_captionstats">COMMENTS:</span> 0<br/>'."\n";
  156. echo ' <span class="podPress_captionstats">MONTHLY VOTES:</span> 0<br/>'."\n";
  157. echo ' <span class="podPress_captionstats">OVERALL VOTES:</span> 0<br/>'."\n";
  158. echo ' <span class="podPress_captionstats">MEMBER: </span>1/2000<br/>'."\n";
  159. echo ' <span class="podPress_captionstats">MONTHLY RANK:</span><br/>Not Yet Ranked<br/>'."\n";
  160. echo ' <br/><img src="'.podPress_url().'images/directoryPreview_PCA_buttons.png" border="0" alt="PCAButtons" /> '."\n";
  161. echo ' </td>'."\n";
  162. echo ' </tr>'."\n";
  163. echo ' </table>'."\n";
  164. echo ' </td>'."\n";
  165. echo ' <td class="podPress_desccell" valign="top">'."\n";
  166. echo ' <font size="3" color="#666666"><b><span id="PCABlognamePreview"></span></b></font><br/>'."\n";
  167. echo ' <span style="color: #666666;" id="PCADescriptionPreview"></span>'."\n";
  168. echo ' </td>'."\n";
  169. echo ' </tr>'."\n";
  170. echo ' </table>'."\n";
  171. echo ' </td>'."\n";
  172. echo ' <td width="5%">'."\n";
  173. echo ' <img src="'.podPress_url().'images/directoryPreview_PCA_right.png" border="0" alt="PCA Right" /> '."\n";
  174. echo ' </td>'."\n";
  175. echo ' </tr>'."\n";
  176. echo ' </table>'."\n";
  177. echo ' </div>'."\n";
  178. echo ' <div id="PodcastReadyPreviewDisplay" style="display: none;">'."\n";
  179. echo ' <div style="width: 100%; text-align: center;"><a href="http://www.podcastready.com/" target="_new">Visit this directory</a> / <a href="http://www.podcastready.com/channel.php?action=subscribe&feed" target="_new" id="PodcastReadyFeedURLPreview">Submit to this directory</a></div>'."\n";
  180. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#CDE4A9">'."\n";
  181. echo ' <tr valign="top">'."\n";
  182. echo ' <td width="200" align="center">'."\n";
  183. echo ' <br/><img id="PodcastReadyPreviewImage" width="175" height="175" alt="Podcast Image" src=""/><br/>'."\n";
  184. echo ' <img src="'.podPress_url().'images/directoryPreview_PodcastReady_buttons.png" border="0" alt="PodcastReadyButtons" /><br/>'."\n";
  185. echo ' </td>'."\n";
  186. echo ' <td>'."\n";
  187. echo ' <br/><b><font size="+1" color="#466B90">Detail for <span id="PodcastReadyBlognamePreview"></span></font></b><br/><br/>'."\n";
  188. echo ' <span id="PodcastReadyDescriptionPreview" style="font-size: small;"></span><br/>'."\n";
  189. echo ' <b>Filed Under:</b> <span id="PodcastReadyCategoryPreview" style="color: #466B90;"></span><br/>'."\n";
  190. echo ' <b>Media Type:</b> MP3<br/><br/>'."\n";
  191. echo ' <img src="'.podPress_url().'images/directoryPreview_PodcastReady_listeners.png" border="0" alt="PodcastReadyOtherPeople" /> '."\n";
  192. echo ' </td>'."\n";
  193. echo ' </tr>'."\n";
  194. echo ' </table>'."\n";
  195. echo ' </div>'."\n";
  196. echo ' <div id="BlubrryPreviewDisplay" style="display: none; border: 0;">'."\n";
  197. echo ' <div style="width: 100%; text-align: center; "><a href="http://www.blubrry.com" target="_new">Visit this community</a> / <a href="http://www.blubrry.com/accountsettings.php?page=addpodcast" target="_new">Join this community</a></div>'."\n";
  198. echo ' <table width="100%" style="background-color: #F2CCFF; color: #003366; font-size:14px; font-weight:bold;" border="0" cellpadding="2" cellspacing="0">'."\n";
  199. echo ' <tr>'."\n";
  200. echo ' <td style="font-size:16px; font-weight:bold;" id="BlubrryBlognamePreview">TITLE OF PODCAST HERE</td>'."\n";
  201. echo ' <td style="text-decoration:underline; text-align:right; font-weight:bold;">Visit Podcast Home Page</td>'."\n";
  202. echo ' </tr>'."\n";
  203. echo ' </table>'."\n";
  204. echo ' <table width="100%" style="background-color: #D2E9FF; color: #003366; font-size:12px;" border="0" cellpadding="2" cellspacing="0">'."\n";
  205. echo ' <tr>'."\n";
  206. echo ' <td valign="top" style="width:230px;">'."\n";
  207. echo ' <table width="220" border="0" cellspacing="0" cellpadding="0" style="padding-left: 6px; padding-top: 6px;">'."\n";
  208. echo ' <tr>'."\n";
  209. echo ' <td width="100" height="100" align="left" valign="top"><img id="BlubrryPreviewImage" width="90" height="90" alt="Podcast Image" src=""/></td>'."\n";
  210. echo ' <td width="120" valign="top"><div id="BlubrryAuthorPreview" style="font-weight: bold;">AUTHOR NAME</div>'."\n";
  211. echo ' <img src="'.podPress_url().'images/directoryPreview_Blubrry_buttons.png" width="64" height="52" /></td>'."\n";
  212. echo ' </tr>'."\n";
  213. echo ' <tr>'."\n";
  214. echo ' <td height="28" colspan="2" valign="top" style="font-size: 14px; font-weight: bold; text-decoration:underline;">Visit Podcast Home Page</td>'."\n";
  215. echo ' </tr>'."\n";
  216. echo ' <tr>'."\n";
  217. echo ' <td height="36" colspan="2" valign="top" style="font-size: 16px; font-weight: bold; color: black;">Current Episodes</td>'."\n";
  218. echo ' </tr>'."\n";
  219. echo ' <tr>'."\n";
  220. echo ' <td colspan="2"><div style="color:#9933D5; font-weight: bold; font-size: 14px;">Latest Podcast Post Title</div>'."\n";
  221. echo ' <div style="font-size: 12px;">The content of your post appears here. Wow your stuff looks good. Hey what if someone wants to listen, they can click on the button below.</div>'."\n";
  222. echo ' <img src="'.podPress_url().'images/directoryPreview_Blubrry_buttons_episode.png" />'."\n";
  223. echo ' </td>'."\n";
  224. echo ' </tr>'."\n";
  225. echo ' </table>'."\n";
  226. echo ' </td>'."\n";
  227. echo ' <td valign="top" style="padding-left: 10px; padding-top: 10px;">'."\n";
  228. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Description</div>'."\n";
  229. echo ' <div style="font-size: 12px; padding-bottom: 5px;" id="BlubrryDescriptionPreview">DESCRIPTION OF PODCAST</div>'."\n";
  230. echo ' <div style="text-align:right; padding-bottom: 10px;"><img src="'.podPress_url().'images/directoryPreview_Blubrry_syndication.png" /></div>'."\n";
  231. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Tags</div>'."\n";
  232. echo ' <div style="padding-bottom: 10px;">mightyseek podpress awesome wordpress plugin</div>'."\n";
  233. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Friends</div>'."\n";
  234. echo ' <div style="background-image:url('.podPress_url().'images/directoryPreview_Blubrry_friends.jpg); background-repeat:no-repeat; background-position: top left; height:113px;">&nbsp;</div>'."\n";
  235. echo ' </td>'."\n";
  236. echo ' </tr>'."\n";
  237. echo ' </table>'."\n";
  238. echo ' </div>'."\n";
  239. echo ' </div><!-- End: podpress_DirectoryPreviewDisplay -->'."\n";
  240. echo '</fieldset>'."\n";
  241. }
  242. /* Utility Functions */
  243. function podPress_getCapList($roles = true, $kill_levels = true){
  244. global $wp_roles;
  245. // Get Role List
  246. foreach($wp_roles->role_objects as $key => $role) {
  247. foreach($role->capabilities as $cap => $grant) {
  248. $capnames[$cap] = $cap;
  249. }
  250. }
  251. if ($caplist = get_option('caplist')) {
  252. $capnames = array_unique(array_merge($caplist, $capnames));
  253. }
  254. $capnames = apply_filters('capabilities_list', $capnames);
  255. if(!is_array($capnames)) $capnames = array();
  256. $capnames = array_unique($capnames);
  257. sort($capnames);
  258. //Filter out the level_x caps, they're obsolete
  259. if($kill_levels) {
  260. $capnames = array_diff($capnames, array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5', 'level_6', 'level_7', 'level_8', 'level_9', 'level_10'));
  261. }
  262. //Filter out roles if required
  263. if (!$roles) {
  264. foreach ($wp_roles->get_names() as $role) {
  265. $key = array_search($role, $capnames);
  266. if ($key !== false && $key !== null) { //array_search() returns null if not found in 4.1
  267. unset($capnames[$key]);
  268. }
  269. }
  270. }
  271. return $capnames;
  272. }
  273. function podPress_maybe_create_table($table_name, $create_ddl) {
  274. GLOBAL $wpdb;
  275. foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
  276. if ($table == $table_name) {
  277. return true;
  278. }
  279. }
  280. //didn't find it try to create it.
  281. $q = $wpdb->query($create_ddl);
  282. // we cannot directly tell that whether this succeeded!
  283. foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
  284. if ($table == $table_name) {
  285. return true;
  286. }
  287. }
  288. return false;
  289. }
  290. function podPress_maybe_add_column($table_name, $column_name, $create_ddl) {
  291. GLOBAL $wpdb, $debug;
  292. foreach ( $wpdb->get_col("DESC $table_name", 0) as $column ) {
  293. if ( $debug ) { printf(__('checking %1$s == %2$s<br />', 'podpress'), $column, $column_name); }
  294. if ( $column == $column_name ) {
  295. return TRUE;
  296. }
  297. }
  298. // didn't find it try to create it.
  299. $q = $wpdb->query($create_ddl);
  300. // we cannot directly tell that whether this succeeded!
  301. foreach ( $wpdb->get_col("DESC $table_name", 0) as $column ) {
  302. if ( $column == $column_name ) {
  303. return TRUE;
  304. }
  305. }
  306. return FALSE;
  307. }
  308. function podPress_filetypes() {
  309. $options['audio_mp3'] = __('MP3 - Standard Audio (iPod Compliant)', 'podpress');
  310. $options['audio_m4a'] = __('M4A - Enhanced Audio (iPod Compliant)', 'podpress');
  311. $options['video_m4v'] = __('M4V - Video (iPod Compliant)', 'podpress');
  312. $options['audio_mp4'] = __('MP4 - Enhanced Audio (iPod Compliant)', 'podpress');
  313. $options['video_mp4'] = __('MP4 - Video (iPod Compliant)', 'podpress');
  314. $options['audio_ogg'] = __('OGG - Ogg Vorbis Audio', 'podpress');
  315. $options['video_ogv'] = __('OGV - Ogg Theora video', 'podpress');
  316. $options['audio_aa'] = __('AA - Audible Encoded (iPod Compliant)', 'podpress');
  317. $options['audio_m3u'] = __('M3U - Streaming Audio', 'podpress');
  318. $options['video_mov'] = __('MOV - Video (iPod Compliant)', 'podpress');
  319. $options['video_qt'] = __('QT - Video (iPod Compliant)', 'podpress');
  320. $options['video_avi'] = __('AVI - Video', 'podpress');
  321. $options['video_mpg'] = __('MPG - Video', 'podpress');
  322. $options['video_asf'] = __('ASF - Video', 'podpress');
  323. $options['video_wmv'] = __('WMV - Video', 'podpress');
  324. $options['audio_wma'] = __('WMA - Audio', 'podpress');
  325. $options['video_flv'] = __('FLV - Flash Video', 'podpress');
  326. $options['video_swf'] = __('SWF - Flash content', 'podpress');
  327. $options['ebook_pdf'] = __('PDF - eBook', 'podpress');
  328. $options['ebook_epub'] = __('EPUB - eBook', 'podpress');
  329. $options['misc_torrent'] = __('Torrent - P2P', 'podpress');
  330. return $options;
  331. }
  332. function podPress_mediaOptions() {
  333. $options = array();
  334. reset($options);
  335. $options = podPress_filetypes();
  336. $options['embed_youtube'] = __('YouTube - Video', 'podpress');
  337. $options['misc_other'] = __('??? - Other', 'podpress');
  338. foreach ($options as $key => $value) {
  339. echo '<option value="'.$key.'">'.$value.'</option>'."\n";
  340. }
  341. }
  342. function podPress_videoDimensionOptions($selected='320:240') {
  343. $dimensions = array();
  344. reset($dimensions);
  345. $dimensions_noimage = array();
  346. reset($dimensions_noimage);
  347. $dimensions['160:120'] = '160 x 120';
  348. $dimensions['320:240'] = '320 x 240';
  349. $dimensions['480:320'] = '480 x 320';
  350. $dimensions['640:480'] = '640 x 480';
  351. $dimensions['720:540'] = '720 x 540';
  352. $dimensions['450:252'] = '450 x 252 [16:9 - 1.78:1]';
  353. $dimensions['480:260'] = '480 x 260 [16:9 - 1.85:1]';
  354. $dimensions['720:405'] = '720 x 405 [16:9 - 1.78:1]';
  355. $dimensions['720:390'] = '720 x 390 [16:9 - 1.85:1]';
  356. echo '<optgroup label="'.__('Common Dimensions', 'podpress').'">'."\n";
  357. foreach ($dimensions as $key => $value) {
  358. if ($key == $selected) {
  359. $selected_str =' selected="selected"';
  360. } else {
  361. $selected_str ='';
  362. }
  363. echo '<option value="'.$key.'"'.$selected_str.'>'.$value.'</option>'."\n";
  364. }
  365. echo '</optgroup>'."\n";
  366. $dimensions_noimage['160:0'] = __('width: 160 px', 'podpress');
  367. $dimensions_noimage['320:0'] = __('width: 320 px', 'podpress');
  368. $dimensions_noimage['480:0'] = __('width: 480 px', 'podpress');
  369. $dimensions_noimage['640:0'] = __('width: 640 px', 'podpress');
  370. $dimensions_noimage['720:0'] = __('width: 720 px', 'podpress');
  371. echo '<optgroup label="'.__('player without preview image', 'podpress').'">'."\n";
  372. foreach ($dimensions_noimage as $key => $value) {
  373. if ($key == $selected) {
  374. $selected_str =' selected="selected"';
  375. } else {
  376. $selected_str ='';
  377. }
  378. echo '<option value="'.$key.'"'.$selected_str.'>'.$value.'</option>'."\n";
  379. }
  380. echo '</optgroup>'."\n";
  381. }
  382. function podPress_itunesLanguageArray() {
  383. // two-letter codes from the ISO 639-2 (http://www.loc.gov/standards/iso639-2/) languages list combined with the RSS language codes (http://www.rssboard.org/rss-language-codes#table)
  384. $langs = array();
  385. $langs['ab'] = 'Abkhazian';
  386. $langs['aa'] = 'Afar';
  387. $langs['af'] = 'Afrikaans';
  388. $langs['ak'] = 'Akan';
  389. $langs['sq'] = 'Albanian';
  390. $langs['am'] = 'Amharic';
  391. $langs['ar'] = 'Arabic';
  392. $langs['an'] = 'Aragonese';
  393. $langs['hy'] = 'Armenian';
  394. $langs['as'] = 'Assamese';
  395. $langs['av'] = 'Avaric';
  396. $langs['ae'] = 'Avestan';
  397. $langs['ay'] = 'Aymara';
  398. $langs['az'] = 'Azerbaijani';
  399. $langs['bm'] = 'Bambara';
  400. $langs['ba'] = 'Bashkir';
  401. $langs['eu'] = 'Basque';
  402. $langs['be'] = 'Belarusian';
  403. $langs['bn'] = 'Bengali';
  404. $langs['bh'] = 'Bihari languages';
  405. $langs['bi'] = 'Bislama';
  406. $langs['nb'] = htmlentities('Bokmĺl, Norwegian; Norwegian Bokmĺl');
  407. $langs['bs'] = 'Bosnian';
  408. $langs['br'] = 'Breton';
  409. $langs['bg'] = 'Bulgarian';
  410. $langs['my'] = 'Burmese';
  411. $langs['ca'] = 'Catalan; Valencian';
  412. $langs['km'] = 'Central Khmer';
  413. $langs['ch'] = 'Chamorro';
  414. $langs['ce'] = 'Chechen';
  415. $langs['ny'] = 'Chichewa; Chewa; Nyanja';
  416. $langs['zh'] = 'Chinese';
  417. $langs['zh-cn'] = 'Chinese (Simplified)';
  418. $langs['zh-tw'] = 'Chinese (Traditional)';
  419. $langs['cu'] = 'Church Slavic; Old Bulgarian;';
  420. $langs['cv'] = 'Chuvash';
  421. $langs['kw'] = 'Cornish';
  422. $langs['co'] = 'Corsican';
  423. $langs['cr'] = 'Cree';
  424. $langs['hr'] = 'Croatian';
  425. $langs['cs'] = 'Czech';
  426. $langs['da'] = 'Danish';
  427. $langs['dv'] = 'Divehi; Dhivehi; Maldivian';
  428. $langs['nl'] = 'Dutch; Flemish';
  429. $langs['nl-be'] = 'Dutch (Belgium)';
  430. $langs['nl-nl'] = 'Dutch (Netherlands)';
  431. $langs['dz'] = 'Dzongkha';
  432. $langs['en'] = 'English';
  433. $langs['en-au'] = 'English (Australia)';
  434. $langs['en-bz'] = 'English (Belize)';
  435. $langs['en-ca'] = 'English (Canada)';
  436. $langs['en-ie'] = 'English (Ireland)';
  437. $langs['en-jm'] = 'English (Jamaica)';
  438. $langs['en-nz'] = 'English (New Zealand)';
  439. $langs['en-ph'] = 'English (Phillipines)';
  440. $langs['en-za'] = 'English (South Africa)';
  441. $langs['en-tt'] = 'English (Trinidad)';
  442. $langs['en-gb'] = 'English (United Kingdom)';
  443. $langs['en-us'] = 'English (United States)';
  444. $langs['en-zw'] = 'English (Zimbabwe)';
  445. $langs['eo'] = 'Esperanto';
  446. $langs['et'] = 'Estonian';
  447. $langs['ee'] = 'Ewe';
  448. $langs['fo'] = 'Faroese';
  449. $langs['fj'] = 'Fijian';
  450. $langs['fi'] = 'Finnish';
  451. $langs['fr'] = 'French';
  452. $langs['fr-be'] = 'French (Belgium)';
  453. $langs['fr-ca'] = 'French (Canada)';
  454. $langs['fr-fr'] = 'French (France)';
  455. $langs['fr-lu'] = 'French (Luxembourg)';
  456. $langs['fr-mc'] = 'French (Monaco)';
  457. $langs['fr-ch'] = 'French (Switzerland)';
  458. $langs['ff'] = 'Fulah';
  459. $langs['gd'] = 'Gaelic; Scottish Gaelic';
  460. $langs['gl'] = 'Galician';
  461. $langs['lg'] = 'Ganda';
  462. $langs['ka'] = 'Georgian';
  463. $langs['de'] = 'German';
  464. $langs['de-at'] = 'German (Austria)';
  465. $langs['de-de'] = 'German (Germany)';
  466. $langs['de-li'] = 'German (Liechtenstein)';
  467. $langs['de-lu'] = 'German (Luxembourg)';
  468. $langs['de-ch'] = 'German (Switzerland)';
  469. $langs['el'] = 'Greek, Modern';
  470. $langs['gn'] = 'Guarani';
  471. $langs['gu'] = 'Gujarati';
  472. $langs['ht'] = 'Haitian; Haitian Creole';
  473. $langs['ha'] = 'Hausa';
  474. $langs['he'] = 'Hebrew';
  475. $langs['hz'] = 'Herero';
  476. $langs['hi'] = 'Hindi';
  477. $langs['ho'] = 'Hiri Motu';
  478. $langs['hu'] = 'Hungarian';
  479. $langs['is'] = 'Icelandic';
  480. $langs['io'] = 'Ido';
  481. $langs['ig'] = 'Igbo';
  482. $langs['id'] = 'Indonesian';
  483. $langs['ia'] = 'Interlingua';
  484. $langs['ie'] = 'Interlingue; Occidental';
  485. $langs['iu'] = 'Inuktitut';
  486. $langs['ik'] = 'Inupiaq';
  487. $langs['ga'] = 'Irish';
  488. $langs['it'] = 'Italian';
  489. $langs['it-it'] = 'Italian (Italy)';
  490. $langs['it-ch'] = 'Italian (Switzerland)';
  491. $langs['ja'] = 'Japanese';
  492. $langs['jv'] = 'Javanese';
  493. $langs['kl'] = 'Kalaallisut; Greenlandic';
  494. $langs['kn'] = 'Kannada';
  495. $langs['kr'] = 'Kanuri';
  496. $langs['ks'] = 'Kashmiri';
  497. $langs['kk'] = 'Kazakh';
  498. $langs['ki'] = 'Kikuyu; Gikuyu';
  499. $langs['rw'] = 'Kinyarwanda';
  500. $langs['ky'] = 'Kirghiz; Kyrgyz';
  501. $langs['kv'] = 'Komi';
  502. $langs['kg'] = 'Kongo';
  503. $langs['ko'] = 'Korean';
  504. $langs['kj'] = 'Kuanyama; Kwanyama';
  505. $langs['ku'] = 'Kurdish';
  506. $langs['lo'] = 'Lao';
  507. $langs['la'] = 'Latin';
  508. $langs['lv'] = 'Latvian';
  509. $langs['li'] = 'Limburgan; Limburger; Limburgish';
  510. $langs['ln'] = 'Lingala';
  511. $langs['lt'] = 'Lithuanian';
  512. $langs['lu'] = 'Luba-Katanga';
  513. $langs['lb'] = 'Luxembourgish; Letzeburgesch';
  514. $langs['mk'] = 'Macedonian';
  515. $langs['mg'] = 'Malagasy';
  516. $langs['ms'] = 'Malay';
  517. $langs['ml'] = 'Malayalam';
  518. $langs['mt'] = 'Maltese';
  519. $langs['gv'] = 'Manx';
  520. $langs['mi'] = 'Maori';
  521. $langs['mr'] = 'Marathi';
  522. $langs['mh'] = 'Marshallese';
  523. $langs['mn'] = 'Mongolian';
  524. $langs['na'] = 'Nauru';
  525. $langs['nv'] = 'Navajo; Navaho';
  526. $langs['nd'] = 'Ndebele, North; North Ndebele';
  527. $langs['nr'] = 'Ndebele, South; South Ndebele';
  528. $langs['ng'] = 'Ndonga';
  529. $langs['ne'] = 'Nepali';
  530. $langs['se'] = 'Northern Sami';
  531. $langs['no'] = 'Norwegian';
  532. $langs['nn'] = 'Norwegian Nynorsk; Nynorsk, Norwegian';
  533. $langs['oc'] = 'Occitan (post 1500)';
  534. $langs['oj'] = 'Ojibwa';
  535. $langs['or'] = 'Oriya';
  536. $langs['om'] = 'Oromo';
  537. $langs['os'] = 'Ossetian; Ossetic';
  538. $langs['pi'] = 'Pali';
  539. $langs['pa'] = 'Panjabi; Punjabi';
  540. $langs['fa'] = 'Persian';
  541. $langs['pl'] = 'Polish';
  542. $langs['pt'] = 'Portuguese';
  543. $langs['pt-br'] = 'Portuguese (Brazil)';
  544. $langs['pt-pt'] = 'Portuguese (Portugal)';
  545. $langs['ps'] = 'Pushto; Pashto';
  546. $langs['qu'] = 'Quechua';
  547. $langs['ro'] = 'Romanian; Moldavian; Moldovan';
  548. $langs['rm'] = 'Romansh';
  549. $langs['ro-mo'] = 'Romanian (Moldova)';
  550. $langs['ro-ro'] = 'Romanian (Romania)';
  551. $langs['rn'] = 'Rundi';
  552. $langs['ru'] = 'Russian';
  553. $langs['ru-mo'] = 'Russian (Moldova)';
  554. $langs['ru-ru'] = 'Russian (Russia)';
  555. $langs['sm'] = 'Samoan';
  556. $langs['sg'] = 'Sango';
  557. $langs['sa'] = 'Sanskrit';
  558. $langs['sc'] = 'Sardinian';
  559. $langs['sr'] = 'Serbian';
  560. $langs['sn'] = 'Shona';
  561. $langs['ii'] = 'Sichuan Yi; Nuosu';
  562. $langs['sd'] = 'Sindhi';
  563. $langs['si'] = 'Sinhala; Sinhalese';
  564. $langs['sk'] = 'Slovak';
  565. $langs['sl'] = 'Slovenian';
  566. $langs['so'] = 'Somali';
  567. $langs['st'] = 'Sotho, Southern';
  568. $langs['es'] = 'Spanish; Castilian';
  569. $langs['es-ar'] = 'Spanish (Argentina)';
  570. $langs['es-bo'] = 'Spanish (Bolivia)';
  571. $langs['es-cl'] = 'Spanish (Chile)';
  572. $langs['es-co'] = 'Spanish (Colombia)';
  573. $langs['es-cr'] = 'Spanish (Costa Rica)';
  574. $langs['es-do'] = 'Spanish (Dominican Republic)';
  575. $langs['es-ec'] = 'Spanish (Ecuador)';
  576. $langs['es-sv'] = 'Spanish (El Salvador)';
  577. $langs['es-gt'] = 'Spanish (Guatemala)';
  578. $langs['es-hn'] = 'Spanish (Honduras)';
  579. $langs['es-mx'] = 'Spanish (Mexico)';
  580. $langs['es-ni'] = 'Spanish (Nicaragua)';
  581. $langs['es-pa'] = 'Spanish (Panama)';
  582. $langs['es-py'] = 'Spanish (Paraguay)';
  583. $langs['es-pe'] = 'Spanish (Peru)';
  584. $langs['es-pr'] = 'Spanish (Puerto Rico)';
  585. $langs['es-es'] = 'Spanish (Spain)';
  586. $langs['es-uy'] = 'Spanish (Uruguay)';
  587. $langs['es-ve'] = 'Spanish (Venezuela)';
  588. $langs['su'] = 'Sundanese';
  589. $langs['sw'] = 'Swahili';
  590. $langs['ss'] = 'Swati';
  591. $langs['sv'] = 'Swedish';
  592. $langs['sv-fi'] = 'Swedish (Finland)';
  593. $langs['sv-se'] = 'Swedish (Sweden)';
  594. $langs['tl'] = 'Tagalog';
  595. $langs['ty'] = 'Tahitian';
  596. $langs['tg'] = 'Tajik';
  597. $langs['ta'] = 'Tamil';
  598. $langs['tt'] = 'Tatar';
  599. $langs['te'] = 'Telugu';
  600. $langs['th'] = 'Thai';
  601. $langs['bo'] = 'Tibetan';
  602. $langs['ti'] = 'Tigrinya';
  603. $langs['to'] = 'Tonga (Tonga Islands)';
  604. $langs['ts'] = 'Tsonga';
  605. $langs['tn'] = 'Tswana';
  606. $langs['tr'] = 'Turkish';
  607. $langs['tk'] = 'Turkmen';
  608. $langs['tw'] = 'Twi';
  609. $langs['ug'] = 'Uighur; Uyghur';
  610. $langs['uk'] = 'Ukrainian';
  611. $langs['ur'] = 'Urdu';
  612. $langs['uz'] = 'Uzbek';
  613. $langs['ve'] = 'Venda';
  614. $langs['vi'] = 'Vietnamese';
  615. $langs['vo'] = htmlentities('Volapük');
  616. $langs['wa'] = 'Walloon';
  617. $langs['cy'] = 'Welsh';
  618. $langs['fy'] = 'Western Frisian';
  619. $langs['wo'] = 'Wolof';
  620. $langs['xh'] = 'Xhosa';
  621. $langs['yi'] = 'Yiddish';
  622. $langs['yo'] = 'Yoruba';
  623. $langs['za'] = 'Zhuang; Chuang';
  624. $langs['zu'] = 'Zulu';
  625. return $langs;
  626. }
  627. function podPress_itunesLanguageOptions($current = 'en-us') {
  628. $langs = podPress_itunesLanguageArray();
  629. reset($langs);
  630. foreach ($langs as $key => $value) {
  631. echo '<option value="'.$key.'"';
  632. if($key == $current) {
  633. echo ' selected="selected"';
  634. }
  635. echo '>'.$value.' ['.$key.']</option>'."\n";
  636. }
  637. }
  638. function podPress_itunesCategoryOptions($current = '') {
  639. $cats = array();
  640. if ('' == trim($current) AND '##Global##' != $current) {
  641. $current = '[ nothing ]';
  642. }
  643. $cats[] = '[ '.__('nothing', 'podpress').' ]';
  644. $cats[] = 'Arts';
  645. $cats[] = 'Arts:Design';
  646. $cats[] = 'Arts:Fashion & Beauty';
  647. $cats[] = 'Arts:Food';
  648. $cats[] = 'Arts:Literature';
  649. $cats[] = 'Arts:Performing Arts';
  650. $cats[] = 'Arts:Visual Arts';
  651. $cats[] = 'Business';
  652. $cats[] = 'Business:Business News';
  653. $cats[] = 'Business:Careers';
  654. $cats[] = 'Business:Investing';
  655. $cats[] = 'Business:Management & Marketing';
  656. $cats[] = 'Business:Shopping';
  657. $cats[] = 'Comedy';
  658. $cats[] = 'Education';
  659. $cats[] = 'Education:Education Technology';
  660. $cats[] = 'Education:Higher Education';
  661. $cats[] = 'Education:K-12';
  662. $cats[] = 'Education:Language Courses';
  663. $cats[] = 'Education:Training';
  664. $cats[] = 'Games & Hobbies';
  665. $cats[] = 'Games & Hobbies:Automotive';
  666. $cats[] = 'Games & Hobbies:Aviation';
  667. $cats[] = 'Games & Hobbies:Hobbies';
  668. $cats[] = 'Games & Hobbies:Other Games';
  669. $cats[] = 'Games & Hobbies:Video Games';
  670. $cats[] = 'Government & Organizations';
  671. $cats[] = 'Government & Organizations:Local';
  672. $cats[] = 'Government & Organizations:National';
  673. $cats[] = 'Government & Organizations:Non-Profit';
  674. $cats[] = 'Government & Organizations:Regional';
  675. $cats[] = 'Health';
  676. $cats[] = 'Health:Alternative Health';
  677. $cats[] = 'Health:Fitness & Nutrition';
  678. $cats[] = 'Health:Self-Help';
  679. $cats[] = 'Health:Sexuality';
  680. $cats[] = 'Kids & Family';
  681. $cats[] = 'Music';
  682. $cats[] = 'News & Politics';
  683. $cats[] = 'Religion & Spirituality';
  684. $cats[] = 'Religion & Spirituality:Buddhism';
  685. $cats[] = 'Religion & Spirituality:Christianity';
  686. $cats[] = 'Religion & Spirituality:Hinduism';
  687. $cats[] = 'Religion & Spirituality:Islam';
  688. $cats[] = 'Religion & Spirituality:Judaism';
  689. $cats[] = 'Religion & Spirituality:Other';
  690. $cats[] = 'Religion & Spirituality:Spirituality';
  691. $cats[] = 'Science & Medicine';
  692. $cats[] = 'Science & Medicine:Medicine';
  693. $cats[] = 'Science & Medicine:Natural Sciences';
  694. $cats[] = 'Science & Medicine:Social Sciences';
  695. $cats[] = 'Society & Culture';
  696. $cats[] = 'Society & Culture:History';
  697. $cats[] = 'Society & Culture:Personal Journals';
  698. $cats[] = 'Society & Culture:Philosophy';
  699. $cats[] = 'Society & Culture:Places & Travel';
  700. $cats[] = 'Sports & Recreation';
  701. $cats[] = 'Sports & Recreation:Amateur';
  702. $cats[] = 'Sports & Recreation:College & High School';
  703. $cats[] = 'Sports & Recreation:Outdoor';
  704. $cats[] = 'Sports & Recreation:Professional';
  705. $cats[] = 'Technology';
  706. $cats[] = 'Technology:Gadgets';
  707. $cats[] = 'Technology:Tech News';
  708. $cats[] = 'Technology:Podcasting';
  709. $cats[] = 'Technology:Software How-To';
  710. $cats[] = 'TV & Film';
  711. reset($cats);
  712. $foundit = false;
  713. foreach ($cats as $value) {
  714. $value = str_replace('&', '&amp;', $value);
  715. echo '<option';
  716. if ( $value == $current OR ('[ nothing ]' === $current AND '[ '.__('nothing', 'podpress').' ]' === $value) ) {
  717. $foundit = true;
  718. echo ' selected="selected"';
  719. }
  720. if ( '[ '.__('nothing', 'podpress').' ]' === $value ) {
  721. echo ' value="[ nothing ]"';
  722. } else {
  723. echo ' value="'.attribute_escape($value).'"';
  724. }
  725. echo '>'.$value.'</option>'."\n";
  726. }
  727. if(!$foundit AND '##Global##' != $current) {
  728. $current = podPress_upgradeCategory($current);
  729. echo '<option selected="selected">'.$current.'</option>'."\n";
  730. }
  731. }
  732. function podPress_upgradeCategory($current) {
  733. $cats['Arts & Entertainment'] = 'Arts';
  734. $cats['Arts & Entertainment:Architecture'] = 'Arts:Design';
  735. $cats['Arts & Entertainment:Books'] = 'Arts:Literature';
  736. $cats['Arts & Entertainment:Design'] = 'Arts:Design';
  737. $cats['Arts & Entertainment:Entertainment'] = 'TV & Film';
  738. $cats['Arts & Entertainment:Games'] = 'Games & Hobbies:Video Games';
  739. $cats['Arts & Entertainment:Performing Arts'] = 'Arts:Performing Arts';
  740. $cats['Arts & Entertainment:Photography'] = 'Arts:Visual Arts';
  741. $cats['Arts & Entertainment:Poetry'] = 'Arts:Literature';
  742. $cats['Arts & Entertainment:Science Fiction'] = 'Arts:Literature';
  743. $cats['Audio Blogs'] = 'Society & Culture:Personal Journals';
  744. $cats['Business'] = 'Business';
  745. $cats['Business:Careers'] = 'Business:Careers';
  746. $cats['Business:Finance'] = 'Business:Business News';
  747. $cats['Business:Investing'] = 'Business:Investing';
  748. $cats['Business:Management'] = 'Business:Management & Marketing';
  749. $cats['Business:Marketing'] = 'Business:Management & Marketing';
  750. $cats['Comedy'] = 'Comedy';
  751. $cats['Education'] = 'Education';
  752. $cats['Education:Higher Education'] = 'Education:Higher Education';
  753. $cats['Education:K-12'] = 'Education:K-12';
  754. $cats['Family'] = 'Kids & Family';
  755. $cats['Food'] = 'Arts:Food';
  756. $cats['Health'] = 'Health';
  757. $cats['Health:Diet & Nutrition'] = 'Health:Fitness & Nutrition';
  758. $cats['Health:Fitness'] = 'Health:Fitness & Nutrition';
  759. $cats['Health:Relationships'] = 'Health:Sexuality';
  760. $cats['Health:Self-Help'] = 'Health:Self-Help';
  761. $cats['Health:Sexuality'] = 'Health:Sexuality';
  762. $cats['International'] = 'Government & Organizations:National';
  763. $cats['International:Australian'] = 'Government & Organizations:National';
  764. $cats['International:Belgian'] = 'Government & Organizations:National';
  765. $cats['International:Brazilian'] = 'Government & Organizations:National';
  766. $cats['International:Canadian'] = 'Government & Organizations:National';
  767. $cats['International:Chinese'] = 'Government & Organizations:National';
  768. $cats['International:Dutch'] = 'Government & Organizations:National';
  769. $cats['International:French'] = 'Government & Organizations:National';
  770. $cats['International:German'] = 'Government & Organizations:National';
  771. $cats['International:Hebrew'] = 'Government & Organizations:National';
  772. $cats['International:Italian'] = 'Government & Organizations:National';
  773. $cats['International:Japanese'] = 'Government & Organizations:National';
  774. $cats['International:Norwegian'] = 'Government & Organizations:National';
  775. $cats['International:Polish'] = 'Government & Organizations:National';
  776. $cats['International:Portuguese'] = 'Government & Organizations:National';
  777. $cats['International:Spanish'] = 'Government & Organizations:National';
  778. $cats['International:Swedish'] = 'Government & Organizations:National';
  779. $cats['Movies & Television'] = 'TV & Film';
  780. $cats['Music'] = 'Music';
  781. $cats['News'] = 'News & Politics';
  782. $cats['Politics'] = 'News & Politics';
  783. $cats['Public Radio'] = 'News & Politics';
  784. $cats['Religion & Spirituality'] = 'Religion & Spirituality';
  785. $cats['Religion & Spirituality:Buddhism'] = 'Religion & Spirituality:Buddhism';
  786. $cats['Religion & Spirituality:Christianity'] = 'Religion & Spirituality:Christianity';
  787. $cats['Religion & Spirituality:Islam'] = 'Religion & Spirituality:Islam';
  788. $cats['Religion & Spirituality:Judaism'] = 'Religion & Spirituality:Judaism';
  789. $cats['Religion & Spirituality:New Age'] = 'Religion & Spirituality:Spirituality';
  790. $cats['Religion & Spirituality:Philosophy'] = 'Religion & Spirituality:Philosophy';
  791. $cats['Religion & Spirituality:Spirituality'] = 'Religion & Spirituality:Spirituality';
  792. $cats['Science'] = 'Science & Medicine';
  793. $cats['Sports'] = 'Sports & Recreation';
  794. $cats['Talk Radio'] = 'News & Politics';
  795. $cats['Technology'] = 'Technology';
  796. $cats['Technology:IT News'] = 'Technology:Tech News';
  797. $cats['Technology:Computers'] = 'Technology:Tech News';
  798. $cats['Technology:Developers'] = 'Technology:Tech News';
  799. $cats['Technology:Gadgets'] = 'Technology:Gadgets';
  800. $cats['Technology:Information Technology'] = 'Technology:Tech News';
  801. $cats['Technology:News'] = 'Technology:Tech News';
  802. $cats['Technology:Operating Systems'] = 'Technology:Tech News';
  803. $cats['Technology:Podcasting'] = 'Technology:Podcasting';
  804. $cats['Technology:Smart Phones'] = 'Technology:Tech News';
  805. $cats['Technology:Text/Speech'] = 'Technology:Tech News';
  806. $cats['Transportation'] = 'Games & Hobbies:Automotive';
  807. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  808. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  809. $cats['Transportation:BBB'] = 'Sports & Recreation:Outdoor';
  810. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  811. $cats['Travel'] = 'Society & Culture:Places & Travel';
  812. $current = str_replace('&amp;', '&', $current);
  813. if(isset($cats[$current])) {
  814. $result = $cats[$current];
  815. } else {
  816. $result = $current;
  817. }
  818. return str_replace('&', '&amp;', $result);
  819. }
  820. function podPress_itunesCategoryOptions2($current = '') {
  821. $cats = array();
  822. $cats['Arts &amp; Entertainment'] = 'Arts &amp; Entertainment';
  823. $cats['Arts &amp; Entertainment:Architecture'] = 'Arts &amp; Entertainment:Architecture';
  824. $cats['Arts &amp; Entertainment:Books'] = 'Arts &amp; Entertainment:Books';
  825. $cats['Arts &amp; Entertainment:Design'] = 'Arts &amp; Entertainment:Design';
  826. $cats['Arts &amp; Entertainment:Poetry'] = 'Arts &amp; Entertainment:Poetry';
  827. $cats['Arts &amp; Entertainment:Games'] = 'Arts &amp; Entertainment:Games';
  828. $cats['Arts &amp; Entertainment:Performing Arts'] = 'Arts &amp; Entertainment:Performing Arts';
  829. $cats['Arts &amp; Entertainment:Photography'] = 'Arts &amp; Entertainment:Photography';
  830. $cats['Arts &amp; Entertainment:Science Fiction'] = 'Arts &amp; Entertainment:Science Fiction';
  831. $cats['Audio Blogs'] = 'Audio Blogs';
  832. $cats['Business'] = 'Business';
  833. $cats['Business:Careers'] = 'Business:Careers';
  834. $cats['Business:Finance'] = 'Business:Finance';
  835. $cats['Business:Investing'] = 'Business:Investing';
  836. $cats['Business:Management'] = 'Business:Management';
  837. $cats['Business:Marketing'] = 'Business:Marketing';
  838. $cats['Comedy'] = 'Comedy';
  839. $cats['Education'] = 'Education';
  840. $cats['Education:K-12'] = 'Education:K-12';
  841. $cats['Education:Higher Education'] = 'Education:Higher Education';
  842. $cats['Family'] = 'Family';
  843. $cats['Food'] = 'Food';
  844. $cats['Health'] = 'Health';
  845. $cats['Health:Diet &amp; Nutrition'] = 'Health:Diet &amp; Nutrition';
  846. $cats['Health:Fitness'] = 'Health:Fitness';
  847. $cats['Health:Relationships'] = 'Health:Relationships';
  848. $cats['Health:Self-Help'] = 'Health:Self-Help';
  849. $cats['Health:Sexuality'] = 'Health:Sexuality';
  850. $cats['International'] = 'International';
  851. $cats['International:Australian'] = 'International:Australian';
  852. $cats['International:Belgian'] = 'International:Belgian';
  853. $cats['International:Brazilian'] = 'International:Brazilian';
  854. $cats['International:Canadian'] = 'International:Canadian';
  855. $cats['International:Chinese'] = 'International:Chinese';
  856. $cats['International:Dutch'] = 'International:Dutch';
  857. $cats['International:French'] = 'International:French';
  858. $cats['International:German'] = 'International:German';
  859. $cats['International:Hebrew'] = 'International:Hebrew';
  860. $cats['International:Italian'] = 'International:Italian';
  861. $cats['International:Japanese'] = 'International:Japanese';
  862. $cats['International:Norwegian'] = 'International:Norwegian';
  863. $cats['International:Polish'] = 'International:Polish';
  864. $cats['International:Portuguese'] = 'International:Portuguese';
  865. $cats['International:Spanish'] = 'International:Spanish';
  866. $cats['International:Swedish'] = 'International:Swedish';
  867. $cats['Movies &amp; Television'] = 'Movies &amp; Television';
  868. $cats['Music'] = 'Music';
  869. $cats['News'] = 'News';
  870. $cats['Politics'] = 'Politics';
  871. $cats['Public Radio'] = 'Public Radio';
  872. $cats['Religion &amp; Spirituality'] = 'Religion &amp; Spirituality';
  873. $cats['Religion &amp; Spirituality:Buddhism'] = 'Religion &amp; Spirituality:Buddhism';
  874. $cats['Religion &amp; Spirituality:Christianity'] = 'Religion &amp; Spirituality:Christianity';
  875. $cats['Religion &amp; Spirituality:Islam'] = 'Religion &amp; Spirituality:Islam';
  876. $cats['Religion &amp; Spirituality:Judaism'] = 'Religion &amp; Spirituality:Judaism';
  877. $cats['Religion &amp; Spirituality:New Age'] = 'Religion &amp; Spirituality:New Age';
  878. $cats['Religion &amp; Spirituality:Philosophy'] = 'Religion &amp; Spirituality:Philosophy';
  879. $cats['Religion &amp; Spirituality:Spirituality'] = 'Religion &amp; Spirituality:Spirituality';
  880. $cats['Science'] = 'Science';
  881. $cats['Sports'] = 'Sports';
  882. $cats['Talk Radio'] = 'Talk Radio';
  883. $cats['Technology'] = 'Technology';
  884. $cats['Technology:Computers'] = 'Technology:Computers';
  885. $cats['Technology:Developers'] = 'Technology:Developers';
  886. $cats['Technology:Gadgets'] = 'Technology:Gadgets';
  887. $cats['Technology:Information Technology'] = 'Technology:Information Technology';
  888. $cats['Technology:News'] = 'Technology:News';
  889. $cats['Technology:Operating Systems'] = 'Technology:Operating Systems';
  890. $cats['Technology:Podcasting'] = 'Technology:Podcasting';
  891. $cats['Technology:Smart Phones'] = 'Technology:Smart Phones';
  892. $cats['Technology:Text/Speech'] = 'Technology:Text/Speech';
  893. $cats['Travel'] = 'Travel';
  894. reset($cats);
  895. foreach ($cats as $key => $value) {
  896. echo '<option value="'.$key.'"';
  897. if($key == $current) {
  898. echo ' selected="selected"';
  899. }
  900. echo '>'.$value.'</option>'."\n";
  901. }
  902. }
  903. /**************************************************************/
  904. /* Functions for supporting the backend processor */
  905. /**************************************************************/
  906. function podPress_ResolveReDirects($uriFileName)
  907. {
  908. GLOBAL $podPress;
  909. $tries = 0;
  910. while($tries < 5) {
  911. $tries++;
  912. $aURL = parse_url($uriFileName);
  913. if($aURL['scheme'] != 'http') {
  914. return;
  915. }
  916. $sHost = $aURL['host'];
  917. $sFilepath = (isset($aURL['path']) ? $aURL['path'] : '/') . (isset($aURL['query']) ? '?' . $aURL['query'] : '');
  918. $nPort = isset($aURL['port']) ? $aURL['port'] : 80;
  919. $fpRemote = @fsockopen($sHost, $nPort, $errno, $errstr, 30);
  920. // Make sure the socket is open
  921. if(!$fpRemote) {
  922. return;
  923. }
  924. // Request headers
  925. $sHeaders = "HEAD " . $sFilepath . " HTTP/1.1\r\n";
  926. $sHeaders .= "Host: ". $sHost . "\r\n";
  927. $sHeaders .= "Connection: Close\r\n\r\n";
  928. // Sending headers
  929. fwrite($fpRemote, $sHeaders);
  930. // Getting back the content
  931. $sRemoteHeaders = '';
  932. while(!feof($fpRemote)) {
  933. $sRemoteHeaders .= fgets($fpRemote, 128);
  934. }
  935. // Closing the socket
  936. fclose($fpRemote);
  937. // parse headers
  938. $crlf = "\r\n";
  939. $headers = array();
  940. $lines = explode($crlf, $sRemoteHeaders);
  941. foreach($lines as $line) {
  942. if(($pos = strpos($line, ':')) !== false) {
  943. $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
  944. }
  945. }
  946. // redirection?
  947. if(isset($headers['location'])) {
  948. $uriFileName = $headers['location'];
  949. } else {
  950. return $uriFileName;
  951. }
  952. }
  953. return $uriFileName;
  954. }
  955. /**
  956. * podPress_getID3tags - function to retrieve the ID3 data from a media file with the help of getID3() - gets called for duration, all ID3 tags and the cover art
  957. *
  958. * @package podPress
  959. * @since (unknown)
  960. *
  961. * @param string $mediafile - the URL of the media file
  962. * @param boolean $resolved - download only the header (TRUE) or more than that (FALSE)
  963. * @param boolean $limitDownload (optional) - file size in kb to limit the amount data which should be downloaded from a remote media file (used in podPress_getCoverArt())
  964. * @param boolean $deletetmpfile (optional) - if a tmp file should be deleted at the end of this function call (TRUE) or not (FALSE). In case this function gets called from the showid3tags() function this parameter is FALSE because there will be a second call for the cover art afterwads and the tmp file should be removed only after that call to avoid an unnecessary download.
  965. * @param boolean $tmp_download_exists (optional) - if there is a tmp file (e.g. after an download of a remote media file) then this is TRUE otherwise it is FALSE
  966. *
  967. * return array - an Array with the ID3 information or an Array which includes at least the key 'error'
  968. */
  969. function podPress_getID3tags($mediafile, $resolved = FALSE, $limitDownload = FALSE, $deletetmpfile = TRUE, $tmp_download_exists = FALSE) {
  970. GLOBAL $podPress;
  971. if($podPress->settings['enablePodangoIntegration']) {
  972. if(substr($mediafile, 0, strlen('Podango:')) == 'Podango:') {
  973. $fileNameParts = explode(':', $mediafile);
  974. $mediafile = 'http://download.podango.com/mediatracker/555/'.$fileNameParts[3].'/'.$fileNameParts[4];
  975. }
  976. }
  977. podPress_var_dump('podPress_getID3tags - before inclusion of the getID3 library');
  978. require_once(ABSPATH.PLUGINDIR.'/podpress/getid3/getid3.php');
  979. $getID3 = new getID3;
  980. if ($getID3 == false) {
  981. $fileinfo['error'] = __('Remote MP3 File could not be read. (error loading ID3 reader)', 'podpress');
  982. return $fileinfo;
  983. }
  984. podPress_var_dump('podPress_getID3tags - after inclusion of the getID3 library');
  985. if(!$resolved) {
  986. $systemFileName = $podPress->convertPodcastFileNameToSystemPath($mediafile);
  987. } else {
  988. $systemFileName = $mediafile;
  989. }
  990. podPress_var_dump('podPress_getID3tags - before a possible download of the media file');
  991. podPress_var_dump('podPress_getID3tags - ' . $systemFileName);
  992. if(file_exists($systemFileName)) {
  993. $uriFileName = $systemFileName;
  994. podPress_var_dump('podPress_getID3tags - local file exists: '.$uriFileName);
  995. } else {
  996. if(!$resolved) {
  997. $uriFileName = $podPress->convertPodcastFileNameToValidWebPath($mediafile);
  998. } else {
  999. $uriFileName = $mediafile;
  1000. }
  1001. $local_uploadURL = $podPress->uploadurl;
  1002. podPress_var_dump('podPress_getID3tags - local_uploadURL: '.$local_uploadURL);
  1003. podPress_var_dump('podPress_getID3tags - local_uploadpath: '.$podPress->uploadpath);
  1004. podPress_var_dump('podPress_getID3tags - tempfilesystempath: '.$podPress->tempfilesystempath);
  1005. podPress_var_dump('podPress_getID3tags - tempfileurlpath: '.$podPress->tempfileurlpath);
  1006. podPress_var_dump('podPress_getID3tags - uriFileName: '.$uriFileName);
  1007. if (FALSE !== $local_uploadURL AND FALSE !== strpos($uriFileName, $local_uploadURL)) { // then it is not a real remote file - it is only an URL to a local file
  1008. // get the absolute folder of the file from the URL
  1009. podPress_var_dump('podPress_getID3tags - it is a local file');
  1010. $uriFileName = $podPress->uploadpath.str_replace($local_uploadURL,'',$uriFileName);
  1011. //$uriFileName = str_replace('\\', '/',$uriFileName);
  1012. podPress_var_dump('podPress_getID3tags - new uriFileName: '.$uriFileName);
  1013. } else {
  1014. podPress_var_dump('podPress_getID3tags - go to podPress_downloadFile');
  1015. $uriFileName = podPress_downloadFile($uriFileName, false, $limitDownload);
  1016. $tmp_download_exists = TRUE;
  1017. }
  1018. }
  1019. podPress_var_dump('podPress_getID3tags - after a possible download of the media file');
  1020. $fileinfo = @$getID3->analyze( $uriFileName );
  1021. // if the first attempt to retrieve the ID3 data went wrong then try it again with a file name which is encoded to the system encoding
  1022. if ( isset($fileinfo['error']) ) {
  1023. // get system encoding
  1024. if ( TRUE == function_exists('iconv_get_encoding') ) {
  1025. $sysenc = iconv_get_encoding('internal_encoding');
  1026. } else {
  1027. $sysenc = FALSE;
  1028. }
  1029. podPress_var_dump('podPress_getID3tags - iconv_get_encoding("internal_encoding")');
  1030. podPress_var_dump( $sysenc );
  1031. $blog_charset = get_bloginfo('charset');
  1032. // convert the encoding of the file name before analyzing the ID3 tags
  1033. if (FALSE !== $sysenc) {
  1034. if ( TRUE == function_exists('mb_detect_encoding') ) {
  1035. $input_enc = mb_detect_encoding($uriFileName);
  1036. podPress_var_dump(PHP_OS.' | input_enc: '.mb_detect_encoding($uriFileName).' | '.$sysenc);
  1037. $fileinfo = @$getID3->analyze( iconv($input_enc, $sysenc, $uriFileName) );
  1038. } else {
  1039. podPress_var_dump(PHP_OS.' | blog_charset: '.$blog_charset.' | '.$sysenc);
  1040. $fileinfo = @$getID3->analyze( iconv($blog_charset, $sysenc, $uriFileName) );
  1041. }
  1042. }
  1043. }
  1044. podPress_var_dump('podPress_getID3tags - after getID3->analyze');
  1045. // log the the getID3() error message if there is one
  1046. if ( isset($fileinfo['error']) ) {
  1047. podPress_var_dump($fileinfo['error']);
  1048. }
  1049. getid3_lib::CopyTagsToComments($fileinfo);
  1050. podPress_var_dump('podPress_getID3tags - after getid3_lib::CopyTagsToComments');
  1051. podPress_var_dump('podPress_getID3tags - tmp_download_exists: '.var_export($tmp_download_exists, TRUE).' | deletetmpfile: '.var_export($deletetmpfile, TRUE));
  1052. if ( TRUE === $tmp_download_exists AND FALSE !== $deletetmpfile ) { // if the file has been downloaded to a local folder then delete the tempfile
  1053. $unlink_result = 'nothing to unlink';
  1054. if ('' != $fileinfo['filenamepath']) { // take the folder and file from getID3 if possible
  1055. podPress_unlinktmpfile($fileinfo['filenamepath']);
  1056. } else {
  1057. podPress_unlinktmpfile($uriFileName);
  1058. }
  1059. } elseif ( TRUE === $tmp_download_exists ) {
  1060. $fileinfo['podpress_tmp_download_exists'] = TRUE;
  1061. }
  1062. podPress_var_dump('podPress_getID3tags - the end');
  1063. return $fileinfo;
  1064. }
  1065. function podPress_unlinktmpfile($filename) {
  1066. $unlink_result = @unlink($filename);
  1067. // If tempnam is available then tempnam creates a tempfile which has no media file extension like .mp3. But getID3 needs these extensions.
  1068. // That is why tempnam (in podPress_downloadFile) is only used to get a the tmp file name and path. If the tempnam has been used then
  1069. // then there are 2 files the tmp file and the tmp file with a media file name extension. The latter was removed in the step before and the next step is
  1070. // to remove the tmp file which was created by tempnam in podPress_downloadFile.
  1071. podPress_var_dump('podPress_getID3tags - result from unlinking the tmp file (A) - '.var_export($unlink_result, TRUE));
  1072. $ext = end(explode('.', $filename));
  1073. if ( FALSE === empty($ext) ) {
  1074. $tempnam_file = substr($filename, 0, (strlen($filename)-strlen($ext)-1));
  1075. $unlink_result = @unlink($tempnam_file);
  1076. }
  1077. podPress_var_dump('podPress_getID3tags - result from unlinking the tmp file (B) - '.var_export($unlink_result, TRUE));
  1078. }
  1079. function podPress_showID3tags($mediafile) {
  1080. if (FALSE !== strpos($mediafile, 'http://www.youtube')) {
  1081. return '';
  1082. }
  1083. //~ $allowed_ext = array('mp3', 'ogg', 'ogv', 'asf', 'avi', 'mov', 'qt', 'mp4', 'm4v', 'm4a', 'wma', 'wmv', 'mpg', 'mpeg', 'flv', 'swf');
  1084. //~ $ext = strtolower(end(explode('.', $mediafile)));
  1085. //~ if (TRUE == in_array($ext, $allowed_ext)) {
  1086. podPress_var_dump('start of the ID3 tag retrieval - '.$mediafile);
  1087. $fileinfo = podPress_getID3tags($mediafile, FALSE, FALSE, FALSE);
  1088. podPress_var_dump('end of the ID3 tag retrieval');
  1089. if(!is_array($fileinfo) OR FALSE == isset($fileinfo['comments']) ) {
  1090. return '<div class="updated message">'.__('The file has probably no information like artist, genre, album, etc.', 'podpress').'<br /><pre class="podpress_id3tags_error">'.var_export($fileinfo, true).'</pre></div>';
  1091. }
  1092. if(isset($_GET['keynum'])) {
  1093. $randID = $_GET['keynum'];
  1094. } else {
  1095. mt_srand(crc32(microtime()));
  1096. $randID = mt_rand(1, 9999);
  1097. }
  1098. $result .= '<table class="the-list-x widefat podpress_id3tag_details_table">'."\n";
  1099. $result .= ' <tr class="alternate">'."\n";
  1100. $result .= ' <th>'.__('Artist', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagArtist">'.(!empty($fileinfo['comments']['artist'][0]) ? htmlentities($fileinfo['comments']['artist'][0]) : '&nbsp;').'</span></td>'."\n";
  1101. $result .= ' </tr>'."\n";
  1102. $result .= ' <tr>'."\n";
  1103. $result .= ' <th>'.__('Album', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagAlbum">'.(!empty($fileinfo['comments']['album'][0]) ? htmlentities($fileinfo['comments']['album'][0]) : '&nbsp;').'</span></td>'."\n";
  1104. $result .= ' </tr>'."\n";
  1105. $result .= ' <tr class="alternate">'."\n";
  1106. $result .= ' <th>'.__('Title', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagTitle">'.(!empty($fileinfo['comments']['title'][0]) ? htmlentities($fileinfo['comments']['title'][0]) : '&nbsp;').'</span></td>'."\n";
  1107. $result .= ' </tr>'."\n";
  1108. $result .= ' <tr>'."\n";
  1109. $result .= ' <th>'.__('Description', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagDescription">'.(!empty($fileinfo['comments']['comment'][0]) ? htmlentities($fileinfo['comments']['comment'][0]) : '&nbsp;').'</span></td>'."\n";
  1110. $result .= ' </tr>'."\n";
  1111. $result .= ' <tr class="alternate">'."\n";
  1112. $result .= ' <th>'.__('Genre', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagGenre">'.(!empty($fileinfo['comments']['genre'][0]) ? htmlentities($fileinfo['comments']['genre'][0]) : '&nbsp;').'</span></td>'."\n";
  1113. $result .= ' </tr>'."\n";
  1114. $result .= ' <tr>'."\n";
  1115. $result .= ' <th>'.__('Length', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagLength">'.(!empty($fileinfo['playtime_string']) ? $fileinfo['playtime_string'] : '&nbsp;').'</span></td>'."\n";
  1116. $result .= ' </tr>'."\n";
  1117. $result .= ' <tr class="alternate">'."\n";
  1118. if ( defined('NONCE_KEY') AND is_string(constant('NONCE_KEY')) AND '' != trim(constant('NONCE_KEY')) ) {
  1119. $nonce = wp_create_nonce(NONCE_KEY);
  1120. } else {
  1121. $nonce = wp_create_nonce('Af|F07*wC7g-+OX$;|Z5;R@Pi]ZgoU|Zex8=`?mO-Mdvu+WC6l=6<O^2d~+~U3MM');
  1122. }
  1123. // The # + time() in the URL of the covert art should make the server show always the current image and not a cached version.
  1124. if ( isset($fileinfo['podpress_tmp_download_exists']) AND TRUE === $fileinfo['podpress_tmp_download_exists'] ) {
  1125. $result .= ' <th>'.__('Cover Art', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagCoverArt"><img src="'.PODPRESS_URL.'/podpress_backend.php?action=id3image&filename='.rawurlencode($fileinfo['filenamepath']).'&tmpdownloadexists=yes&_ajax_nonce=' . $nonce . '#'.time().'" alt="" /></span></td>'."\n";
  1126. podPress_var_dump('podPress_showID3tags - podpress_tmp_download_exists = TRUE');
  1127. } else {
  1128. $result .= ' <th>'.__('Cover Art', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagCoverArt"><img src="'.PODPRESS_URL.'/podpress_backend.php?action=id3image&filename='.rawurlencode($fileinfo['filenamepath']).'&tmpdownloadexists=no&_ajax_nonce=' . $nonce . '#'.time().'" alt="" /></span></td>'."\n";
  1129. podPress_var_dump('podPress_showID3tags - podpress_tmp_download_exists = FALSE');
  1130. }
  1131. $result .= ' </tr>'."\n";
  1132. //~ $result .= ' <tr>'."\n";
  1133. //~ $result .= ' <th>The getID3() output:</th><td><pre class="podpress_id3tags_error">'.var_export($fileinfo, true).'</pre></td>'."\n";
  1134. //~ $result .= ' </tr>'."\n";
  1135. $result .= '</table>'."\n";
  1136. return $result;
  1137. //~ } else {
  1138. //~ return __('unknown', 'podpress');
  1139. //~ }
  1140. }
  1141. function podPress_getCoverArt($mediafile, $tmp_download_exists = FALSE) {
  1142. podPress_var_dump('podPress_getCoverArt - start');
  1143. if ( TRUE === $tmp_download_exists ) {
  1144. // if the local file is a tmp file of a download then delete it after retrieving the cover art
  1145. $fileinfo = podPress_getID3tags($mediafile, TRUE, 500000, TRUE, TRUE);
  1146. } else {
  1147. $fileinfo = podPress_getID3tags($mediafile, TRUE, 500000, TRUE, FALSE);
  1148. }
  1149. podPress_var_dump('podPress_getCoverArt - after getid3tags');
  1150. if ( isset($fileinfo['id3v2']['APIC'][0]) ) {
  1151. $ref = $fileinfo['id3v2']['APIC'][0];
  1152. if ( (FALSE == isset($ref['image_mime']) OR (isset($ref['image_mime']) AND empty($ref['image_mime']))) AND isset($ref['mime']) ) {
  1153. $ref['image_mime'] = $ref['mime'];
  1154. }
  1155. podPress_var_dump('podPress_getCoverArt - (id3v2 - APIC) '. $ref['image_mime']);
  1156. } elseif ( isset($fileinfo['id3v2']['PIC'][0]) ) {
  1157. $ref = $fileinfo['id3v2']['PIC'][0];
  1158. if ( (FALSE == isset($ref['image_mime']) OR (isset($ref['image_mime']) AND empty($ref['image_mime']))) AND isset($ref['mime']) ) {
  1159. $ref['image_mime'] = $ref['mime'];
  1160. }
  1161. podPress_var_dump('podPress_getCoverArt - (id3v2 - PIC) '. $ref['image_mime']);
  1162. } elseif ( isset($fileinfo['comments']['artwork'][0]) ) {
  1163. $ref['data'] = $fileinfo['comments']['artwork'][0];
  1164. podPress_var_dump('podPress_getCoverArt - (m4a comments) '. $ref['image_mime']);
  1165. } elseif ( isset($fileinfo['tags']['quicktime']['artwork'][0]) ) {
  1166. $ref['data'] = $fileinfo['tags']['quicktime']['artwork'][0];
  1167. podPress_var_dump('podPress_getCoverArt - (m4a tags) '. $ref['image_mime']);
  1168. } else {
  1169. $ref['image_mime'] = 'image/png';
  1170. $ref['datalength'] = @filesize('images/powered_by_podpress.png');
  1171. $ref['data'] = @file_get_contents('images/powered_by_podpress.png');
  1172. podPress_var_dump('podPress_getCoverArt - (default image) '. $ref['image_mime']);
  1173. }
  1174. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // some day in the past
  1175. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT', false, 200);
  1176. if ( isset($ref['image_mime']) AND FALSE == empty($ref['image_mime']) ) {
  1177. header('Content-type: '.$ref['image_mime']);
  1178. }
  1179. if ( isset($ref['datalength']) AND FALSE == empty($ref['datalength']) ) {
  1180. header('Content-Length: '.$ref['datalength']);
  1181. }
  1182. //set_time_limit(0);
  1183. echo $ref['data'];
  1184. podPress_var_dump('podPress_getCoverArt - end');
  1185. }
  1186. function podPress_getDuration($mediafile) {
  1187. GLOBAL $podPress;
  1188. if($podPress->settings['enablePodangoIntegration']) {
  1189. if(substr($mediafile, 0, strlen('Podango:')) == 'Podango:') {
  1190. $fileNameParts = explode(':', $mediafile);
  1191. $mediafile = 'http://download.podango.com/mediatracker/555/'.$fileNameParts[3].'/'.$fileNameParts[4];
  1192. }
  1193. }
  1194. $allowed_ext = array('mp3', 'ogg', 'ogv', 'avi', 'mov', 'qt', 'mp4', 'm4v', 'm4a', 'wma', 'wmv', 'mpg', 'mpeg', 'flv', 'swf');
  1195. $ext = strtolower(end(explode('.', $mediafile)));
  1196. if (TRUE == in_array($ext, $allowed_ext)) {
  1197. podPress_var_dump('start of the duration retrieval');
  1198. $systemFileName = $podPress->convertPodcastFileNameToSystemPath($mediafile);
  1199. if(file_exists($systemFileName)) {
  1200. $uriFileName = $systemFileName;
  1201. } else {
  1202. $systemFileName = $podPress->TryToFindAbsFileName($mediafile);
  1203. if(FALSE !== $systemFileName) {
  1204. $uriFileName = $systemFileName;
  1205. } else {
  1206. $uriFileName = $podPress->convertPodcastFileNameToValidWebPath($mediafile);
  1207. }
  1208. }
  1209. podPress_var_dump('podPress_getDuration - file: '.$uriFileName);
  1210. $fileinfo = podPress_getID3tags($uriFileName, true);
  1211. podPress_var_dump('podPress_getDuration - playtime_string: '.$fileinfo['playtime_string']);
  1212. podPress_var_dump('end of the duration retrieval');
  1213. return trim($fileinfo['playtime_string']);
  1214. } else {
  1215. return __('UNKNOWN', 'podpress');
  1216. }
  1217. }
  1218. /**
  1219. * podPress_downloadFile - downloads the header a part or the whole file from a remote server (to give getID3() the chance to retrieve the ID3 information like duration etc.)
  1220. *
  1221. * @package podPress
  1222. * @since (unknown)
  1223. *
  1224. * @param string $uriFileName - the URL of the media file
  1225. * @param boolean $getHeaders - download only the header (TRUE) or more than that (FALSE)
  1226. * @param numeric $limitDownload - file size in kb to limit the amount data which should be downloaded from a remote media file (used in podPress_getCoverArt())
  1227. *
  1228. * return mixed - the full HTTP response header or the file name of the downloaded file
  1229. */
  1230. function podPress_downloadFile($uriFileName, $getHeaders = false, $limitDownload = false) {
  1231. GLOBAL $podPress;
  1232. // some downloads may hit time limits -> lets find out these limits, stop the process a moment before and return an error message
  1233. // search for PHP time limits
  1234. $max_execution_time = intval(ini_get('max_execution_time'));
  1235. podPress_var_dump('podPress_downloadFile - max_execution_time: '.$max_execution_time);
  1236. $safety = 2; // seconds
  1237. // get the OS type on the server
  1238. $hairstick = php_uname();
  1239. $is_windows = stristr( $hairstick, 'win' );
  1240. // search for CPU time limits
  1241. if (FALSE === $is_windows) {
  1242. @exec('ulimit -t', $output) or $output[0] = 10;
  1243. $int_output = intval($output[0]);
  1244. podPress_var_dump('podPress_downloadFile - ulimit -t: '. $output[0].' - (int): '.$int_output);
  1245. if (is_string($output[0]) AND 10 > $int_output) {
  1246. $max_time = max(($safety+2), $max_execution_time); // if max_execution_time is somehow weird small
  1247. } else {
  1248. $max_time = min(intval($output[0]), $max_execution_time); // if the CPU limit is bigger than 10 then take the max. of the CPU limit and the max_execution_time
  1249. }
  1250. } else {
  1251. $max_time = $max_execution_time; // on Windows systems
  1252. }
  1253. podPress_var_dump('podPress_downloadFile - time limit: '.$max_time);
  1254. $aborttimelimit = FALSE;
  1255. $aborthttperror = FALSE;
  1256. $start_time = array_sum(explode(chr(32), microtime()));
  1257. podPress_var_dump('podPress_downloadFile - given URL: '.$uriFileName);
  1258. $uriFileName = podPress_ResolveReDirects($uriFileName);
  1259. $aURL = @parse_url($uriFileName);
  1260. if ( $aURL['scheme'] != 'http' ) {
  1261. podPress_var_dump('podPress_downloadFile - returning - not a http:// URL : '.var_export($aURL, TRUE));
  1262. return;
  1263. }
  1264. $sHost = $aURL['host'];
  1265. $sFilepath = (isset($aURL['path']) ? $aURL['path'] : '/') . (isset($aURL['query']) ? '?' . $aURL['query'] : '');
  1266. // mask white spaces in the file name
  1267. $sFilepath = str_replace(' ', '%20', $sFilepath);
  1268. $nPort = isset($aURL['port']) ? $aURL['port'] : 80;
  1269. if ( function_exists('fsockopen') ) {
  1270. $fpRemote = @fsockopen($sHost, $nPort, $errno, $errstr, 30);
  1271. } else {
  1272. $fpRemote = FALSE;
  1273. }
  1274. if ( FALSE !== $fpRemote ) {
  1275. if ( TRUE === $getHeaders ) {
  1276. podPress_var_dump('podPress_downloadFile - get only the header');
  1277. podPress_var_dump('podPress_downloadFile - ' . $sHost . $sFilepath);
  1278. $sHeaders = "HEAD " . $sFilepath . " HTTP/1.1\r\n";
  1279. $sHeaders .= "Host: ". $sHost . "\r\n";
  1280. $sHeaders .= "Connection: Close\r\n\r\n";
  1281. podPress_var_dump($sHeaders);
  1282. // Sending headers
  1283. fwrite($fpRemote, $sHeaders);
  1284. // Getting back the header information
  1285. $header = '';
  1286. $line = '';
  1287. $continue = true;
  1288. $soFar = 0;
  1289. // Processing the server answer (header) line by line
  1290. while(!feof($fpRemote) && $continue) {
  1291. $line = fgets($fpRemote, 1024);
  1292. $soFar = $soFar+1024;
  1293. if ($limitDownload !== false && $soFar > $limitDownload) {
  1294. $continue = false;
  1295. }
  1296. $header .= $line;
  1297. }
  1298. // Closing the socket
  1299. fclose($fpRemote);
  1300. podPress_var_dump('podPress_downloadFile - (header) before return');
  1301. podPress_var_dump($header);
  1302. return $header;
  1303. } else {
  1304. podPress_var_dump('podPress_downloadFile - download the file');
  1305. podPress_var_dump('podPress_downloadFile - ' . $sHost . $sFilepath);
  1306. $sHeaders = "GET " . $sFilepath . " HTTP/1.1\r\n";
  1307. $sHeaders .= "Host: ". $sHost . "\r\n";
  1308. $sHeaders .= "Connection: Close\r\n\r\n";
  1309. // Sending headers
  1310. fwrite($fpRemote, $sHeaders);
  1311. // determine a temp folder and temp file name
  1312. $ext = podPress_getFileExt($uriFileName);
  1313. $pos = strpos($ext, '?');
  1314. if($pos) {
  1315. $ext = substr($ext, 0, $pos);
  1316. }
  1317. // Trying to write into the servers temp folder. The temp file has to have the media files extension. Because getID3 does not work without it.
  1318. $localtempfilename = @tempnam('/tmp', 'getID3').'.'.$ext;
  1319. if (FALSE == $localtempfilename OR '.'.$ext == $localtempfilename) {
  1320. // If it is not possible to get the temp folder via tempnam() then try to write into the temp folder of podPress
  1321. $podPress->checkWritableTempFileDir();
  1322. $localtempfilename = $podPress->tempfilesystempath.'/podpress_tmp.'.$ext;
  1323. }
  1324. if (!$fp_local = @fopen($localtempfilename, 'wb')) {
  1325. // if it is not possible to open a temp file then return
  1326. // Closing the socket
  1327. fclose($fpRemote);
  1328. return '';
  1329. }
  1330. podPress_var_dump('podPress_downloadFile - (file) localtempfilename: '.$localtempfilename);
  1331. // Getting back header + content
  1332. $continue = true;
  1333. $is_body = false;
  1334. $soFar = 0;
  1335. $line = "";
  1336. $trimmed_line = "";
  1337. $step_time = array_sum(explode(chr(32), microtime()));
  1338. // Processing the server answer (header + content) line by line
  1339. while( !feof($fpRemote) && $continue ) {
  1340. $line = fgets($fpRemote, 1024);
  1341. $soFar = $soFar+1024;
  1342. // some times the answer of the remote server contains a HTTP header which should not be a part of the temp file
  1343. // after the HTTP should always be a empty line which is followed by the remote file - see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4
  1344. if ($is_body) {
  1345. if($limitDownload !== false && $soFar > $limitDownload) {
  1346. $continue = false;
  1347. }
  1348. // write the content of the remote file into the temp file
  1349. fwrite($fp_local, $line);
  1350. } else {
  1351. $trimmed_line = Trim($line);
  1352. // contol the first line (chunk) of the header information
  1353. if ($soFar <= 1024) {
  1354. // check the HTTP status number
  1355. $HTTP_result = preg_match('/HTTP\/[0-9].[0-9] ([1-5][0-9][0-9])/', $trimmed_line, $headerMatches);
  1356. // If the HTTP status is not 200 then something with the filename (or URL) was not ok or something on the server was wrong.
  1357. if (isset($headerMatches[1]) AND '200' != $headerMatches[1]) {
  1358. podPress_var_dump('podPress_downloadFile - aborting - HTTP status: ' . $headerMatches[1]);
  1359. $aborthttperror = TRUE;
  1360. $continue = FALSE;
  1361. }
  1362. }
  1363. if ( FALSE !== empty($trimmed_line) ) {
  1364. // if the line is empty then the last line of the HTTP header of the server answer and the file content begins
  1365. $is_body = true;
  1366. }
  1367. }
  1368. $step_time = array_sum(explode(chr(32), microtime()));
  1369. if (($step_time - $start_time) >= ($max_time-$safety)) {
  1370. $continue = FALSE;
  1371. $aborttimelimit = TRUE;
  1372. podPress_var_dump('podPress_downloadFile - aborting download because of a time limit');
  1373. }
  1374. }
  1375. // Closing the temp file
  1376. fclose($fp_local);
  1377. // Closing the socket
  1378. fclose($fpRemote);
  1379. podPress_var_dump('podPress_downloadFile - (file) before return');
  1380. // return the name of the temp file
  1381. return $localtempfilename;
  1382. }
  1383. } else {
  1384. if ( TRUE === $getHeaders ) {
  1385. podPress_var_dump('podPress_downloadFile - fpRemote = false | getHeaders = true');
  1386. if ( TRUE == function_exists('curl_init') ) {
  1387. $ch = curl_init($uriFileName);
  1388. // make sure we get the header
  1389. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  1390. // make it a http HEAD request
  1391. curl_setopt($ch, CURLOPT_NOBODY, TRUE);
  1392. // add useragent
  1393. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
  1394. //Tell curl to write the response to a variable
  1395. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  1396. // The maximum number of seconds to allow cURL to wait for a connection.
  1397. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, min(10, $max_time-$safety));
  1398. // The maximum number of seconds to allow cURL functions to execute.
  1399. curl_setopt($ch, CURLOPT_TIMEOUT, ($max_time-$safety));
  1400. // Tell curl to stop when it encounters an error
  1401. curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
  1402. $content = curl_exec($ch);
  1403. podPress_var_dump('podPress_downloadFile - cURL HTTP code: ' . var_export(curl_getinfo($ch, CURLINFO_HTTP_CODE), TRUE));
  1404. // Check if any error occured
  1405. if ( !curl_errno($ch) ) {
  1406. $bytes = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
  1407. $total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
  1408. podPress_var_dump('File size: ' . $bytes . ' bytes');
  1409. podPress_var_dump('Took ' . $total_time . ' seconds to send a request to ' . $url);
  1410. //clearstatcache();
  1411. }
  1412. @curl_close($ch);
  1413. podPress_var_dump($content);
  1414. return $content;
  1415. } else {
  1416. podPress_var_dump('podPress_downloadFile - cUrl is not available');
  1417. return '';
  1418. }
  1419. } else {
  1420. podPress_var_dump('podPress_downloadFile - fpRemote = false | getHeaders = false');
  1421. if ( TRUE == function_exists('curl_init') ) {
  1422. // determine a temp folder and temp file name
  1423. $ext = podPress_getFileExt($uriFileName);
  1424. $pos = strpos($ext, '?');
  1425. if($pos) {
  1426. $ext = substr($ext, 0, $pos);
  1427. }
  1428. // Trying to write into the servers temp folder. The temp file has to have the media files extension. Because getID3 does not work without it.
  1429. $localtempfilename = @tempnam('/tmp', 'getID3').'.'.$ext;
  1430. if (FALSE == $localtempfilename OR '.'.$ext == $localtempfilename) {
  1431. // If it is not possible to get the temp folder via tempnam() then try to write into the temp folder of podPress
  1432. $podPress->checkWritableTempFileDir();
  1433. $localtempfilename = $podPress->tempfilesystempath.'/podpress_tmp.'.$ext;
  1434. }
  1435. if (!$fp_local = @fopen($localtempfilename, 'wb')) {
  1436. // if it is not possible to open a temp file then return
  1437. podPress_var_dump('podPress_downloadFile - (file) it is not possible to open a temp file');
  1438. return '';
  1439. }
  1440. podPress_var_dump('podPress_downloadFile - (file) localtempfilename: '.$localtempfilename);
  1441. // starting cURL
  1442. $ch = curl_init($uriFileName);
  1443. podPress_var_dump('podPress_downloadFile - cURL HTTP code:');
  1444. podPress_var_dump( curl_getinfo($ch, CURLINFO_HTTP_CODE) );
  1445. // make sure we get the header
  1446. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  1447. // make it a http GET request
  1448. curl_setopt($ch, CURLOPT_NOBODY, FALSE);
  1449. curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
  1450. // add useragent
  1451. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
  1452. if ( FALSE !== $limitDownload ) {
  1453. podPress_var_dump('podPress_downloadFile - download only that part: 0-'.$limitDownload);
  1454. curl_setopt($ch, CURLOPT_RANGE, '0-'.$limitDownload);
  1455. }
  1456. // Do not put the response into a variable. (Put it into a file.)
  1457. curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
  1458. // the target file (handle) for the download
  1459. curl_setopt($ch, CURLOPT_FILE, $fp_local);
  1460. // The maximum number of seconds to allow cURL to wait for a connection.
  1461. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, min(10, $max_time-$safety));
  1462. // The maximum number of seconds to allow cURL functions to execute.
  1463. curl_setopt($ch, CURLOPT_TIMEOUT, ($max_time-$safety));
  1464. // Tell curl to stop when it encounters an error
  1465. curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
  1466. @curl_exec($ch);
  1467. // If the HTTP status is not 200 then something with the filename (or URL) was not ok or something on the server was wrong.
  1468. $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  1469. if ( '200' != $http_code ) {
  1470. podPress_var_dump('podPress_downloadFile - aborting - HTTP status: ' . $http_code);
  1471. }
  1472. // Check if any error occured
  1473. if ( !curl_errno($ch) ) {
  1474. $bytes = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
  1475. $total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
  1476. podPress_var_dump('File size: ' . $bytes . ' bytes');
  1477. podPress_var_dump('Took ' . $total_time . ' seconds to send a request to ' . $url);
  1478. //clearstatcache();
  1479. }
  1480. @curl_close($ch);
  1481. // Closing the temp file
  1482. fclose($fp_local);
  1483. return $localtempfilename;
  1484. } else {
  1485. podPress_var_dump('podPress_downloadFile - cUrl is not available');
  1486. return '';
  1487. }
  1488. }
  1489. }
  1490. }
  1491. function podPress_getFileSize($mediafile) {
  1492. GLOBAL $podPress;
  1493. podPress_var_dump('start of the file size retrieval');
  1494. if($podPress->settings['enablePodangoIntegration']) {
  1495. if(substr($mediafile, 0, strlen('Podango:')) == 'Podango:') {
  1496. $fileNameParts = explode(':', $mediafile);
  1497. $mediafile = 'http://download.podango.com/mediatracker/555/'.$fileNameParts[3].'/'.$fileNameParts[4];
  1498. }
  1499. }
  1500. podPress_var_dump('podPress_getFileSize - media file: '.$mediafile);
  1501. $systemFileName = $podPress->convertPodcastFileNameToSystemPath($mediafile);
  1502. if(file_exists($systemFileName)) {
  1503. $filesize = filesize($systemFileName);
  1504. podPress_var_dump('end of the file size retrieval - (local file) file size: '.$filesize);
  1505. return $filesize;
  1506. }
  1507. // if it is a remote file then get the file size from the header information:
  1508. $uriFileName = $podPress->convertPodcastFileNameToValidWebPath($mediafile);
  1509. // Request only the HTTP header (second parameter is TRUE)
  1510. $sRemoteHeaders = podPress_downloadFile($uriFileName, TRUE);
  1511. // check the HTTP status number
  1512. $HTTP_result = preg_match('/HTTP\/[0-9].[0-9] ([1-5][0-9][0-9])/', $sRemoteHeaders, $headerMatches);
  1513. // If the HTTP status is not 200 then something with the filename (or URL) was not ok or something on the server was wrong. It is possible that the HTTP header contain in such cases sometimes a content-length. But if the status is not 200 then is most likely not the length of the media file.
  1514. if (isset($headerMatches[1]) AND '200' != $headerMatches[1]) {
  1515. podPress_var_dump('end of the file size retrieval - unable to retrieve the file size - '. $HTTP_result . ' - ' . $headerMatches[0]);
  1516. return;
  1517. } else {
  1518. // Parsing the headers
  1519. preg_match('/Content-Length:\s([0-9].+?)\s/', $sRemoteHeaders, $aMatches);
  1520. if ( isset($aMatches[1]) ) {
  1521. podPress_var_dump('end of the file size retrieval - file size: '.$aMatches[1]);
  1522. return (int)$aMatches[1];
  1523. } else {
  1524. podPress_var_dump('end of the file size retrieval - unable to retrieve the file size');
  1525. return;
  1526. }
  1527. }
  1528. }
  1529. /**
  1530. * podPress_var_dump - writes a variable into a log file in the podPress folder (helper function - only for development purposes)
  1531. *
  1532. * @package podPress
  1533. * @since 8.8.5 RC 2
  1534. *
  1535. * @param mixed $var
  1536. */
  1537. function podPress_var_dump($var) {
  1538. if ( defined( 'PODPRESS_DEBUG_LOG' ) AND TRUE === constant( 'PODPRESS_DEBUG_LOG' ) ) {
  1539. // write the out put to the log file
  1540. $filename = PODPRESS_DIR.'/podpress_log.dat';
  1541. if ( is_file($filename) ) {
  1542. $result = @chmod($filename, 0777);
  1543. if (FALSE === $result) {
  1544. return sprintf(__('This PHP script has not the permission to use chmod for the %1$s file.', 'podpress'), $filename);
  1545. }
  1546. if ( (filesize($filename)/1024) > 100 ) { // delete the Logfile if it is bigger than 100 kByte
  1547. $result = @unlink($filename);
  1548. if (FALSE === $result) {
  1549. $returnmsg = sprintf(' '.__('This PHP script has not the permission to delete the %1$s file (unlink).', 'podpress'), $filename);
  1550. }
  1551. }
  1552. }
  1553. $handle = @fopen($filename, "a");
  1554. if ( FALSE !== $handle ) {
  1555. //@fputs($handle, '['.date('j.m.Y - H:i:s', time()).'] '.var_export($var, TRUE)."\n");
  1556. @fputs($handle, '['.date('j.m.Y - H:i:s').'] '.var_export($var, TRUE)."\n");
  1557. $status = @fclose($handle);
  1558. $returnmsg .= '';
  1559. } else {
  1560. $returnmsg .= sprintf(__('This PHP script has not the permission to use create or open the %1$s file for writing (fopen).', 'podpress'), $filename);
  1561. }
  1562. if ( is_file($filename) ) {
  1563. $result = @chmod($filename, 0644);
  1564. if (FALSE === $result) {
  1565. $returnmsg = sprintf(' '.__('This PHP script has not the permission to use chmod for the %1$s file.', 'podpress'), $filename);
  1566. }
  1567. }
  1568. return $returnmsg;
  1569. }
  1570. }
  1571. /** podPress_get_real_url - demasks an URL which is masked with the podPress stats scheme
  1572. * @package podPress
  1573. * @since 8.8.10.3 beta 5
  1574. * @param mixed $url - the masked url
  1575. * @param mixed $print - print (TRUE) or return the result (FALSE)
  1576. * @return string - the real URL
  1577. */
  1578. function podPress_get_real_url($url, $count = TRUE, $print = TRUE) {
  1579. $requested = parse_url($url);
  1580. $requested = $requested['path'];
  1581. $realURL = 'false';
  1582. $pos = 0;
  1583. if ( $pos = strpos($requested, 'podpress_trac') ) {
  1584. if ( $pos == 0 ) {
  1585. $pos = strpos($requested, 'podpress_trac');
  1586. }
  1587. $pos = $pos+14;
  1588. if ( substr($requested, $pos, 1) == '/' ) {
  1589. $pos = $pos+1;
  1590. }
  1591. $requested = substr($requested, $pos);
  1592. $parts = explode('/', $requested);
  1593. if ( count($parts) == 4 ) {
  1594. $postID = $parts[1];
  1595. $mediaNum = $parts[2];
  1596. $filename = rawurlencode($parts[3]);
  1597. $method = $parts[0];
  1598. $allowedMethods = array('feed', 'play', 'web');
  1599. $realSysPath = false;
  1600. $statID = false;
  1601. if ( in_array($method, $allowedMethods) && is_numeric($postID) && is_numeric($mediaNum) ) {
  1602. $mediaFiles = podPress_get_post_meta($postID, '_podPressMedia', true);
  1603. if (isset($mediaFiles[$mediaNum]) ) {
  1604. if ( $mediaFiles[$mediaNum]['URI'] == urldecode($filename) ) {
  1605. $realURL = $filename;
  1606. } elseif ( podPress_getFileName($mediaFiles[$mediaNum]['URI']) == urldecode($filename) ) {
  1607. $realURL = $mediaFiles[$mediaNum]['URI'];
  1608. } elseif ( podPress_getFileName($mediaFiles[$mediaNum]['URI_torrent']) == urldecode($filename) ) {
  1609. $realURL = $mediaFiles[$mediaNum]['URI_torrent'];
  1610. }
  1611. }
  1612. }
  1613. if ( TRUE === $count ) {
  1614. $badextensions = array('.smi', '.jpg', '.png', '.gif');
  1615. if ($filename && !in_array(strtolower(substr($filename, -4)), $badextensions)) {
  1616. global $podPress;
  1617. podPress_StatCounter($postID, $filename, $method);
  1618. if ( $podPress->settings['statLogging'] == 'Full' || $podPress->settings['statLogging'] == 'FullPlus' ) {
  1619. $statID = podPress_StatCollector($postID, $filename, $method);
  1620. }
  1621. }
  1622. }
  1623. //~ $realSysPath = $podPress->convertPodcastFileNameToSystemPath(str_replace('%20', ' ', $realURL));
  1624. //~ if (FALSE === $realSysPath) {
  1625. //~ $realSysPath = $podPress->TryToFindAbsFileName(str_replace('%20', ' ', $realURL));
  1626. //~ }
  1627. //~ $realURL = $podPress->convertPodcastFileNameToValidWebPath($realURL);
  1628. //~ if ($podPress->settings['enable3rdPartyStats'] == 'PodTrac') {
  1629. //~ $realURL = str_replace(array('ftp://', 'http://', 'https://'), '', $realURL);
  1630. //~ $realURL = $podPress->podtrac_url.$realURL;
  1631. //~ } elseif( strtolower($podPress->settings['enable3rdPartyStats']) == 'blubrry' && !empty($podPress->settings['statBluBrryProgramKeyword'])) {
  1632. //~ $realURL = str_replace('http://', '', $realURL);
  1633. //~ $realURL = $podPress->blubrry_url.$podPress->settings['statBluBrryProgramKeyword'].'/'.$realURL;
  1634. //~ }
  1635. }
  1636. }
  1637. if ( TRUE === $print ) {
  1638. echo $realURL;
  1639. } else {
  1640. return $realURL;
  1641. }
  1642. }
  1643. ?>