PageRenderTime 55ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/bill742/verbalbrew
PHP | 1712 lines | 1379 code | 123 blank | 210 comment | 432 complexity | 12984c8d59d3c7aff9f5236de6b85b2a MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0, AGPL-1.0, LGPL-2.1, GPL-2.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. class podPress_class {
  19. var $settings = array();
  20. // Global hardcoded settings
  21. var $podcasttag_regexp = "/\[podcast:([^]]+)]/";
  22. var $podcasttag = '[display_podcast]';
  23. var $podtrac_url = 'http://www.podtrac.com/pts/redirect.mp3?';
  24. var $blubrry_url = 'http://media.blubrry.com/';
  25. var $requiredadminrights = 'manage_categories';//'level_7';
  26. var $realm = 'Premium Subscribers Content';
  27. var $justposted = false;
  28. var $uploadurl = '';
  29. var $uploadpath = '';
  30. var $tempfilesystempath = '';
  31. var $tempfileurlpath = '';
  32. var $tempcontentaddedto = array();
  33. var $podangoapi;
  34. var $isexcerpt = FALSE;
  35. /*************************************************************/
  36. /* Load up the plugin values and get ready to action */
  37. /*************************************************************/
  38. function podPress_class() {
  39. //$this->feed_getCategory();
  40. // this is not workin in WP 3.0: //$this->uploadpath = get_option('upload_path');
  41. $wp_upload_dir = wp_upload_dir(); // since WP 2.0.0 but the return values were different back than
  42. if (FALSE == isset($wp_upload_dir['basedir']) OR FALSE == isset($wp_upload_dir['baseurl'])) {
  43. $wp_upload_dir = $this->upload_dir();
  44. }
  45. $this->uploadpath = $wp_upload_dir['basedir'];
  46. $this->uploadurl = $wp_upload_dir['baseurl'];
  47. $this->tempfilesystempath = $this->uploadpath.'/podpress_temp';
  48. $this->tempfileurlpath = $wp_upload_dir['baseurl'].'/podpress_temp';
  49. // load up podPress general config
  50. $this->settings = podPress_get_option('podPress_config');
  51. // make sure things look current, if not run the settings checker
  52. if(!is_array($this->settings) OR TRUE == version_compare(PODPRESS_VERSION, $this->settings['lastChecked'], '>') ) {
  53. $this->checkSettings();
  54. }
  55. if(is_object($GLOBALS['wp_rewrite'])
  56. && is_array($GLOBALS['wp_object_cache'])
  57. && is_array($GLOBALS['wp_object_cache']['cache'])
  58. && is_array($GLOBALS['wp_object_cache']['cache']['options'])
  59. && is_array($GLOBALS['wp_object_cache']['cache']['options']['alloptions'])
  60. && is_array($GLOBALS['wp_object_cache']['cache']['options']['alloptions']['rewrite_rules'])
  61. && !strpos($GLOBALS['wp_object_cache']['cache']['options']['alloptions']['rewrite_rules'], 'playlist.xspf')
  62. ) {
  63. $GLOBALS['wp_rewrite']->flush_rules();
  64. }
  65. }
  66. // taken from wp_upload_dir() of WP 2.8.4 to keep up the compatibility of this podPress version with older WP version
  67. // new in podPress since 8.8.5 beta 9
  68. function upload_dir() {
  69. $siteurl = get_option( 'siteurl' );
  70. $upload_path = get_option( 'upload_path' );
  71. $upload_path = trim($upload_path);
  72. if ( empty($upload_path) ) {
  73. $dir = WP_CONTENT_DIR . '/uploads';
  74. } else {
  75. $dir = $upload_path;
  76. }
  77. // $dir is absolute, $path is (maybe) relative to ABSPATH
  78. $dir = $this->path_join( ABSPATH, $dir );
  79. if ( !$url = get_option( 'upload_url_path' ) ) {
  80. if ( empty($upload_path) or ( $upload_path == $dir ) ) {
  81. $url = WP_CONTENT_URL . '/uploads';
  82. } else {
  83. $url = trailingslashit( $siteurl ) . $upload_path;
  84. }
  85. }
  86. if ( defined('UPLOADS') ) {
  87. $dir = ABSPATH . UPLOADS;
  88. $url = trailingslashit( $siteurl ) . UPLOADS;
  89. }
  90. return array( 'basedir' => $dir, 'baseurl' => $url);
  91. }
  92. // taken from WP 2.8.4 to keep up the compatibility of this podPress version with older WP version (new in WP since 2.5)
  93. // new in podPress since 8.8.5 beta 9
  94. function path_join( $base, $path ) {
  95. if ( $this->path_is_absolute($path) ) { return $path; }
  96. return rtrim($base, '/') . '/' . ltrim($path, '/');
  97. }
  98. // taken from WP 2.8.4 to keep up the compatibility of this podPress version with older WP version (new in WP since 2.5)
  99. // new in podPress since 8.8.5 beta 9
  100. function path_is_absolute( $path ) {
  101. // this is definitive if true but fails if $path does not exist or contains a symbolic link
  102. if ( realpath($path) == $path ) { return true;}
  103. if ( strlen($path) == 0 || $path{0} == '.' ) { return false; }
  104. // windows allows absolute paths like this
  105. if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) { return true; }
  106. // a path starting with / or \ is absolute; anything else is relative
  107. return (bool) preg_match('#^[/\\\\]#', $path);
  108. }
  109. /*************************************************************/
  110. // Handles all the default values for a new installation of the plugin
  111. // activate() is called only from podpress_upgrade_class.php during
  112. // the version check and upgrade routine which runs also after the plugin activation
  113. /*************************************************************/
  114. function activate() {
  115. GLOBAL $wpdb;
  116. if (function_exists('get_role') AND function_exists('is_role')) {
  117. if (FALSE === is_role('premium_subscriber')) {
  118. add_role('premium_subscriber', 'Premium Subscriber', $caps);
  119. }
  120. if (TRUE === is_role('premium_subscriber')) {
  121. $ps_role = get_role('premium_subscriber');
  122. if (Null !== $ps_role AND !$ps_role->has_cap('premium_content')) {
  123. $ps_role->add_cap('premium_content');
  124. }
  125. if(Null !== $ps_role AND !$ps_role->has_cap('read')) {
  126. $ps_role->add_cap('read');
  127. }
  128. }
  129. if (TRUE === is_role('administrator')) {
  130. $role = get_role('administrator');
  131. if (Null !== $role AND !$role->has_cap('premium_content')) {
  132. $role->add_cap('premium_content');
  133. }
  134. }
  135. }
  136. $this->createstatistictables();
  137. if(function_exists('wp_cache_flush')) {
  138. wp_cache_flush();
  139. }
  140. $current = get_option('podPress_version');
  141. if ( FALSE === $current ) {
  142. $current = constant('PODPRESS_VERSION');
  143. update_option('podPress_version', $current);
  144. }
  145. //$this->checkSettings();
  146. }
  147. /**
  148. * createstatistictables - creates the db tables for the statistics
  149. *
  150. * @package podPress
  151. * @since 8.8.10.3 beta 5
  152. *
  153. */
  154. function createstatistictables() {
  155. GLOBAL $wpdb;
  156. // ntm: create the table with the collation or db_charset (since 8.8.5 beta 4)
  157. if ( TRUE == defined('DB_COLLATE') AND '' !== DB_COLLATE ) {
  158. $db_charset = ' COLLATE ' . DB_COLLATE;
  159. } elseif ( (FALSE == defined('DB_COLLATE') OR '' == DB_COLLATE) AND TRUE == defined('DB_CHARSET') AND '' !== DB_CHARSET ) {
  160. $db_charset = ' DEFAULT CHARACTER SET ' . DB_CHARSET;
  161. } else {
  162. $db_charset = '';
  163. }
  164. // Create stats table
  165. $create_table = "CREATE TABLE ".$wpdb->prefix."podpress_statcounts (".
  166. "postID int(11) NOT NULL default '0',".
  167. "media varchar(255) NOT NULL,".
  168. "total int(11) default '1',".
  169. "feed int(11) default '0',".
  170. "web int(11) default '0',".
  171. "play int(11) default '0',".
  172. "PRIMARY KEY (media)) " . $db_charset;
  173. podPress_maybe_create_table($wpdb->prefix."podpress_statcounts", $create_table);
  174. // Create stats table
  175. $create_table = "CREATE TABLE ".$wpdb->prefix."podpress_stats (".
  176. "id int(11) unsigned NOT NULL auto_increment,".
  177. "postID int(11) NOT NULL default '0',".
  178. "media varchar(255) NOT NULL default '',".
  179. "method varchar(50) NOT NULL default '',".
  180. "remote_ip varchar(15) NOT NULL default '',".
  181. "country varchar(50) NOT NULL default '',".
  182. "language VARCHAR(5) NOT NULL default '',".
  183. "domain varchar(255) NOT NULL default '',".
  184. "referer varchar(255) NOT NULL default '',".
  185. "resource varchar(255) NOT NULL default '',".
  186. "user_agent varchar(255) NOT NULL default '',".
  187. "platform varchar(50) NOT NULL default '',".
  188. "browser varchar(50) NOT NULL default '',".
  189. "version varchar(15) NOT NULL default '',".
  190. "dt int(10) unsigned NOT NULL default '0',".
  191. "completed TINYINT(1) UNSIGNED DEFAULT '0',".
  192. "UNIQUE KEY id (id)) " . $db_charset;
  193. podPress_maybe_create_table($wpdb->prefix."podpress_stats", $create_table);
  194. }
  195. /**
  196. * checkLocalPathToMediaFiles - checks whether the "Local path to media files directory" exists or not. (This procedure is simply taken from the checkSettings() function earlier versions.)
  197. *
  198. * @package podPress
  199. * @since 8.8.5 beta 4
  200. *
  201. */
  202. function checkLocalPathToMediaFiles() {
  203. unset($this->settings['autoDetectedMediaFilePath']);
  204. $mediaFilePath = stripslashes($this->settings['mediaFilePath']);
  205. if ( FALSE == isset($this->settings['mediaFilePath']) OR FALSE == file_exists( $mediaFilePath ) ) {
  206. $this->settings['autoDetectedMediaFilePath'] = $this->uploadpath;
  207. if (!file_exists($this->settings['autoDetectedMediaFilePath'])) {
  208. $this->settings['autoDetectedMediaFilePath'] .= ' ('.__('Auto Detection Failed.', 'podpress').') '.strval($this->uploadpath);
  209. }
  210. }
  211. }
  212. function checkSettings() {
  213. GLOBAL $wp_object_cache, $wp_rewrite, $wp_version;
  214. if ( !is_array($this->settings) ) {
  215. $this->settings = podPress_get_option('podPress_config');
  216. if(!is_array($this->settings)) {
  217. $this->settings = array();
  218. }
  219. }
  220. $this->settings['lastChecked'] = PODPRESS_VERSION;
  221. // Make sure some standard values are set.
  222. $x = get_option('rss_language');
  223. if(!$x || empty($x))
  224. {
  225. add_option('rss_language', 'en');
  226. }
  227. $x = get_option('rss_image');
  228. if(!$x || empty($x))
  229. {
  230. podPress_update_option('rss_image', podPress_url().'images/powered_by_podpress.jpg');
  231. }
  232. // ntm: these settings are for the theme compatibility check resp. message. It seems to me that this checker was not in place at least since 8.8.
  233. // I could not find the routine which searches through the theme files for the wp_head and get_header etc. calls. Until there is such a test, I will set these values to TRUE.
  234. //~ if($this->settings['compatibilityChecks']['themeTested'] !== true) {
  235. //~ $this->settings['compatibilityChecks']['themeTested'] = false;
  236. //~ }
  237. //~ if($this->settings['compatibilityChecks']['wp_head'] !== true) {
  238. //~ $this->settings['compatibilityChecks']['wp_head'] = false;
  239. //~ }
  240. //~ if($this->settings['compatibilityChecks']['wp_footer'] !== true) {
  241. //~ $this->settings['compatibilityChecks']['wp_footer'] = false;
  242. //~ }
  243. $this->settings['compatibilityChecks']['themeTested'] = TRUE;
  244. $this->settings['compatibilityChecks']['wp_head'] = TRUE;
  245. $this->settings['compatibilityChecks']['wp_footer'] = TRUE;
  246. if(!is_bool($this->settings['enableStats'])) {
  247. if($this->settings['enableStats']== 'true') {
  248. $this->settings['enableStats'] = true;
  249. } else {
  250. $this->settings['enableStats'] = false;
  251. }
  252. }
  253. // no dashboardwidget support for WP 2.5.x and WP 2.6.x
  254. if ( TRUE == isset($this->settings['disabledashboardwidget']) AND TRUE === $this->settings['disabledashboardwidget'] OR (TRUE == version_compare($wp_version, '2.5', '>=') AND TRUE == version_compare($wp_version, '2.7', '<')) ) {
  255. $this->settings['disabledashboardwidget'] = TRUE;
  256. } else {
  257. $this->settings['disabledashboardwidget'] = FALSE;
  258. }
  259. if(!$this->settings['statMethod'] || empty($this->settings['statMethod']) || $this->settings['statMethod'] == 'htaccess')
  260. {
  261. $this->settings['statMethod'] = 'permalinks';
  262. }
  263. if(!$this->settings['statLogging'] || empty($this->settings['statLogging']))
  264. {
  265. $this->settings['statLogging'] = 'Counts';
  266. }
  267. if(empty($this->settings['enable3rdPartyStats'])) {
  268. $this->settings['enable3rdPartyStats'] = 'No';
  269. }
  270. if(!is_bool($this->settings['enableBlubrryStats'])) {
  271. if($this->settings['enableBlubrryStats']== 'true') {
  272. $this->settings['enableBlubrryStats'] = true;
  273. } else {
  274. $this->settings['enableBlubrryStats'] = false;
  275. }
  276. }
  277. if(!$this->settings['rss_copyright'] || empty($this->settings['rss_copyright']))
  278. {
  279. $this->settings['rss_copyright'] = __('Copyright', 'podpress').' &#xA9; '.get_bloginfo('blogname').' '. date('Y',time());
  280. }
  281. if(podPress_WPVersionCheck('2.0.0')) {
  282. if(!is_bool($this->settings['enablePremiumContent'])) {
  283. if($this->settings['enablePremiumContent']== 'true') {
  284. $this->settings['enablePremiumContent'] = true;
  285. } else {
  286. $this->settings['enablePremiumContent'] = false;
  287. }
  288. }
  289. } else {
  290. $this->settings['enablePremiumContent'] = false;
  291. }
  292. if(empty($this->settings['premiumMethod'])) {
  293. $this->settings['premiumMethod'] = 'Digest';
  294. }
  295. if(!defined('PODPRESS_PREMIUM_METHOD')) {
  296. define('PODPRESS_PREMIUM_METHOD', $this->settings['premiumMethod']);
  297. }
  298. if(!is_bool($this->settings['enableTorrentCasting'])) {
  299. if($this->settings['enableTorrentCasting']== 'true') {
  300. $this->settings['enableTorrentCasting'] = true;
  301. } else {
  302. $this->settings['enableTorrentCasting'] = false;
  303. }
  304. }
  305. if(empty($this->settings['podcastFeedURL'])) {
  306. if(podPress_WPVersionCheck('2.1')) {
  307. //~ $this->settings['podcastFeedURL'] = get_option('siteurl').'/?feed=podcast';
  308. $this->settings['podcastFeedURL'] = get_feed_link('podcast');
  309. } else {
  310. $this->settings['podcastFeedURL'] = get_option('siteurl').'/?feed=rss2';
  311. }
  312. }
  313. if ( FALSE == isset($this->settings['mediaWebPath']) OR TRUE == empty($this->settings['mediaWebPath']) ) {
  314. $this->settings['mediaWebPath'] = $this->uploadurl;
  315. }
  316. $this->checkLocalPathToMediaFiles();
  317. if(empty($this->settings['maxMediaFiles']) || $this->settings['maxMediaFiles'] < 1) {
  318. $this->settings['maxMediaFiles'] = 10;
  319. }
  320. if(!$this->settings['contentBeforeMore'] || empty($this->settings['contentBeforeMore']))
  321. {
  322. $this->settings['contentBeforeMore'] = 'yes';
  323. }
  324. if(!$this->settings['contentLocation'] || empty($this->settings['contentLocation']))
  325. {
  326. $this->settings['contentLocation'] = 'end';
  327. }
  328. if(!$this->settings['contentImage'] || empty($this->settings['contentImage']))
  329. {
  330. $this->settings['contentImage'] = 'button';
  331. }
  332. if(!$this->settings['contentPlayer'] || empty($this->settings['contentPlayer']))
  333. {
  334. $this->settings['contentPlayer'] = 'both';
  335. }
  336. if(!$this->settings['contentHidePlayerPlayNow'] || empty($this->settings['contentHidePlayerPlayNow']))
  337. {
  338. $this->settings['contentHidePlayerPlayNow'] = 'enabled';
  339. }
  340. if(FALSE == isset($this->settings['videoPreviewImage']) OR empty($this->settings['videoPreviewImage'])) {
  341. $this->settings['videoPreviewImage'] = PODPRESS_URL.'/images/vpreview_center.png';
  342. }
  343. if(!is_bool($this->settings['disableVideoPreview'])) {
  344. if($this->settings['disableVideoPreview']== 'true') {
  345. $this->settings['disableVideoPreview'] = true;
  346. } else {
  347. $this->settings['disableVideoPreview'] = false;
  348. }
  349. }
  350. if(!$this->settings['contentDownload'] || empty($this->settings['contentDownload']))
  351. {
  352. $this->settings['contentDownload'] = 'enabled';
  353. }
  354. if(!$this->settings['contentDownloadText'] || empty($this->settings['contentDownloadText']))
  355. {
  356. $this->settings['contentDownloadText'] = 'enabled';
  357. }
  358. if(!$this->settings['contentDownloadStats'] || empty($this->settings['contentDownloadStats']))
  359. {
  360. $this->settings['contentDownloadStats'] = 'enabled';
  361. }
  362. if(!$this->settings['contentDuration'] || empty($this->settings['contentDuration']))
  363. {
  364. $this->settings['contentDuration'] = 'enabled';
  365. }
  366. if ( FALSE == isset($this->settings['contentfilesize']) OR TRUE == empty($this->settings['contentfilesize'])) {
  367. $this->settings['contentfilesize'] = 'disabled';
  368. }
  369. if ( FALSE == isset($this->settings['incontentandexcerpt']) ) {
  370. $this->settings['incontentandexcerpt'] = 'in_content_and_excerpt';
  371. }
  372. if(!is_bool($this->settings['contentAutoDisplayPlayer'])) {
  373. if($this->settings['contentAutoDisplayPlayer'] == 'false') {
  374. $this->settings['contentAutoDisplayPlayer'] = false;
  375. } else {
  376. $this->settings['contentAutoDisplayPlayer'] = true;
  377. }
  378. }
  379. if ( FALSE == is_bool($this->settings['enableFooter']) ) {
  380. $this->settings['enableFooter'] = false;
  381. }
  382. if ( FALSE == isset($this->settings['mp3Player']) ) {
  383. $this->settings['mp3Player'] = '1pixelout';
  384. }
  385. if($this->settings['player']['bg'] == '') {
  386. $this->resetPlayerSettings();
  387. }
  388. if(empty($this->settings['iTunes']['summary'])) {
  389. $this->settings['iTunes']['summary'] = stripslashes(get_option('blogdescription'));
  390. } else {
  391. $this->settings['iTunes']['summary'] = stripslashes($this->settings['iTunes']['summary']);
  392. }
  393. $this->settings['iTunes']['keywords'] = stripslashes($this->settings['iTunes']['keywords']);
  394. $this->settings['iTunes']['subtitle'] = stripslashes($this->settings['iTunes']['subtitle']);
  395. $this->settings['iTunes']['author'] = stripslashes($this->settings['iTunes']['author']);
  396. $this->settings['iTunes']['FeedID'] = stripslashes($this->settings['iTunes']['FeedID']);
  397. $this->settings['iTunes']['FeedID'] = str_replace(' ', '', $this->settings['iTunes']['FeedID']);
  398. if(!empty($this->settings['iTunes']['FeedID']) && !is_numeric($this->settings['iTunes']['FeedID'])) {
  399. $this->settings['iTunes']['FeedID'] = settype($this->settings['iTunes']['FeedID'], 'double');
  400. }
  401. if(empty($this->settings['iTunes']['explicit'])) {
  402. $this->settings['iTunes']['explicit'] = 'No';
  403. }
  404. if(empty($this->settings['iTunes']['image'])) {
  405. $x = get_option('rss_image');
  406. if ( FALSE !== $x && $x != podPress_url().'images/powered_by_podpress.jpg') {
  407. $this->settings['iTunes']['image'] = $x;
  408. } else {
  409. $this->settings['iTunes']['image'] = podPress_url().'images/powered_by_podpress_large.jpg';
  410. }
  411. }
  412. if ( FALSE == isset($this->settings['iTunes']['new-feed-url']) OR ('Enable' != $this->settings['iTunes']['new-feed-url'] AND 'Disable' != $this->settings['iTunes']['new-feed-url']) ) {
  413. $this->settings['iTunes']['new-feed-url'] = 'Disable';
  414. }
  415. if ( FALSE == isset($this->settings['iTunes']['block']) OR ('Yes' != $this->settings['iTunes']['block'] AND 'No' != $this->settings['iTunes']['block']) ) {
  416. $this->settings['iTunes']['block'] = 'No';
  417. }
  418. if ( FALSE == isset($this->settings['rss_license_url']) ) {
  419. $this->settings['rss_license_url'] = '';
  420. }
  421. // since 8.8.8: default settings for the fully customizable feeds
  422. if ( FALSE == is_array($this->settings['podpress_feeds']) OR empty($this->settings['podpress_feeds']) ) {
  423. $email = get_option('admin_email');
  424. if ( FALSE === $email ) {
  425. $email = '';
  426. }
  427. $tagline = $this->settings['iTunes']['subtitle'];
  428. if ( FALSE === $tagline ) {
  429. $tagline = '';
  430. }
  431. $blog_charset = get_bloginfo('charset');
  432. $rss_language = get_option('rss_language');
  433. if ( FALSE === $rss_language ) { $rss_language = 'en'; }
  434. $rss_image = get_option('rss_image');
  435. if ( FALSE === $rss_image OR TRUE == empty($rss_image) ) {
  436. $rss_image = PODPRESS_URL.'/images/powered_by_podpress.jpg';
  437. }
  438. $ttl = get_option('rss_ttl');
  439. if ( FALSE === $ttl OR (!empty($ttl) && $ttl < 1440) ) {
  440. $ttl = 1440;
  441. }
  442. //~ if ( defined('PODPRESS_TAKEOVER_OLD_SETTINGS') AND TRUE === constant('PODPRESS_TAKEOVER_OLD_SETTINGS') ) {
  443. if ( FALSE == is_array($this->settings['iTunes']['category']) ) {
  444. $itunescategory = Array();
  445. }
  446. $this->settings['podpress_feeds'][0] = array(
  447. 'use' => TRUE,
  448. 'premium' => FALSE,
  449. 'name' => __('Podcast Feed', 'podpress'),
  450. 'slug' => 'podcast',
  451. 'feedtitle' => 'append',
  452. 'subtitle' => $tagline,
  453. 'itunes-newfeedurl' => 'Disable',
  454. 'descr' => $this->settings['iTunes']['summary'],
  455. 'itunes-category' => $itunescategory,
  456. 'rss_category' => $this->settings['rss_category'],
  457. 'itunes-keywords' => $this->settings['iTunes']['keywords'],
  458. 'itunes-author' => $this->settings['iTunes']['author'],
  459. 'email' => $email,
  460. 'itunes-image' => $this->settings['iTunes']['image'],
  461. 'rss_image' => $rss_image,
  462. 'copyright' => $this->settings['rss_copyright'],
  463. 'license_url' => $this->settings['rss_license_url'],
  464. 'language' => $rss_language,
  465. 'charset' => $blog_charset,
  466. 'FileTypes' => Array(),
  467. 'inclCategories' => Array(),
  468. 'show_only_podPress_podcasts' => TRUE,
  469. 'bypass_incl_selection' => FALSE,
  470. 'itunes-explicit' => $this->settings['iTunes']['explicit'],
  471. 'feedtype' => 'rss',
  472. 'ttl' => $ttl,
  473. 'itunes-feedid' => $this->settings['iTunes']['FeedID'],
  474. 'itunes-block' => $this->settings['iTunes']['block'],
  475. 'use_headerlink' => FALSE
  476. );
  477. $this->settings['podpress_feeds'][1] = array(
  478. 'use' => FALSE,
  479. 'premium' => FALSE,
  480. 'name' => __('Enhanced Podcast Feed', 'podpress'),
  481. 'slug' => 'enhancedpodcast',
  482. 'feedtitle' => 'append',
  483. 'subtitle' => $tagline,
  484. 'itunes-newfeedurl' => 'Disable',
  485. 'descr' => $this->settings['iTunes']['summary'],
  486. 'itunes-category' => $itunescategory,
  487. 'rss_category' => $this->settings['rss_category'],
  488. 'itunes-keywords' => $this->settings['iTunes']['keywords'],
  489. 'itunes-author' => $this->settings['iTunes']['author'],
  490. 'email' => $email,
  491. 'itunes-image' => $this->settings['iTunes']['image'],
  492. 'rss_image' => $rss_image,
  493. 'copyright' => $this->settings['rss_copyright'],
  494. 'license_url' => $this->settings['rss_license_url'],
  495. 'language' => $rss_language,
  496. 'charset' => $blog_charset,
  497. 'FileTypes' => Array('audio_m4a', 'video_m4v'),
  498. 'inclCategories' => Array(),
  499. 'show_only_podPress_podcasts' => TRUE,
  500. 'bypass_incl_selection' => FALSE,
  501. 'itunes-explicit' => $this->settings['iTunes']['explicit'],
  502. 'feedtype' => 'atom',
  503. 'ttl' => $ttl,
  504. 'itunes-feedid' => $this->settings['iTunes']['FeedID'],
  505. 'itunes-block' => $this->settings['iTunes']['block'],
  506. 'use_headerlink' => FALSE
  507. );
  508. $this->settings['podpress_feeds'][2] = array(
  509. 'use' => FALSE,
  510. 'premium' => FALSE,
  511. 'name' => __('Torrent Feed', 'podpress'),
  512. 'slug' => 'torrent',
  513. 'feedtitle' => 'append',
  514. 'subtitle' => $tagline,
  515. 'itunes-newfeedurl' => 'Disable',
  516. 'descr' => $this->settings['iTunes']['summary'],
  517. 'itunes-category' => $itunescategory,
  518. 'rss_category' => $this->settings['rss_category'],
  519. 'itunes-keywords' => $this->settings['iTunes']['keywords'],
  520. 'itunes-author' => $this->settings['iTunes']['author'],
  521. 'email' => $email,
  522. 'itunes-image' => $this->settings['iTunes']['image'],
  523. 'rss_image' => $rss_image,
  524. 'copyright' => $this->settings['rss_copyright'],
  525. 'license_url' => $this->settings['rss_license_url'],
  526. 'language' => $rss_language,
  527. 'charset' => $blog_charset,
  528. 'FileTypes' => Array('torrent'),
  529. 'inclCategories' => Array(),
  530. 'show_only_podPress_podcasts' => TRUE,
  531. 'bypass_incl_selection' => FALSE,
  532. 'itunes-explicit' => $this->settings['iTunes']['explicit'],
  533. 'feedtype' => 'atom',
  534. 'ttl' => $ttl,
  535. 'itunes-feedid' => $this->settings['iTunes']['FeedID'],
  536. 'itunes-block' => $this->settings['iTunes']['block'],
  537. 'use_headerlink' => FALSE
  538. );
  539. if ( FALSE == defined('PODPRESS_DEACTIVATE_PREMIUM') OR FALSE === constant('PODPRESS_DEACTIVATE_PREMIUM') ) {
  540. $this->settings['podpress_feeds'][3] = array(
  541. 'use' => FALSE,
  542. 'premium' => TRUE,
  543. 'name' => __('Premium Feed', 'podpress'),
  544. 'slug' => 'premium',
  545. 'feedtitle' => 'append',
  546. 'subtitle' => $tagline,
  547. 'itunes-newfeedurl' => 'Disable',
  548. 'descr' => $this->settings['iTunes']['summary'],
  549. 'itunes-category' => $itunescategory,
  550. 'rss_category' => $this->settings['rss_category'],
  551. 'itunes-keywords' => $this->settings['iTunes']['keywords'],
  552. 'itunes-author' => $this->settings['iTunes']['author'],
  553. 'email' => $email,
  554. 'itunes-image' => $this->settings['iTunes']['image'],
  555. 'rss_image' => $rss_image,
  556. 'copyright' => $this->settings['rss_copyright'],
  557. 'license_url' => $this->settings['rss_license_url'],
  558. 'language' => $rss_language,
  559. 'charset' => $blog_charset,
  560. 'FileTypes' => Array(),
  561. 'inclCategories' => Array(),
  562. 'show_only_podPress_podcasts' => TRUE,
  563. 'bypass_incl_selection' => FALSE,
  564. 'itunes-explicit' => $this->settings['iTunes']['explicit'],
  565. 'feedtype' => 'rss',
  566. 'ttl' => $ttl,
  567. 'itunes-feedid' => $this->settings['iTunes']['FeedID'],
  568. 'itunes-block' => $this->settings['iTunes']['block'],
  569. 'use_headerlink' => FALSE
  570. );
  571. }
  572. //~ } else {
  573. //~ // in case it is a first time installation
  574. //~ $this->settings['podpress_feeds'][0] = array(
  575. //~ 'use' => TRUE,
  576. //~ 'premium' => FALSE,
  577. //~ 'name' => __('Podcast Feed', 'podpress'),
  578. //~ 'slug' => 'podcast',
  579. //~ 'feedtitle' => 'append',
  580. //~ 'subtitle' => '',
  581. //~ 'itunes-newfeedurl' => 'Disable',
  582. //~ 'descr' => '',
  583. //~ 'itunes-category' => Array(),
  584. //~ 'rss_category' => '',
  585. //~ 'itunes-keywords' => '',
  586. //~ 'itunes-author' => '',
  587. //~ 'email' => '',
  588. //~ 'itunes-image' => $this->settings['iTunes']['image'],
  589. //~ 'rss_image' => $rss_image,
  590. //~ 'copyright' => $this->settings['rss_copyright'],
  591. //~ 'license_url' => '',
  592. //~ 'language' => $rss_langauge,
  593. //~ 'charset' => $blog_charset,
  594. //~ 'FileTypes' => Array(),
  595. //~ 'itunes-explicit' => 'No',
  596. //~ 'feedtype' => 'rss',
  597. //~ 'ttl' => $ttl,
  598. //~ 'itunes-feedid' => '',
  599. //~ 'itunes-block' => 'No'
  600. //~ );
  601. //~ }
  602. }
  603. podPress_update_option('podPress_config', $this->settings);
  604. if (
  605. is_object($wp_rewrite)
  606. && is_array($wp_object_cache)
  607. && is_array($wp_object_cache['cache'])
  608. && is_array($wp_object_cache['cache']['options'])
  609. && is_array($wp_object_cache['cache']['options']['alloptions'])
  610. && is_array($wp_object_cache['cache']['options']['alloptions']['rewrite_rules'])
  611. && !strpos($wp_object_cache['cache']['options']['alloptions']['rewrite_rules'], 'playlist.xspf')
  612. ) {
  613. $wp_rewrite->flush_rules();
  614. }
  615. }
  616. function deactivate() {
  617. // at the moment I have nothing I would want to clean up
  618. }
  619. /**
  620. * make_upgrade - helps to update the current settings
  621. *
  622. * @package podPress
  623. * @since 8.8.8 beta 5
  624. *
  625. */
  626. function update_podpress_class($podpress_version_from_db = '0') {
  627. if (class_exists('podPressUpgrade_class')) {
  628. $u = new podPressUpgrade_class($podpress_version_from_db);
  629. $this->settings = $u->settings;
  630. }
  631. return $this;
  632. }
  633. function iTunesLink() {
  634. return '<a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id='.$this->settings['iTunes']['FeedID'].'"><img src="'.podPress_url().'images/itunes.png" border="0" alt="View in iTunes"/></a>';
  635. }
  636. function PlayerDefaultSettings() {
  637. // ntm: these colors are from the recent audio-player plugin
  638. // The new colors should make it clear that the 1PixelOut player was also updated in 8.8.5
  639. $result['bg'] = '#E5E5E5';
  640. $result['text'] = '#333333';
  641. $result['leftbg'] = '#CCCCCC';
  642. $result['lefticon'] = '#333333';
  643. $result['volslider'] = '#666666';
  644. $result['voltrack'] = '#FFFFFF';
  645. $result['rightbg'] = '#B4B4B4';
  646. $result['rightbghover'] = '#999999';
  647. $result['righticon'] = '#333333';
  648. $result['righticonhover'] = '#FFFFFF';
  649. $result['loader'] = '#009900';
  650. $result['track'] = '#FFFFFF';
  651. $result['border'] = '#CCCCCC';
  652. $result['tracker'] = '#DDDDDD';
  653. $result['skip'] = '#666666';
  654. $result['slider'] = '#666666'; // this is only for the Podango player
  655. $result['initialvolume'] = 70; // for 1Pixelout player (since podPress 8.8.5.2)
  656. $result['buffer'] = 5; // for 1Pixelout player (since podPress 8.8.5.2)
  657. $result['checkpolicy'] = 'no'; // for 1Pixelout player (since podPress 8.8.5.2)
  658. // player settings which are no direct resp. JS parameters of the players
  659. $result['overwriteTitleandArtist'] = 'no'; // for 1Pixelout player (since podPress 8.8.5.2)
  660. $result['listenWrapper'] = false;
  661. return $result;
  662. }
  663. function resetPlayerSettings() {
  664. $result = $this->PlayerDefaultSettings();
  665. $this->settings['player'] = $result;
  666. return $result;
  667. }
  668. function convertPodcastFileNameToValidWebPath($filename) {
  669. if ( strpos(substr($filename, 0, 10), '://') ) {
  670. $url = $filename;
  671. } else {
  672. if ( substr($filename, 0,1) == '/' ) {
  673. $baseurl = strtolower(strtok($_SERVER['SERVER_PROTOCOL'], '/')).'://'.$_SERVER['HTTP_HOST'].$this->settings['mediaWebPath'];
  674. } elseif ( strpos(substr($this->settings['mediaWebPath'], 0, 10), '://') ) {
  675. $baseurl = $this->settings['mediaWebPath'];
  676. } else {
  677. $baseurl = get_option('siteurl').$this->settings['mediaWebPath'];
  678. }
  679. if ( substr($filename, -1, 1) != '/' ) {
  680. $baseurl .= '/';
  681. }
  682. $url = $baseurl.$filename;
  683. }
  684. return $url;
  685. }
  686. function convertPodcastFileNameToWebPath($postID, $mediaNum, $filename = '', $method = false){
  687. $url = $this->convertPodcastFileNameToValidWebPath($filename);
  688. if($method != false) {
  689. if($this->settings['enableStats']) {
  690. $filename_part = podPress_getFileName($url);
  691. if($this->settings['statMethod'] == 'download.mp3') {
  692. $url = podPress_url().'download.mp3?'.$method.'='.$postID.'/'.$mediaNum.'/'.$filename_part;
  693. } else {
  694. $url = get_bloginfo('home').'/podpress_trac/'.$method.'/'.$postID.'/'.$mediaNum.'/'.$filename_part;
  695. }
  696. } elseif($this->settings['enable3rdPartyStats'] == 'Podtrac') {
  697. $url = str_replace(array('ftp://', 'http://', 'https://'), '', $url);
  698. $url = $this->podtrac_url.$url;
  699. } elseif($this->settings['enable3rdPartyStats'] == 'BluBrry' && !empty($this->settings['statBluBrryProgramKeyword'])) {
  700. $url = $this->blubrry_url.$this->settings['statBluBrryProgramKeyword'].'/'.$url;
  701. }
  702. }
  703. $url = str_replace(' ', '%20', $url);
  704. return $url;
  705. }
  706. function convertPodcastFileNameToSystemPath($filename = ''){
  707. if( FALSE === strpos(substr($filename, 0, 10), '://') ) {
  708. //if ( FALSE === empty($this->settings['mediaFilePath']) ) {
  709. $filename = $this->settings['mediaFilePath'].'/'.$filename;
  710. if(file_exists($filename))
  711. {
  712. return $filename;
  713. }
  714. //}
  715. }
  716. return false;
  717. }
  718. /**
  719. * TryToFindAbsFileName - tries to build a absolute path for the given URL and checks whether the build path exists and is local or not. This inetended deal with the (real) URLs of the media files
  720. *
  721. * @package podPress
  722. * @since 8.8.6 beta 1
  723. *
  724. * @param str $url - The (real) URL of a media file. (real URL means the URL of a media file and not the URLs masked for statistics)
  725. *
  726. * @return mixed the abspath to the file or FALSE
  727. */
  728. function TryToFindAbsFileName($url = '') {
  729. if (FALSE == empty($url)) {
  730. $uploadpath = $this->uploadpath;
  731. // remove drive letter
  732. $uploadpath_WL = end(explode(':', $uploadpath));
  733. // remove doubled backslashes
  734. $uploadpath_san1 = str_replace("\\\\", "\\", $uploadpath_WL);
  735. // replace backslash with slashes
  736. $uploadpath_san2 = str_replace("\\", "/", $uploadpath_san1);
  737. $uploadpath_parts = explode('/', $uploadpath_san2);
  738. //$result= parse_url($url);
  739. $home= get_bloginfo('home');
  740. $result['path'] = str_replace($home, '', $url);
  741. $urlpath_parts = explode('/', $result['path']);
  742. $diff = array_diff($urlpath_parts, $uploadpath_parts);
  743. $filename = $uploadpath.'/'.implode('/', $diff);
  744. if (TRUE === file_exists($filename)) {
  745. return $filename;
  746. } else {
  747. return false;
  748. }
  749. } else {
  750. return false;
  751. }
  752. }
  753. /**
  754. * checkWritableTempFileDir - (return values different since 8.8.6) controls whether the podPress temp/-folder is exists, or can be created and is writeable. This folder is e.g. uploads/podpress_temp/
  755. *
  756. * @package podPress
  757. * @since 8.8.6 beta 5
  758. *
  759. * @param bool $returnMessages - If it is true then the function returns in case of an error instead of false a string.
  760. *
  761. * @return mixed - TRUE if the folder exists and is writeable / FALSE or a string if there is a problem
  762. */
  763. function checkWritableTempFileDir($returnMessages = FALSE) {
  764. $siteurl = get_option('siteurl');
  765. if (file_exists($this->tempfilesystempath)) {
  766. if(is_writable($this->tempfilesystempath)) {
  767. if ($returnMessages) {
  768. return __('(The folder is writeable.)', 'podpress');
  769. } else {
  770. return true;
  771. }
  772. } else {
  773. if ($returnMessages) {
  774. return '<p class="message error">'.sprintf(__('Your uploads/podpress_temp directory is not writable. Please set permissions as needed, and make sure <a href="%1$s/wp-admin/options-misc.php">configuration</a> is correct.', 'podpress'), $siteurl).'<br />'.__('Currently set to:', 'podpress').'<code>'.$this->tempfilesystempath."</code></p>\n";
  775. } else {
  776. return false;
  777. }
  778. }
  779. } elseif (!file_exists($this->uploadpath)) {
  780. if ($returnMessages) {
  781. return '<p class="message error">'.sprintf(__('Your WordPress upload directory does not exist. Please create it and make sure <a href="%1$s/wp-admin/options-misc.php">configuration</a> is correct.', 'podpress'), $siteurl).'<br />'.__('Currently set to:', 'podpress').'<code>'.$this->uploadpath."</code></p>\n";
  782. } else {
  783. return false;
  784. }
  785. } elseif (!is_writable($this->uploadpath)) {
  786. if ($returnMessages) {
  787. return '<p class="message error">'.sprintf(__('Your WordPress upload directory is not writable. Please set permissions as needed, and make sure <a href="%1$s/wp-admin/options-misc.php">configuration</a> is correct.', 'podpress'), $siteurl).'<br />'.__('Currently set to:', 'podpress').'<code>'.$this->uploadpath."</code></p>\n";
  788. } else {
  789. return false;
  790. }
  791. } else {
  792. $mkdir = @mkdir($this->tempfilesystempath);
  793. if (!$mkdir) {
  794. if ($returnMessages) {
  795. return '<p class="message error">'.__('Could not create uploads/podpress_temp directory. Please set permission of the following directory to 755 or 777:', 'podpress').'<br /><code>'.$this->tempfilesystempath."</code></p>\n";
  796. } else {
  797. return false;
  798. }
  799. } else {
  800. if ($returnMessages) {
  801. return __('(The folder is writeable.)', 'podpress');
  802. } else {
  803. return true;
  804. }
  805. }
  806. }
  807. }
  808. /*************************************************************/
  809. /* Load up the plugin values and get ready to action */
  810. /*************************************************************/
  811. function addPostData($input, $forEdit = false) {
  812. $input->podPressMedia = podPress_get_post_meta($input->ID, '_podPressMedia', true);
  813. if(!is_array($input->podPressMedia)) {
  814. $x = maybe_unserialize($input->podPressMedia);
  815. if(is_array($x)) {
  816. $input->podPressMedia = $x;
  817. }
  818. if(!is_array($input->podPressMedia)) {
  819. $x = maybe_unserialize($input->podPressMedia, true);
  820. if(is_array($x)) {
  821. $input->podPressMedia = $x;
  822. }
  823. }
  824. }
  825. if(is_array($input->podPressMedia)) {
  826. reset($input->podPressMedia);
  827. while (list($key) = each($input->podPressMedia)) {
  828. if( !empty($input->podPressMedia[$key]['URI']) ) {
  829. if ( TRUE == isset($input->podPressMedia[$key]['premium_only']) AND ($input->podPressMedia[$key]['premium_only'] == 'on' || $input->podPressMedia[$key]['premium_only'] == true) ) {
  830. $input->podPressMedia[$key]['content_level'] = 'premium_content';
  831. } elseif ( !isset($input->podPressMedia[$key]['content_level']) ) {
  832. $input->podPressMedia[$key]['content_level'] = 'free';
  833. }
  834. if(!isset($input->podPressMedia[$key]['type'])) {
  835. $input->podPressMedia[$key]['type'] = '';
  836. }
  837. settype($input->podPressMedia[$key]['size'], 'int');
  838. if(0 >= $input->podPressMedia[$key]['size']) {
  839. $filepath = $this->convertPodcastFileNameToSystemPath($input->podPressMedia[$key]['URI']);
  840. if($filepath) {
  841. $input->podPressMedia[$key]['size'] = filesize ($filepath);
  842. } else {
  843. $input->podPressMedia[$key]['size'] = 1;
  844. }
  845. }
  846. $input->podPressMedia[$key]['ext'] = podPress_getFileExt($input->podPressMedia[$key]['URI']);
  847. $input->podPressMedia[$key]['mimetype'] = podPress_mimetypes($input->podPressMedia[$key]['ext']);
  848. if(!$forEdit && $this->settings['enablePremiumContent'] && $input->podPressMedia[$key]['content_level'] != 'free' && @$GLOBALS['current_user']->allcaps[$input->podPressMedia[$key]['content_level']] != 1) {
  849. $input->podPressMedia[$key]['authorized'] = false;
  850. $input->podPressMedia[$key]['URI'] = '';
  851. $input->podPressMedia[$key]['URI_torrent'] = '';
  852. } else {
  853. $input->podPressMedia[$key]['authorized'] = true;
  854. }
  855. }
  856. }
  857. }
  858. $input->podPressPostSpecific = podPress_get_post_meta($input->ID, '_podPressPostSpecific', true);
  859. if(!is_array($input->podPressPostSpecific)) {
  860. $input->podPressPostSpecific = array();
  861. }
  862. if(empty($input->podPressPostSpecific['itunes:subtitle'])) {
  863. $input->podPressPostSpecific['itunes:subtitle'] = '##PostExcerpt##';
  864. }
  865. if(empty($input->podPressPostSpecific['itunes:summary'])) {
  866. $input->podPressPostSpecific['itunes:summary'] = '##PostExcerpt##';
  867. }
  868. if(empty($input->podPressPostSpecific['itunes:keywords'])) {
  869. $input->podPressPostSpecific['itunes:keywords'] = '##WordPressCats##';
  870. }
  871. if(empty($input->podPressPostSpecific['itunes:author'])) {
  872. $input->podPressPostSpecific['itunes:author'] = '##Global##';
  873. }
  874. if(empty($input->podPressPostSpecific['itunes:explicit'])) {
  875. $input->podPressPostSpecific['itunes:explicit'] = 'Default';
  876. }
  877. if(empty($input->podPressPostSpecific['itunes:block'])) {
  878. $input->podPressPostSpecific['itunes:block'] = 'Default';
  879. }
  880. return $input;
  881. }
  882. function the_posts($input) {
  883. if ( FALSE === is_admin() && !$this->settings['compatibilityChecks']['themeTested'] ) {
  884. $this->settings['compatibilityChecks']['themeTested'] = true;
  885. podPress_update_option('podPress_config', $this->settings);
  886. }
  887. if(!is_array($input)) {
  888. return $input;
  889. }
  890. foreach($input as $key=>$value) {
  891. $input[$key] = $this->addPostData($value);
  892. }
  893. return $input;
  894. }
  895. /**
  896. * posts_distinct - filter function which return 'DISTINCT' while it is a search query. because joining the postmeta data leads to duplicate posts in the result list.
  897. *
  898. * @package podPress
  899. * @since 8.8.10 beta 2
  900. *
  901. * @param str $input
  902. *
  903. * @return str $input - is 'DISTINCT' or an empty string
  904. */
  905. function posts_distinct($input) {
  906. if ( is_search() AND isset($this->settings['activate_podpressmedia_search']) AND TRUE === $this->settings['activate_podpressmedia_search'] ) {
  907. $input = "DISTINCT";
  908. }
  909. return apply_filters('podpress_posts_distinct', $input);
  910. }
  911. function posts_join($input) {
  912. GLOBAL $wpdb;
  913. if ( is_search() AND isset($this->settings['activate_podpressmedia_search']) AND TRUE === $this->settings['activate_podpressmedia_search'] ) {
  914. $input .= " JOIN ".$wpdb->prefix."postmeta ON ".$wpdb->prefix."posts.ID=".$wpdb->prefix."postmeta.post_id ";
  915. } else {
  916. if ( defined('PODPRESS_PODCASTSONLY') AND FALSE !== constant('PODPRESS_PODCASTSONLY') ) {
  917. $input .= " JOIN ".$wpdb->prefix."postmeta ON ".$wpdb->prefix."posts.ID=".$wpdb->prefix."postmeta.post_id ";
  918. }
  919. }
  920. return apply_filters('podpress_posts_join', $input);
  921. }
  922. function posts_where($input) {
  923. GLOBAL $wpdb, $wp;
  924. if ( is_search() AND isset($this->settings['activate_podpressmedia_search']) AND TRUE === $this->settings['activate_podpressmedia_search'] ) {
  925. // search in the URI and title for the term
  926. $input .= " OR (".$wpdb->prefix."postmeta.meta_key='_podPressMedia' AND ( 1 = (".$wpdb->prefix."postmeta.meta_value REGEXP 's:5:\"title\";s:[0-9]+:\".*".$wpdb->escape($wp->query_vars['s'])."') OR 1 = (".$wpdb->prefix."postmeta.meta_value REGEXP 's:3:\"URI\";s:[0-9]+:\".*".$wp->query_vars['s']."')) )";
  927. } else {
  928. if ( defined('PODPRESS_PODCASTSONLY') AND FALSE !== constant('PODPRESS_PODCASTSONLY') ) {
  929. $input .= " AND ".$wpdb->prefix."postmeta.meta_key='_podPressMedia' ";
  930. }
  931. }
  932. return apply_filters('podpress_posts_where', $input);
  933. }
  934. function insert_the_excerpt($content = '') {
  935. GLOBAL $post;
  936. if ( FALSE == !empty($post->post_excerpt) ) {
  937. $this->tempcontentaddedto[$post->ID] = true;
  938. }
  939. $this->isexcerpt = true;
  940. return $content;
  941. }
  942. function insert_the_excerptplayer($content = '') {
  943. GLOBAL $post;
  944. $this->isexcerpt = true;
  945. $content = $this->insert_content($content, TRUE);
  946. return $content;
  947. }
  948. function insert_content($content = '', $is_the_excerpt = FALSE) {
  949. GLOBAL $post, $podPressTemplateData, $podPressTemplateUnauthorizedData, $wpdb;
  950. if ( !empty($post->post_password) ) { // if there's a password
  951. if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie
  952. return $content;
  953. }
  954. }
  955. if ( $this->isexcerpt === $is_the_excerpt ) {
  956. unset($this->tempcontentaddedto[$post->ID]);
  957. }
  958. $this->isexcerpt = FALSE;
  959. if ( isset($this->tempcontentaddedto[$post->ID]) ) {
  960. if ( is_feed() ) {
  961. return str_replace($this->podcasttag,'',$content);
  962. } else {
  963. return $content;
  964. }
  965. } else {
  966. $this->tempcontentaddedto[$post->ID] = true;
  967. }
  968. if ( is_feed() ) {
  969. return str_replace($this->podcasttag, '', $content);
  970. }
  971. if(!is_array($post->podPressMedia)) {
  972. return str_replace($this->podcasttag,'',$content);
  973. }
  974. if ( FALSE === stristr($content, $this->podcasttag) ) {
  975. if($this->settings['contentBeforeMore'] == 'no') {
  976. if (is_home() or is_archive()) {
  977. if ( FALSE !== strpos($post->post_content, '<!--more-->') ) {
  978. return $content;
  979. }
  980. }
  981. }
  982. if($this->settings['contentLocation'] == 'start') {
  983. $content = $this->podcasttag.$content;
  984. } else {
  985. $content .= $this->podcasttag;
  986. }
  987. }
  988. $podpressTag_in_the_content = '<p>'.$this->podcasttag.'</p>';
  989. // add the player and the other elements not if the related setting has been set
  990. if ( TRUE == isset($this->settings['incontentandexcerpt']) ) {
  991. if ( $is_the_excerpt === TRUE ) {
  992. switch ( $this->settings['incontentandexcerpt'] ) {
  993. default :
  994. case 'in_content_and_excerpt' :
  995. case 'in_excerpt_only' :
  996. break;
  997. case 'in_content_only' :
  998. if ( FALSE !== stripos($content, $podpressTag_in_the_content) ) {
  999. return str_replace($podpressTag_in_the_content, '', $content);
  1000. } else {
  1001. return str_replace($this->podcasttag,'',$content);
  1002. }
  1003. break;
  1004. }
  1005. } else {
  1006. switch ( $this->settings['incontentandexcerpt'] ) {
  1007. default :
  1008. case 'in_content_and_excerpt' :
  1009. case 'in_content_only' :
  1010. break;
  1011. case 'in_excerpt_only' :
  1012. if ( FALSE !== stripos($content, $podpressTag_in_the_content) ) {
  1013. return str_replace($podpressTag_in_the_content, '', $content);
  1014. } else {
  1015. return str_replace($this->podcasttag,'',$content);
  1016. }
  1017. break;
  1018. }
  1019. }
  1020. }
  1021. //~ $podPressRSSContent = '';
  1022. $showmp3player = false;
  1023. $showvideopreview = false;
  1024. $showvideoplayer = false;
  1025. $podPressTemplateData = array();
  1026. $podPressTemplateData['showDownloadText'] = $this->settings['contentDownloadText'];
  1027. $podPressTemplateData['showDownloadStats'] = $this->settings['contentDownloadStats'];
  1028. $podPressTemplateData['showDuration'] = $this->settings['contentDuration'];
  1029. $podPressTemplateData['showfilesize'] = $this->settings['contentfilesize'];
  1030. $this->playerCount++;
  1031. $podPressTemplateData['files'] = array();
  1032. $podPressTemplateData['player'] = array();
  1033. reset($post->podPressMedia);
  1034. while (list($key) = each($post->podPressMedia)) {
  1035. if(empty($post->podPressMedia[$key]['previewImage'])) {
  1036. $post->podPressMedia[$key]['previewImage'] = $this->settings['videoPreviewImage'];
  1037. }
  1038. $supportedVideoTypes = array('video_mp4', 'video_m4v', 'video_mov', 'video_qt', 'video_avi', 'video_mpg', 'video_asf', 'video_wmv', 'video_flv', 'video_swf', 'video_ogv');
  1039. if (TRUE == $this->settings['disableVideoPreview'] AND TRUE == in_array($post->podPressMedia[$key]['type'], $supportedVideoTypes)) {
  1040. $post->podPressMedia[$key]['disablePreview'] = true;
  1041. }
  1042. if ( TRUE == isset($post->podPressMedia[$key]['feedonly']) AND 'on' == $post->podPressMedia[$key]['feedonly'] ) {
  1043. continue;
  1044. }
  1045. $post->podPressMedia[$key]['title'] = htmlentities(stripslashes($post->podPressMedia[$key]['title']), ENT_QUOTES, get_option('blog_charset'));
  1046. $post->podPressMedia[$key]['stats'] = false;
  1047. if($this->settings['enableStats']) {
  1048. $pos = strrpos($post->podPressMedia[$key]['URI'], '/');
  1049. //$len = strlen($post->podPressMedia[$key]['URI']);
  1050. while(substr($post->podPressMedia[$key]['URI'], $pos, 1) == '/') {
  1051. $pos++;
  1052. }
  1053. $filename = substr($post->podPressMedia[$key]['URI'], $pos);
  1054. if($this->settings['statLogging'] == 'Full' || $this->settings['statLogging'] == 'FullPlus') {
  1055. $where = $this->wherestr_to_exclude_bots('', 'AND');
  1056. $query_string="SELECT method, COUNT(DISTINCT id) as downloads FROM ".$wpdb->prefix."podpress_stats WHERE postID='".$post->ID."' AND media='".rawurlencode($filename)."' ".$where."GROUP BY method ORDER BY method ASC";
  1057. $stats = $wpdb->get_results($query_string);
  1058. if (0 < count($stats)) {
  1059. $feed = intval($stats[0]->downloads);
  1060. $play = intval($stats[1]->downloads);
  1061. $web = intval($stats[2]->downloads);
  1062. $post->podPressMedia[$key]['stats'] = array('feed'=>$feed, 'web'=>$web, 'play'=>$play, 'total'=>($feed+$play+$web));
  1063. }
  1064. } else {
  1065. $sql = "SELECT * FROM ".$wpdb->prefix."podpress_statcounts WHERE media = '".rawurlencode($filename)."'";
  1066. $stats = $wpdb->get_results($sql);
  1067. if($stats) {
  1068. $post->podPressMedia[$key]['stats'] = array('feed'=>intval($stats[0]->feed), 'web'=>intval($stats[0]->web), 'play'=>intval($stats[0]->play), 'total'=>intval($stats[0]->total));
  1069. }
  1070. }
  1071. }
  1072. $supportedMediaTypes = array('audio_mp3', 'audio_ogg', 'audio_m4a', 'audio_mp4', 'audio_m3u', 'video_mp4', 'video_m4v', 'video_mov', 'video_qt', 'video_avi', 'video_mpg', 'video_asf', 'video_wmv', 'audio_wma', 'video_flv', 'video_swf', 'video_ogv', 'ebook_pdf', 'ebook_epub', 'embed_youtube', 'misc_torrent');
  1073. if(!in_array($post->podPressMedia[$key]['type'], $supportedMediaTypes)) {
  1074. $post->podPressMedia[$key]['type'] = 'misc_other';
  1075. }
  1076. // this loop is for the basics. After this the unauthorized content will stop
  1077. if(empty($post->podPressMedia[$key]['title'])) {
  1078. $post->podPressMedia[$key]['title'] = podPress_defaultTitles($post->podPressMedia[$key]['type']);
  1079. }
  1080. if ( '##Global##' == $post->podPressPostSpecific['itunes:author'] ) {
  1081. Global $podPress;
  1082. if (empty($podPress->settings['iTunes']['author'])) {
  1083. $post->podPressMedia[$key]['artist'] = get_bloginfo('blogname');
  1084. } else {
  1085. $post->podPressMedia[$key]['artist'] = $podPress->settings['iTunes']['author'];
  1086. }
  1087. } else {
  1088. $post->podPressMedia[$key]['artist'] = $post->podPressPostSpecific['itunes:author'];
  1089. }
  1090. if($this->settings['contentImage'] != 'none') {
  1091. $post->podPressMedia[$key]['image'] = $post->podPressMedia[$key]['type'].'_'.$this->settings['contentImage'].'.png';
  1092. }
  1093. if($post->podPressMedia[$key]['authorized']) {
  1094. $post->podPressMedia[$key]['URI_orig'] = $post->podPressMedia[$key]['URI'];
  1095. $post->podPressMedia[$key]['URI'] = $this->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI'], 'web');
  1096. $post->podPressMedia[$key]['URI_Player'] = $this->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI_orig'], 'play');
  1097. if(!empty($post->podPressMedia[$key]['URI_torrent'])) {
  1098. $post->podPressMedia[$key]['URI_torrent'] = $this->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI_torrent'], 'web');
  1099. }
  1100. if($this->settings['contentDownload'] == 'disabled') {
  1101. $post->podPressMedia[$key]['enableDownload'] = false;
  1102. $post->podPressMedia[$key]['enableTorrentDownload'] = false;
  1103. } else {
  1104. $post->podPressMedia[$key]['enableDownload'] = true;
  1105. //~ $podPressRSSContent .= '<a href="'.$post->podPressMedia[$key]['URI'].'">'.__('Download', 'podpress').' '.__($post->podPressMedia[$key]['title'], 'podpress').'</a><br/>';
  1106. if($this->settings['enableTorrentCasting'] && !empty($post->podPressMedia[$key]['URI_torrent'])) {
  1107. $post->podPressMedia[$key]['enableTorrentDownload'] = true;
  1108. }
  1109. }
  1110. switch($this->settings['contentPlayer']) {
  1111. case 'disabled':
  1112. $post->podPressMedia[$key]['enablePlayer'] = fal

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