PowerPress Podcasting plugin by Blubrry - Version 6.0

Version Description

  • Released on 12/19/2014
  • You must have WordPress 3.6 or newer and PHP 5.2 or newer for PowerPress 6.0.
  • NEW FEATURE: Playlist player, utilizes WordPress built-in playlist specifically for podcasting. Learn more
  • NEW FEATURE: Subscribe links, adds subscribe on iTunes and via RSS links below the player and links.
  • NEW FEATURE: Subscribe page template and [powerpress_subscribe] page shortcode added. Create a "Subscribe to podcast" page for your podcast.
  • NEW FEATURE: Subscribe to podcast widget, adds subscribe on iTunes and via RSS links to side bar, with optional link to subscribe to podcast page.
  • NEW FEATURE: Podcasting SEO settings. Includes options to customize podcast feed titles, AudioObjects, VideoObjects, and highlight key iTunes fields.
  • NEW FEATURE: Migrate to Blubrry Podcast Hosting in 3 easy steps added.
  • iTunes image requirements updated, 1400x1400 minimum size is now "required" and 2048x2048 is now the maximum size for iTunes artwork.
  • iTunes category and subcategory selection updated for latest iTunes category selection rules.
  • Enhnaced iTunes Summary is back! The feature actually never left, but for the past few years links were not formatted in the iOS app. Now that they are, we now recommend the feature.
  • Fixed bug where Feed Maximizer option only worked when Podcast Channels was enabled (Thanks Daniel Lewis for bringing to our attention!)
  • Fixed bug where player and links would not appear if Yoast's WordPress SEO plugin option "Add Open Graph meta data" was enabled.
  • iTunes keywords feature has been removed, feature was deprecated last year by Apple. The iTunes keywords field will appear for previous episodes that used the feature.
  • Added support for Opus audio with content type audio/ogg. (Thanks thebugcast for the heads up!)
  • Files with 'ogg' file extension are now treated as audio/ogg, unless the following define is added to your wp-config.php: define('POWERPRESS_OGG_VIDEO', true); (Thanks thebugcast for pointing out the default!)
  • Updated the Find and Replace episode URLs tool to use native WordPress MySQL query functions.
  • Changed the logic for HEAD requests for HTTP authentication. Default WordPress behavior is to exit all HEAD requests. (Thanks thebugcast!)
  • Changed all content types to either use the site default or use UTF8 (applies to play in new window and 401 Unauthorized HTML pages).
  • Added new powerpress_premium_content_authorized filter for premium plugins to override the default behavior which uses roles and capabilities.
  • Updated the getid3 library to latest version, PowerPress now includes ogg duration detection support for "Speex" or "vorbis".
  • We are no longer detecting if the sample rate is optimal, we're no longer worried about Flash playback.
  • Removed Flow Player, Simple Flash, AudioPlay and Flash Mp3 Maxi players. These flash players are no longer supported.
  • New MediaElement.js Audio player max width setting added. Player will now display full with otherwise. Player is now responsive, the width will shrink or stretch for the screen.
  • Improved MediaElement.js Video player width and height settings. Player will now display full width, or as styled by the theme's CSS if width and height are blank. Player is now responsive, the width will shrink or stretch for the screen, the height can be set with a blank width to allow for the player to fit different screens.
  • We are now warning users not to use Flash based players in the player selection screens.
  • Added option to set stats redirect at the channel/post type level. Requires a define CHANNEL_STATS_REDIRECT and/or POST_TYPE_STATS_REDIRECT in the wp-config.php file.
  • FeedBurner feed URL when set will be used in the new subscribe page and subscribe sidebar widget (Thanks Daniel Lewis for bringing to our attention)
  • Playlist Player no longer includes the play time when it is zero. (Thanks Daniel Lewis for bringing to our attention)
  • Program Titles with double quotes in the general settings was not escaped correctly, it is now fixed. (Thanks Robin for bringing to our attention)
  • Edit value fields now use the esc_attr() wordpress function rather than the htmlspecialchars() native PHP function.
  • Added powerpress_admin_capabilities filter for premium capabilities. (Thanks Blair Williams for the suggestion)
  • Made subscribe sidebar and subscribe embed button icons Retina screen compatible
  • Re-added the blubrry folder icon for blubrry podcast hosting customers.
  • Tweaked wording and updated documentation for SEO settings (Thanks Daniel Lewis for the feedback!)
  • Tweaked updated documentation for the PowerPress Playlist (Thanks Daniel Lewis for asking questions, it helped us better document the features)
  • Fixed subscribe links always displaying (thanks Thiago Miro for pointing out the bug)
  • Fixed upload itunes image and poster image episode functions to use selected image size when "Link URL" is blank (Thanks Daniel Lewis for bringing to our attention)
  • Added a learn more link to the SEO page.
  • Added code for the new Subscribe embed so the subscribe embed CSS is only loaded when the shortcode is used in a page.
  • Added the wp-video and wp-video-shortcode classes to the MEJS video player so latest CSS styling in WordPress is again applied 100% of the time to the MEJS player packaged in PowerPress.
  • Playlist player will now use the iTunes episode image if one is set for each episode. Program level image is used if no image is set.
  • Playlist player taxonomy podcasting now accepts the term_taxonomy_id, making it more efficient.
  • Moved the Shortcodes into their own section in Media Appearance settings, they are now included in Podcast Channels, Category Podcasting, Post Type podcasting and Taxonomy podcasting with the appropriate attributes set for convenience.
  • Brazilian Portuguese translation for v6.0+ by Leo Lopes from Radiofobia.

=

Download this release

Release Info

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

Code changes from version 5.0.10 to 6.0

Files changed (51) hide show
  1. 3rdparty/maxi_player/generator.js +0 -147
  2. audioplay.swf +0 -0
  3. buttons/classic/pausedown.png +0 -0
  4. buttons/classic/pauseover.png +0 -0
  5. buttons/classic/pauseup.png +0 -0
  6. buttons/classic/playdown.png +0 -0
  7. buttons/classic/playover.png +0 -0
  8. buttons/classic/playup.png +0 -0
  9. buttons/classic/stopdown.png +0 -0
  10. buttons/classic/stopover.png +0 -0
  11. buttons/classic/stopup.png +0 -0
  12. buttons/classic_small/pausedown.png +0 -0
  13. buttons/classic_small/pauseover.png +0 -0
  14. buttons/classic_small/pauseup.png +0 -0
  15. buttons/classic_small/playdown.png +0 -0
  16. buttons/classic_small/playover.png +0 -0
  17. buttons/classic_small/playup.png +0 -0
  18. buttons/classic_small/stopdown.png +0 -0
  19. buttons/classic_small/stopover.png +0 -0
  20. buttons/classic_small/stopup.png +0 -0
  21. buttons/negative/pausedown.png +0 -0
  22. buttons/negative/pauseover.png +0 -0
  23. buttons/negative/pauseup.png +0 -0
  24. buttons/negative/playdown.png +0 -0
  25. buttons/negative/playover.png +0 -0
  26. buttons/negative/playup.png +0 -0
  27. buttons/negative/stopdown.png +0 -0
  28. buttons/negative/stopover.png +0 -0
  29. buttons/negative/stopup.png +0 -0
  30. buttons/negative_small/pausedown.png +0 -0
  31. buttons/negative_small/pauseover.png +0 -0
  32. buttons/negative_small/pauseup.png +0 -0
  33. buttons/negative_small/playdown.png +0 -0
  34. buttons/negative_small/playover.png +0 -0
  35. buttons/negative_small/playup.png +0 -0
  36. buttons/negative_small/stopdown.png +0 -0
  37. buttons/negative_small/stopover.png +0 -0
  38. buttons/negative_small/stopup.png +0 -0
  39. class.powerpress-subscribe-widget.php +256 -0
  40. css/admin.css +18 -10
  41. css/dashboard.css +23 -1
  42. css/subscribe.css +171 -0
  43. getid3/getid3.lib.php +1379 -1317
  44. getid3/getid3.php +1809 -1766
  45. getid3/module.audio-video.quicktime.php +2246 -2134
  46. getid3/module.audio-video.riff.php +2586 -2409
  47. getid3/module.audio.aac.php +513 -515
  48. getid3/module.audio.flac.php +443 -0
  49. getid3/module.audio.mp3.php +2012 -2011
  50. getid3/module.audio.ogg.php +756 -0
  51. getid3/module.tag.apetag.php +0 -317
3rdparty/maxi_player/generator.js DELETED
@@ -1,147 +0,0 @@
1
- var generator = new Object();
2
- generator.params = new Object();
3
- generator.updateParam = function(name, value)
4
- {
5
- //var element = document.getElementById(id);
6
- switch (this.params[name].type) {
7
- case "url":
8
- case "text":
9
- case "color":
10
- this.params[name].value = value;
11
- break;
12
- case "int":
13
- this.params[name].value = Number(value);
14
- break;
15
- case "bool":
16
- this.params[name].value = value; // (value == "on")?1:0;
17
- break;
18
- }
19
- }
20
-
21
- generator.addParam = function(id, name, type, defaultValue)
22
- {
23
- var element = document.getElementById(id);
24
- this.params[name] = new Object();
25
- this.params[name].type = type;
26
- this.params[name].defaultValue = defaultValue;
27
- this.params[name].element = element;
28
- switch (type) {
29
- case "url":
30
- case "text":
31
- this.params[name].value = element.value;
32
- element.onchange = delegate(this.params[name], function()
33
- {
34
- this.value = this.element.value;
35
- generator.updatePlayer();
36
- });
37
- break;
38
- case "color":
39
- this.params[name].value = element.value.replace(/#/, '');
40
- element.onchange = delegate(this.params[name], function()
41
- {
42
- this.value = this.element.value;
43
- generator.updatePlayer();
44
- });
45
- break;
46
- break;
47
- case "int":
48
- this.params[name].value = Number(element.value);
49
- element.onchange = delegate(this.params[name], function()
50
- {
51
- this.value = Number(this.element.value);
52
- generator.updatePlayer();
53
- });
54
- break;
55
- case "bool":
56
- this.params[name].value = element.value; // (element.value == "on")?1:0;
57
- element.onchange = delegate(this.params[name], function()
58
- {
59
- this.value = this.element.value; // (this.element.value == "on")?1:0;
60
- generator.updatePlayer();
61
- });
62
- break;
63
- }
64
- };
65
- generator.updatePlayer = function()
66
- {
67
- var out = '<object type="application/x-shockwave-flash" data="'+this.player+'" width="'+this.params.width.value+'" height="'+this.params.height.value+'">'+"\n";
68
- out += ' <param name="movie" value="'+this.player+'" />'+"\n";
69
- if (this.params.bgcolor) {
70
- out += ' <param name="bgcolor" value="#'+this.params.bgcolor.value.replace(/#/, '')+'" />'+"\n";
71
- }
72
- out += ' <param name="FlashVars" value="';
73
-
74
- var separator = '';
75
- for (var i in this.params) {
76
- if (this.params[i].value != this.params[i].defaultValue && this.params[i].value != '' ) {
77
- if (this.params[i].type == "url") {
78
- out += separator + i + '=' + escape(this.params[i].value);
79
- }
80
- else if(this.params[i].type == "color") {
81
- out += separator + i + '=' + this.params[i].value.replace(/#/, '');
82
- }
83
- else {
84
- out += separator + i + '=' + escapeHTML(this.params[i].value);
85
- }
86
- separator = '&amp;';
87
- }
88
- }
89
-
90
- out += '" />'+"\n";
91
- out += '</object>';
92
-
93
- var player = document.getElementById("player_preview");
94
- player.innerHTML = out;
95
- };
96
-
97
- var params = new Object();
98
-
99
- /* =============== UTILS =============== */
100
- var delegate = function(pTarget, pFunction)
101
- {
102
- var f = function(){
103
- arguments.callee.func.apply(arguments.callee.target, arguments);
104
- };
105
- f.target = pTarget;
106
- f.func = pFunction;
107
- return f;
108
- }
109
- var escapeHTML = function(str) {
110
- str = String(str);
111
- str = str.replace(/&/gi, '');
112
-
113
- var div = document.createElement("div");
114
- var text = document.createTextNode('');
115
- div.appendChild(text);
116
- text.data = str;
117
-
118
- var result = div.innerHTML;
119
- result = result.replace(/"/gi, '&quot;');
120
-
121
- return result;
122
- }
123
- var findPosX = function (obj)
124
- {
125
- var curleft = 0;
126
- do {
127
- curleft += obj.offsetLeft || 0;
128
- obj = obj.offsetParent;
129
- } while (obj);
130
- return curleft;
131
- };
132
- var findPosY = function (obj)
133
- {
134
- var curtop = 0;
135
- do {
136
- curtop += obj.offsetTop || 0;
137
- obj = obj.offsetParent;
138
- } while (obj);
139
- return curtop;
140
- };
141
- var twoChar = function (str)
142
- {
143
- if (str.length == 1) {
144
- return "0" + str;
145
- }
146
- return str;
147
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
audioplay.swf DELETED
Binary file
buttons/classic/pausedown.png DELETED
Binary file
buttons/classic/pauseover.png DELETED
Binary file
buttons/classic/pauseup.png DELETED
Binary file
buttons/classic/playdown.png DELETED
Binary file
buttons/classic/playover.png DELETED
Binary file
buttons/classic/playup.png DELETED
Binary file
buttons/classic/stopdown.png DELETED
Binary file
buttons/classic/stopover.png DELETED
Binary file
buttons/classic/stopup.png DELETED
Binary file
buttons/classic_small/pausedown.png DELETED
Binary file
buttons/classic_small/pauseover.png DELETED
Binary file
buttons/classic_small/pauseup.png DELETED
Binary file
buttons/classic_small/playdown.png DELETED
Binary file
buttons/classic_small/playover.png DELETED
Binary file
buttons/classic_small/playup.png DELETED
Binary file
buttons/classic_small/stopdown.png DELETED
Binary file
buttons/classic_small/stopover.png DELETED
Binary file
buttons/classic_small/stopup.png DELETED
Binary file
buttons/negative/pausedown.png DELETED
Binary file
buttons/negative/pauseover.png DELETED
Binary file
buttons/negative/pauseup.png DELETED
Binary file
buttons/negative/playdown.png DELETED
Binary file
buttons/negative/playover.png DELETED
Binary file
buttons/negative/playup.png DELETED
Binary file
buttons/negative/stopdown.png DELETED
Binary file
buttons/negative/stopover.png DELETED
Binary file
buttons/negative/stopup.png DELETED
Binary file
buttons/negative_small/pausedown.png DELETED
Binary file
buttons/negative_small/pauseover.png DELETED
Binary file
buttons/negative_small/pauseup.png DELETED
Binary file
buttons/negative_small/playdown.png DELETED
Binary file
buttons/negative_small/playover.png DELETED
Binary file
buttons/negative_small/playup.png DELETED
Binary file
buttons/negative_small/stopdown.png DELETED
Binary file
buttons/negative_small/stopover.png DELETED
Binary file
buttons/negative_small/stopup.png DELETED
Binary file
class.powerpress-subscribe-widget.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package PowerPressSubscribe_Widget
4
+ */
5
+ class PowerPressSubscribe_Widget extends WP_Widget {
6
+
7
+ function __construct() {
8
+ load_plugin_textdomain( 'powerpress' );
9
+
10
+ parent::__construct(
11
+ 'powerpress_subscribe',
12
+ __( 'Subscribe to Podcast' , 'powerpress'),
13
+ array( 'description' => __( 'Display subscribe to podcast links.' , 'powerpress') )
14
+ );
15
+
16
+ if ( is_active_widget( false, false, $this->id_base ) ) {
17
+ add_action( 'wp_head', array( $this, 'css' ) );
18
+ }
19
+ }
20
+
21
+ function css() {
22
+ ?>
23
+
24
+ <style type="text/css">
25
+
26
+ /*
27
+ PowerPress subscribe sidebar widget
28
+ */
29
+ .widget-area .widget_powerpress_subscribe h2,
30
+ .widget-area .widget_powerpress_subscribe h3,
31
+ .widget-area .widget_powerpress_subscribe h4,
32
+ .widget_powerpress_subscribe h2,
33
+ .widget_powerpress_subscribe h3,
34
+ .widget_powerpress_subscribe h4 {
35
+ margin-bottom: 0;
36
+ padding-bottom: 0;
37
+ }
38
+
39
+ .pp-ssb-widget {
40
+ width: 100%;
41
+ margin: 0 auto;
42
+ font-family: Sans-serif;
43
+ color: #FFFFFF;
44
+ }
45
+ body .pp-ssb-widget a.pp-ssb-btn {
46
+ width: 100% !important;
47
+ height: 48px;
48
+ padding: 0;
49
+ color: #FFFFFF;
50
+ display: inline-block;
51
+ margin: 10px 0 10px 0;
52
+ text-decoration: none;
53
+ text-align:left;
54
+ vertical-align: middle;
55
+ line-height: 48px;
56
+ font-size: 90% !important;
57
+ font-weight: bold !important;
58
+ overflow: hidden;
59
+ border-radius: 1px;
60
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
61
+ }
62
+
63
+ body .sidebar .widget .pp-ssb-widget a:link,
64
+ body .sidebar .widget .pp-ssb-widget a:visited,
65
+ body .sidebar .widget .pp-ssb-widget a:active,
66
+ body .sidebar .widget .pp-ssb-widget a:hover,
67
+ body .pp-ssb-widget a.pp-ssb-btn:link,
68
+ body .pp-ssb-widget a.pp-ssb-btn:visited,
69
+ body .pp-ssb-widget a.pp-ssb-btn:active,
70
+ body .pp-ssb-widget a.pp-ssb-btn:hover {
71
+ text-decoration: none !important;
72
+ color: #FFFFFF;
73
+ }
74
+ .pp-ssb-widget-dark a,
75
+ .pp-ssb-widget-modern a {
76
+ background-color: #222222;
77
+ }
78
+ .pp-ssb-widget-modern a.pp-ssb-itunes {
79
+ background-color: #732BBE;
80
+ }
81
+ .pp-ssb-widget-modern a.pp-ssb-email {
82
+ background-color: #337EC9;
83
+ }
84
+ .pp-ssb-widget-modern a.pp-ssb-rss {
85
+ background-color: #FF8800;
86
+ }
87
+ .pp-ssb-ic {
88
+ width: 48px;
89
+ height: 48px;
90
+ border: 0;
91
+ display: inline-block;
92
+ vertical-align: middle;
93
+ margin-right: 2px;
94
+ background-image: url(<?php echo powerpress_get_root_url(); ?>/images/spriteStandard.png);
95
+ background-repeat: no-repeat;
96
+ background-size: 294px;
97
+ }
98
+ .pp-ssb-itunes .pp-ssb-ic {
99
+ background-position: -49px 0;
100
+ }
101
+ .pp-ssb-rss .pp-ssb-ic {
102
+ background-position: 0 -49px;
103
+ }
104
+ .pp-ssb-email .pp-ssb-ic {
105
+ background-position: -196px -49px;
106
+ }
107
+ .pp-ssb-more .pp-ssb-ic {
108
+ background-position: -49px -49px;
109
+ }
110
+ /* Retina-specific stuff here */
111
+ @media only screen and (-webkit-min-device-pixel-ratio: 2.0),
112
+ only screen and (min--moz-device-pixel-ratio: 2.0),
113
+ only screen and (-o-min-device-pixel-ratio: 200/100),
114
+ only screen and (min-device-pixel-ratio: 2.0) {
115
+ .pp-sub-ic {
116
+ background-image: url(<?php echo powerpress_get_root_url(); ?>/images/spriteRetina.png);
117
+ }
118
+ }
119
+ </style>
120
+ <?php
121
+ }
122
+
123
+ function form( $instance ) {
124
+ if ( empty($instance['title']) ) {
125
+ $instance['title'] = __( 'Subscribe to Podcast' , 'powerpress');
126
+ }
127
+ if ( empty($instance['subscribe_type']) ) {
128
+ $instance['subscribe_type'] = '';
129
+ }
130
+ if ( empty($instance['subscribe_post_type']) ) {
131
+ $instance['subscribe_post_type'] = '';
132
+ }
133
+ if ( empty($instance['subscribe_feed_slug']) ) {
134
+ $instance['subscribe_feed_slug'] = '';
135
+ }
136
+ if ( empty($instance['subscribe_category_id']) ) {
137
+ $instance['subscribe_category_id'] = '';
138
+ }
139
+
140
+
141
+ ?>
142
+ <p>
143
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' , 'powerpress'); ?></label>
144
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
145
+ </p>
146
+ <p>
147
+ <label for="<?php echo $this->get_field_id('subscribe_type'); ?>"><?php _e( 'Select Podcast Type:', 'powerpress' ); ?></label>
148
+ <select class="widefat" id="<?php echo $this->get_field_id('subscribe_type'); ?>" name="<?php echo $this->get_field_name('subscribe_type'); ?>">
149
+ <?php
150
+ $types = array(''=>__('Default Podcast','powerpress'), 'channel'=>__('Podcast Channel','powerpress'), 'category'=>__('Category Podcasting','powerpress') ); //, 'post_type'=>__('Post Type Podcasting','powerpress'), 'ttid'=>__('Taxonomy Podcasting','powerpress'));
151
+ while( list($type, $label) = each($types) ) {
152
+ echo '<option value="' . $type . '"'
153
+ . selected( $instance['subscribe_type'], $type, false )
154
+ . '>' . $label . "</option>\n";
155
+ }
156
+ ?>
157
+ </select>
158
+ </p>
159
+ <?php
160
+ /*
161
+ ?>
162
+ <p id="<?php echo $this->get_field_id('subscribe_post_type_section'); ?>">
163
+ <label for="<?php echo $this->get_field_id('subscribe_post_type'); ?>"><?php _e( 'Select Post Type:', 'powerpress' ); ?></label>
164
+ <select class="widefat" id="<?php echo $this->get_field_id('subscribe_post_type'); ?>" name="<?php echo $this->get_field_name('subscribe_post_type'); ?>">
165
+ <option value=""><?php echo __('Select Post Type', 'powerpress'); ?></option>
166
+ <?php
167
+ $post_types = powerpress_admin_get_post_types(false);
168
+ while( list($index, $label) = each($post_types) ) {
169
+ echo '<option value="' . $label . '"'
170
+ . selected( $instance['subscribe_post_type'], $label, false )
171
+ . '>' . $label . "</option>\n";
172
+ }
173
+ ?>
174
+ </select>
175
+ </p>
176
+ <?php */ ?>
177
+
178
+ <p id="<?php echo $this->get_field_id('subscribe_feed_slug_section'); ?>">
179
+ <label for="<?php echo $this->get_field_id( 'subscribe_feed_slug' ); ?>"><?php esc_html_e( 'Feed Slug:' , 'powerpress'); ?></label>
180
+ <input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_feed_slug' ); ?>" name="<?php echo $this->get_field_name( 'subscribe_feed_slug' ); ?>" type="text" value="<?php echo esc_attr( $instance['subscribe_feed_slug'] ); ?>" />
181
+ </p>
182
+
183
+ <p id="<?php echo $this->get_field_id('subscribe_category_id_section'); ?>">
184
+ <label for="<?php echo $this->get_field_id( 'subscribe_category_id' ); ?>"><?php esc_html_e( 'Category ID:' , 'powerpress'); ?></label>
185
+ <input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_category_id' ); ?>" name="<?php echo $this->get_field_name( 'subscribe_category_id' ); ?>" type="text" value="<?php echo esc_attr( $instance['subscribe_category_id'] ); ?>" />
186
+ </p>
187
+
188
+ <?php
189
+ }
190
+
191
+ function update( $new_instance, $old_instance ) {
192
+ $instance['title'] = strip_tags( $new_instance['title'] );
193
+ $instance['subscribe_type'] = strip_tags( $new_instance['subscribe_type'] ); // general, channel, category, post_type, ttid
194
+ $instance['subscribe_post_type'] = strip_tags( $new_instance['subscribe_post_type'] );; // eg sermons
195
+ $instance['subscribe_feed_slug'] = strip_tags( $new_instance['subscribe_feed_slug'] );; // e.g. podcast
196
+ $instance['subscribe_category_id'] = strip_tags( $new_instance['subscribe_category_id'] );; // e.g. 456
197
+ //$instance['subscribe_term_taxonomy_id'] = strip_tags( $new_instance['subscribe_term_taxonomy_id'] );; // e.g. 345
198
+ return $instance;
199
+ }
200
+
201
+ function widget( $args, $instance ) {
202
+
203
+ $ExtraData = array('type'=>'general', 'feed'=>'', 'taxonomy_term_id'=>'', 'cat_id'=>'', 'post_type'=>'');
204
+ if( !empty($instance['subscribe_type']) )
205
+ $ExtraData['type'] = $instance['subscribe_type'];
206
+
207
+ switch( $instance['subscribe_type'] )
208
+ {
209
+ case 'post_type': {
210
+ if( empty($instance['subscribe_post_type']) )
211
+ return;
212
+ $ExtraData['post_type'] = $instance['subscribe_post_type'];
213
+ };
214
+ case 'channel': {
215
+ if( empty($instance['subscribe_feed_slug']) )
216
+ return;
217
+ $ExtraData['feed'] = $instance['subscribe_feed_slug'];
218
+ }; break;
219
+ case 'ttid': {
220
+ if( empty($instance['subscribe_term_taxonomy_id']) || !is_numeric($instance['subscribe_term_taxonomy_id']) )
221
+ return;
222
+ $ExtraData['taxonomy_term_id'] = $instance['subscribe_term_taxonomy_id'];
223
+ }; break;
224
+ case 'category': {
225
+ if( empty($instance['subscribe_category_id']) || !is_numeric($instance['subscribe_category_id']) )
226
+ return;
227
+ $ExtraData['cat_id'] = $instance['subscribe_category_id'];
228
+ }; break;
229
+ default: {
230
+ // Doesn't matter, we'r using the default podcast channel
231
+
232
+ };
233
+ }
234
+
235
+ $Settings = powerpresssubscribe_get_settings( $ExtraData );
236
+ if( empty($Settings) )
237
+ return;
238
+
239
+ echo $args['before_widget'];
240
+ if ( ! empty( $instance['title'] ) ) {
241
+ echo $args['before_title'];
242
+ echo esc_html( $instance['title'] );
243
+ echo $args['after_title'];
244
+ }
245
+
246
+ echo powerpress_do_subscribe_sidebar_widget( $Settings );
247
+ echo $args['after_widget'];
248
+ return;
249
+ }
250
+ }
251
+
252
+ function powerpress_subscribe_register_widget() {
253
+ register_widget( 'PowerPressSubscribe_Widget' );
254
+ }
255
+
256
+ add_action( 'widgets_init', 'powerpress_subscribe_register_widget' );
css/admin.css CHANGED
@@ -2,28 +2,29 @@
2
  .powerpress-notice,
3
  div.powerpress-notice,
4
  .wrap div.powerpress-notice {
5
- margin-top: 20px;
6
- margin-bottom: 10px;
7
  line-height: 29px;
8
  font-size: 12px;
9
  border-width: 1px;
10
  border-style: solid;
11
  font-weight: bold;
 
12
  }
13
  .powerpress-error,
14
  div.powerpress-error,
15
  .wrap div.powerpress-error {
16
- margin-top: 10px;
17
- margin-bottom: 10px;
18
  line-height: 29px;
19
  font-size: 12px;
20
  border-width: 1px;
21
  border-style: solid;
22
  font-weight: bold;
23
- margin-top: 20px;
24
  }
25
  #powerpress_settings {
26
- background-image:url(http://images.blubrry.com/powerpress/blubrry_logo5.png);
27
  background-repeat: no-repeat;
28
  background-position: bottom right;
29
  }
@@ -243,11 +244,21 @@ padding-bottom: 15px;
243
  left: 0;
244
  position: absolute;
245
  }
 
 
 
 
246
  #powerpress_steps p {
247
  font-size: 20px;
248
  margin: 20px 4px;
249
  color: #CCCCCC;
250
- line-height:120%
 
 
 
 
 
 
251
  }
252
  #powerpress_steps a {
253
  color: #CCCCCC;
@@ -260,7 +271,6 @@ padding-bottom: 15px;
260
 
261
  #powerpress_steps .active-step h3 {
262
  color: #337EC9;
263
-
264
  }
265
  #powerpress_steps .active-step p,
266
  #powerpress_steps .active-step a {
@@ -376,5 +386,3 @@ padding-bottom: 15px;
376
  margin-right: 10px;
377
  }
378
  }
379
-
380
-
2
  .powerpress-notice,
3
  div.powerpress-notice,
4
  .wrap div.powerpress-notice {
5
+ margin: 20px 0 10px;
6
+ padding: 0 5px;
7
  line-height: 29px;
8
  font-size: 12px;
9
  border-width: 1px;
10
  border-style: solid;
11
  font-weight: bold;
12
+ /* background-color: #FFFFE0; /* yellow */
13
  }
14
  .powerpress-error,
15
  div.powerpress-error,
16
  .wrap div.powerpress-error {
17
+ margin: 20px 5px 10px;
18
+ padding: 0 10px;
19
  line-height: 29px;
20
  font-size: 12px;
21
  border-width: 1px;
22
  border-style: solid;
23
  font-weight: bold;
24
+ /* background-color: #ffebe8; /* red */
25
  }
26
  #powerpress_settings {
27
+ background-image:url(//images.blubrry.com/powerpress/blubrry_logo5.png);
28
  background-repeat: no-repeat;
29
  background-position: bottom right;
30
  }
244
  left: 0;
245
  position: absolute;
246
  }
247
+ #powerpress_single_step h3 {
248
+ color: #337EC9;
249
+ font-size: 24px;
250
+ }
251
  #powerpress_steps p {
252
  font-size: 20px;
253
  margin: 20px 4px;
254
  color: #CCCCCC;
255
+ line-height:120%;
256
+ }
257
+ #powerpress_steps p.normal {
258
+ font-size: 14px;
259
+ margin: 8px 0 8px 8px;
260
+ color: #CCCCCC;
261
+ line-height: normal;
262
  }
263
  #powerpress_steps a {
264
  color: #CCCCCC;
271
 
272
  #powerpress_steps .active-step h3 {
273
  color: #337EC9;
 
274
  }
275
  #powerpress_steps .active-step p,
276
  #powerpress_steps .active-step a {
386
  margin-right: 10px;
387
  }
388
  }
 
 
css/dashboard.css CHANGED
@@ -42,4 +42,26 @@
42
  #powerpress_dashboard_notice_3 a.browse-happy-link,
43
  #powerpress_dashboard_notice_3 a.update-browser-link {
44
  text-shadow: #d29a04 0 1px 0;
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  #powerpress_dashboard_notice_3 a.browse-happy-link,
43
  #powerpress_dashboard_notice_3 a.update-browser-link {
44
  text-shadow: #d29a04 0 1px 0;
45
+ }
46
+
47
+ /*
48
+ .powerpressadmin-mejs-video {
49
+ width: auto;
50
+ }
51
+ .powerpressadmin-mejs-video .powerpress_player {
52
+ position: relative;
53
+ width: 100%;
54
+ height: 0;
55
+ padding-bottom: 56.2%;
56
+ }
57
+
58
+ .powerpressadmin-mejs-video .powerpress_player .wp-video,
59
+ .powerpressadmin-mejs-video .powerpress_player .mejs-container,
60
+ .powerpressadmin-mejs-video .powerpress_player video {
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ width: 100% !important;
65
+ height: 100% !important;
66
+ }
67
+ */
css/subscribe.css ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* subscribe.css PowerPress subscribe widget */
2
+
3
+ .pp-sub-widget {
4
+ width: 100%;
5
+ max-width: 800px;
6
+ margin: 10px auto;
7
+ border: 3px solid #787878;
8
+ font-family: Sans-serif;
9
+ background-color: #FFFFFF;
10
+ }
11
+ .pp-sub-widget .pp-sub-bx {
12
+ -webkit-column-count: 2;
13
+ -moz-column-count: 2;
14
+ column-count: 2;
15
+ -webkit-column-gap: 20px;
16
+ -moz-column-gap: 20px;
17
+ column-gap: 20px;
18
+ width: auto;
19
+ height: auto;
20
+ margin: 0 10px -10px 10px;
21
+ }
22
+
23
+ .pp-sub-widget div.pp-sub-h {
24
+ margin: 10px 10px 0 10px;
25
+ font-size: 90%;
26
+ font-weight: bold;
27
+ color: #666666;
28
+ }
29
+ .pp-sub-widget h2.pp-sub-t {
30
+ margin: 10px 10px 0 10px !important;
31
+ padding: 0 !important;
32
+ font-size: 200% !important;
33
+ color: #222222 !important;
34
+ }
35
+
36
+ .pp-sub-widget a.pp-sub-btn {
37
+ width: 100%;
38
+ height: 48px;
39
+ padding: 0px 0px 0px 0px;
40
+ color: #FFFFFF;
41
+ display: inline-block;
42
+ margin: 10px 0 10px 0;
43
+ text-decoration: none;
44
+ text-align:left;
45
+ vertical-align: middle;
46
+ line-height: 48px;
47
+ font-size: 90% !important;
48
+ font-weight: bold !important;
49
+ overflow: hidden;
50
+ border-radius: 1px;
51
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
52
+ }
53
+
54
+ .pp-sub-widget .pp-sub-btn-l {
55
+
56
+ }
57
+ body .entry-content .pp-sub-widget a:link,
58
+ body .entry-content .pp-sub-widget a:visited,
59
+ body .entry-content .pp-sub-widget a:active,
60
+ body .entry-content .pp-sub-widget a:hover,
61
+ body .pp-sub-widget a:link,
62
+ body .pp-sub-widget a:visited,
63
+ body .pp-sub-widget a:active,
64
+ body .pp-sub-widget a:hover {
65
+ text-decoration: none !important;
66
+ color: #FFFFFF !important;
67
+ }
68
+
69
+ .pp-sub-widget img.pp-sub-l {
70
+ width: 100% !important;
71
+ height: auto !important;
72
+ max-width: 300px;
73
+ padding: 0;
74
+ margin: 10px 0;
75
+
76
+ box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
77
+ }
78
+ .pp-sub-widget .pp-sub-btns {
79
+ width: 100% !important;
80
+ margin: 0;
81
+ padding: 0;
82
+ display: inline-block;
83
+ }
84
+ .pp-sub-widget .pp-sub-m {
85
+ clear: both;
86
+ margin: 10px;
87
+ }
88
+ .pp-sub-widget p.pp-sub-m-p {
89
+ margin: 0;
90
+ font-size: 90%;
91
+ color: #222222;
92
+ }
93
+ .pp-sub-widget .pp-sub-m-i {
94
+ width: 80%;
95
+ color: #333333;
96
+ font-size: 85%;
97
+ border: 1px solid #999999;
98
+ padding: 5px;
99
+ }
100
+ @media screen and (max-width: 400px) {
101
+ .pp-sub-widget .pp-sub-bx {
102
+ -webkit-column-count: 1;
103
+ -moz-column-count: 1;
104
+ column-count: 1;
105
+ -webkit-column-gap: 0;
106
+ -moz-column-gap: 0;
107
+ column-gap: 0;
108
+ }
109
+ .pp-sub-widget .pp-sub-t {
110
+ font-size: 150%;
111
+ }
112
+ }
113
+ .pp-sub-widget-dark a,
114
+ .pp-sub-widget-modern a {
115
+ background-color: #222222;
116
+ }
117
+ .pp-sub-widget-modern a.pp-sub-itunes {
118
+ background-color: #732BBE;
119
+ }
120
+ .pp-sub-widget-modern a.pp-sub-pr,
121
+ .pp-sub-widget-modern a.pp-sub-email {
122
+ background-color: #337EC9;
123
+ }
124
+ .pp-sub-widget-modern a.pp-sub-bp,
125
+ .pp-sub-widget-modern a.pp-sub-rss {
126
+ background-color: #FF8800;
127
+ }
128
+
129
+ .pp-sub-widget-modern div.pp-sub-h,
130
+ .pp-sub-widget-modern p.pp-sub-m-p {
131
+ color: #337EC9;
132
+ }
133
+
134
+ .pp-sub-widget .pp-sub-ic {
135
+ width: 48px;
136
+ height: 48px;
137
+ border: 0;
138
+ display: inline-block;
139
+ vertical-align: middle;
140
+ margin-right: 2px;
141
+ }
142
+ .pp-sub-ic {
143
+ background-image: url(../images/spriteStandard.png);
144
+ background-repeat: no-repeat;
145
+ background-size: 294px;
146
+ }
147
+ .pp-sub-itunes .pp-sub-ic {
148
+ background-position: -49px 0;
149
+ }
150
+ .pp-sub-rss .pp-sub-ic {
151
+ background-position: 0 -49px;
152
+ }
153
+ .pp-sub-email .pp-sub-ic {
154
+ background-position: -196px -49px;
155
+ }
156
+ .pp-sub-pr .pp-sub-ic {
157
+ background-position: -196px 0;
158
+ }
159
+ .pp-sub-bp .pp-sub-ic {
160
+ background-position: -147px 0;
161
+ }
162
+
163
+ /* Retina-specific stuff here */
164
+ @media only screen and (-webkit-min-device-pixel-ratio: 2.0),
165
+ only screen and (min--moz-device-pixel-ratio: 2.0),
166
+ only screen and (-o-min-device-pixel-ratio: 200/100),
167
+ only screen and (min-device-pixel-ratio: 2.0) {
168
+ .pp-sub-ic {
169
+ background-image: url(../images/spriteRetina.png);
170
+ }
171
+ }
getid3/getid3.lib.php CHANGED
@@ -1,1317 +1,1379 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // //
8
- // getid3.lib.php - part of getID3() //
9
- // See readme.txt for more details //
10
- // ///
11
- /////////////////////////////////////////////////////////////////
12
-
13
-
14
- class getid3_lib
15
- {
16
-
17
- static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
18
- $returnstring = '';
19
- for ($i = 0; $i < strlen($string); $i++) {
20
- if ($hex) {
21
- $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
22
- } else {
23
- $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '�');
24
- }
25
- if ($spaces) {
26
- $returnstring .= ' ';
27
- }
28
- }
29
- if (!empty($htmlencoding)) {
30
- if ($htmlencoding === true) {
31
- $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
32
- }
33
- $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
34
- }
35
- return $returnstring;
36
- }
37
-
38
- static function trunc($floatnumber) {
39
- // truncates a floating-point number at the decimal point
40
- // returns int (if possible, otherwise float)
41
- if ($floatnumber >= 1) {
42
- $truncatednumber = floor($floatnumber);
43
- } elseif ($floatnumber <= -1) {
44
- $truncatednumber = ceil($floatnumber);
45
- } else {
46
- $truncatednumber = 0;
47
- }
48
- if (getid3_lib::intValueSupported($truncatednumber)) {
49
- $truncatednumber = (int) $truncatednumber;
50
- }
51
- return $truncatednumber;
52
- }
53
-
54
-
55
- static function safe_inc(&$variable, $increment=1) {
56
- if (isset($variable)) {
57
- $variable += $increment;
58
- } else {
59
- $variable = $increment;
60
- }
61
- return true;
62
- }
63
-
64
- static function CastAsInt($floatnum) {
65
- // convert to float if not already
66
- $floatnum = (float) $floatnum;
67
-
68
- // convert a float to type int, only if possible
69
- if (getid3_lib::trunc($floatnum) == $floatnum) {
70
- // it's not floating point
71
- if (getid3_lib::intValueSupported($floatnum)) {
72
- // it's within int range
73
- $floatnum = (int) $floatnum;
74
- }
75
- }
76
- return $floatnum;
77
- }
78
-
79
- public static function intValueSupported($num) {
80
- // check if integers are 64-bit
81
- static $hasINT64 = null;
82
- if ($hasINT64 === null) { // 10x faster than is_null()
83
- $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
84
- if (!$hasINT64 && !defined('PHP_INT_MIN')) {
85
- define('PHP_INT_MIN', ~PHP_INT_MAX);
86
- }
87
- }
88
- // if integers are 64-bit - no other check required
89
- if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
90
- return true;
91
- }
92
- return false;
93
- }
94
-
95
- static function DecimalizeFraction($fraction) {
96
- list($numerator, $denominator) = explode('/', $fraction);
97
- return $numerator / ($denominator ? $denominator : 1);
98
- }
99
-
100
-
101
- static function DecimalBinary2Float($binarynumerator) {
102
- $numerator = getid3_lib::Bin2Dec($binarynumerator);
103
- $denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
104
- return ($numerator / $denominator);
105
- }
106
-
107
-
108
- static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
109
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
110
- if (strpos($binarypointnumber, '.') === false) {
111
- $binarypointnumber = '0.'.$binarypointnumber;
112
- } elseif ($binarypointnumber{0} == '.') {
113
- $binarypointnumber = '0'.$binarypointnumber;
114
- }
115
- $exponent = 0;
116
- while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
117
- if (substr($binarypointnumber, 1, 1) == '.') {
118
- $exponent--;
119
- $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
120
- } else {
121
- $pointpos = strpos($binarypointnumber, '.');
122
- $exponent += ($pointpos - 1);
123
- $binarypointnumber = str_replace('.', '', $binarypointnumber);
124
- $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
125
- }
126
- }
127
- $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
128
- return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
129
- }
130
-
131
-
132
- static function Float2BinaryDecimal($floatvalue) {
133
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
134
- $maxbits = 128; // to how many bits of precision should the calculations be taken?
135
- $intpart = getid3_lib::trunc($floatvalue);
136
- $floatpart = abs($floatvalue - $intpart);
137
- $pointbitstring = '';
138
- while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
139
- $floatpart *= 2;
140
- $pointbitstring .= (string) getid3_lib::trunc($floatpart);
141
- $floatpart -= getid3_lib::trunc($floatpart);
142
- }
143
- $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
144
- return $binarypointnumber;
145
- }
146
-
147
-
148
- static function Float2String($floatvalue, $bits) {
149
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
150
- switch ($bits) {
151
- case 32:
152
- $exponentbits = 8;
153
- $fractionbits = 23;
154
- break;
155
-
156
- case 64:
157
- $exponentbits = 11;
158
- $fractionbits = 52;
159
- break;
160
-
161
- default:
162
- return false;
163
- break;
164
- }
165
- if ($floatvalue >= 0) {
166
- $signbit = '0';
167
- } else {
168
- $signbit = '1';
169
- }
170
- $normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
171
- $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
172
- $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
173
- $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
174
-
175
- return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
176
- }
177
-
178
-
179
- static function LittleEndian2Float($byteword) {
180
- return getid3_lib::BigEndian2Float(strrev($byteword));
181
- }
182
-
183
-
184
- static function BigEndian2Float($byteword) {
185
- // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
186
- // http://www.psc.edu/general/software/packages/ieee/ieee.html
187
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
188
-
189
- $bitword = getid3_lib::BigEndian2Bin($byteword);
190
- if (!$bitword) {
191
- return 0;
192
- }
193
- $signbit = $bitword{0};
194
-
195
- switch (strlen($byteword) * 8) {
196
- case 32:
197
- $exponentbits = 8;
198
- $fractionbits = 23;
199
- break;
200
-
201
- case 64:
202
- $exponentbits = 11;
203
- $fractionbits = 52;
204
- break;
205
-
206
- case 80:
207
- // 80-bit Apple SANE format
208
- // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
209
- $exponentstring = substr($bitword, 1, 15);
210
- $isnormalized = intval($bitword{16});
211
- $fractionstring = substr($bitword, 17, 63);
212
- $exponent = pow(2, getid3_lib::Bin2Dec($exponentstring) - 16383);
213
- $fraction = $isnormalized + getid3_lib::DecimalBinary2Float($fractionstring);
214
- $floatvalue = $exponent * $fraction;
215
- if ($signbit == '1') {
216
- $floatvalue *= -1;
217
- }
218
- return $floatvalue;
219
- break;
220
-
221
- default:
222
- return false;
223
- break;
224
- }
225
- $exponentstring = substr($bitword, 1, $exponentbits);
226
- $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
227
- $exponent = getid3_lib::Bin2Dec($exponentstring);
228
- $fraction = getid3_lib::Bin2Dec($fractionstring);
229
-
230
- if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
231
- // Not a Number
232
- $floatvalue = false;
233
- } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
234
- if ($signbit == '1') {
235
- $floatvalue = '-infinity';
236
- } else {
237
- $floatvalue = '+infinity';
238
- }
239
- } elseif (($exponent == 0) && ($fraction == 0)) {
240
- if ($signbit == '1') {
241
- $floatvalue = -0;
242
- } else {
243
- $floatvalue = 0;
244
- }
245
- $floatvalue = ($signbit ? 0 : -0);
246
- } elseif (($exponent == 0) && ($fraction != 0)) {
247
- // These are 'unnormalized' values
248
- $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fractionstring);
249
- if ($signbit == '1') {
250
- $floatvalue *= -1;
251
- }
252
- } elseif ($exponent != 0) {
253
- $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fractionstring));
254
- if ($signbit == '1') {
255
- $floatvalue *= -1;
256
- }
257
- }
258
- return (float) $floatvalue;
259
- }
260
-
261
-
262
- static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
263
- $intvalue = 0;
264
- $bytewordlen = strlen($byteword);
265
- if ($bytewordlen == 0) {
266
- return false;
267
- }
268
- for ($i = 0; $i < $bytewordlen; $i++) {
269
- if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
270
- //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
271
- $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
272
- } else {
273
- $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
274
- }
275
- }
276
- if ($signed && !$synchsafe) {
277
- // synchsafe ints are not allowed to be signed
278
- if ($bytewordlen <= PHP_INT_SIZE) {
279
- $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
280
- if ($intvalue & $signMaskBit) {
281
- $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
282
- }
283
- } else {
284
- throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in getid3_lib::BigEndian2Int()');
285
- break;
286
- }
287
- }
288
- return getid3_lib::CastAsInt($intvalue);
289
- }
290
-
291
-
292
- static function LittleEndian2Int($byteword, $signed=false) {
293
- return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
294
- }
295
-
296
-
297
- static function BigEndian2Bin($byteword) {
298
- $binvalue = '';
299
- $bytewordlen = strlen($byteword);
300
- for ($i = 0; $i < $bytewordlen; $i++) {
301
- $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
302
- }
303
- return $binvalue;
304
- }
305
-
306
-
307
- static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
308
- if ($number < 0) {
309
- throw new Exception('ERROR: getid3_lib::BigEndian2String() does not support negative numbers');
310
- }
311
- $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
312
- $intstring = '';
313
- if ($signed) {
314
- if ($minbytes > PHP_INT_SIZE) {
315
- throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in getid3_lib::BigEndian2String()');
316
- }
317
- $number = $number & (0x80 << (8 * ($minbytes - 1)));
318
- }
319
- while ($number != 0) {
320
- $quotient = ($number / ($maskbyte + 1));
321
- $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
322
- $number = floor($quotient);
323
- }
324
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
325
- }
326
-
327
-
328
- static function Dec2Bin($number) {
329
- while ($number >= 256) {
330
- $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
331
- $number = floor($number / 256);
332
- }
333
- $bytes[] = $number;
334
- $binstring = '';
335
- for ($i = 0; $i < count($bytes); $i++) {
336
- $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
337
- }
338
- return $binstring;
339
- }
340
-
341
-
342
- static function Bin2Dec($binstring, $signed=false) {
343
- $signmult = 1;
344
- if ($signed) {
345
- if ($binstring{0} == '1') {
346
- $signmult = -1;
347
- }
348
- $binstring = substr($binstring, 1);
349
- }
350
- $decvalue = 0;
351
- for ($i = 0; $i < strlen($binstring); $i++) {
352
- $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
353
- }
354
- return getid3_lib::CastAsInt($decvalue * $signmult);
355
- }
356
-
357
-
358
- static function Bin2String($binstring) {
359
- // return 'hi' for input of '0110100001101001'
360
- $string = '';
361
- $binstringreversed = strrev($binstring);
362
- for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
363
- $string = chr(getid3_lib::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
364
- }
365
- return $string;
366
- }
367
-
368
-
369
- static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
370
- $intstring = '';
371
- while ($number > 0) {
372
- if ($synchsafe) {
373
- $intstring = $intstring.chr($number & 127);
374
- $number >>= 7;
375
- } else {
376
- $intstring = $intstring.chr($number & 255);
377
- $number >>= 8;
378
- }
379
- }
380
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
381
- }
382
-
383
-
384
- static function array_merge_clobber($array1, $array2) {
385
- // written by kc�hireability*com
386
- // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
387
- if (!is_array($array1) || !is_array($array2)) {
388
- return false;
389
- }
390
- $newarray = $array1;
391
- foreach ($array2 as $key => $val) {
392
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
393
- $newarray[$key] = getid3_lib::array_merge_clobber($newarray[$key], $val);
394
- } else {
395
- $newarray[$key] = $val;
396
- }
397
- }
398
- return $newarray;
399
- }
400
-
401
-
402
- static function array_merge_noclobber($array1, $array2) {
403
- if (!is_array($array1) || !is_array($array2)) {
404
- return false;
405
- }
406
- $newarray = $array1;
407
- foreach ($array2 as $key => $val) {
408
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
409
- $newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
410
- } elseif (!isset($newarray[$key])) {
411
- $newarray[$key] = $val;
412
- }
413
- }
414
- return $newarray;
415
- }
416
-
417
-
418
- static function ksort_recursive(&$theArray) {
419
- ksort($theArray);
420
- foreach ($theArray as $key => $value) {
421
- if (is_array($value)) {
422
- self::ksort_recursive($theArray[$key]);
423
- }
424
- }
425
- return true;
426
- }
427
-
428
- static function fileextension($filename, $numextensions=1) {
429
- if (strstr($filename, '.')) {
430
- $reversedfilename = strrev($filename);
431
- $offset = 0;
432
- for ($i = 0; $i < $numextensions; $i++) {
433
- $offset = strpos($reversedfilename, '.', $offset + 1);
434
- if ($offset === false) {
435
- return '';
436
- }
437
- }
438
- return strrev(substr($reversedfilename, 0, $offset));
439
- }
440
- return '';
441
- }
442
-
443
-
444
- static function PlaytimeString($seconds) {
445
- $sign = (($seconds < 0) ? '-' : '');
446
- $seconds = abs($seconds);
447
- $H = floor( $seconds / 3600);
448
- $M = floor(($seconds - (3600 * $H) ) / 60);
449
- $S = round( $seconds - (3600 * $H) - (60 * $M) );
450
- return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
451
- }
452
-
453
-
454
- static function DateMac2Unix($macdate) {
455
- // Macintosh timestamp: seconds since 00:00h January 1, 1904
456
- // UNIX timestamp: seconds since 00:00h January 1, 1970
457
- return getid3_lib::CastAsInt($macdate - 2082844800);
458
- }
459
-
460
-
461
- static function FixedPoint8_8($rawdata) {
462
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
463
- }
464
-
465
-
466
- static function FixedPoint16_16($rawdata) {
467
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
468
- }
469
-
470
-
471
- static function FixedPoint2_30($rawdata) {
472
- $binarystring = getid3_lib::BigEndian2Bin($rawdata);
473
- return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
474
- }
475
-
476
-
477
- static function CreateDeepArray($ArrayPath, $Separator, $Value) {
478
- // assigns $Value to a nested array path:
479
- // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
480
- // is the same as:
481
- // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
482
- // or
483
- // $foo['path']['to']['my'] = 'file.txt';
484
- while ($ArrayPath && ($ArrayPath{0} == $Separator)) {
485
- $ArrayPath = substr($ArrayPath, 1);
486
- }
487
- if (($pos = strpos($ArrayPath, $Separator)) !== false) {
488
- $ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
489
- } else {
490
- $ReturnedArray[$ArrayPath] = $Value;
491
- }
492
- return $ReturnedArray;
493
- }
494
-
495
- static function array_max($arraydata, $returnkey=false) {
496
- $maxvalue = false;
497
- $maxkey = false;
498
- foreach ($arraydata as $key => $value) {
499
- if (!is_array($value)) {
500
- if ($value > $maxvalue) {
501
- $maxvalue = $value;
502
- $maxkey = $key;
503
- }
504
- }
505
- }
506
- return ($returnkey ? $maxkey : $maxvalue);
507
- }
508
-
509
- static function array_min($arraydata, $returnkey=false) {
510
- $minvalue = false;
511
- $minkey = false;
512
- foreach ($arraydata as $key => $value) {
513
- if (!is_array($value)) {
514
- if ($value > $minvalue) {
515
- $minvalue = $value;
516
- $minkey = $key;
517
- }
518
- }
519
- }
520
- return ($returnkey ? $minkey : $minvalue);
521
- }
522
-
523
- static function XML2array($XMLstring) {
524
- if (function_exists('simplexml_load_string')) {
525
- if (function_exists('get_object_vars')) {
526
- $XMLobject = simplexml_load_string($XMLstring);
527
- return self::SimpleXMLelement2array($XMLobject);
528
- }
529
- }
530
- return false;
531
- }
532
-
533
- static function SimpleXMLelement2array($XMLobject) {
534
- if (!is_object($XMLobject) && !is_array($XMLobject)) {
535
- return $XMLobject;
536
- }
537
- $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
538
- foreach ($XMLarray as $key => $value) {
539
- $XMLarray[$key] = self::SimpleXMLelement2array($value);
540
- }
541
- return $XMLarray;
542
- }
543
-
544
-
545
- // Allan Hansen <ah�artemis*dk>
546
- // getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position
547
- static function hash_data($file, $offset, $end, $algorithm) {
548
- static $tempdir = '';
549
- if (!getid3_lib::intValueSupported($end)) {
550
- return false;
551
- }
552
- switch ($algorithm) {
553
- case 'md5':
554
- $hash_function = 'md5_file';
555
- $unix_call = 'md5sum';
556
- $windows_call = 'md5sum.exe';
557
- $hash_length = 32;
558
- break;
559
-
560
- case 'sha1':
561
- $hash_function = 'sha1_file';
562
- $unix_call = 'sha1sum';
563
- $windows_call = 'sha1sum.exe';
564
- $hash_length = 40;
565
- break;
566
-
567
- default:
568
- throw new Exception('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
569
- break;
570
- }
571
- $size = $end - $offset;
572
- while (true) {
573
- if (GETID3_OS_ISWINDOWS) {
574
-
575
- // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
576
- // Fall back to create-temp-file method:
577
- if ($algorithm == 'sha1') {
578
- break;
579
- }
580
-
581
- $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
582
- foreach ($RequiredFiles as $required_file) {
583
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
584
- // helper apps not available - fall back to old method
585
- break;
586
- }
587
- }
588
- $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
589
- $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
590
- $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
591
-
592
- } else {
593
-
594
- $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
595
- $commandline .= 'tail -c'.$size.' | ';
596
- $commandline .= $unix_call;
597
-
598
- }
599
- if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
600
- //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
601
- break;
602
- }
603
- return substr(`$commandline`, 0, $hash_length);
604
- }
605
-
606
- if (empty($tempdir)) {
607
- // yes this is ugly, feel free to suggest a better way
608
- require_once(dirname(__FILE__).'/getid3.php');
609
- $getid3_temp = new getID3();
610
- $tempdir = $getid3_temp->tempdir;
611
- unset($getid3_temp);
612
- }
613
- // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
614
- if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
615
- // can't find anywhere to create a temp file, just fail
616
- return false;
617
- }
618
-
619
- // Init
620
- $result = false;
621
-
622
- // copy parts of file
623
- try {
624
- getid3_lib::CopyFileParts($file, $data_filename, $offset, $end - $offset);
625
- $result = $hash_function($data_filename);
626
- } catch (Exception $e) {
627
- throw new Exception('getid3_lib::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
628
- }
629
- unlink($data_filename);
630
- return $result;
631
- }
632
-
633
- static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
634
- if (!getid3_lib::intValueSupported($offset + $length)) {
635
- throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
636
- }
637
- if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
638
- if (($fp_dest = fopen($filename_dest, 'wb'))) {
639
- if (fseek($fp_src, $offset, SEEK_SET) == 0) {
640
- $byteslefttowrite = $length;
641
- while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
642
- $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
643
- $byteslefttowrite -= $byteswritten;
644
- }
645
- return true;
646
- } else {
647
- throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
648
- }
649
- fclose($fp_dest);
650
- } else {
651
- throw new Exception('failed to create file for writing '.$filename_dest);
652
- }
653
- fclose($fp_src);
654
- } else {
655
- throw new Exception('failed to open file for reading '.$filename_source);
656
- }
657
- return false;
658
- }
659
-
660
- static function iconv_fallback_int_utf8($charval) {
661
- if ($charval < 128) {
662
- // 0bbbbbbb
663
- $newcharstring = chr($charval);
664
- } elseif ($charval < 2048) {
665
- // 110bbbbb 10bbbbbb
666
- $newcharstring = chr(($charval >> 6) | 0xC0);
667
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
668
- } elseif ($charval < 65536) {
669
- // 1110bbbb 10bbbbbb 10bbbbbb
670
- $newcharstring = chr(($charval >> 12) | 0xE0);
671
- $newcharstring .= chr(($charval >> 6) | 0xC0);
672
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
673
- } else {
674
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
675
- $newcharstring = chr(($charval >> 18) | 0xF0);
676
- $newcharstring .= chr(($charval >> 12) | 0xC0);
677
- $newcharstring .= chr(($charval >> 6) | 0xC0);
678
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
679
- }
680
- return $newcharstring;
681
- }
682
-
683
- // ISO-8859-1 => UTF-8
684
- static function iconv_fallback_iso88591_utf8($string, $bom=false) {
685
- if (function_exists('utf8_encode')) {
686
- return utf8_encode($string);
687
- }
688
- // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
689
- $newcharstring = '';
690
- if ($bom) {
691
- $newcharstring .= "\xEF\xBB\xBF";
692
- }
693
- for ($i = 0; $i < strlen($string); $i++) {
694
- $charval = ord($string{$i});
695
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
696
- }
697
- return $newcharstring;
698
- }
699
-
700
- // ISO-8859-1 => UTF-16BE
701
- static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
702
- $newcharstring = '';
703
- if ($bom) {
704
- $newcharstring .= "\xFE\xFF";
705
- }
706
- for ($i = 0; $i < strlen($string); $i++) {
707
- $newcharstring .= "\x00".$string{$i};
708
- }
709
- return $newcharstring;
710
- }
711
-
712
- // ISO-8859-1 => UTF-16LE
713
- static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
714
- $newcharstring = '';
715
- if ($bom) {
716
- $newcharstring .= "\xFF\xFE";
717
- }
718
- for ($i = 0; $i < strlen($string); $i++) {
719
- $newcharstring .= $string{$i}."\x00";
720
- }
721
- return $newcharstring;
722
- }
723
-
724
- // ISO-8859-1 => UTF-16LE (BOM)
725
- static function iconv_fallback_iso88591_utf16($string) {
726
- return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
727
- }
728
-
729
- // UTF-8 => ISO-8859-1
730
- static function iconv_fallback_utf8_iso88591($string) {
731
- if (function_exists('utf8_decode')) {
732
- return utf8_decode($string);
733
- }
734
- // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
735
- $newcharstring = '';
736
- $offset = 0;
737
- $stringlength = strlen($string);
738
- while ($offset < $stringlength) {
739
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
740
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
741
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
742
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
743
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
744
- (ord($string{($offset + 3)}) & 0x3F);
745
- $offset += 4;
746
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
747
- // 1110bbbb 10bbbbbb 10bbbbbb
748
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
749
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
750
- (ord($string{($offset + 2)}) & 0x3F);
751
- $offset += 3;
752
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
753
- // 110bbbbb 10bbbbbb
754
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
755
- (ord($string{($offset + 1)}) & 0x3F);
756
- $offset += 2;
757
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
758
- // 0bbbbbbb
759
- $charval = ord($string{$offset});
760
- $offset += 1;
761
- } else {
762
- // error? throw some kind of warning here?
763
- $charval = false;
764
- $offset += 1;
765
- }
766
- if ($charval !== false) {
767
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
768
- }
769
- }
770
- return $newcharstring;
771
- }
772
-
773
- // UTF-8 => UTF-16BE
774
- static function iconv_fallback_utf8_utf16be($string, $bom=false) {
775
- $newcharstring = '';
776
- if ($bom) {
777
- $newcharstring .= "\xFE\xFF";
778
- }
779
- $offset = 0;
780
- $stringlength = strlen($string);
781
- while ($offset < $stringlength) {
782
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
783
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
784
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
785
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
786
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
787
- (ord($string{($offset + 3)}) & 0x3F);
788
- $offset += 4;
789
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
790
- // 1110bbbb 10bbbbbb 10bbbbbb
791
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
792
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
793
- (ord($string{($offset + 2)}) & 0x3F);
794
- $offset += 3;
795
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
796
- // 110bbbbb 10bbbbbb
797
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
798
- (ord($string{($offset + 1)}) & 0x3F);
799
- $offset += 2;
800
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
801
- // 0bbbbbbb
802
- $charval = ord($string{$offset});
803
- $offset += 1;
804
- } else {
805
- // error? throw some kind of warning here?
806
- $charval = false;
807
- $offset += 1;
808
- }
809
- if ($charval !== false) {
810
- $newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
811
- }
812
- }
813
- return $newcharstring;
814
- }
815
-
816
- // UTF-8 => UTF-16LE
817
- static function iconv_fallback_utf8_utf16le($string, $bom=false) {
818
- $newcharstring = '';
819
- if ($bom) {
820
- $newcharstring .= "\xFF\xFE";
821
- }
822
- $offset = 0;
823
- $stringlength = strlen($string);
824
- while ($offset < $stringlength) {
825
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
826
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
827
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
828
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
829
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
830
- (ord($string{($offset + 3)}) & 0x3F);
831
- $offset += 4;
832
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
833
- // 1110bbbb 10bbbbbb 10bbbbbb
834
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
835
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
836
- (ord($string{($offset + 2)}) & 0x3F);
837
- $offset += 3;
838
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
839
- // 110bbbbb 10bbbbbb
840
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
841
- (ord($string{($offset + 1)}) & 0x3F);
842
- $offset += 2;
843
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
844
- // 0bbbbbbb
845
- $charval = ord($string{$offset});
846
- $offset += 1;
847
- } else {
848
- // error? maybe throw some warning here?
849
- $charval = false;
850
- $offset += 1;
851
- }
852
- if ($charval !== false) {
853
- $newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
854
- }
855
- }
856
- return $newcharstring;
857
- }
858
-
859
- // UTF-8 => UTF-16LE (BOM)
860
- static function iconv_fallback_utf8_utf16($string) {
861
- return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
862
- }
863
-
864
- // UTF-16BE => UTF-8
865
- static function iconv_fallback_utf16be_utf8($string) {
866
- if (substr($string, 0, 2) == "\xFE\xFF") {
867
- // strip BOM
868
- $string = substr($string, 2);
869
- }
870
- $newcharstring = '';
871
- for ($i = 0; $i < strlen($string); $i += 2) {
872
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
873
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
874
- }
875
- return $newcharstring;
876
- }
877
-
878
- // UTF-16LE => UTF-8
879
- static function iconv_fallback_utf16le_utf8($string) {
880
- if (substr($string, 0, 2) == "\xFF\xFE") {
881
- // strip BOM
882
- $string = substr($string, 2);
883
- }
884
- $newcharstring = '';
885
- for ($i = 0; $i < strlen($string); $i += 2) {
886
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
887
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
888
- }
889
- return $newcharstring;
890
- }
891
-
892
- // UTF-16BE => ISO-8859-1
893
- static function iconv_fallback_utf16be_iso88591($string) {
894
- if (substr($string, 0, 2) == "\xFE\xFF") {
895
- // strip BOM
896
- $string = substr($string, 2);
897
- }
898
- $newcharstring = '';
899
- for ($i = 0; $i < strlen($string); $i += 2) {
900
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
901
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
902
- }
903
- return $newcharstring;
904
- }
905
-
906
- // UTF-16LE => ISO-8859-1
907
- static function iconv_fallback_utf16le_iso88591($string) {
908
- if (substr($string, 0, 2) == "\xFF\xFE") {
909
- // strip BOM
910
- $string = substr($string, 2);
911
- }
912
- $newcharstring = '';
913
- for ($i = 0; $i < strlen($string); $i += 2) {
914
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
915
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
916
- }
917
- return $newcharstring;
918
- }
919
-
920
- // UTF-16 (BOM) => ISO-8859-1
921
- static function iconv_fallback_utf16_iso88591($string) {
922
- $bom = substr($string, 0, 2);
923
- if ($bom == "\xFE\xFF") {
924
- return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
925
- } elseif ($bom == "\xFF\xFE") {
926
- return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
927
- }
928
- return $string;
929
- }
930
-
931
- // UTF-16 (BOM) => UTF-8
932
- static function iconv_fallback_utf16_utf8($string) {
933
- $bom = substr($string, 0, 2);
934
- if ($bom == "\xFE\xFF") {
935
- return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
936
- } elseif ($bom == "\xFF\xFE") {
937
- return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
938
- }
939
- return $string;
940
- }
941
-
942
- static function iconv_fallback($in_charset, $out_charset, $string) {
943
-
944
- if ($in_charset == $out_charset) {
945
- return $string;
946
- }
947
-
948
- // iconv() availble
949
- if (function_exists('iconv')) {
950
- if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
951
- switch ($out_charset) {
952
- case 'ISO-8859-1':
953
- $converted_string = rtrim($converted_string, "\x00");
954
- break;
955
- }
956
- return $converted_string;
957
- }
958
-
959
- // iconv() may sometimes fail with "illegal character in input string" error message
960
- // and return an empty string, but returning the unconverted string is more useful
961
- return $string;
962
- }
963
-
964
-
965
- // iconv() not available
966
- static $ConversionFunctionList = array();
967
- if (empty($ConversionFunctionList)) {
968
- $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
969
- $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
970
- $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
971
- $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
972
- $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
973
- $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
974
- $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
975
- $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
976
- $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
977
- $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
978
- $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
979
- $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
980
- $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
981
- $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
982
- }
983
- if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
984
- $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
985
- return getid3_lib::$ConversionFunction($string);
986
- }
987
- throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
988
- }
989
-
990
-
991
- static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
992
- $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
993
- $HTMLstring = '';
994
-
995
- switch ($charset) {
996
- case '1251':
997
- case '1252':
998
- case '866':
999
- case '932':
1000
- case '936':
1001
- case '950':
1002
- case 'BIG5':
1003
- case 'BIG5-HKSCS':
1004
- case 'cp1251':
1005
- case 'cp1252':
1006
- case 'cp866':
1007
- case 'EUC-JP':
1008
- case 'EUCJP':
1009
- case 'GB2312':
1010
- case 'ibm866':
1011
- case 'ISO-8859-1':
1012
- case 'ISO-8859-15':
1013
- case 'ISO8859-1':
1014
- case 'ISO8859-15':
1015
- case 'KOI8-R':
1016
- case 'koi8-ru':
1017
- case 'koi8r':
1018
- case 'Shift_JIS':
1019
- case 'SJIS':
1020
- case 'win-1251':
1021
- case 'Windows-1251':
1022
- case 'Windows-1252':
1023
- $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1024
- break;
1025
-
1026
- case 'UTF-8':
1027
- $strlen = strlen($string);
1028
- for ($i = 0; $i < $strlen; $i++) {
1029
- $char_ord_val = ord($string{$i});
1030
- $charval = 0;
1031
- if ($char_ord_val < 0x80) {
1032
- $charval = $char_ord_val;
1033
- } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
1034
- $charval = (($char_ord_val & 0x07) << 18);
1035
- $charval += ((ord($string{++$i}) & 0x3F) << 12);
1036
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
1037
- $charval += (ord($string{++$i}) & 0x3F);
1038
- } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
1039
- $charval = (($char_ord_val & 0x0F) << 12);
1040
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
1041
- $charval += (ord($string{++$i}) & 0x3F);
1042
- } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
1043
- $charval = (($char_ord_val & 0x1F) << 6);
1044
- $charval += (ord($string{++$i}) & 0x3F);
1045
- }
1046
- if (($charval >= 32) && ($charval <= 127)) {
1047
- $HTMLstring .= htmlentities(chr($charval));
1048
- } else {
1049
- $HTMLstring .= '&#'.$charval.';';
1050
- }
1051
- }
1052
- break;
1053
-
1054
- case 'UTF-16LE':
1055
- for ($i = 0; $i < strlen($string); $i += 2) {
1056
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
1057
- if (($charval >= 32) && ($charval <= 127)) {
1058
- $HTMLstring .= chr($charval);
1059
- } else {
1060
- $HTMLstring .= '&#'.$charval.';';
1061
- }
1062
- }
1063
- break;
1064
-
1065
- case 'UTF-16BE':
1066
- for ($i = 0; $i < strlen($string); $i += 2) {
1067
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
1068
- if (($charval >= 32) && ($charval <= 127)) {
1069
- $HTMLstring .= chr($charval);
1070
- } else {
1071
- $HTMLstring .= '&#'.$charval.';';
1072
- }
1073
- }
1074
- break;
1075
-
1076
- default:
1077
- $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1078
- break;
1079
- }
1080
- return $HTMLstring;
1081
- }
1082
-
1083
-
1084
-
1085
- static function RGADnameLookup($namecode) {
1086
- static $RGADname = array();
1087
- if (empty($RGADname)) {
1088
- $RGADname[0] = 'not set';
1089
- $RGADname[1] = 'Track Gain Adjustment';
1090
- $RGADname[2] = 'Album Gain Adjustment';
1091
- }
1092
-
1093
- return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1094
- }
1095
-
1096
-
1097
- static function RGADoriginatorLookup($originatorcode) {
1098
- static $RGADoriginator = array();
1099
- if (empty($RGADoriginator)) {
1100
- $RGADoriginator[0] = 'unspecified';
1101
- $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1102
- $RGADoriginator[2] = 'set by user';
1103
- $RGADoriginator[3] = 'determined automatically';
1104
- }
1105
-
1106
- return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1107
- }
1108
-
1109
-
1110
- static function RGADadjustmentLookup($rawadjustment, $signbit) {
1111
- $adjustment = $rawadjustment / 10;
1112
- if ($signbit == 1) {
1113
- $adjustment *= -1;
1114
- }
1115
- return (float) $adjustment;
1116
- }
1117
-
1118
-
1119
- static function RGADgainString($namecode, $originatorcode, $replaygain) {
1120
- if ($replaygain < 0) {
1121
- $signbit = '1';
1122
- } else {
1123
- $signbit = '0';
1124
- }
1125
- $storedreplaygain = intval(round($replaygain * 10));
1126
- $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1127
- $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1128
- $gainstring .= $signbit;
1129
- $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1130
-
1131
- return $gainstring;
1132
- }
1133
-
1134
- static function RGADamplitude2dB($amplitude) {
1135
- return 20 * log10($amplitude);
1136
- }
1137
-