PageRenderTime 70ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/openfarmtech/weblog-content
PHP | 1350 lines | 1124 code | 141 blank | 85 comment | 120 complexity | c491d2c8103a3f809a082a7f7d5631f2 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.0, LGPL-3.0, BSD-3-Clause, GPL-3.0, LGPL-2.1, AGPL-3.0, CC-BY-SA-3.0

Large files files are truncated, but you can click here to view the full file

  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>Directory Preview:</legend>';
  40. 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;';
  41. /// YAHOO! Podcast is shutdown since 2007 - see, http://en.wikipedia.org/wiki/Yahoo!_Podcasts
  42. //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;';
  43. 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>';
  44. 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>';
  45. 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>';
  46. echo ' '."\n";
  47. echo ' <div id="iTunesPreviewDisplay" style="border: 0;">'."\n";
  48. 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";
  49. echo ' <table width="100%" cellspacing="2" cellpadding="5" class="editform" style="background-color:#8CA9CB;">'."\n";
  50. echo ' <tr valign="top">'."\n";
  51. echo ' <td colspan="3">'."\n";
  52. echo ' <b><font size="+1"><span id="iTunesBlognamePreview"></span></font></b><br/>'."\n";
  53. echo ' </td>'."\n";
  54. echo ' </tr>'."\n";
  55. echo ' <tr valign="top">'."\n";
  56. echo ' <td width="1%">'."\n";
  57. echo ' <img id="iTunesPreviewImage" width="175" height="175" alt="Podcast Image" src=""/>'."\n";
  58. echo ' </td>'."\n";
  59. echo ' <td align="left">'."\n";
  60. echo ' <span id="itunesAuthorPreview" style="font-weight: bold;"></span><br/><br/>'."\n";
  61. echo ' <span style="font-size: small;">'."\n";
  62. echo ' Category: <span id="itunesCategoryPreview"></span><br/>'."\n";
  63. echo ' Language: <span id="iTunesRssLanguagePreview">English</span><br/>'."\n";
  64. echo ' Total: n episodes<br/><br/>'."\n";
  65. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_subscribebutton.png" border="0" alt="iTunesSubscriptions" /> '."\n";
  66. echo ' </span>'."\n";
  67. echo ' </td>'."\n";
  68. echo ' <td rowspan="3" width="1%">'."\n";
  69. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_seeallpodcasts.png" border="0" alt="iTunesSeeAllPodcasts" /> '."\n";
  70. echo ' <br/><br/>'."\n";
  71. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_alsosubcribedto.png" border="0" alt="iTunesAlsoSubscribeTo" /> '."\n";
  72. echo ' </td>'."\n";
  73. echo ' </tr>'."\n";
  74. echo ' <tr valign="top">'."\n";
  75. echo ' <td colspan="2">'."\n";
  76. echo ' <b><font size="+1" color="#163B6A">Podcast Description</font></b><br/><br/>'."\n";
  77. echo ' <span id="itunesDescriptionPreview" style="font-size: small;"></span>'."\n";
  78. echo ' </td>'."\n";
  79. echo ' </tr>'."\n";
  80. echo ' <tr valign="top">'."\n";
  81. echo ' <td colspan="2" bgcolor="#8DAACC">'."\n";
  82. echo ' <table width="100%" bgcolor="#8DAACC">'."\n";
  83. echo ' <tr>'."\n";
  84. echo ' <td align="left">'."\n";
  85. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_l_reviews.png" border="0" alt="iTunesReviews" /> '."\n";
  86. echo ' </td>'."\n";
  87. echo ' <td align="right">'."\n";
  88. echo ' <img src="'.podPress_url().'images/directoryPreview_iTunes_r_reviews.png" border="0" alt="iTunesReviews" /> '."\n";
  89. echo ' </td>'."\n";
  90. echo ' </tr>'."\n";
  91. echo ' </table>'."\n";
  92. echo ' </td>'."\n";
  93. echo ' </tr>'."\n";
  94. echo ' </table>'."\n";
  95. echo ' </div>'."\n";
  96. echo ' <div id="YahooPreviewDisplay" style="display: none;">'."\n";
  97. 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";
  98. echo ' <div style="width: 100%; border: 1px solid grey;">'."\n";
  99. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0">'."\n";
  100. echo ' <tr valign="top">'."\n";
  101. echo ' <td colspan="3">'."\n";
  102. echo ' <b><font size="+1" color="#669900">Series Information: <span id="YahooBlognamePreview"></span></font></b><br/><br/>'."\n";
  103. echo ' </td>'."\n";
  104. echo ' </tr>'."\n";
  105. echo ' <tr valign="top">'."\n";
  106. echo ' <td width="1%" rowspan="2">'."\n";
  107. echo ' <img id="YahooPreviewImage" width="175" height="175" alt="Podcast Image" src=""/><br/><br/>'."\n";
  108. echo ' <img src="'.podPress_url().'images/directoryPreview_yahoo_buttons.png" border="0" alt="YahooButtons" /> '."\n";
  109. echo ' </td>'."\n";
  110. echo ' <td colspan="2">'."\n";
  111. echo ' <span id="YahooDescriptionPreview" style="font-size: small;"></span>'."\n";
  112. echo ' </td>'."\n";
  113. echo ' </tr>'."\n";
  114. echo ' <tr valign="top">'."\n";
  115. echo ' <td align="left">'."\n";
  116. echo ' <font size="+1" color="#669900">Details</font><br/>'."\n";
  117. echo ' Episodes: N<br/>'."\n";
  118. echo ' Web Site: <font color="#2597D6">'.get_option('siteurl').'</font><br/>'."\n";
  119. echo ' RSS: <span id="YahooFeedURLPreview" style="color: #2597D6;"></span><br/>'."\n";
  120. echo ' Author: <span id="YahooAuthorPreview"></span><br/>'."\n";
  121. echo ' Language: <span id="YahooRssLanguagePreview">English</span><br/>'."\n";
  122. echo ' Copyright: --<br/>'."\n";
  123. echo ' Published: whatever date<br/>'."\n";
  124. echo ' </td>'."\n";
  125. echo ' <td align="left">'."\n";
  126. echo ' <font size="+1" color="#669900">Ratings</font><br/>'."\n";
  127. echo ' Be the first to rate!<br/><br/>'."\n";
  128. echo ' <b>Rate it:</b><br/>'."\n";
  129. echo ' <img src="'.podPress_url().'images/directoryPreview_yahoo_stars.png" border="0" alt="YahooStars" /> '."\n";
  130. echo ' <br/><font color="#2597D6">Write a Review</font><br/>'."\n";
  131. echo ' </td>'."\n";
  132. echo ' </tr>'."\n";
  133. echo ' </table>'."\n";
  134. echo ' </div>'."\n";
  135. echo ' </div>'."\n";
  136. echo ' <div id="PodcastAlleyPreviewDisplay" style="display: none; border: 0;">'."\n";
  137. 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";
  138. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFFFFF;">'."\n";
  139. echo ' <tr valign="top">'."\n";
  140. echo ' <td width="5%">'."\n";
  141. echo ' <img src="'.podPress_url().'images/directoryPreview_PCA_left.png" border="0" alt="PCA Left" /> '."\n";
  142. echo ' </td>'."\n";
  143. echo ' <td width="90%">'."\n";
  144. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#F2F2F2;">'."\n";
  145. echo ' <tr valign="top">'."\n";
  146. echo ' <td class="podPress_statscell" valign="top" width="140">'."\n";
  147. echo ' <table class="podPress_statstable" width="100%" border="0" cellspacing="0" cellpadding="0">'."\n";
  148. echo ' <tr>'."\n";
  149. echo ' <td class="podPress_statshead">Podcast Stats</td>'."\n";
  150. echo ' </tr>'."\n";
  151. echo ' <tr>'."\n";
  152. echo ' <td class="podPress_linkscell">'."\n";
  153. echo ' <p><span class="podPress_captionstats">GENRE: </span> <span id="PCACategoryPreview"></span><br/>'."\n";
  154. echo ' <span class="podPress_captionstats">COMMENTS:</span> 0<br/>'."\n";
  155. echo ' <span class="podPress_captionstats">MONTHLY VOTES:</span> 0<br/>'."\n";
  156. echo ' <span class="podPress_captionstats">OVERALL VOTES:</span> 0<br/>'."\n";
  157. echo ' <span class="podPress_captionstats">MEMBER: </span>1/2000<br/>'."\n";
  158. echo ' <span class="podPress_captionstats">MONTHLY RANK:</span><br/>Not Yet Ranked<br/>'."\n";
  159. echo ' <br/><img src="'.podPress_url().'images/directoryPreview_PCA_buttons.png" border="0" alt="PCAButtons" /> '."\n";
  160. echo ' </td>'."\n";
  161. echo ' </tr>'."\n";
  162. echo ' </table>'."\n";
  163. echo ' </td>'."\n";
  164. echo ' <td class="podPress_desccell" valign="top">'."\n";
  165. echo ' <font size="3" color="#666666"><b><span id="PCABlognamePreview"></span></b></font><br/>'."\n";
  166. echo ' <span style="color: #666666;" id="PCADescriptionPreview"></span>'."\n";
  167. echo ' </td>'."\n";
  168. echo ' </tr>'."\n";
  169. echo ' </table>'."\n";
  170. echo ' </td>'."\n";
  171. echo ' <td width="5%">'."\n";
  172. echo ' <img src="'.podPress_url().'images/directoryPreview_PCA_right.png" border="0" alt="PCA Right" /> '."\n";
  173. echo ' </td>'."\n";
  174. echo ' </tr>'."\n";
  175. echo ' </table>'."\n";
  176. echo ' </div>'."\n";
  177. echo ' <div id="PodcastReadyPreviewDisplay" style="display: none;">'."\n";
  178. 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";
  179. echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#CDE4A9">'."\n";
  180. echo ' <tr valign="top">'."\n";
  181. echo ' <td width="200" align="center">'."\n";
  182. echo ' <br/><img id="PodcastReadyPreviewImage" width="175" height="175" alt="Podcast Image" src=""/><br/>'."\n";
  183. echo ' <img src="'.podPress_url().'images/directoryPreview_PodcastReady_buttons.png" border="0" alt="PodcastReadyButtons" /><br/>'."\n";
  184. echo ' </td>'."\n";
  185. echo ' <td>'."\n";
  186. echo ' <br/><b><font size="+1" color="#466B90">Detail for <span id="PodcastReadyBlognamePreview"></span></font></b><br/><br/>'."\n";
  187. echo ' <span id="PodcastReadyDescriptionPreview" style="font-size: small;"></span><br/>'."\n";
  188. echo ' <b>Filed Under:</b> <span id="PodcastReadyCategoryPreview" style="color: #466B90;"></span><br/>'."\n";
  189. echo ' <b>Media Type:</b> MP3<br/><br/>'."\n";
  190. echo ' <img src="'.podPress_url().'images/directoryPreview_PodcastReady_listeners.png" border="0" alt="PodcastReadyOtherPeople" /> '."\n";
  191. echo ' </td>'."\n";
  192. echo ' </tr>'."\n";
  193. echo ' </table>'."\n";
  194. echo ' </div>'."\n";
  195. echo '<div id="BlubrryPreviewDisplay" style="display: none; border: 0;">'."\n";
  196. 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";
  197. echo ' <table width="100%" style="background-color: #F2CCFF; color: #003366; font-size:14px; font-weight:bold;" border="0" cellpadding="2" cellspacing="0">'."\n";
  198. echo ' <tr>'."\n";
  199. echo ' <td style="font-size:16px; font-weight:bold;" id="BlubrryBlognamePreview">TITLE OF PODCAST HERE</td>'."\n";
  200. echo ' <td style="text-decoration:underline; text-align:right; font-weight:bold;">Visit Podcast Home Page</td>'."\n";
  201. echo ' </tr>'."\n";
  202. echo ' </table>'."\n";
  203. echo ' <table width="100%" style="background-color: #D2E9FF; color: #003366; font-size:12px;" border="0" cellpadding="2" cellspacing="0">'."\n";
  204. echo ' <tr>'."\n";
  205. echo ' <td valign="top" style="width:230px;">'."\n";
  206. echo ' <table width="220" border="0" cellspacing="0" cellpadding="0" style="padding-left: 6px; padding-top: 6px;">'."\n";
  207. echo ' <tr>'."\n";
  208. echo ' <td width="100" height="100" align="left" valign="top"><img id="BlubrryPreviewImage" width="90" height="90" alt="Podcast Image" src=""/></td>'."\n";
  209. echo ' <td width="120" valign="top"><div id="BlubrryAuthorPreview" style="font-weight: bold;">AUTHOR NAME</div>'."\n";
  210. echo ' <img src="'.podPress_url().'images/directoryPreview_Blubrry_buttons.png" width="64" height="52" /></strong></td>'."\n";
  211. echo ' </tr>'."\n";
  212. echo ' <tr>'."\n";
  213. echo ' <td height="28" colspan="2" valign="top" style="font-size: 14px; font-weight: bold; text-decoration:underline;">Visit Podcast Home Page</td>'."\n";
  214. echo ' </tr>'."\n";
  215. echo ' <tr>'."\n";
  216. echo ' <td height="36" colspan="2" valign="top" style="font-size: 16px; font-weight: bold; color: black;">Current Episodes</td>'."\n";
  217. echo ' </tr>'."\n";
  218. echo ' <tr>'."\n";
  219. echo ' <td colspan="2"><div style="color:#9933D5; font-weight: bold; font-size: 14px;">Latest Podcast Post Title</div>'."\n";
  220. 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";
  221. echo ' <img src="'.podPress_url().'images/directoryPreview_Blubrry_buttons_episode.png" />'."\n";
  222. echo ' </td>'."\n";
  223. echo ' </tr>'."\n";
  224. echo ' </table>'."\n";
  225. echo ' </td>'."\n";
  226. echo ' <td valign="top" style="padding-left: 10px; padding-top: 10px;">'."\n";
  227. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Description</div>'."\n";
  228. echo ' <div style="font-size: 12px; padding-bottom: 5px;" id="BlubrryDescriptionPreview">DESCRIPTION OF PODCAST</div>'."\n";
  229. echo ' <div style="text-align:right; padding-bottom: 10px;"><img src="'.podPress_url().'images/directoryPreview_Blubrry_syndication.png" /></div>'."\n";
  230. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Tags</div>'."\n";
  231. echo ' <div style="padding-bottom: 10px;">mightyseek podpress awesome wordpress plugin</div>'."\n";
  232. echo ' <div style="font-size: 18px; font-weight: bold; padding-bottom: 10px;">Friends</div>'."\n";
  233. 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";
  234. echo ' </td>'."\n";
  235. echo ' </tr>'."\n";
  236. echo ' </table>'."\n";
  237. echo '</div>'."\n";
  238. echo ' </fieldset>'."\n";
  239. }
  240. /* Utility Functions */
  241. function podPress_getCapList($roles = true, $kill_levels = true){
  242. global $wp_roles;
  243. // Get Role List
  244. foreach($wp_roles->role_objects as $key => $role) {
  245. foreach($role->capabilities as $cap => $grant) {
  246. $capnames[$cap] = $cap;
  247. }
  248. }
  249. if ($caplist = get_option('caplist')) {
  250. $capnames = array_unique(array_merge($caplist, $capnames));
  251. }
  252. $capnames = apply_filters('capabilities_list', $capnames);
  253. if(!is_array($capnames)) $capnames = array();
  254. $capnames = array_unique($capnames);
  255. sort($capnames);
  256. //Filter out the level_x caps, they're obsolete
  257. if($kill_levels) {
  258. $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'));
  259. }
  260. //Filter out roles if required
  261. if (!$roles) {
  262. foreach ($wp_roles->get_names() as $role) {
  263. $key = array_search($role, $capnames);
  264. if ($key !== false && $key !== null) { //array_search() returns null if not found in 4.1
  265. unset($capnames[$key]);
  266. }
  267. }
  268. }
  269. return $capnames;
  270. }
  271. function podPress_maybe_create_table($table_name, $create_ddl) {
  272. GLOBAL $wpdb;
  273. foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
  274. if ($table == $table_name) {
  275. return true;
  276. }
  277. }
  278. //didn't find it try to create it.
  279. $q = $wpdb->query($create_ddl);
  280. // we cannot directly tell that whether this succeeded!
  281. foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
  282. if ($table == $table_name) {
  283. return true;
  284. }
  285. }
  286. return false;
  287. }
  288. function podPress_maybe_add_column($table_name, $column_name, $create_ddl) {
  289. GLOBAL $wpdb, $debug;
  290. foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
  291. if ($debug) echo("checking $column == $column_name<br />");
  292. if ($column == $column_name) {
  293. return true;
  294. }
  295. }
  296. //didn't find it try to create it.
  297. $q = $wpdb->query($create_ddl);
  298. // we cannot directly tell that whether this succeeded!
  299. foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
  300. if ($column == $column_name) {
  301. return true;
  302. }
  303. }
  304. return false;
  305. }
  306. function podPress_mediaOptions() {
  307. $options = array();
  308. reset($options);
  309. $options['audio_mp3'] = __('MP3 - Standard Audio (iPod Compliant)', 'podpress');
  310. $options['audio_ogg'] = __('OGG - Ogg Vorbis Audio', 'podpress');
  311. $options['audio_m4a'] = __('M4A - Enhanced Audio (iPod Compliant)', 'podpress');
  312. $options['audio_mp4'] = __('MP4 - Enhanced Audio (iPod Compliant)', 'podpress');
  313. $options['audio_aa'] = __('AA - Audible Encoded (iPod Compliant)', 'podpress');
  314. $options['audio_m3u'] = __('M3U - Streaming Audio', 'podpress');
  315. $options['video_mp4'] = __('MP4 - Video (iPod Compliant)', 'podpress');
  316. $options['video_m4v'] = __('M4V - Video (iPod Compliant)', 'podpress');
  317. $options['video_mov'] = __('MOV - Video (iPod Compliant)', 'podpress');
  318. $options['video_qt'] = __('QT - Video (iPod Compliant)', 'podpress');
  319. $options['video_avi'] = __('AVI - Video', 'podpress');
  320. $options['video_mpg'] = __('MPG - Video', 'podpress');
  321. $options['video_asf'] = __('ASF - Video', 'podpress');
  322. $options['video_wmv'] = __('WMV - Video', 'podpress');
  323. $options['audio_wma'] = __('WMA - Audio', 'podpress');
  324. $options['video_flv'] = __('FLV - Flash Video', 'podpress');
  325. $options['video_swf'] = __('SWF - Flash content', 'podpress');
  326. $options['video_ogv'] = __('OGV - Ogg Theora video', 'podpress');
  327. $options['ebook_pdf'] = __('PDF - eBook', 'podpress');
  328. $options['embed_youtube'] = __('YouTube - Video', 'podpress');
  329. $options['misc_torrent'] = __('Torrent - P2P', 'podpress');
  330. $options['misc_other'] = __('??? - Other', 'podpress');
  331. foreach ($options as $key => $value) {
  332. echo '<option value="'.$key.'">'.$value.'</option>'."\n";
  333. }
  334. }
  335. function podPress_videoDimensionOptions($selected='320:240') {
  336. $dimensions = array();
  337. reset($dimensions);
  338. $dimensions_noimage = array();
  339. reset($dimensions_noimage);
  340. $dimensions['160:120'] = '160 x 120';
  341. $dimensions['320:240'] = '320 x 240';
  342. $dimensions['480:320'] = '480 x 320';
  343. $dimensions['640:480'] = '640 x 480';
  344. $dimensions['720:540'] = '720 x 540';
  345. $dimensions['450:252'] = '450 x 252 [16:9 - 1.78:1]';
  346. $dimensions['480:260'] = '480 x 260 [16:9 - 1.85:1]';
  347. $dimensions['720:405'] = '720 x 405 [16:9 - 1.78:1]';
  348. $dimensions['720:390'] = '720 x 390 [16:9 - 1.85:1]';
  349. echo '<optgroup label="'.__('Common Dimensions', 'podpress').'">'."\n";
  350. foreach ($dimensions as $key => $value) {
  351. if ($key == $selected) {
  352. $selected_str =' selected="selected"';
  353. } else {
  354. $selected_str ='';
  355. }
  356. echo '<option value="'.$key.'"'.$selected_str.'>'.$value.'</option>'."\n";
  357. }
  358. echo '</optgroup>'."\n";
  359. $dimensions_noimage['160:0'] = __('width: 160 px', 'podpress');
  360. $dimensions_noimage['320:0'] = __('width: 320 px', 'podpress');
  361. $dimensions_noimage['480:0'] = __('width: 480 px', 'podpress');
  362. $dimensions_noimage['640:0'] = __('width: 640 px', 'podpress');
  363. $dimensions_noimage['720:0'] = __('width: 720 px', 'podpress');
  364. echo '<optgroup label="'.__('player without preview image', 'podpress').'">'."\n";
  365. foreach ($dimensions_noimage as $key => $value) {
  366. if ($key == $selected) {
  367. $selected_str =' selected="selected"';
  368. } else {
  369. $selected_str ='';
  370. }
  371. echo '<option value="'.$key.'"'.$selected_str.'>'.$value.'</option>'."\n";
  372. }
  373. echo '</optgroup>'."\n";
  374. }
  375. function podPress_itunesLanguageArray() {
  376. $langs = array();
  377. $langs['af'] = 'Afrikaans';
  378. $langs['sq'] = 'Albanian';
  379. $langs['eu'] = 'Basque';
  380. $langs['be'] = 'Belarusian';
  381. $langs['bg'] = 'Bulgarian';
  382. $langs['ca'] = 'Catalan';
  383. $langs['zh-cn'] = 'Chinese (Simplified)';
  384. $langs['zh-tw'] = 'Chinese (Traditional)';
  385. $langs['hr'] = 'Croatian';
  386. $langs['cs'] = 'Czech';
  387. $langs['da'] = 'Danish';
  388. $langs['nl'] = 'Dutch';
  389. $langs['nl-be'] = 'Dutch (Belgium)';
  390. $langs['nl-nl'] = 'Dutch (Netherlands)';
  391. $langs['en'] = 'English';
  392. $langs['en-au'] = 'English (Australia)';
  393. $langs['en-bz'] = 'English (Belize)';
  394. $langs['en-ca'] = 'English (Canada)';
  395. $langs['en-ie'] = 'English (Ireland)';
  396. $langs['en-jm'] = 'English (Jamaica)';
  397. $langs['en-nz'] = 'English (New Zealand)';
  398. $langs['en-ph'] = 'English (Phillipines)';
  399. $langs['en-za'] = 'English (South Africa)';
  400. $langs['en-tt'] = 'English (Trinidad)';
  401. $langs['en-gb'] = 'English (United Kingdom)';
  402. $langs['en-us'] = 'English (United States)';
  403. $langs['en-zw'] = 'English (Zimbabwe)';
  404. $langs['et'] = 'Estonian';
  405. $langs['fo'] = 'Faeroese';
  406. $langs['fi'] = 'Finnish';
  407. $langs['fr'] = 'French';
  408. $langs['fr-be'] = 'French (Belgium)';
  409. $langs['fr-ca'] = 'French (Canada)';
  410. $langs['fr-fr'] = 'French (France)';
  411. $langs['fr-lu'] = 'French (Luxembourg)';
  412. $langs['fr-mc'] = 'French (Monaco)';
  413. $langs['fr-ch'] = 'French (Switzerland)';
  414. $langs['gl'] = 'Galician';
  415. $langs['gd'] = 'Gaelic';
  416. $langs['de'] = 'German';
  417. $langs['de-at'] = 'German (Austria)';
  418. $langs['de-de'] = 'German (Germany)';
  419. $langs['de-li'] = 'German (Liechtenstein)';
  420. $langs['de-lu'] = 'German (Luxembourg)';
  421. $langs['de-ch'] = 'German (Switzerland)';
  422. $langs['el'] = 'Greek';
  423. $langs['haw'] = 'Hawaiian';
  424. $langs['hu'] = 'Hungarian';
  425. $langs['is'] = 'Icelandic';
  426. $langs['in'] = 'Indonesian';
  427. $langs['ga'] = 'Irish';
  428. $langs['it'] = 'Italian';
  429. $langs['it-it'] = 'Italian (Italy)';
  430. $langs['it-ch'] = 'Italian (Switzerland)';
  431. $langs['ja'] = 'Japanese';
  432. $langs['ko'] = 'Korean';
  433. $langs['mk'] = 'Macedonian';
  434. $langs['no'] = 'Norwegian';
  435. $langs['pl'] = 'Polish';
  436. $langs['pt'] = 'Portuguese';
  437. $langs['pt-br'] = 'Portuguese (Brazil)';
  438. $langs['pt-pt'] = 'Portuguese (Portugal)';
  439. $langs['ro'] = 'Romanian';
  440. $langs['ro-mo'] = 'Romanian (Moldova)';
  441. $langs['ro-ro'] = 'Romanian (Romania)';
  442. $langs['ru'] = 'Russian';
  443. $langs['ru-mo'] = 'Russian (Moldova)';
  444. $langs['ru-ru'] = 'Russian (Russia)';
  445. $langs['sr'] = 'Serbian';
  446. $langs['sk'] = 'Slovak';
  447. $langs['sl'] = 'Slovenian';
  448. $langs['es'] = 'Spanish';
  449. $langs['es-ar'] = 'Spanish (Argentina)';
  450. $langs['es-bo'] = 'Spanish (Bolivia)';
  451. $langs['es-cl'] = 'Spanish (Chile)';
  452. $langs['es-co'] = 'Spanish (Colombia)';
  453. $langs['es-cr'] = 'Spanish (Costa Rica)';
  454. $langs['es-do'] = 'Spanish (Dominican Republic)';
  455. $langs['es-ec'] = 'Spanish (Ecuador)';
  456. $langs['es-sv'] = 'Spanish (El Salvador)';
  457. $langs['es-gt'] = 'Spanish (Guatemala)';
  458. $langs['es-hn'] = 'Spanish (Honduras)';
  459. $langs['es-mx'] = 'Spanish (Mexico)';
  460. $langs['es-ni'] = 'Spanish (Nicaragua)';
  461. $langs['es-pa'] = 'Spanish (Panama)';
  462. $langs['es-py'] = 'Spanish (Paraguay)';
  463. $langs['es-pe'] = 'Spanish (Peru)';
  464. $langs['es-pr'] = 'Spanish (Puerto Rico)';
  465. $langs['es-es'] = 'Spanish (Spain)';
  466. $langs['es-uy'] = 'Spanish (Uruguay)';
  467. $langs['es-ve'] = 'Spanish (Venezuela)';
  468. $langs['sv'] = 'Swedish';
  469. $langs['sv-fi'] = 'Swedish (Finland)';
  470. $langs['sv-se'] = 'Swedish (Sweden)';
  471. $langs['tr'] = 'Turkish';
  472. $langs['uk'] = 'Ukranian';
  473. return $langs;
  474. }
  475. function podPress_itunesLanguageOptions($current = 'en-us') {
  476. $langs = podPress_itunesLanguageArray();
  477. reset($langs);
  478. foreach ($langs as $key => $value) {
  479. echo '<option value="'.$key.'"';
  480. if($key == $current) {
  481. echo ' selected="selected"';
  482. }
  483. echo '>'.$value.' ['.$key.']</option>'."\n";
  484. }
  485. }
  486. function podPress_itunesCategoryOptions($current = '') {
  487. $cats = array();
  488. if ('' == trim($current) AND '##Global##' != $current) {
  489. $current='[ '.__('nothing', 'podpress').' ]';
  490. }
  491. $cats[] = '[ '.__('nothing', 'podpress').' ]';
  492. $cats[] = 'Arts';
  493. $cats[] = 'Arts:Design';
  494. $cats[] = 'Arts:Fashion & Beauty';
  495. $cats[] = 'Arts:Food';
  496. $cats[] = 'Arts:Literature';
  497. $cats[] = 'Arts:Performing Arts';
  498. $cats[] = 'Arts:Visual Arts';
  499. $cats[] = 'Business';
  500. $cats[] = 'Business:Business News';
  501. $cats[] = 'Business:Careers';
  502. $cats[] = 'Business:Investing';
  503. $cats[] = 'Business:Management & Marketing';
  504. $cats[] = 'Business:Shopping';
  505. $cats[] = 'Comedy';
  506. $cats[] = 'Education';
  507. $cats[] = 'Education:Education Technology';
  508. $cats[] = 'Education:Higher Education';
  509. $cats[] = 'Education:K-12';
  510. $cats[] = 'Education:Language Courses';
  511. $cats[] = 'Education:Training';
  512. $cats[] = 'Games & Hobbies';
  513. $cats[] = 'Games & Hobbies:Automotive';
  514. $cats[] = 'Games & Hobbies:Aviation';
  515. $cats[] = 'Games & Hobbies:Hobbies';
  516. $cats[] = 'Games & Hobbies:Other Games';
  517. $cats[] = 'Games & Hobbies:Video Games';
  518. $cats[] = 'Government & Organizations';
  519. $cats[] = 'Government & Organizations:Local';
  520. $cats[] = 'Government & Organizations:National';
  521. $cats[] = 'Government & Organizations:Non-Profit';
  522. $cats[] = 'Government & Organizations:Regional';
  523. $cats[] = 'Health';
  524. $cats[] = 'Health:Alternative Health';
  525. $cats[] = 'Health:Fitness & Nutrition';
  526. $cats[] = 'Health:Self-Help';
  527. $cats[] = 'Health:Sexuality';
  528. $cats[] = 'Kids & Family';
  529. $cats[] = 'Music';
  530. $cats[] = 'News & Politics';
  531. $cats[] = 'Religion & Spirituality';
  532. $cats[] = 'Religion & Spirituality:Buddhism';
  533. $cats[] = 'Religion & Spirituality:Christianity';
  534. $cats[] = 'Religion & Spirituality:Hinduism';
  535. $cats[] = 'Religion & Spirituality:Islam';
  536. $cats[] = 'Religion & Spirituality:Judaism';
  537. $cats[] = 'Religion & Spirituality:Other';
  538. $cats[] = 'Religion & Spirituality:Spirituality';
  539. $cats[] = 'Science & Medicine';
  540. $cats[] = 'Science & Medicine:Medicine';
  541. $cats[] = 'Science & Medicine:Natural Sciences';
  542. $cats[] = 'Science & Medicine:Social Sciences';
  543. $cats[] = 'Society & Culture';
  544. $cats[] = 'Society & Culture:History';
  545. $cats[] = 'Society & Culture:Personal Journals';
  546. $cats[] = 'Society & Culture:Philosophy';
  547. $cats[] = 'Society & Culture:Places & Travel';
  548. $cats[] = 'Sports & Recreation';
  549. $cats[] = 'Sports & Recreation:Amateur';
  550. $cats[] = 'Sports & Recreation:College & High School';
  551. $cats[] = 'Sports & Recreation:Outdoor';
  552. $cats[] = 'Sports & Recreation:Professional';
  553. $cats[] = 'Technology';
  554. $cats[] = 'Technology:Gadgets';
  555. $cats[] = 'Technology:Tech News';
  556. $cats[] = 'Technology:Podcasting';
  557. $cats[] = 'Technology:Software How-To';
  558. $cats[] = 'TV & Film';
  559. reset($cats);
  560. $foundit = false;
  561. foreach ($cats as $value) {
  562. $value = str_replace('&', '&amp;', $value);
  563. echo '<option';
  564. if($value == $current) {
  565. $foundit = true;
  566. echo ' selected="selected"';
  567. }
  568. //~ if ( '[ '.__('nothing', 'podpress').' ]' === $value ) {
  569. //~ echo ' value="nothing"';
  570. //~ }
  571. echo ' value="'.attribute_escape($value).'"';
  572. echo '>'.$value.'</option>'."\n";
  573. }
  574. if(!$foundit AND '##Global##' != $current) {
  575. $current = podPress_upgradeCategory($current);
  576. echo '<option selected="selected">'.$current.'</option>'."\n";
  577. }
  578. }
  579. function podPress_upgradeCategory($current) {
  580. $cats['Arts & Entertainment'] = 'Arts';
  581. $cats['Arts & Entertainment:Architecture'] = 'Arts:Design';
  582. $cats['Arts & Entertainment:Books'] = 'Arts:Literature';
  583. $cats['Arts & Entertainment:Design'] = 'Arts:Design';
  584. $cats['Arts & Entertainment:Entertainment'] = 'TV & Film';
  585. $cats['Arts & Entertainment:Games'] = 'Games & Hobbies:Video Games';
  586. $cats['Arts & Entertainment:Performing Arts'] = 'Arts:Performing Arts';
  587. $cats['Arts & Entertainment:Photography'] = 'Arts:Visual Arts';
  588. $cats['Arts & Entertainment:Poetry'] = 'Arts:Literature';
  589. $cats['Arts & Entertainment:Science Fiction'] = 'Arts:Literature';
  590. $cats['Audio Blogs'] = 'Society & Culture:Personal Journals';
  591. $cats['Business'] = 'Business';
  592. $cats['Business:Careers'] = 'Business:Careers';
  593. $cats['Business:Finance'] = 'Business:Business News';
  594. $cats['Business:Investing'] = 'Business:Investing';
  595. $cats['Business:Management'] = 'Business:Management & Marketing';
  596. $cats['Business:Marketing'] = 'Business:Management & Marketing';
  597. $cats['Comedy'] = 'Comedy';
  598. $cats['Education'] = 'Education';
  599. $cats['Education:Higher Education'] = 'Education:Higher Education';
  600. $cats['Education:K-12'] = 'Education:K-12';
  601. $cats['Family'] = 'Kids & Family';
  602. $cats['Food'] = 'Arts:Food';
  603. $cats['Health'] = 'Health';
  604. $cats['Health:Diet & Nutrition'] = 'Health:Fitness & Nutrition';
  605. $cats['Health:Fitness'] = 'Health:Fitness & Nutrition';
  606. $cats['Health:Relationships'] = 'Health:Sexuality';
  607. $cats['Health:Self-Help'] = 'Health:Self-Help';
  608. $cats['Health:Sexuality'] = 'Health:Sexuality';
  609. $cats['International'] = 'Government & Organizations:National';
  610. $cats['International:Australian'] = 'Government & Organizations:National';
  611. $cats['International:Belgian'] = 'Government & Organizations:National';
  612. $cats['International:Brazilian'] = 'Government & Organizations:National';
  613. $cats['International:Canadian'] = 'Government & Organizations:National';
  614. $cats['International:Chinese'] = 'Government & Organizations:National';
  615. $cats['International:Dutch'] = 'Government & Organizations:National';
  616. $cats['International:French'] = 'Government & Organizations:National';
  617. $cats['International:German'] = 'Government & Organizations:National';
  618. $cats['International:Hebrew'] = 'Government & Organizations:National';
  619. $cats['International:Italian'] = 'Government & Organizations:National';
  620. $cats['International:Japanese'] = 'Government & Organizations:National';
  621. $cats['International:Norwegian'] = 'Government & Organizations:National';
  622. $cats['International:Polish'] = 'Government & Organizations:National';
  623. $cats['International:Portuguese'] = 'Government & Organizations:National';
  624. $cats['International:Spanish'] = 'Government & Organizations:National';
  625. $cats['International:Swedish'] = 'Government & Organizations:National';
  626. $cats['Movies & Television'] = 'TV & Film';
  627. $cats['Music'] = 'Music';
  628. $cats['News'] = 'News & Politics';
  629. $cats['Politics'] = 'News & Politics';
  630. $cats['Public Radio'] = 'News & Politics';
  631. $cats['Religion & Spirituality'] = 'Religion & Spirituality';
  632. $cats['Religion & Spirituality:Buddhism'] = 'Religion & Spirituality:Buddhism';
  633. $cats['Religion & Spirituality:Christianity'] = 'Religion & Spirituality:Christianity';
  634. $cats['Religion & Spirituality:Islam'] = 'Religion & Spirituality:Islam';
  635. $cats['Religion & Spirituality:Judaism'] = 'Religion & Spirituality:Judaism';
  636. $cats['Religion & Spirituality:New Age'] = 'Religion & Spirituality:Spirituality';
  637. $cats['Religion & Spirituality:Philosophy'] = 'Religion & Spirituality:Philosophy';
  638. $cats['Religion & Spirituality:Spirituality'] = 'Religion & Spirituality:Spirituality';
  639. $cats['Science'] = 'Science & Medicine';
  640. $cats['Sports'] = 'Sports & Recreation';
  641. $cats['Talk Radio'] = 'News & Politics';
  642. $cats['Technology'] = 'Technology';
  643. $cats['Technology:IT News'] = 'Technology:Tech News';
  644. $cats['Technology:Computers'] = 'Technology:Tech News';
  645. $cats['Technology:Developers'] = 'Technology:Tech News';
  646. $cats['Technology:Gadgets'] = 'Technology:Gadgets';
  647. $cats['Technology:Information Technology'] = 'Technology:Tech News';
  648. $cats['Technology:News'] = 'Technology:Tech News';
  649. $cats['Technology:Operating Systems'] = 'Technology:Tech News';
  650. $cats['Technology:Podcasting'] = 'Technology:Podcasting';
  651. $cats['Technology:Smart Phones'] = 'Technology:Tech News';
  652. $cats['Technology:Text/Speech'] = 'Technology:Tech News';
  653. $cats['Transportation'] = 'Games & Hobbies:Automotive';
  654. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  655. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  656. $cats['Transportation:BBB'] = 'Sports & Recreation:Outdoor';
  657. $cats['Transportation:BBB'] = 'Games & Hobbies:Automotive';
  658. $cats['Travel'] = 'Society & Culture:Places & Travel';
  659. $current = str_replace('&amp;', '&', $current);
  660. if(isset($cats[$current])) {
  661. $result = $cats[$current];
  662. } else {
  663. $result = $current;
  664. }
  665. return str_replace('&', '&amp;', $result);
  666. }
  667. function podPress_itunesCategoryOptions2($current = '') {
  668. $cats = array();
  669. $cats['Arts &amp; Entertainment'] = 'Arts &amp; Entertainment';
  670. $cats['Arts &amp; Entertainment:Architecture'] = 'Arts &amp; Entertainment:Architecture';
  671. $cats['Arts &amp; Entertainment:Books'] = 'Arts &amp; Entertainment:Books';
  672. $cats['Arts &amp; Entertainment:Design'] = 'Arts &amp; Entertainment:Design';
  673. $cats['Arts &amp; Entertainment:Poetry'] = 'Arts &amp; Entertainment:Poetry';
  674. $cats['Arts &amp; Entertainment:Games'] = 'Arts &amp; Entertainment:Games';
  675. $cats['Arts &amp; Entertainment:Performing Arts'] = 'Arts &amp; Entertainment:Performing Arts';
  676. $cats['Arts &amp; Entertainment:Photography'] = 'Arts &amp; Entertainment:Photography';
  677. $cats['Arts &amp; Entertainment:Science Fiction'] = 'Arts &amp; Entertainment:Science Fiction';
  678. $cats['Audio Blogs'] = 'Audio Blogs';
  679. $cats['Business'] = 'Business';
  680. $cats['Business:Careers'] = 'Business:Careers';
  681. $cats['Business:Finance'] = 'Business:Finance';
  682. $cats['Business:Investing'] = 'Business:Investing';
  683. $cats['Business:Management'] = 'Business:Management';
  684. $cats['Business:Marketing'] = 'Business:Marketing';
  685. $cats['Comedy'] = 'Comedy';
  686. $cats['Education'] = 'Education';
  687. $cats['Education:K-12'] = 'Education:K-12';
  688. $cats['Education:Higher Education'] = 'Education:Higher Education';
  689. $cats['Family'] = 'Family';
  690. $cats['Food'] = 'Food';
  691. $cats['Health'] = 'Health';
  692. $cats['Health:Diet &amp; Nutrition'] = 'Health:Diet &amp; Nutrition';
  693. $cats['Health:Fitness'] = 'Health:Fitness';
  694. $cats['Health:Relationships'] = 'Health:Relationships';
  695. $cats['Health:Self-Help'] = 'Health:Self-Help';
  696. $cats['Health:Sexuality'] = 'Health:Sexuality';
  697. $cats['International'] = 'International';
  698. $cats['International:Australian'] = 'International:Australian';
  699. $cats['International:Belgian'] = 'International:Belgian';
  700. $cats['International:Brazilian'] = 'International:Brazilian';
  701. $cats['International:Canadian'] = 'International:Canadian';
  702. $cats['International:Chinese'] = 'International:Chinese';
  703. $cats['International:Dutch'] = 'International:Dutch';
  704. $cats['International:French'] = 'International:French';
  705. $cats['International:German'] = 'International:German';
  706. $cats['International:Hebrew'] = 'International:Hebrew';
  707. $cats['International:Italian'] = 'International:Italian';
  708. $cats['International:Japanese'] = 'International:Japanese';
  709. $cats['International:Norwegian'] = 'International:Norwegian';
  710. $cats['International:Polish'] = 'International:Polish';
  711. $cats['International:Portuguese'] = 'International:Portuguese';
  712. $cats['International:Spanish'] = 'International:Spanish';
  713. $cats['International:Swedish'] = 'International:Swedish';
  714. $cats['Movies &amp; Television'] = 'Movies &amp; Television';
  715. $cats['Music'] = 'Music';
  716. $cats['News'] = 'News';
  717. $cats['Politics'] = 'Politics';
  718. $cats['Public Radio'] = 'Public Radio';
  719. $cats['Religion &amp; Spirituality'] = 'Religion &amp; Spirituality';
  720. $cats['Religion &amp; Spirituality:Buddhism'] = 'Religion &amp; Spirituality:Buddhism';
  721. $cats['Religion &amp; Spirituality:Christianity'] = 'Religion &amp; Spirituality:Christianity';
  722. $cats['Religion &amp; Spirituality:Islam'] = 'Religion &amp; Spirituality:Islam';
  723. $cats['Religion &amp; Spirituality:Judaism'] = 'Religion &amp; Spirituality:Judaism';
  724. $cats['Religion &amp; Spirituality:New Age'] = 'Religion &amp; Spirituality:New Age';
  725. $cats['Religion &amp; Spirituality:Philosophy'] = 'Religion &amp; Spirituality:Philosophy';
  726. $cats['Religion &amp; Spirituality:Spirituality'] = 'Religion &amp; Spirituality:Spirituality';
  727. $cats['Science'] = 'Science';
  728. $cats['Sports'] = 'Sports';
  729. $cats['Talk Radio'] = 'Talk Radio';
  730. $cats['Technology'] = 'Technology';
  731. $cats['Technology:Computers'] = 'Technology:Computers';
  732. $cats['Technology:Developers'] = 'Technology:Developers';
  733. $cats['Technology:Gadgets'] = 'Technology:Gadgets';
  734. $cats['Technology:Information Technology'] = 'Technology:Information Technology';
  735. $cats['Technology:News'] = 'Technology:News';
  736. $cats['Technology:Operating Systems'] = 'Technology:Operating Systems';
  737. $cats['Technology:Podcasting'] = 'Technology:Podcasting';
  738. $cats['Technology:Smart Phones'] = 'Technology:Smart Phones';
  739. $cats['Technology:Text/Speech'] = 'Technology:Text/Speech';
  740. $cats['Travel'] = 'Travel';
  741. reset($cats);
  742. foreach ($cats as $key => $value) {
  743. echo '<option value="'.$key.'"';
  744. if($key == $current) {
  745. echo ' selected="selected"';
  746. }
  747. echo '>'.$value.'</option>'."\n";
  748. }
  749. }
  750. /**************************************************************/
  751. /* Functions for supporting the backend processor */
  752. /**************************************************************/
  753. function podPress_ResolveReDirects($uriFileName)
  754. {
  755. GLOBAL $podPress;
  756. $tries = 0;
  757. while($tries < 5) {
  758. $tries++;
  759. $aURL = parse_url($uriFileName);
  760. if($aURL['scheme'] != 'http') {
  761. return;
  762. }
  763. $sHost = $aURL['host'];
  764. $sFilepath = (isset($aURL['path']) ? $aURL['path'] : '/') . (isset($aURL['query']) ? '?' . $aURL['query'] : '');
  765. $nPort = isset($aURL['port']) ? $aURL['port'] : 80;
  766. $fpRemote = @fsockopen($sHost, $nPort, $errno, $errstr, 30);
  767. // Make sure the socket is open
  768. if(!$fpRemote) {
  769. return;
  770. }
  771. // Request headers
  772. $sHeaders = "HEAD " . $sFilepath . " HTTP/1.1\r\n";
  773. $sHeaders .= "Host: ". $sHost . "\r\n";
  774. $sHeaders .= "Connection: Close\r\n\r\n";
  775. // Sending headers
  776. fwrite($fpRemote, $sHeaders);
  777. // Getting back the content
  778. $sRemoteHeaders = '';
  779. while(!feof($fpRemote)) {
  780. $sRemoteHeaders .= fgets($fpRemote, 128);
  781. }
  782. // Closing the socket
  783. fclose($fpRemote);
  784. // parse headers
  785. $crlf = "\r\n";
  786. $headers = array();
  787. $lines = explode($crlf, $sRemoteHeaders);
  788. foreach($lines as $line) {
  789. if(($pos = strpos($line, ':')) !== false) {
  790. $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
  791. }
  792. }
  793. // redirection?
  794. if(isset($headers['location'])) {
  795. $uriFileName = $headers['location'];
  796. } else {
  797. return $uriFileName;
  798. }
  799. }
  800. return $uriFileName;
  801. }
  802. function podPress_getID3tags($mediafile, $resolved = false, $limitDownload = false) {
  803. GLOBAL $podPress;
  804. $tmp_download_exists = FALSE;
  805. if($podPress->settings['enablePodangoIntegration']) {
  806. if(substr($mediafile, 0, strlen('Podango:')) == 'Podango:') {
  807. $fileNameParts = explode(':', $mediafile);
  808. $mediafile = 'http://download.podango.com/mediatracker/555/'.$fileNameParts[3].'/'.$fileNameParts[4];
  809. }
  810. }
  811. podPress_var_dump('podPress_getID3tags - before inclusion of the getID3 library');
  812. require_once(ABSPATH.PLUGINDIR.'/podpress/getid3/getid3.php');
  813. $getID3 = new getID3;
  814. if($getID3 == false) {
  815. return __('Remote MP3 File could not be read. (error loading ID3 reader)', 'podpress');
  816. }
  817. podPress_var_dump('podPress_getID3tags - after inclusion of the getID3 library');
  818. if(!$resolved) {
  819. $systemFileName = $podPress->convertPodcastFileNameToSystemPath($mediafile);
  820. } else {
  821. $systemFileName = $mediafile;
  822. }
  823. podPress_var_dump('podPress_getID3tags - before a possible download of the media file');
  824. if(file_exists($systemFileName)) {
  825. $uriFileName = $systemFileName;
  826. } else {
  827. if(!$resolved) {
  828. $uriFileName = $podPress->convertPodcastFileNameToValidWebPath($mediafile);
  829. } else {
  830. $uriFileName = $mediafile;
  831. }
  832. $local_uploadURL = $podPress->uploadURL;
  833. podPress_var_dump('podPress_getID3tags - local_uploadURL: '.$local_uploadURL);
  834. podPress_var_dump('podPress_getID3tags - local_uploadPath: '.$podPress->uploadPath);
  835. podPress_var_dump('podPress_getID3tags - tempFileSystemPath: '.$podPress->tempFileSystemPath);
  836. podPress_var_dump('podPress_getID3tags - tempFileURLPath: '.$podPress->tempFileURLPath);
  837. podPress_var_dump('podPress_getID3tags - uriFileName: '.$uriFileName);
  838. 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
  839. // get the absolute folder of the file from the URL
  840. podPress_var_dump('podPress_getID3tags - it is a local file');
  841. $uriFileName = $podPress->uploadPath.str_replace($local_uploadURL,'',$uriFileName);
  842. $uriFileName = str_replace('\\', '/',$uriFileName);
  843. podPress_var_dump('podPress_getID3tags - new uriFileName: '.$uriFileName);
  844. } else {
  845. podPress_var_dump('podPress_getID3tags - go to podPress_downloadFile');
  846. $uriFileName = podPress_downloadFile($uriFileName, false, $limitDownload);
  847. $tmp_download_exists = TRUE;
  848. }
  849. }
  850. podPress_var_dump('podPress_getID3tags - after a possible download of the media file');
  851. $fileinfo = @$getID3->analyze($uriFileName);
  852. podPress_var_dump('podPress_getID3tags - after getID3->analyze');
  853. getid3_lib::CopyTagsToComments($fileinfo);
  854. podPress_var_dump('podPress_getID3tags - after getid3_lib::CopyTagsToComments');
  855. if (TRUE === $tmp_download_exists) { // if the file has been downloaded to a local folder then delete the tempfile
  856. if ('' != $fileinfo['filenamepath']) { // take the folder and file from getID3 if possible
  857. $unlink_result = @unlink($fileinfo['filenamepath']);
  858. // If tempnam is available then tempnam creates a tempfile which has no media file extension like .mp3. But getID3 needs these extensions.
  859. // 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
  860. // 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
  861. // to remove the tmp file which was created by tempnam in podPress_downloadFile.
  862. $ext = end(explode('.', $fileinfo['filenamepath']));
  863. if (FALSE === empty($ext)) {
  864. $tempnam_file = substr($fileinfo['filenamepath'], 0, (strlen($fileinfo['filenamepath'])-strlen($ext)-1));
  865. $unlink_result = @unlink($tempnam_file);
  866. }
  867. } else {
  868. $unlink_result = @unlink($uriFileName);
  869. $ext = end(explode('.', $uriFileName));
  870. if (FALSE === empty($ext)) {
  871. $tempnam_file = substr($uriFileName, 0, (strlen($uriFileName)-strlen($ext)-1));
  872. $unlink_result = @unlink($tempnam_file);
  873. }
  874. }
  875. }
  876. podPress_var_dump('podPress_getID3tags - the end');
  877. return $fileinfo;
  878. }
  879. function podPress_showID3tags($mediafile) {
  880. if (FALSE !== strpos($mediafile, 'http://www.youtube')) {
  881. return '';
  882. }
  883. podPress_var_dump('start of the ID3 tag retrieval');
  884. $fileinfo = podPress_getID3tags($mediafile, false);
  885. podPress_var_dump('end of the ID3 tag retrieval');
  886. if(!is_array($fileinfo) OR FALSE == isset($fileinfo['comments']) ) {
  887. return '<div class="updated message">'.__('The file has probably no information like artist, genre, album, etc.', 'podpress').'<br /><pre>'.var_export($fileinfo, true).'</pre></div>';
  888. }
  889. if(isset($_GET['keynum'])) {
  890. $randID = $_GET['keynum'];
  891. } else {
  892. mt_srand(crc32(microtime()));
  893. $randID = mt_rand(1, 9999);
  894. }
  895. $result .= '<table class="the-list-x widefat podpress_id3tag_details_table">'."\n";
  896. $result .= ' <tr class="alternate">'."\n";
  897. $result .= ' <th>'.__('Artist', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagArtist">'.(!empty($fileinfo['comments']['artist'][0]) ? $fileinfo['comments']['artist'][0] : '&nbsp;').'</span></td>'."\n";
  898. $result .= ' </tr>'."\n";
  899. $result .= ' <tr>'."\n";
  900. $result .= ' <th>'.__('Album', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagAlbum">'.(!empty($fileinfo['comments']['album'][0]) ? $fileinfo['comments']['album'][0] : '&nbsp;').'</span></td>'."\n";
  901. $result .= ' </tr>'."\n";
  902. $result .= ' <tr class="alternate">'."\n";
  903. $result .= ' <th>'.__('Title', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagTitle">'.(!empty($fileinfo['comments']['title'][0]) ? $fileinfo['comments']['title'][0] : '&nbsp;').'</span></td>'."\n";
  904. $result .= ' </tr>'."\n";
  905. $result .= ' <tr>'."\n";
  906. $result .= ' <th>'.__('Description', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagDescription">'.(!empty($fileinfo['comments']['comment'][0]) ? $fileinfo['comments']['comment'][0] : '&nbsp;').'</span></td>'."\n";
  907. $result .= ' </tr>'."\n";
  908. $result .= ' <tr class="alternate">'."\n";
  909. $result .= ' <th>'.__('Genre', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagGenre">'.(!empty($fileinfo['comments']['genre'][0]) ? $fileinfo['comments']['genre'][0] : '&nbsp;').'</span></td>'."\n";
  910. $result .= ' </tr>'."\n";
  911. $result .= ' <tr>'."\n";
  912. $result .= ' <th>'.__('Length', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagLength">'.(!empty($fileinfo['playtime_string']) ? $fileinfo['playtime_string'] : '&nbsp;').'</span></td>'."\n";
  913. $result .= ' </tr>'."\n";
  914. $result .= ' <tr class="alternate">'."\n";
  915. $result .= ' <th>'.__('Cover Art', 'podpress').'</th><td><span id="podPressMedia_'.$randID.'_tagCoverArt"><img src="'.podPress_url().'podpress_backend.php?action=id3image&filename='.urlencode($mediafile).'" alt="."/></span></td>'."\n";
  916. $result .= ' </tr>'."\n";
  917. //~ $result .= ' <tr>'."\n";
  918. //~ $result .= ' <td colspan="2"><a href="#" onclick="podPressID3ToPost(\''.$randID.'\'); return false;">'.__('Copy contents to post details', 'podpress').'</a></td>'."\n";
  919. //~ $result .= ' </tr>'."\n";
  920. $result .= '</table>'."\n";
  921. return $result;
  922. }
  923. function podPress_getCoverArt($mediafile) {
  924. $fileinfo = podPress_getID3tags($mediafile, false, 500000);
  925. if(isset($fileinfo['id3v2']['APIC'][0])) {
  926. $ref = $fileinfo['id3v2']['APIC'][0];
  927. } elseif(isset($fileinfo['id3v2']['PIC'][0])) {
  928. $ref = $fileinfo['id3v2']['PIC'][0];
  929. } else {
  930. $ref['image_mime'] = 'image/jpeg';
  931. $ref['datalength'] = @filesize('images/powered_by_podpress.png');
  932. $ref['data'] = @file_get_contents('images/powered_by_podpress.png');
  933. }
  934. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // some day in the past
  935. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  936. header('Content-type: '.$ref['image_mime']);
  937. // header('Content-Disposition: attachment; filename="coverart.png"');
  938. header("Content-Length: ".$ref['datalength']);
  939. set_time_limit(0);
  940. echo $ref['data'];
  941. }
  942. function podPress_getDuration($mediafile)
  943. {
  944. GLOBAL $podPress;
  945. if($podPress->settings['enablePodangoIntegration']) {
  946. if(substr($mediafile, 0, strlen('Podango:')) == 'Podango:') {
  947. $fileNameParts = explode(':', $mediafile);
  948. $mediafile = 'http://download.podango.com/mediatracker/555/'.$fileNameParts[3].'/'.$fileNameParts[4];
  949. }
  950. }
  951. $id3formats = array('mp3', 'ogg', 'avi', 'mov', '.qt', 'mp4', 'm4v', 'm4a', 'wma', 'wmv', 'mpg', 'peg', 'flv', 'swf');
  952. if(in_array(strtolower(substr($mediafile, -3, 3)), $id3formats)) {
  953. podPress_var_dump('start of the duration retrieval');
  954. $systemFileName = $podPress->convertPodcastFileNameToSystemPath($mediafile);
  955. if(file_exists($systemFileName)) {
  956. $uriFileName = $systemFileName;
  957. } else {
  958. $systemFileName = $podPress->TryToFindAbsFileName($mediafile);
  959. if(FALSE !== $systemFileName) {
  960. $uriFileName = $systemFileName;
  961. } else {
  962. $uriFileName = $podPress->convertPodcastFileNameToValidWebPath($mediafile);
  963. }
  964. }
  965. $fileinfo = podPress_getID3tags($uriFileName, true);
  966. podPress_var_dump('end of the duration retrieval');
  967. return $fileinfo['playtime_string'];
  968. }
  969. }
  970. function podPress_downloadFile($uriFileName, $getHeaders = false, $limitDownload = false) {
  971. GLOBAL $podPress;
  972. // some downloads may hit time limits -> lets find out these limits, stop the process a moment before and return an error message
  973. // search for PHP time limits
  974. $max_execution_time = intval(ini_get('max…

Large files files are truncated, but you can click here to view the full file