PowerPress Podcasting plugin by Blubrry - Version 0.8.0

Version Description

Download this release

Release Info

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

Code changes from version 0.7.3 to 0.8.0

3rdparty/JSON.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
+
4
+ /**
5
+ * Converts to and from JSON format.
6
+ *
7
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
8
+ * format. It is easy for humans to read and write. It is easy for machines
9
+ * to parse and generate. It is based on a subset of the JavaScript
10
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
11
+ * This feature can also be found in Python. JSON is a text format that is
12
+ * completely language independent but uses conventions that are familiar
13
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
14
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
15
+ * ideal data-interchange language.
16
+ *
17
+ * This package provides a simple encoder and decoder for JSON notation. It
18
+ * is intended for use with client-side Javascript applications that make
19
+ * use of HTTPRequest to perform server communication functions - data can
20
+ * be encoded into JSON notation for use in a client-side javascript, or
21
+ * decoded from incoming Javascript requests. JSON format is native to
22
+ * Javascript, and can be directly eval()'ed with no further parsing
23
+ * overhead
24
+ *
25
+ * All strings should be in ASCII or UTF-8 format!
26
+ *
27
+ * LICENSE: Redistribution and use in source and binary forms, with or
28
+ * without modification, are permitted provided that the following
29
+ * conditions are met: Redistributions of source code must retain the
30
+ * above copyright notice, this list of conditions and the following
31
+ * disclaimer. Redistributions in binary form must reproduce the above
32
+ * copyright notice, this list of conditions and the following disclaimer
33
+ * in the documentation and/or other materials provided with the
34
+ * distribution.
35
+ *
36
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
37
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
39
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
41
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
42
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
45
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46
+ * DAMAGE.
47
+ *
48
+ * @category
49
+ * @package Services_JSON
50
+ * @author Michal Migurski <mike-json@teczno.com>
51
+ * @author Matt Knapp <mdknapp[at]gmail[dot]com>
52
+ * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
53
+ * @copyright 2005 Michal Migurski
54
+ * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
55
+ * @license http://www.opensource.org/licenses/bsd-license.php
56
+ * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
57
+ */
58
+
59
+ /**
60
+ * Marker constant for Services_JSON::decode(), used to flag stack state
61
+ */
62
+ define('SERVICES_JSON_SLICE', 1);
63
+
64
+ /**
65
+ * Marker constant for Services_JSON::decode(), used to flag stack state
66
+ */
67
+ define('SERVICES_JSON_IN_STR', 2);
68
+
69
+ /**
70
+ * Marker constant for Services_JSON::decode(), used to flag stack state
71
+ */
72
+ define('SERVICES_JSON_IN_ARR', 3);
73
+
74
+ /**
75
+ * Marker constant for Services_JSON::decode(), used to flag stack state
76
+ */
77
+ define('SERVICES_JSON_IN_OBJ', 4);
78
+
79
+ /**
80
+ * Marker constant for Services_JSON::decode(), used to flag stack state
81
+ */
82
+ define('SERVICES_JSON_IN_CMT', 5);
83
+
84
+ /**
85
+ * Behavior switch for Services_JSON::decode()
86
+ */
87
+ define('SERVICES_JSON_LOOSE_TYPE', 16);
88
+
89
+ /**
90
+ * Behavior switch for Services_JSON::decode()
91
+ */
92
+ define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
93
+
94
+ /**
95
+ * Converts to and from JSON format.
96
+ *
97
+ * Brief example of use:
98
+ *
99
+ * <code>
100
+ * // create a new instance of Services_JSON
101
+ * $json = new Services_JSON();
102
+ *
103
+ * // convert a complexe value to JSON notation, and send it to the browser
104
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
105
+ * $output = $json->encode($value);
106
+ *
107
+ * print($output);
108
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
109
+ *
110
+ * // accept incoming POST data, assumed to be in JSON notation
111
+ * $input = file_get_contents('php://input', 1000000);
112
+ * $value = $json->decode($input);
113
+ * </code>
114
+ */
115
+ class Services_JSON
116
+ {
117
+ /**
118
+ * constructs a new JSON instance
119
+ *
120
+ * @param int $use object behavior flags; combine with boolean-OR
121
+ *
122
+ * possible values:
123
+ * - SERVICES_JSON_LOOSE_TYPE: loose typing.
124
+ * "{...}" syntax creates associative arrays
125
+ * instead of objects in decode().
126
+ * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
127
+ * Values which can't be encoded (e.g. resources)
128
+ * appear as NULL instead of throwing errors.
129
+ * By default, a deeply-nested resource will
130
+ * bubble up with an error, so all return values
131
+ * from encode() should be checked with isError()
132
+ */
133
+ function Services_JSON($use = 0)
134
+ {
135
+ $this->use = $use;
136
+ }
137
+
138
+ /**
139
+ * convert a string from one UTF-16 char to one UTF-8 char
140
+ *
141
+ * Normally should be handled by mb_convert_encoding, but
142
+ * provides a slower PHP-only method for installations
143
+ * that lack the multibye string extension.
144
+ *
145
+ * @param string $utf16 UTF-16 character
146
+ * @return string UTF-8 character
147
+ * @access private
148
+ */
149
+ function utf162utf8($utf16)
150
+ {
151
+ // oh please oh please oh please oh please oh please
152
+ if(function_exists('mb_convert_encoding')) {
153
+ return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154
+ }
155
+
156
+ $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
157
+
158
+ switch(true) {
159
+ case ((0x7F & $bytes) == $bytes):
160
+ // this case should never be reached, because we are in ASCII range
161
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
162
+ return chr(0x7F & $bytes);
163
+
164
+ case (0x07FF & $bytes) == $bytes:
165
+ // return a 2-byte UTF-8 character
166
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
+ return chr(0xC0 | (($bytes >> 6) & 0x1F))
168
+ . chr(0x80 | ($bytes & 0x3F));
169
+
170
+ case (0xFFFF & $bytes) == $bytes:
171
+ // return a 3-byte UTF-8 character
172
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
173
+ return chr(0xE0 | (($bytes >> 12) & 0x0F))
174
+ . chr(0x80 | (($bytes >> 6) & 0x3F))
175
+ . chr(0x80 | ($bytes & 0x3F));
176
+ }
177
+
178
+ // ignoring UTF-32 for now, sorry
179
+ return '';
180
+ }
181
+
182
+ /**
183
+ * convert a string from one UTF-8 char to one UTF-16 char
184
+ *
185
+ * Normally should be handled by mb_convert_encoding, but
186
+ * provides a slower PHP-only method for installations
187
+ * that lack the multibye string extension.
188
+ *
189
+ * @param string $utf8 UTF-8 character
190
+ * @return string UTF-16 character
191
+ * @access private
192
+ */
193
+ function utf82utf16($utf8)
194
+ {
195
+ // oh please oh please oh please oh please oh please
196
+ if(function_exists('mb_convert_encoding')) {
197
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
198
+ }
199
+
200
+ switch(strlen($utf8)) {
201
+ case 1:
202
+ // this case should never be reached, because we are in ASCII range
203
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
204
+ return $utf8;
205
+
206
+ case 2:
207
+ // return a UTF-16 character from a 2-byte UTF-8 char
208
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209
+ return chr(0x07 & (ord($utf8{0}) >> 2))
210
+ . chr((0xC0 & (ord($utf8{0}) << 6))
211
+ | (0x3F & ord($utf8{1})));
212
+
213
+ case 3:
214
+ // return a UTF-16 character from a 3-byte UTF-8 char
215
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216
+ return chr((0xF0 & (ord($utf8{0}) << 4))
217
+ | (0x0F & (ord($utf8{1}) >> 2)))
218
+ . chr((0xC0 & (ord($utf8{1}) << 6))
219
+ | (0x7F & ord($utf8{2})));
220
+ }
221
+
222
+ // ignoring UTF-32 for now, sorry
223
+ return '';
224
+ }
225
+
226
+ /**
227
+ * encodes an arbitrary variable into JSON format
228
+ *
229
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
230
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
231
+ * if var is a strng, note that encode() always expects it
232
+ * to be in ASCII or UTF-8 format!
233
+ *
234
+ * @return mixed JSON string representation of input var or an error if a problem occurs
235
+ * @access public
236
+ */
237
+ function encode($var)
238
+ {
239
+ switch (gettype($var)) {
240
+ case 'boolean':
241
+ return $var ? 'true' : 'false';
242
+
243
+ case 'NULL':
244
+ return 'null';
245
+
246
+ case 'integer':
247
+ return (int) $var;
248
+
249
+ case 'double':
250
+ case 'float':
251
+ return (float) $var;
252
+
253
+ case 'string':
254
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
255
+ $ascii = '';
256
+ $strlen_var = strlen($var);
257
+
258
+ /*
259
+ * Iterate over every character in the string,
260
+ * escaping with a slash or encoding to UTF-8 where necessary
261
+ */
262
+ for ($c = 0; $c < $strlen_var; ++$c) {
263
+
264
+ $ord_var_c = ord($var{$c});
265
+
266
+ switch (true) {
267
+ case $ord_var_c == 0x08:
268
+ $ascii .= '\b';
269
+ break;
270
+ case $ord_var_c == 0x09:
271
+ $ascii .= '\t';
272
+ break;
273
+ case $ord_var_c == 0x0A:
274
+ $ascii .= '\n';
275
+ break;
276
+ case $ord_var_c == 0x0C:
277
+ $ascii .= '\f';
278
+ break;
279
+ case $ord_var_c == 0x0D:
280
+ $ascii .= '\r';
281
+ break;
282
+
283
+ case $ord_var_c == 0x22:
284
+ case $ord_var_c == 0x2F:
285
+ case $ord_var_c == 0x5C:
286
+ // double quote, slash, slosh
287
+ $ascii .= '\\'.$var{$c};
288
+ break;
289
+
290
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291
+ // characters U-00000000 - U-0000007F (same as ASCII)
292
+ $ascii .= $var{$c};
293
+ break;
294
+
295
+ case (($ord_var_c & 0xE0) == 0xC0):
296
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
297
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
299
+ $c += 1;
300
+ $utf16 = $this->utf82utf16($char);
301
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
302
+ break;
303
+
304
+ case (($ord_var_c & 0xF0) == 0xE0):
305
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
+ $char = pack('C*', $ord_var_c,
308
+ ord($var{$c + 1}),
309
+ ord($var{$c + 2}));
310
+ $c += 2;
311
+ $utf16 = $this->utf82utf16($char);
312
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
313
+ break;
314
+
315
+ case (($ord_var_c & 0xF8) == 0xF0):
316
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
317
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318
+ $char = pack('C*', $ord_var_c,
319
+ ord($var{$c + 1}),
320
+ ord($var{$c + 2}),
321
+ ord($var{$c + 3}));
322
+ $c += 3;
323
+ $utf16 = $this->utf82utf16($char);
324
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
325
+ break;
326
+
327
+ case (($ord_var_c & 0xFC) == 0xF8):
328
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
329
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330
+ $char = pack('C*', $ord_var_c,
331
+ ord($var{$c + 1}),
332
+ ord($var{$c + 2}),
333
+ ord($var{$c + 3}),
334
+ ord($var{$c + 4}));
335
+ $c += 4;
336
+ $utf16 = $this->utf82utf16($char);
337
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
338
+ break;
339
+
340
+ case (($ord_var_c & 0xFE) == 0xFC):
341
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343
+ $char = pack('C*', $ord_var_c,
344
+ ord($var{$c + 1}),
345
+ ord($var{$c + 2}),
346
+ ord($var{$c + 3}),
347
+ ord($var{$c + 4}),
348
+ ord($var{$c + 5}));
349
+ $c += 5;
350
+ $utf16 = $this->utf82utf16($char);
351
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
352
+ break;
353
+ }
354
+ }
355
+
356
+ return '"'.$ascii.'"';
357
+
358
+ case 'array':
359
+ /*
360
+ * As per JSON spec if any array key is not an integer
361
+ * we must treat the the whole array as an object. We
362
+ * also try to catch a sparsely populated associative
363
+ * array with numeric keys here because some JS engines
364
+ * will create an array with empty indexes up to
365
+ * max_index which can cause memory issues and because
366
+ * the keys, which may be relevant, will be remapped
367
+ * otherwise.
368
+ *
369
+ * As per the ECMA and JSON specification an object may
370
+ * have any string as a property. Unfortunately due to
371
+ * a hole in the ECMA specification if the key is a
372
+ * ECMA reserved word or starts with a digit the
373
+ * parameter is only accessible using ECMAScript's
374
+ * bracket notation.
375
+ */
376
+
377
+ // treat as a JSON object
378
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
379
+ $properties = array_map(array($this, 'name_value'),
380
+ array_keys($var),
381
+ array_values($var));
382
+
383
+ foreach($properties as $property) {
384
+ if(Services_JSON::isError($property)) {
385
+ return $property;
386
+ }
387
+ }
388
+
389
+ return '{' . join(',', $properties) . '}';
390
+ }
391
+
392
+ // treat it like a regular array
393
+ $elements = array_map(array($this, 'encode'), $var);
394
+
395
+ foreach($elements as $element) {
396
+ if(Services_JSON::isError($element)) {
397
+ return $element;
398
+ }
399
+ }
400
+
401
+ return '[' . join(',', $elements) . ']';
402
+
403
+ case 'object':
404
+ $vars = get_object_vars($var);
405
+
406
+ $properties = array_map(array($this, 'name_value'),
407
+ array_keys($vars),
408
+ array_values($vars));
409
+
410
+ foreach($properties as $property) {
411
+ if(Services_JSON::isError($property)) {
412
+ return $property;
413
+ }
414
+ }
415
+
416
+ return '{' . join(',', $properties) . '}';
417
+
418
+ default:
419
+ return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
420
+ ? 'null'
421
+ : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
422
+ }
423
+ }
424
+
425
+ /**
426
+ * array-walking function for use in generating JSON-formatted name-value pairs
427
+ *
428
+ * @param string $name name of key to use
429
+ * @param mixed $value reference to an array element to be encoded
430
+ *
431
+ * @return string JSON-formatted name-value pair, like '"name":value'
432
+ * @access private
433
+ */
434
+ function name_value($name, $value)
435
+ {
436
+ $encoded_value = $this->encode($value);
437
+
438
+ if(Services_JSON::isError($encoded_value)) {
439
+ return $encoded_value;
440
+ }
441
+
442
+ return $this->encode(strval($name)) . ':' . $encoded_value;
443
+ }
444
+
445
+ /**
446
+ * reduce a string by removing leading and trailing comments and whitespace
447
+ *
448
+ * @param $str string string value to strip of comments and whitespace
449
+ *
450
+ * @return string string value stripped of comments and whitespace
451
+ * @access private
452
+ */
453
+ function reduce_string($str)
454
+ {
455
+ $str = preg_replace(array(
456
+
457
+ // eliminate single line comments in '// ...' form
458
+ '#^\s*//(.+)$#m',
459
+
460
+ // eliminate multi-line comments in '/* ... */' form, at start of string
461
+ '#^\s*/\*(.+)\*/#Us',
462
+
463
+ // eliminate multi-line comments in '/* ... */' form, at end of string
464
+ '#/\*(.+)\*/\s*$#Us'
465
+
466
+ ), '', $str);
467
+
468
+ // eliminate extraneous space
469
+ return trim($str);
470
+ }
471
+
472
+ /**
473
+ * decodes a JSON string into appropriate variable
474
+ *
475
+ * @param string $str JSON-formatted string
476
+ *
477
+ * @return mixed number, boolean, string, array, or object
478
+ * corresponding to given JSON input string.
479
+ * See argument 1 to Services_JSON() above for object-output behavior.
480
+ * Note that decode() always returns strings
481
+ * in ASCII or UTF-8 format!
482
+ * @access public
483
+ */
484
+ function decode($str)
485
+ {
486
+ $str = $this->reduce_string($str);
487
+
488
+ switch (strtolower($str)) {
489
+ case 'true':
490
+ return true;
491
+
492
+ case 'false':
493
+ return false;
494
+
495
+ case 'null':
496
+ return null;
497
+
498
+ default:
499
+ $m = array();
500
+
501
+ if (is_numeric($str)) {
502
+ // Lookie-loo, it's a number
503
+
504
+ // This would work on its own, but I'm trying to be
505
+ // good about returning integers where appropriate:
506
+ // return (float)$str;
507
+
508
+ // Return float or int, as appropriate
509
+ return ((float)$str == (integer)$str)
510
+ ? (integer)$str
511
+ : (float)$str;
512
+
513
+ } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
514
+ // STRINGS RETURNED IN UTF-8 FORMAT
515
+ $delim = substr($str, 0, 1);
516
+ $chrs = substr($str, 1, -1);
517
+ $utf8 = '';
518
+ $strlen_chrs = strlen($chrs);
519
+
520
+ for ($c = 0; $c < $strlen_chrs; ++$c) {
521
+
522
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
523
+ $ord_chrs_c = ord($chrs{$c});
524
+
525
+ switch (true) {
526
+ case $substr_chrs_c_2 == '\b':
527
+ $utf8 .= chr(0x08);
528
+ ++$c;
529
+ break;
530
+ case $substr_chrs_c_2 == '\t':
531
+ $utf8 .= chr(0x09);
532
+ ++$c;
533
+ break;
534
+ case $substr_chrs_c_2 == '\n':
535
+ $utf8 .= chr(0x0A);
536
+ ++$c;
537
+ break;
538
+ case $substr_chrs_c_2 == '\f':
539
+ $utf8 .= chr(0x0C);
540
+ ++$c;
541
+ break;
542
+ case $substr_chrs_c_2 == '\r':
543
+ $utf8 .= chr(0x0D);
544
+ ++$c;
545
+ break;
546
+
547
+ case $substr_chrs_c_2 == '\\"':
548
+ case $substr_chrs_c_2 == '\\\'':
549
+ case $substr_chrs_c_2 == '\\\\':
550
+ case $substr_chrs_c_2 == '\\/':
551
+ if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552
+ ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553
+ $utf8 .= $chrs{++$c};
554
+ }
555
+ break;
556
+
557
+ case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
558
+ // single, escaped unicode character
559
+ $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
560
+ . chr(hexdec(substr($chrs, ($c + 4), 2)));
561
+ $utf8 .= $this->utf162utf8($utf16);
562
+ $c += 5;
563
+ break;
564
+
565
+ case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566
+ $utf8 .= $chrs{$c};
567
+ break;
568
+
569
+ case ($ord_chrs_c & 0xE0) == 0xC0:
570
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
571
+ //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
572
+ $utf8 .= substr($chrs, $c, 2);
573
+ ++$c;
574
+ break;
575
+
576
+ case ($ord_chrs_c & 0xF0) == 0xE0:
577
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
578
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
579
+ $utf8 .= substr($chrs, $c, 3);
580
+ $c += 2;
581
+ break;
582
+
583
+ case ($ord_chrs_c & 0xF8) == 0xF0:
584
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
585
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
586
+ $utf8 .= substr($chrs, $c, 4);
587
+ $c += 3;
588
+ break;
589
+
590
+ case ($ord_chrs_c & 0xFC) == 0xF8:
591
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
592
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
593
+ $utf8 .= substr($chrs, $c, 5);
594
+ $c += 4;
595
+ break;
596
+
597
+ case ($ord_chrs_c & 0xFE) == 0xFC:
598
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
599
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
600
+ $utf8 .= substr($chrs, $c, 6);
601
+ $c += 5;
602
+ break;
603
+
604
+ }
605
+
606
+ }
607
+
608
+ return $utf8;
609
+
610
+ } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611
+ // array, or object notation
612
+
613
+ if ($str{0} == '[') {
614
+ $stk = array(SERVICES_JSON_IN_ARR);
615
+ $arr = array();
616
+ } else {
617
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
618
+ $stk = array(SERVICES_JSON_IN_OBJ);
619
+ $obj = array();
620
+ } else {
621
+ $stk = array(SERVICES_JSON_IN_OBJ);
622
+ $obj = new stdClass();
623
+ }
624
+ }
625
+
626
+ array_push($stk, array('what' => SERVICES_JSON_SLICE,
627
+ 'where' => 0,
628
+ 'delim' => false));
629
+
630
+ $chrs = substr($str, 1, -1);
631
+ $chrs = $this->reduce_string($chrs);
632
+
633
+ if ($chrs == '') {
634
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
635
+ return $arr;
636
+
637
+ } else {
638
+ return $obj;
639
+
640
+ }
641
+ }
642
+
643
+ //print("\nparsing {$chrs}\n");
644
+
645
+ $strlen_chrs = strlen($chrs);
646
+
647
+ for ($c = 0; $c <= $strlen_chrs; ++$c) {
648
+
649
+ $top = end($stk);
650
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
651
+
652
+ if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653
+ // found a comma that is not inside a string, array, etc.,
654
+ // OR we've reached the end of the character list
655
+ $slice = substr($chrs, $top['where'], ($c - $top['where']));
656
+ array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
657
+ //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
658
+
659
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
660
+ // we are in an array, so just push an element onto the stack
661
+ array_push($arr, $this->decode($slice));
662
+
663
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
664
+ // we are in an object, so figure
665
+ // out the property name and set an
666
+ // element in an associative array,
667
+ // for now
668
+ $parts = array();
669
+
670
+ if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
671
+ // "name":value pair
672
+ $key = $this->decode($parts[1]);
673
+ $val = $this->decode($parts[2]);
674
+
675
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
676
+ $obj[$key] = $val;
677
+ } else {
678
+ $obj->$key = $val;
679
+ }
680
+ } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
681
+ // name:value pair, where name is unquoted
682
+ $key = $parts[1];
683
+ $val = $this->decode($parts[2]);
684
+
685
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
686
+ $obj[$key] = $val;
687
+ } else {
688
+ $obj->$key = $val;
689
+ }
690
+ }
691
+
692
+ }
693
+
694
+ } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695
+ // found a quote, and we are not inside a string
696
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
697
+ //print("Found start of string at {$c}\n");
698
+
699
+ } elseif (($chrs{$c} == $top['delim']) &&
700
+ ($top['what'] == SERVICES_JSON_IN_STR) &&
701
+ ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702
+ // found a quote, we're in a string, and it's not escaped
703
+ // we know that it's not escaped becase there is _not_ an
704
+ // odd number of backslashes at the end of the string so far
705
+ array_pop($stk);
706
+ //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707
+
708
+ } elseif (($chrs{$c} == '[') &&
709
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710
+ // found a left-bracket, and we are in an array, object, or slice
711
+ array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712
+ //print("Found start of array at {$c}\n");
713
+
714
+ } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715
+ // found a right-bracket, and we're in an array
716
+ array_pop($stk);
717
+ //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718
+
719
+ } elseif (($chrs{$c} == '{') &&
720
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721
+ // found a left-brace, and we are in an array, object, or slice
722
+ array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723
+ //print("Found start of object at {$c}\n");
724
+
725
+ } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726
+ // found a right-brace, and we're in an object
727
+ array_pop($stk);
728
+ //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
729
+
730
+ } elseif (($substr_chrs_c_2 == '/*') &&
731
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
732
+ // found a comment start, and we are in an array, object, or slice
733
+ array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
734
+ $c++;
735
+ //print("Found start of comment at {$c}\n");
736
+
737
+ } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
738
+ // found a comment end, and we're in one now
739
+ array_pop($stk);
740
+ $c++;
741
+
742
+ for ($i = $top['where']; $i <= $c; ++$i)
743
+ $chrs = substr_replace($chrs, ' ', $i, 1);
744
+
745
+ //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
746
+
747
+ }
748
+
749
+ }
750
+
751
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
752
+ return $arr;
753
+
754
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
755
+ return $obj;
756
+
757
+ }
758
+
759
+ }
760
+ }
761
+ }
762
+
763
+ /**
764
+ * @todo Ultimately, this should just call PEAR::isError()
765
+ */
766
+ function isError($data, $code = null)
767
+ {
768
+ if (class_exists('pear')) {
769
+ return PEAR::isError($data, $code);
770
+ } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
771
+ is_subclass_of($data, 'services_json_error'))) {
772
+ return true;
773
+ }
774
+
775
+ return false;
776
+ }
777
+ }
778
+
779
+ if (class_exists('PEAR_Error')) {
780
+
781
+ class Services_JSON_Error extends PEAR_Error
782
+ {
783
+ function Services_JSON_Error($message = 'unknown error', $code = null,
784
+ $mode = null, $options = null, $userinfo = null)
785
+ {
786
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
787
+ }
788
+ }
789
+
790
+ } else {
791
+
792
+ /**
793
+ * @todo Ultimately, this class shall be descended from PEAR_Error
794
+ */
795
+ class Services_JSON_Error
796
+ {
797
+ function Services_JSON_Error($message = 'unknown error', $code = null,
798
+ $mode = null, $options = null, $userinfo = null)
799
+ {
800
+
801
+ }
802
+ }
803
+
804
+ }
805
+
806
+ ?>
css/jquery.css ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* jquery.css */
2
+ body {
3
+ font-family: Arial, Helvetica, sans-serif;
4
+
5
+ /* background-color: #D2E9FF; */
6
+ }
7
+ img {
8
+ border: 0;
9
+ }
10
+ #accountinfo label, h1, h2, h3, h4, h5, a {
11
+ color: #3D517E;
12
+ }
13
+ input[type="button"],
14
+ input[type="submit"] {
15
+ font-family: Geneva, Arial, Helvetica, sans-serif;
16
+ text-decoration: none;
17
+ font-size: 14px !important;
18
+ line-height: 16px;
19
+ cursor: pointer;
20
+ border-width: 1px;
21
+ border-style: solid;
22
+ border-color:#99ADC2;
23
+ -moz-border-radius: 5px;
24
+ -khtml-border-radius: 5px;
25
+ -webkit-border-radius: 5px;
26
+ border-radius: 5px;
27
+ -moz-box-sizing: content-box;
28
+ -webkit-box-sizing: content-box;
29
+ -khtml-box-sizing: content-box;
30
+ box-sizing: content-box;
31
+ background-color: #E8F4FF;
32
+ color: #003366;
33
+ font-weight: bold;
34
+ padding-top: 2px;
35
+ padding-right: 8px;
36
+ padding-bottom: 2px;
37
+ padding-left: 8px;
38
+ }
39
+
40
+ ul.media {
41
+
42
+ }
43
+ ul.media li {
44
+ list-style-type: none;
45
+ }
46
+ ul.media li a {
47
+ font-weight: bold;
48
+ }
49
+
50
+ #accountinfo {
51
+
52
+ }
53
+ #accountinfo p {
54
+ font-size: 90%;
55
+ }
56
+ #accountinfo label {
57
+ float: left;
58
+ width: 240px;
59
+ margin-right: 10px;
60
+ display: block;
61
+ font-weight: bold;
62
+ }
63
+ #accountinfo input[type=text], #accountinfo input[type=password] {
64
+ width: 240px;
65
+ }
66
+ #accountinfo select {
67
+ width: 242px;
68
+ }
69
+ .powerpress-notice {
70
+ border: 1px solid #FFCC00;
71
+ font-size: 12px;
72
+ color: #000000;
73
+ background-color: #FFFFCC;
74
+ font-weight: bold;
75
+ padding: 5px;
76
+ margin: 20px;
77
+ }
78
+
79
+ #media-items-container {
80
+ margin: 10px;
81
+ }
82
+ #media-items {
83
+ border-bottom-color: #dfdfdf;
84
+ border-bottom-width: 1px;
85
+ border-bottom-style: solid;
86
+ min-height: 36px;
87
+ width: 100%;
88
+ }
89
+ .media-item {
90
+
91
+ border-top-color: #dfdfdf;
92
+ border-top-width: 1px;
93
+ border-top-style: solid;
94
+ min-height: 36px;
95
+ width: 100%;
96
+
97
+ border-left-color: #dfdfdf;
98
+ border-left-width: 1px;
99
+ border-left-style: solid;
100
+ border-right-color: #dfdfdf;
101
+ border-right-width: 1px;
102
+ border-right-style: solid;
103
+ position: relative;
104
+
105
+ padding-top: 15px;
106
+
107
+ }
108
+ .media-item .media-name {
109
+ margin-left: 10px;
110
+ }
111
+ .media-item-links {
112
+ position: absolute;
113
+ top: 15px;
114
+ right: 10px;
115
+ text-align: right;
116
+ }
images/folder.png ADDED
Binary file
powerpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
- Version: 0.7.3
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
@@ -29,7 +29,7 @@ License: GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
- define('POWERPRESS_VERSION', '0.7.3' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
@@ -347,22 +347,36 @@ function powerpress_rss2_head()
347
  return; // Not a feed we manage
348
 
349
  $feed_slug = get_query_var( 'feed' );
 
350
 
351
- $Feed = get_option('powerpress_feed');
352
- if( powerpress_is_custom_podcast_feed() )
353
  {
354
- $CustomFeed = get_option('powerpress_feed_'.$feed_slug);
355
  if( $CustomFeed )
356
  $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
357
  }
 
 
 
 
 
358
 
359
  if( !isset($Feed['url']) || trim($Feed['url']) == '' )
360
- $Feed['url'] = get_bloginfo('url');
361
-
 
 
 
 
362
 
 
363
  // We made it this far, lets write stuff to the feed!
364
- echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" -->'.PHP_EOL;
365
-
 
 
 
366
  // add the itunes:new-feed-url tag to feed
367
  if( powerpress_is_custom_podcast_feed() )
368
  {
@@ -375,12 +389,12 @@ function powerpress_rss2_head()
375
  }
376
 
377
  if( $Feed['itunes_summary'] )
378
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 4000 ) .'</itunes:summary>'.PHP_EOL;
379
  else
380
- echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 4000 ) .'</itunes:summary>'.PHP_EOL;
381
 
382
  if( $powerpress_feed['itunes_talent_name'] )
383
- echo "\t\t<itunes:author>" . wp_specialchars($powerpress_feed['itunes_talent_name']) . '</itunes:author>'.PHP_EOL;
384
 
385
  if( $powerpress_feed['explicit'] )
386
  echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
@@ -414,12 +428,12 @@ function powerpress_rss2_head()
414
  }
415
 
416
  if( trim($Feed['itunes_subtitle']) )
417
- echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle']) . '</itunes:subtitle>'.PHP_EOL;
418
  else
419
- echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description') ) .'</itunes:subtitle>'.PHP_EOL;
420
 
421
  if( trim($Feed['itunes_keywords']) )
422
- echo "\t".'<itunes:keywords>' . powerpress_format_itunes_value($Feed['itunes_keywords']) . '</itunes:keywords>'.PHP_EOL;
423
 
424
  if( $Feed['rss2_image'] )
425
  {
@@ -554,7 +568,7 @@ function powerpress_rss2_item()
554
 
555
  // Check and see if we're working with a podcast episode
556
  $custom_enclosure = false;
557
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
558
  {
559
  $enclosureData = get_post_meta($post->ID, '_'. get_query_var('feed') .':enclosure', true);
560
  $custom_enclosure = true;
@@ -668,30 +682,31 @@ function powerpress_rss2_item()
668
  }
669
 
670
  if( $keywords )
671
- echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value($keywords) . '</itunes:keywords>'.PHP_EOL;
672
 
673
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
674
  $content_no_html = $post->post_content;
675
- if( function_exists('strip_shortcodes') )
676
- $content_no_html = strip_shortcodes( $content_no_html );
677
  $content_no_html = str_replace(']]>', ']]&gt;', $content_no_html);
678
  $content_no_html = strip_tags($content_no_html);
679
 
680
  $excerpt_no_html = strip_tags($post->post_excerpt);
681
 
682
  if( $subtitle )
683
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($subtitle, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
684
  else if( $excerpt_no_html )
685
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($excerpt_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
686
  else
687
- echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 250, true)) .'</itunes:subtitle>'.PHP_EOL;
688
 
689
- if( !isset($powerpress_feed['enhance_itunes_summary']) || $powerpress_feed['enhance_itunes_summary'] )
690
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
691
  else if( $summary )
692
- echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($summary, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
 
 
693
  else
694
- echo "\t\t<itunes:summary>". powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000) .'</itunes:summary>'.PHP_EOL;
695
 
696
  if( $author )
697
  echo "\t\t<itunes:author>" . wp_specialchars($author) . '</itunes:author>'.PHP_EOL;
@@ -713,10 +728,8 @@ function powerpress_filter_rss_enclosure($content)
713
  if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
714
  return $content; // Another podcasting plugin is enabled...
715
 
716
- if( !powerpress_is_podcast_feed() )
717
- return ''; // All custom podcast feeds we handle directly
718
 
719
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
720
  return ''; // We will handle this enclosure in the powerpress_rss2_item() function
721
 
722
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
@@ -727,11 +740,11 @@ function powerpress_filter_rss_enclosure($content)
727
  $OrigURL = $matches[1];
728
 
729
  if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' )
730
- return; // The URL value is invalid
731
 
732
  global $post, $powerpress_rss_enclosure_post_id;
733
  if( @$powerpress_rss_enclosure_post_id == $post->ID )
734
- return; // we've already included one enclosure, lets not allow anymore
735
  $powerpress_rss_enclosure_post_id = $post->ID;
736
 
737
  // Modified Media URL
@@ -750,7 +763,10 @@ function powerpress_bloginfo_rss($content, $field = '')
750
  {
751
  if( powerpress_is_custom_podcast_feed() )
752
  {
753
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
 
 
 
754
  //$Feed = true;
755
  if( $Feed )
756
  {
@@ -759,10 +775,18 @@ function powerpress_bloginfo_rss($content, $field = '')
759
  case 'description': {
760
  if( isset($Feed['description']) && $Feed['description'] != '' )
761
  return $Feed['description'];
 
 
 
 
 
 
762
  }; break;
763
  case 'url': {
764
  if( isset($Feed['url']) && $Feed['url'] != '' )
765
  return trim($Feed['url']);
 
 
766
  }; break;
767
  case 'name':
768
  default: {
@@ -780,6 +804,49 @@ function powerpress_bloginfo_rss($content, $field = '')
780
  add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
781
 
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  function powerpress_do_podcast_feed($for_comments=false)
784
  {
785
  global $wp_query;
@@ -792,12 +859,13 @@ function powerpress_template_redirect()
792
  if( is_feed() && powerpress_is_custom_podcast_feed() )
793
  {
794
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
795
- $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
796
- if( $Feed && trim(@$Feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && @$_GET['redirect'] != 'no' )
 
797
  {
798
  if (function_exists('status_header'))
799
  status_header( 302 );
800
- header("Location: " . trim($Feed['feed_redirect_url']));
801
  header("HTTP/1.1 302 Temporary Redirect");
802
  exit();
803
  }
@@ -859,14 +927,38 @@ function powerpress_load_general_feed_settings()
859
 
860
  if( $GeneralSettings )
861
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  $feed_slug = get_query_var('feed');
863
 
864
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
865
  {
866
  $Feed = get_option('powerpress_feed'); // Get overall feed settings
867
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
868
- if( $FeedCustom )
869
- $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
870
 
871
  $powerpress_feed = array();
872
  $powerpress_feed['is_custom'] = true;
@@ -879,7 +971,10 @@ function powerpress_load_general_feed_settings()
879
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
880
  else
881
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
882
- $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
 
 
 
883
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
884
  }
885
  else
@@ -919,7 +1014,10 @@ function powerpress_load_general_feed_settings()
919
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
920
  else
921
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
922
- $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
 
 
 
923
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
924
  }; break;
925
  // All other cases we let fall through
@@ -958,8 +1056,11 @@ function powerpress_is_custom_podcast_feed()
958
  }
959
 
960
  function powerpress_posts_join($join)
961
- {
962
- if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
 
 
 
963
  {
964
  global $wpdb;
965
  $join .= " INNER JOIN {$wpdb->postmeta} ";
@@ -972,12 +1073,15 @@ add_filter('posts_join', 'powerpress_posts_join' );
972
 
973
  function powerpress_posts_where($where)
974
  {
 
 
 
975
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
976
  {
977
  global $wpdb, $powerpress_feed;
978
  $where .= " AND (";
979
 
980
- if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' )
981
  $where .= " {$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
982
  else
983
  $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
@@ -996,6 +1100,9 @@ add_filter('posts_where', 'powerpress_posts_where' );
996
  // Add the groupby needed for enclosures only
997
  function powerpress_posts_groupby($groupby)
998
  {
 
 
 
999
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1000
  {
1001
  global $wpdb;
@@ -1162,12 +1269,11 @@ function powerpress_itunes_summary($html)
1162
  $html = str_replace('<li>', '<li>* ', $html);
1163
 
1164
  // Now do all the other regular conversions...
1165
- if( function_exists('strip_shortcodes') )
1166
- $html = strip_shortcodes( $html );
1167
  $html = str_replace(']]>', ']]&gt;', $html);
1168
  $content_no_html = strip_tags($html);
1169
 
1170
- return powerpress_format_itunes_value(powerpress_smart_trim($content_no_html, 4000), 4000);
1171
  }
1172
 
1173
  function powerpress_itunes_categories($PrefixSubCategories = false)
@@ -1279,21 +1385,74 @@ function powerpress_get_root_url()
1279
  return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/';
1280
  }
1281
 
1282
- function powerpress_format_itunes_value($value, $char_limit = 255, $specialchars = true)
1283
  {
1284
- // Code added to solve issue with KimiliFlashEmbed plugin
1285
- // 99.9% of the time this code will not be necessary
1286
- $value = preg_replace("/\[(kml_(flash|swf)embed)\b(.*?)(?:(\/))?(\]|$)/s", '', $value);
1287
  if( DB_CHARSET != 'utf8' ) // Check if the string is UTF-8
1288
  $value = utf8_encode($value); // If it is not, convert to UTF-8 then decode it...
 
 
 
 
 
1289
  if(version_compare("5", phpversion(), ">"))
1290
- $value = str_replace('&nbsp;', ' ', $value); // Best we can do for PHP4
1291
  else
1292
  $value = @html_entity_decode($value, ENT_COMPAT, 'UTF-8'); // Remove any additional entities such as &nbsp;
 
1293
 
1294
- if( strlen($value) > $char_limit )
1295
- return wp_specialchars(substr($value, 0, $char_limit));
1296
- return wp_specialchars($value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297
  }
1298
 
1299
  function powerpress_smart_trim($value, $char_limit = 250, $remove_new_lines = false)
@@ -1380,16 +1539,24 @@ function powerpress_byte_size($ppbytes)
1380
  return $ppsize;
1381
  }
1382
 
1383
- // Merges settings where $S
1384
  function powerpress_merge_empty_feed_settings($CustomFeedSettings, $FeedSettings)
1385
  {
 
 
 
 
 
 
 
 
1386
  while( list($key,$value) = each($CustomFeedSettings) )
1387
  {
1388
- if( $value === '' && $FeedSettings[$key] != $value )
1389
- $CustomFeedSettings[$key] = $FeedSettings[$key];
1390
  }
1391
 
1392
- return $CustomFeedSettings;
1393
  }
1394
 
1395
  function powerpress_readable_duration($duration, $include_hour=false)
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://www.blubrry.com/powerpress/
5
  Description: <a href="http://www.blubrry.com/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics and iTunes integration.
6
+ Version: 0.8.0
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
29
  */
30
 
31
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
32
+ define('POWERPRESS_VERSION', '0.8.0' );
33
 
34
  /////////////////////////////////////////////////////
35
  // The following define options should be placed in your
347
  return; // Not a feed we manage
348
 
349
  $feed_slug = get_query_var( 'feed' );
350
+ $cat_ID = get_query_var('cat');
351
 
352
+ $Feed = get_option('powerpress_feed'); // Get the main feed settings
353
+ if( is_category() )
354
  {
355
+ $CustomFeed = get_option('powerpress_cat_feed_'.$cat_ID); // Get the custom podcast feed settings saved in the database
356
  if( $CustomFeed )
357
  $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
358
  }
359
+ else if( powerpress_is_custom_podcast_feed() ) // If we're handling a custom podcast feed...
360
+ {
361
+ $CustomFeed = get_option('powerpress_feed_'.$feed_slug); // Get the custom podcast feed settings saved in the database
362
+ $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
363
+ }
364
 
365
  if( !isset($Feed['url']) || trim($Feed['url']) == '' )
366
+ {
367
+ if( is_category() )
368
+ $Feed['url'] = get_category_link($cat_ID);
369
+ else
370
+ $Feed['url'] = get_bloginfo('url');
371
+ }
372
 
373
+ $General = get_option('powerpress_general');
374
  // We made it this far, lets write stuff to the feed!
375
+ if( $General['advanced_mode'] == 0 )
376
+ echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" mode="simple" -->'.PHP_EOL;
377
+ else
378
+ echo '<!-- podcast_generator="Blubrry PowerPress/'. POWERPRESS_VERSION .'" mode="advanced" -->'.PHP_EOL;
379
+
380
  // add the itunes:new-feed-url tag to feed
381
  if( powerpress_is_custom_podcast_feed() )
382
  {
389
  }
390
 
391
  if( $Feed['itunes_summary'] )
392
+ echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( $Feed['itunes_summary'], 'summary' ) .'</itunes:summary>'.PHP_EOL;
393
  else
394
+ echo "\t".'<itunes:summary>'. powerpress_format_itunes_value( get_bloginfo('description'), 'summary' ) .'</itunes:summary>'.PHP_EOL;
395
 
396
  if( $powerpress_feed['itunes_talent_name'] )
397
+ echo "\t<itunes:author>" . wp_specialchars($powerpress_feed['itunes_talent_name']) . '</itunes:author>'.PHP_EOL;
398
 
399
  if( $powerpress_feed['explicit'] )
400
  echo "\t".'<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>'.PHP_EOL;
428
  }
429
 
430
  if( trim($Feed['itunes_subtitle']) )
431
+ echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle', true) . '</itunes:subtitle>'.PHP_EOL;
432
  else
433
+ echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
434
 
435
  if( trim($Feed['itunes_keywords']) )
436
+ echo "\t".'<itunes:keywords>' . powerpress_format_itunes_value($Feed['itunes_keywords'], 'keywords') . '</itunes:keywords>'.PHP_EOL;
437
 
438
  if( $Feed['rss2_image'] )
439
  {
568
 
569
  // Check and see if we're working with a podcast episode
570
  $custom_enclosure = false;
571
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
572
  {
573
  $enclosureData = get_post_meta($post->ID, '_'. get_query_var('feed') .':enclosure', true);
574
  $custom_enclosure = true;
682
  }
683
 
684
  if( $keywords )
685
+ echo "\t\t<itunes:keywords>" . powerpress_format_itunes_value($keywords, 'keywords') . '</itunes:keywords>'.PHP_EOL;
686
 
687
  // Strip and format the wordpress way, but don't apply any other filters for these itunes tags
688
  $content_no_html = $post->post_content;
689
+ $content_no_html = strip_shortcodes( $content_no_html );
 
690
  $content_no_html = str_replace(']]>', ']]&gt;', $content_no_html);
691
  $content_no_html = strip_tags($content_no_html);
692
 
693
  $excerpt_no_html = strip_tags($post->post_excerpt);
694
 
695
  if( $subtitle )
696
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($subtitle, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
697
  else if( $excerpt_no_html )
698
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($excerpt_no_html, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
699
  else
700
+ echo "\t\t<itunes:subtitle>". powerpress_format_itunes_value($content_no_html, 'subtitle', true) .'</itunes:subtitle>'.PHP_EOL;
701
 
702
+ if( $powerpress_feed['enhance_itunes_summary'] )
703
  echo "\t\t<itunes:summary>". powerpress_itunes_summary($post->post_content) .'</itunes:summary>'.PHP_EOL;
704
  else if( $summary )
705
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($summary, 'summary') .'</itunes:summary>'.PHP_EOL;
706
+ else if( $excerpt_no_html )
707
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($excerpt_no_html, 'summary') .'</itunes:summary>'.PHP_EOL;
708
  else
709
+ echo "\t\t<itunes:summary>". powerpress_format_itunes_value($content_no_html, 'summary') .'</itunes:summary>'.PHP_EOL;
710
 
711
  if( $author )
712
  echo "\t\t<itunes:author>" . wp_specialchars($author) . '</itunes:author>'.PHP_EOL;
728
  if( defined('PODPRESS_VERSION') || isset($GLOBALS['podcasting_player_id']) || isset($GLOBALS['podcast_channel_active']) )
729
  return $content; // Another podcasting plugin is enabled...
730
 
 
 
731
 
732
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
733
  return ''; // We will handle this enclosure in the powerpress_rss2_item() function
734
 
735
  $match_count = preg_match('/\surl="([^"]*)"/', $content, $matches);
740
  $OrigURL = $matches[1];
741
 
742
  if( substr($OrigURL, 0, 5) != 'http:' && substr($OrigURL, 0, 6) != 'https:' )
743
+ return ''; // The URL value is invalid
744
 
745
  global $post, $powerpress_rss_enclosure_post_id;
746
  if( @$powerpress_rss_enclosure_post_id == $post->ID )
747
+ return ''; // we've already included one enclosure, lets not allow anymore
748
  $powerpress_rss_enclosure_post_id = $post->ID;
749
 
750
  // Modified Media URL
763
  {
764
  if( powerpress_is_custom_podcast_feed() )
765
  {
766
+ if( is_category() )
767
+ $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
768
+ else
769
+ $Feed = get_option('powerpress_feed_'.get_query_var('feed') );
770
  //$Feed = true;
771
  if( $Feed )
772
  {
775
  case 'description': {
776
  if( isset($Feed['description']) && $Feed['description'] != '' )
777
  return $Feed['description'];
778
+ else if( is_category() )
779
+ {
780
+ $category = get_category( get_query_var('cat') );
781
+ if( $category->description )
782
+ return $category->description;
783
+ }
784
  }; break;
785
  case 'url': {
786
  if( isset($Feed['url']) && $Feed['url'] != '' )
787
  return trim($Feed['url']);
788
+ else if( is_category() )
789
+ return get_category_link( get_query_var('cat') );
790
  }; break;
791
  case 'name':
792
  default: {
804
  add_filter('get_bloginfo_rss', 'powerpress_bloginfo_rss', 10, 2);
805
 
806
 
807
+ function powerpress_wp_title_rss($title)
808
+ {
809
+ if( powerpress_is_custom_podcast_feed() )
810
+ {
811
+ if( is_category() )
812
+ {
813
+ $Feed = get_option('powerpress_cat_feed_'.get_query_var('cat') );
814
+ if( $Feed && isset($Feed['title']) && $Feed['title'] != '' )
815
+ return ''; // We alrady did a custom title, lets not add the category to it...
816
+ }
817
+ else
818
+ {
819
+ return ''; // It is not a category, lets not mess with our beautiful title then
820
+ }
821
+ }
822
+ return $title;
823
+ }
824
+
825
+ add_filter('wp_title_rss', 'powerpress_wp_title_rss');
826
+
827
+ function powerpress_rss_language($value)
828
+ {
829
+ if( powerpress_is_custom_podcast_feed() )
830
+ {
831
+ $feed_slug = get_query_var('feed');
832
+ $cat_ID = get_query_var('cat');
833
+
834
+ if( $cat_ID )
835
+ $Feed = get_option('powerpress_cat_feed_'. $cat_ID);
836
+ else if( $feed_slug != 'podcast' )
837
+ $Feed = get_option('powerpress_feed');
838
+ else
839
+ $Feed = get_option('powerpress_feed_'. $feed_slug);
840
+
841
+ if( $Feed && isset($Feed['rss_language']) && $Feed['rss_language'] != '' )
842
+ $value = $Feed['rss_language'];
843
+ }
844
+ return $value;
845
+ }
846
+
847
+ add_filter('option_rss_language', 'powerpress_rss_language');
848
+
849
+
850
  function powerpress_do_podcast_feed($for_comments=false)
851
  {
852
  global $wp_query;
859
  if( is_feed() && powerpress_is_custom_podcast_feed() )
860
  {
861
  remove_action('template_redirect', 'ol_feed_redirect'); // Remove this action
862
+ global $powerpress_feed;
863
+
864
+ if( is_array($powerpress_feed) && trim(@$powerpress_feed['feed_redirect_url']) != '' && !preg_match("/feedburner|feedsqueezer|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'] ) && @$_GET['redirect'] != 'no' )
865
  {
866
  if (function_exists('status_header'))
867
  status_header( 302 );
868
+ header("Location: " . trim($powerpress_feed['feed_redirect_url']));
869
  header("HTTP/1.1 302 Temporary Redirect");
870
  exit();
871
  }
927
 
928
  if( $GeneralSettings )
929
  {
930
+ if( is_category() && in_array( get_query_var('cat'), $GeneralSettings['custom_cat_feeds']) )
931
+ {
932
+ $cat_ID = get_query_var('cat');
933
+ $Feed = get_option('powerpress_feed'); // Get overall feed settings
934
+ $FeedCustom = get_option('powerpress_cat_feed_'.$cat_ID); // Get custom feed specific settings
935
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
936
+
937
+ $powerpress_feed = array();
938
+ $powerpress_feed['is_custom'] = true;
939
+ $powerpress_feed['category'] = $cat_ID;
940
+ $powerpress_feed['process_podpress'] = true; // Category feeds could originate from Podpress
941
+ $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') .'/';
942
+ $explicit = array("no", "yes", "clean");
943
+ $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
944
+ if( $Feed['itunes_talent_name'] )
945
+ $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
946
+ else
947
+ $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
948
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
949
+ $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
950
+ if( $Feed['feed_redirect_url'] != '' )
951
+ $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
952
+ return;
953
+ }
954
+
955
  $feed_slug = get_query_var('feed');
956
 
957
  if( isset($GeneralSettings['custom_feeds']) && is_array($GeneralSettings['custom_feeds']) && isset($GeneralSettings['custom_feeds'][ $feed_slug ] ))
958
  {
959
  $Feed = get_option('powerpress_feed'); // Get overall feed settings
960
  $FeedCustom = get_option('powerpress_feed_'.$feed_slug); // Get custom feed specific settings
961
+ $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $Feed);
 
962
 
963
  $powerpress_feed = array();
964
  $powerpress_feed['is_custom'] = true;
971
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
972
  else
973
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
974
+ if( version_compare( '5', phpversion(), '>=' ) )
975
+ $powerpress_feed['enhance_itunes_summary'] = 0;
976
+ else
977
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
978
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
979
  }
980
  else
1014
  $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
1015
  else
1016
  $powerpress_feed['itunes_talent_name'] = get_bloginfo_rss('name');
1017
+ if( version_compare( '5', phpversion(), '>=' ) )
1018
+ $powerpress_feed['enhance_itunes_summary'] = 0;
1019
+ else
1020
+ $powerpress_feed['enhance_itunes_summary'] = @$Feed['enhance_itunes_summary'];
1021
  $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
1022
  }; break;
1023
  // All other cases we let fall through
1056
  }
1057
 
1058
  function powerpress_posts_join($join)
1059
+ {
1060
+ if( is_category() )
1061
+ return $join;
1062
+
1063
+ if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) && !is_category() )
1064
  {
1065
  global $wpdb;
1066
  $join .= " INNER JOIN {$wpdb->postmeta} ";
1073
 
1074
  function powerpress_posts_where($where)
1075
  {
1076
+ if( is_category() )
1077
+ return $where;
1078
+
1079
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1080
  {
1081
  global $wpdb, $powerpress_feed;
1082
  $where .= " AND (";
1083
 
1084
+ if( powerpress_is_custom_podcast_feed() && get_query_var('feed') != 'podcast' && !is_category() )
1085
  $where .= " {$wpdb->postmeta}.meta_key = '_". get_query_var('feed') .":enclosure' ";
1086
  else
1087
  $where .= " {$wpdb->postmeta}.meta_key = 'enclosure' ";
1100
  // Add the groupby needed for enclosures only
1101
  function powerpress_posts_groupby($groupby)
1102
  {
1103
+ if( is_category() )
1104
+ return $groupby;
1105
+
1106
  if( is_feed() && (powerpress_is_custom_podcast_feed() || get_query_var('feed') == 'podcast' ) )
1107
  {
1108
  global $wpdb;
1269
  $html = str_replace('<li>', '<li>* ', $html);
1270
 
1271
  // Now do all the other regular conversions...
1272
+ $html = strip_shortcodes( $html );
 
1273
  $html = str_replace(']]>', ']]&gt;', $html);
1274
  $content_no_html = strip_tags($html);
1275
 
1276
+ return powerpress_format_itunes_value($content_no_html, 'summary');
1277
  }
1278
 
1279
  function powerpress_itunes_categories($PrefixSubCategories = false)
1385
  return WP_PLUGIN_URL . '/'. $powerpress_dirname .'/';
1386
  }
1387
 
1388
+ function powerpress_format_itunes_value($value, $tag = 255, $remove_new_lines = false)
1389
  {
 
 
 
1390
  if( DB_CHARSET != 'utf8' ) // Check if the string is UTF-8
1391
  $value = utf8_encode($value); // If it is not, convert to UTF-8 then decode it...
1392
+
1393
+ // Code added to solve issue with KimiliFlashEmbed plugin and also remove the shortcode for the WP Audio Player
1394
+ // 99.9% of the time this code will not be necessary
1395
+ $value = preg_replace("/\[(kml_(flash|swf)embed|audio\:)\b(.*?)(?:(\/))?(\]|$)/isu", '', $value);
1396
+
1397
  if(version_compare("5", phpversion(), ">"))
1398
+ $value = preg_replace( '/&nbsp;/ui' , ' ', $value); // Best we can do for PHP4
1399
  else
1400
  $value = @html_entity_decode($value, ENT_COMPAT, 'UTF-8'); // Remove any additional entities such as &nbsp;
1401
+ $value = preg_replace( '/&amp;/ui' , '&', $value); // Best we can do for PHP4. precaution in case it didn't get removed from function above.
1402
 
1403
+ if( $remove_new_lines )
1404
+ $value = preg_replace( array("/\r\n\r\n/u", "/\n/u", "/\r/u", "/\t/u") , array(' - ',' ', '', ' '), $value);
1405
+
1406
+ return wp_specialchars( powerpress_trim_itunes_value($value, $tag) );
1407
+ }
1408
+
1409
+ function powerpress_trim_itunes_value($value, $tag = 'summary')
1410
+ {
1411
+ $length = (function_exists('mb_strlen')?mb_strlen($value):strlen($value) );
1412
+ $trim_at = false;
1413
+ switch($tag)
1414
+ {
1415
+ case 'summary': {
1416
+ // 4000 character limit
1417
+ if( $length > 4000 )
1418
+ $trim_at = 4000;
1419
+ }; break;
1420
+ case 'subtitle':
1421
+ case 'keywords':
1422
+ case 'author':
1423
+ case 'name':
1424
+ default: {
1425
+ // 255 character limit
1426
+ if( $length > 255 )
1427
+ $trim_at = 255;
1428
+ };
1429
+ }
1430
+
1431
+ if( $trim_at )
1432
+ {
1433
+ // Start trimming
1434
+ $value = (function_exists('mb_substr')?mb_substr($value, 0, $trim_at):substr($value, 0, $trim_at) );
1435
+ $clean_break = false;
1436
+ if( preg_match('/(.*[,\n.\?!])[^,\n.\?!]/isu', $value, $matches) ) // pattern modifiers: case (i)nsensitive, entire (s)tring and (u)nicode
1437
+ {
1438
+ if( isset( $matches[1]) )
1439
+ {
1440
+ $detected_eof_pos = (function_exists('mb_strlen')?mb_strlen($matches[1]):strlen($matches[1]) );
1441
+ // Look back at most 50 characters...
1442
+ if( $detected_eof_pos > 3950 || ($detected_eof_pos > 205 && $detected_eof_pos < 255 ) )
1443
+ {
1444
+ $value = $matches[1];
1445
+ $clean_break = true;
1446
+ }
1447
+ // Otherwise we want to continue with the same value we started with...
1448
+ }
1449
+ }
1450
+
1451
+ if( $clean_break == false && $tag = 'subtitle' ) // Subtitle we want to add a ... at the end
1452
+ $value = (function_exists('mb_substr')?mb_substr($value, 0, 252):substr($value, 0, 252) ). '...';
1453
+ }
1454
+
1455
+ return $value;
1456
  }
1457
 
1458
  function powerpress_smart_trim($value, $char_limit = 250, $remove_new_lines = false)
1539
  return $ppsize;
1540
  }
1541
 
1542
+ // Merges settings from feed settings page to empty custom feed settings
1543
  function powerpress_merge_empty_feed_settings($CustomFeedSettings, $FeedSettings)
1544
  {
1545
+ // Remove settings from main $FeedSettings that should not be copied to custom feed.
1546
+ unset($FeedSettings['itunes_new_feed_url']);
1547
+ unset($FeedSettings['apply_to']);
1548
+ unset($FeedSettings['feed_redirect_url']);
1549
+
1550
+ if( !$CustomFeedSettings )
1551
+ return $FeedSettings; // If the $CustomFeedSettings is false
1552
+
1553
  while( list($key,$value) = each($CustomFeedSettings) )
1554
  {
1555
+ if( $value !== '' || !isset($FeedSettings[$key]) )
1556
+ $FeedSettings[$key] = $value;
1557
  }
1558
 
1559
+ return $FeedSettings;
1560
  }
1561
 
1562
  function powerpress_readable_duration($duration, $include_hour=false)
powerpressadmin-basic.php CHANGED
@@ -214,6 +214,30 @@ while( list($value,$desc) = each($options) )
214
  ?>
215
  </div>
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  <h2><?php _e("Media Statistics"); ?></h2>
219
  <p>
@@ -269,7 +293,11 @@ Enter your Redirect URL issued by your media statistics service provider below.
269
  </tr>
270
  </table>
271
  </div>
272
-
 
 
 
 
273
  <input type="hidden" id="hide_free_stats" name="General[hide_free_stats]" value="<?php echo $General['hide_free_stats']; ?>" />
274
 
275
  <div id="blubrry_stats_box" style="<?php if( $General['hide_free_stats'] == 1 ) echo 'display:none;'; ?>">
214
  ?>
215
  </div>
216
 
217
+ <?php
218
+
219
+ $ModeDesc = 'None';
220
+ if( $General['blubrry_auth'] )
221
+ $ModeDesc = 'Media Statistics Only';
222
+ if( $General['blubrry_hosting'] )
223
+ $ModeDesc = 'Media Statistics and Hosting';
224
+
225
+ ?>
226
+ <h2><?php _e("Blubrry Services Integration"); ?></h2>
227
+ <p>
228
+ Adds <a href="http://www.blubrry.com/podcast_statistics/" title="Blubrry Media Statistics" target="_blank">Blubrry Media Statistics</a> to your blog's <a href="<?php echo admin_url(); ?>" title="WordPress Dashboard">dashboard</a> plus
229
+ features for <a href="https://secure.blubrry.com/podcast-publishing-premium-with-hosting/" title="Blubrry Media Hosting" target="_blank">Blubrry Media Hosting</a> users to quickly select and publish uploaded media.
230
+ </p>
231
+ <table class="form-table">
232
+ <tr valign="top">
233
+ <th scope="row">
234
+ <?php _e("Blubrry Services"); ?>
235
+ </th>
236
+ <td>
237
+ <p style="margin-top: 5px;"><span id="service_mode"><?php echo $ModeDesc; ?></span> (<strong><a href="<?php echo admin_url(); ?>?action=powerpress-jquery-account&KeepThis=true&TB_iframe=true&width=500&height=400&modal=true" target="_blank" class="thickbox" style="color: #3D517E;" title="Blubrry Services Integration">Click here to configure Blubrry Services</a></strong>)</p>
238
+ </td>
239
+ </tr>
240
+ </table>
241
 
242
  <h2><?php _e("Media Statistics"); ?></h2>
243
  <p>
293
  </tr>
294
  </table>
295
  </div>
296
+ <style type="text/css">
297
+ #TB_window {
298
+ border: solid 1px #3D517E;
299
+ }
300
+ </style>
301
  <input type="hidden" id="hide_free_stats" name="General[hide_free_stats]" value="<?php echo $General['hide_free_stats']; ?>" />
302
 
303
  <div id="blubrry_stats_box" style="<?php if( $General['hide_free_stats'] == 1 ) echo 'display:none;'; ?>">
powerpressadmin-categoryfeeds.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ function powerpress_admin_customfeeds_columns($data=array())
5
+ {
6
+ $data['name'] = 'Category Name';
7
+ $data['feed-slug'] = 'Slug';
8
+ //$data['episode-count'] = 'Episodes';
9
+ $data['url'] = 'Feed URL';
10
+ return $data;
11
+ }
12
+
13
+ add_filter('manage_powerpressadmin_categoryfeeds_columns', 'powerpress_admin_customfeeds_columns');
14
+
15
+ function powerpress_admin_categoryfeeds()
16
+ {
17
+ $General = powerpress_get_settings('powerpress_general');
18
+
19
+
20
+ ?>
21
+ <h2><?php echo __("Category Podcast Feeds"); ?></h2>
22
+ <p>
23
+ Category podcast feeds add custom podcast settings to specific blog category feeds.
24
+ Category podcast feeds allow you to organize episodes by topic.
25
+ </p>
26
+ <p>
27
+ If you are looking to organize episodes by file or format, please use <a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php'); ?>" title="Custom Podcast Feeds">Custom Podcast Feeds</a>.
28
+ </p>
29
+
30
+ <style type="text/css">
31
+
32
+ .column-url {
33
+ width: 40%;
34
+ }
35
+ .column-name {
36
+ width: 30%;
37
+ }
38
+ .column-feed-slug {
39
+ width: 15%;
40
+ }
41
+ .column-episode-count {
42
+ width: 15%;
43
+ }
44
+ </style>
45
+ <div id="col-container">
46
+
47
+ <div id="col-right">
48
+ <table class="widefat fixed" cellspacing="0">
49
+ <thead>
50
+ <tr>
51
+ <?php print_column_headers('powerpressadmin_categoryfeeds'); ?>
52
+ </tr>
53
+ </thead>
54
+
55
+ <tfoot>
56
+ <tr>
57
+ <?php print_column_headers('powerpressadmin_categoryfeeds', false); ?>
58
+ </tr>
59
+ </tfoot>
60
+ <tbody>
61
+ <?php
62
+
63
+
64
+ $Feeds = array();
65
+ if( isset($General['custom_cat_feeds']) )
66
+ $Feeds = $General['custom_cat_feeds'];
67
+
68
+ $count = 0;
69
+ while( list($null, $cat_ID) = each($Feeds) )
70
+ {
71
+ $category = get_category_to_edit($cat_ID);
72
+
73
+
74
+ $columns = powerpress_admin_customfeeds_columns();
75
+ $hidden = array();
76
+ if( $feed_slug == 'podcast' )
77
+ $feed_title = 'Podcast Feed (default)';
78
+ $feed_title = wp_specialchars($feed_title);
79
+ if( $count % 2 == 0 )
80
+ echo '<tr valign="middle" class="alternate">';
81
+ else
82
+ echo '<tr valign="middle">';
83
+
84
+ $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php&amp;action=powerpress-editcategoryfeed&amp;cat=') . $cat_ID;
85
+
86
+ $feed_title = $category->name;
87
+ $url = get_category_feed_link($cat_ID);
88
+ $short_url = str_replace('http://', '', $url);
89
+ $short_url = str_replace('www.', '', $short_url);
90
+ if (strlen($short_url) > 35)
91
+ $short_url = substr($short_url, 0, 32).'...';
92
+
93
+ foreach($columns as $column_name=>$column_display_name) {
94
+ $class = "class=\"column-$column_name\"";
95
+
96
+
97
+
98
+ //$short_url = '';
99
+
100
+ switch($column_name) {
101
+ case 'feed-slug': {
102
+
103
+ echo "<td $class>{$category->slug}";
104
+ echo "</td>";
105
+
106
+ }; break;
107
+ case 'name': {
108
+
109
+ echo '<td '.$class.'><strong><a class="row-title" href="'.$edit_link.'" title="' . attribute_escape(sprintf(__('Edit "%s"'), $feed_title)) . '">'.$feed_title.'</a></strong><br />';
110
+ $actions = array();
111
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
112
+ $actions['remove'] = "<a class='submitdelete' href='". admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_categoryfeeds.php&amp;action=powerpress-delete-category-feed&amp;cat=$cat_ID", 'powerpress-delete-category-feed-' . $cat_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to remove podcast settings for category feed '%s'\n 'Cancel' to stop, 'OK' to delete."), $feed_title )) . "') ) { return true;}return false;\">" . __('Remove') . "</a>";
113
+ $action_count = count($actions);
114
+ $i = 0;
115
+ echo '<div class="row-actions">';
116
+ foreach ( $actions as $action => $linkaction ) {
117
+ ++$i;
118
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
119
+ echo '<span class="'.$action.'">'.$linkaction.$sep .'</span>';
120
+ }
121
+ echo '</div>';
122
+ echo '</td>';
123
+
124
+ }; break;
125
+
126
+ case 'url': {
127
+
128
+ echo "<td $class><a href='$url' title='". attribute_escape(sprintf(__('Visit %s'), $feed_title))."' target=\"_blank\">$short_url</a>";
129
+ echo '<div class="row-actions">';
130
+ echo '<span class="'.$action .'"><a href="http://www.feedvalidator.org/check.cgi?url='. urlencode($url) .'" target="_blank">' . __('Validate Feed') . '</a></span>';
131
+ echo '</div>';
132
+ echo "</td>";
133
+
134
+ }; break;
135
+
136
+ case 'episode-count': {
137
+
138
+ echo "<td $class>$episode_total";
139
+ echo "</td>";
140
+
141
+ }; break;
142
+ default: {
143
+
144
+ }; break;
145
+ }
146
+ }
147
+ echo "\n </tr>\n";
148
+ $count++;
149
+ }
150
+ ?>
151
+ </tbody>
152
+ </table>
153
+ </div> <!-- col-right -->
154
+
155
+ <div id="col-left">
156
+ <div class="col-wrap">
157
+ <div class="form-wrap">
158
+ <h3><?php _e('Add Podcast Settings to existing Category Feed'); ?></h3>
159
+ <input type="hidden" name="action" value="powerpress-addcategoryfeed" />
160
+ <?php
161
+ //wp_original_referer_field(true, 'previous');
162
+ wp_nonce_field('powerpress-add-category-feed');
163
+ ?>
164
+
165
+ <div class="form-field form-required">
166
+ <label for="feed_name"><?php _e('Category') ?></label>
167
+ <select name="cat" id="cat_id" style="width: 100%;">
168
+ <option value="">Select Category</option>
169
+ <?php
170
+ wp_dropdown_cats();
171
+ ?>
172
+ </select>
173
+
174
+ </div>
175
+
176
+ <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Podcast Settings to Category Feed'); ?>" /></p>
177
+
178
+ </div>
179
+ </div>
180
+
181
+ </div> <!-- col-left -->
182
+
183
+ </div> <!-- col-container -->
184
+
185
+ <h3>Example Usage</h3>
186
+ <p>
187
+ Example 1: You have a podcast that covers two topics that sometimes share same posts and sometimes do not. Use your main podcast feed as a combined feed of both topics
188
+ and use category feeds to distribute topic specific episodes.
189
+ </p>
190
+ <p>
191
+ Example 2: You want to use categories to keep episodes separate from each other. Each category can be used to distribute separate podcasts with the main podcast feed
192
+ combining all categories to provide a network feed.
193
+ </p>
194
+
195
+ <?php
196
+ }
197
+ ?>
powerpressadmin-customfeeds.php CHANGED
@@ -19,10 +19,13 @@ function powerpress_admin_customfeeds()
19
 
20
  ?>
21
  <h2><?php echo __("Custom Podcast Feeds"); ?></h2>
22
- <p style="">
23
  Custom podcast feeds allow you to associate multiple media files and/or formats to one blog post. Note that additional custom feeds
24
  will not appear in the online player or in download links.
25
  </p>
 
 
 
26
 
27
  <style type="text/css">
28
 
19
 
20
  ?>
21
  <h2><?php echo __("Custom Podcast Feeds"); ?></h2>
22
+ <p>
23
  Custom podcast feeds allow you to associate multiple media files and/or formats to one blog post. Note that additional custom feeds
24
  will not appear in the online player or in download links.
25
  </p>
26
+ <p>
27
+ If you are looking to organize episodes by topic, please use <a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php'); ?>" title="Category Podcast Feeds">Category Podcast Feeds</a>.
28
+ </p>
29
 
30
  <style type="text/css">
31
 
powerpressadmin-dashboard.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function powerpress_dashboard_head()
4
+ {
5
+ ?>
6
+ <style type="text/css">
7
+ #blubrry_stats_summary {
8
+
9
+ }
10
+ #blubrry_stats_summary label {
11
+ width: 40%;
12
+ max-width: 150px;
13
+ float: left;
14
+ }
15
+ #blubrry_stats_summary h2 {
16
+ font-size: 14px;
17
+ margin: 0;
18
+ padding: 0;
19
+ }
20
+ .blubrry_stats_ul {
21
+ padding-left: 20px;
22
+ margin-top: 5px;
23
+ margin-bottom: 10px;
24
+ }
25
+ .blubrry_stats_ul li {
26
+ list-style-type: none;
27
+ margin: 0px;
28
+ padding: 0px;
29
+ }
30
+ #blubrry_stats_media {
31
+ display: none;
32
+ }
33
+ #blubrry_stats_media_show {
34
+ text-align: right;
35
+ font-size: 85%;
36
+ }
37
+ #blubrry_stats_media h4 {
38
+ margin-bottom: 10px;
39
+ }
40
+ .blubrry_stats_title {
41
+ margin-left: 10px;
42
+ }
43
+ .blubrry_stats_updated {
44
+ font-size: 80%;
45
+ }
46
+ </style>
47
+ <?php
48
+ }
49
+
50
+ function powerpress_dashboard_stats_content()
51
+ {
52
+ $content = false;
53
+ $StatsCached = get_option('powerpress_stats');
54
+ if( $StatsCached && $StatsCached['updated'] > (time()-(60*60*3)) )
55
+ $content = $StatsCached['content'];
56
+
57
+ if( !$content )
58
+ {
59
+ $Settings = get_option('powerpress_general');
60
+ $UserPass = $Settings['blubrry_auth'];
61
+ $Keyword = $Settings['blubrry_program_keyword'];
62
+
63
+ if( !$UserPass )
64
+ {
65
+ $content = '<p>Wait a sec! This feature is only available to Blubrry Podcast Community members. Join our community to get free podcast statistics and access to other valuable <a href="http://www.blubrry.com/powerpress_services/" target="_blank">services</a>.</p>
66
+ <p>Our <a href="http://www.blubrry.com/powerpress_services/" target="_blank">podcast-hosting</a> integrated PowerPress makes podcast publishing simple. Check out the <a href="http://www.blubrry.com/powerpress_services/" target="_blank">video</a> on our exciting three-step publishing system!</p>';
67
+ }
68
+ else
69
+ {
70
+ $api_url = sprintf('%s/stats/%s/summary.html?nobody=1', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Keyword);
71
+
72
+ $content = powerpress_remote_fopen($api_url, $UserPass);
73
+ if( $content )
74
+ update_option('powerpress_stats', array('updated'=>time(), 'content'=>$content) );
75
+ else
76
+ $content = 'Error: An error occurred authenticating user.';
77
+ }
78
+ }
79
+ ?>
80
+ <div id="">
81
+ <?php
82
+ //$content = http_get('http://api.blubrry.local/stats/compiled_weekly2/summary.html?year=2008&month=7', 'amandato@gmail.com', 'testit');
83
+
84
+ //$decoded = my_json_decode($content['data'], true);
85
+ //print_r( $content );
86
+ echo $content;
87
+ //echo 'Podcast Statistics go here.';
88
+
89
+ if( $UserPass )
90
+ {
91
+ ?>
92
+ <div id="blubrry_stats_media_show">
93
+ <a href="<?php echo admin_url(); ?>?action=powerpress-jquery-stats&KeepThis=true&TB_iframe=true" title="Blubrry Media statistics" class="thickbox">more</a>
94
+ </div>
95
+ <?php } ?>
96
+ </div>
97
+ <?php
98
+ }
99
+
100
+
101
+ function powerpress_dashboard_setup()
102
+ {
103
+ $Settings = get_option('powerpress_general');
104
+ $Settings['blubrry_stats'] = true;
105
+ if( $Settings && $Settings['blubrry_stats'] == true )
106
+ {
107
+ wp_add_dashboard_widget( 'powerpress_dashboard_stats', __( 'Blubrry Podcast Statistics' ), 'powerpress_dashboard_stats_content' );
108
+ }
109
+ }
110
+
111
+ add_action('admin_head-index.php', 'powerpress_dashboard_head');
112
+ add_action('wp_dashboard_setup', 'powerpress_dashboard_setup');
113
+
114
+ ?>
powerpressadmin-editfeed.php CHANGED
@@ -1,6 +1,109 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  // powerpressadmin_editfeed.php
3
- function powerpress_admin_editfeed($feed_slug=false)
4
  {
5
  $UploadArray = wp_upload_dir();
6
  $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
@@ -23,6 +126,11 @@ function powerpress_admin_editfeed($feed_slug=false)
23
  }
24
  $FeedSettings = powerpress_default_settings($FeedSettings, 'editfeed_custom');
25
  }
 
 
 
 
 
26
  else
27
  {
28
  $FeedSettings = powerpress_get_settings('powerpress_feed');
@@ -35,6 +143,13 @@ function powerpress_admin_editfeed($feed_slug=false)
35
  $FeedTitle = sprintf( '%s: %s', $FeedTitle, $General['custom_feeds'][$feed_slug]) ;
36
  echo sprintf('<input type="hidden" name="feed_slug" value="%s" />', $feed_slug);
37
  }
 
 
 
 
 
 
 
38
  $AdvancedMode = $General['advanced_mode'];
39
  ?>
40
  <h2><?php echo $FeedTitle; ?></h2>
@@ -43,6 +158,11 @@ function powerpress_admin_editfeed($feed_slug=false)
43
  <p style="margin-bottom: 0;">
44
  <?php _e('Configure your custom podcast feed.'); ?>
45
  </p>
 
 
 
 
 
46
  <?php } else { ?>
47
  <input type="hidden" name="action" value="powerpress-save-feedsettings" />
48
  <p style="margin-bottom: 0;">
@@ -50,7 +170,7 @@ function powerpress_admin_editfeed($feed_slug=false)
50
  </p>
51
  <?php } ?>
52
  <table class="form-table">
53
- <?php if( !$feed_slug ) { ?>
54
  <?php if( $AdvancedMode ) { ?>
55
  <tr valign="top">
56
  <th scope="row">
@@ -101,11 +221,38 @@ while( list($value,$desc) = each($applyoptions) )
101
  <tr valign="top">
102
  <th scope="row">
103
 
104
- <?php _e("Important Feeds"); ?></th>
105
  <td>
106
- <p style="margin-top: 5px;">Main RSS2 Feed: <a href="<?php echo get_bloginfo('rss2_url'); ?>" title="Main RSS 2 Feed" target="_blank"><?php echo get_bloginfo('rss2_url'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_bloginfo('rss2_url')); ?>" title="Validate Feed" target="_blank">validate</a></p>
107
- <p>Special Podcast only Feed: <a href="<?php echo get_feed_link('podcast'); ?>" title="Podcast Feed" target="_blank"><?php echo get_feed_link('podcast'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link('podcast')); ?>" title="Validate Feed" target="_blank">validate</a></p>
 
 
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </td>
110
  </tr>
111
  <?php } else { // Else if( $feed_slug) ?>
@@ -115,16 +262,26 @@ while( list($value,$desc) = each($applyoptions) )
115
  <?php _e("Feed URL"); ?> <br />
116
  </th>
117
  <td>
 
 
 
118
  <p style="margin-top: 0;"><a href="<?php echo get_feed_link($feed_slug); ?>" target="_blank"><?php echo get_feed_link($feed_slug); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link($feed_slug)); ?>" target="_blank"><?php _e('validate'); ?></a></p>
 
119
  </td>
120
  </tr>
121
 
 
122
  <tr valign="top">
123
  <th scope="row">
124
  <?php _e("Feed Title"); ?>
125
  </th>
126
  <td>
127
- <input type="text" name="Feed[title]"style="width: 60%;" value="<?php echo $FeedSettings['title']; ?>" maxlength="250" /> (leave blank to use blog title)
 
 
 
 
 
128
  </td>
129
  </tr>
130
  <tr valign="top">
@@ -132,7 +289,12 @@ while( list($value,$desc) = each($applyoptions) )
132
  <?php _e("Feed Description"); ?>
133
  </th>
134
  <td>
135
- <input type="text" name="Feed[description]"style="width: 60%;" value="<?php echo $FeedSettings['description']; ?>" maxlength="1000" /> (leave blank to use blog description)
 
 
 
 
 
136
  </td>
137
  </tr>
138
 
@@ -142,18 +304,14 @@ while( list($value,$desc) = each($applyoptions) )
142
  </th>
143
  <td>
144
  <input type="text" name="Feed[url]"style="width: 60%;" value="<?php echo $FeedSettings['url']; ?>" maxlength="250" /> (optional)
 
145
  <p>e.g. <?php echo get_bloginfo('home'); ?>/custom-page/</p>
 
 
 
146
  </td>
147
  </tr>
148
 
149
- <tr valign="top">
150
- <th scope="row">
151
- <?php _e("Show the most recent"); ?>
152
- </th>
153
- <td>
154
- <input type="text" name="Feed[posts_per_rss]"style="width: 50px;" value="<?php echo $FeedSettings['posts_per_rss']; ?>" maxlength="5" /> episodes (leave blank to use blog default: <?php form_option('posts_per_rss'); ?>)
155
- </td>
156
- </tr>
157
 
158
  <tr valign="top">
159
  <th scope="row">
@@ -162,8 +320,12 @@ while( list($value,$desc) = each($applyoptions) )
162
  <td>
163
  <input type="text" name="Feed[feed_redirect_url]"style="width: 60%;" value="<?php echo $FeedSettings['feed_redirect_url']; ?>" maxlength="100" /> (leave blank to use current feed)
164
  <p>Use this option to redirect this feed to a hosted feed service such as <a href="http://www.feedburner.com/" target="_blank">FeedBurner</a>.</p>
165
- <?php
166
- $link = get_feed_link($feed_slug);
 
 
 
 
167
  if( strstr($link, '?') )
168
  $link .= "&redirect=no";
169
  else
@@ -175,6 +337,18 @@ else
175
 
176
  <?php } // End $feed_slug ?>
177
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  <?php if( $AdvancedMode ) { ?>
179
  <tr valign="top">
180
  <th scope="row" >
@@ -212,7 +386,10 @@ else
212
  <p style="margin-top: 5px;">Your summary may not contain HTML and cannot exceed 4,000 characters in length.</p>
213
 
214
  <textarea name="Feed[itunes_summary]" rows="5" style="width:80%;" ><?php echo $FeedSettings['itunes_summary']; ?></textarea>
215
- <div><input type="checkbox" name="Feed[enhance_itunes_summary]" value="1" <?php echo ($FeedSettings['enhance_itunes_summary']?'checked ':''); ?>/> Enhance iTunes Summary from Blog Posts (<a href="http://help.blubrry.com/blubrry-powerpress/settings/enhanced-itunes-summary/" target="_blank">What's this</a>)</div>
 
 
 
216
  </td>
217
  </tr>
218
 
@@ -361,6 +538,35 @@ while( list($value,$desc) = each($explicit) )
361
  </tr>
362
 
363
  <?php if( $AdvancedMode ) { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  <tr valign="top">
365
  <th scope="row">
366
  <?php _e("Talent Name"); ?> <br />
1
  <?php
2
+
3
+ function powerpress_languages()
4
+ {
5
+ // List copied from PodPress:
6
+ $langs = array();
7
+ $langs['af'] = 'Afrikaans';
8
+ $langs['sq'] = 'Albanian';
9
+ $langs['eu'] = 'Basque';
10
+ $langs['be'] = 'Belarusian';
11
+ $langs['bg'] = 'Bulgarian';
12
+ $langs['ca'] = 'Catalan';
13
+ $langs['zh-cn'] = 'Chinese (Simplified)';
14
+ $langs['zh-tw'] = 'Chinese (Traditional)';
15
+ $langs['hr'] = 'Croatian';
16
+ $langs['cs'] = 'Czech';
17
+ $langs['da'] = 'Danish';
18
+ $langs['nl'] = 'Dutch';
19
+ $langs['nl-be'] = 'Dutch (Belgium)';
20
+ $langs['nl-nl'] = 'Dutch (Netherlands)';
21
+ $langs['en'] = 'English';
22
+ $langs['en-au'] = 'English (Australia)';
23
+ $langs['en-bz'] = 'English (Belize)';
24
+ $langs['en-ca'] = 'English (Canada)';
25
+ $langs['en-ie'] = 'English (Ireland)';
26
+ $langs['en-jm'] = 'English (Jamaica)';
27
+ $langs['en-nz'] = 'English (New Zealand)';
28
+ $langs['en-ph'] = 'English (Phillipines)';
29
+ $langs['en-za'] = 'English (South Africa)';
30
+ $langs['en-tt'] = 'English (Trinidad)';
31
+ $langs['en-gb'] = 'English (United Kingdom)';
32
+ $langs['en-us'] = 'English (United States)';
33
+ $langs['en-zw'] = 'English (Zimbabwe)';
34
+ $langs['et'] = 'Estonian';
35
+ $langs['fo'] = 'Faeroese';
36
+ $langs['fi'] = 'Finnish';
37
+ $langs['fr'] = 'French';
38
+ $langs['fr-be'] = 'French (Belgium)';
39
+ $langs['fr-ca'] = 'French (Canada)';
40
+ $langs['fr-fr'] = 'French (France)';
41
+ $langs['fr-lu'] = 'French (Luxembourg)';
42
+ $langs['fr-mc'] = 'French (Monaco)';
43
+ $langs['fr-ch'] = 'French (Switzerland)';
44
+ $langs['gl'] = 'Galician';
45
+ $langs['gd'] = 'Gaelic';
46
+ $langs['de'] = 'German';
47
+ $langs['de-at'] = 'German (Austria)';
48
+ $langs['de-de'] = 'German (Germany)';
49
+ $langs['de-li'] = 'German (Liechtenstein)';
50
+ $langs['de-lu'] = 'German (Luxembourg)';
51
+ $langs['de-ch'] = 'German (Switzerland)';
52
+ $langs['el'] = 'Greek';
53
+ $langs['haw'] = 'Hawaiian';
54
+ $langs['hu'] = 'Hungarian';
55
+ $langs['is'] = 'Icelandic';
56
+ $langs['in'] = 'Indonesian';
57
+ $langs['ga'] = 'Irish';
58
+ $langs['it'] = 'Italian';
59
+ $langs['it-it'] = 'Italian (Italy)';
60
+ $langs['it-ch'] = 'Italian (Switzerland)';
61
+ $langs['ja'] = 'Japanese';
62
+ $langs['ko'] = 'Korean';
63
+ $langs['mk'] = 'Macedonian';
64
+ $langs['no'] = 'Norwegian';
65
+ $langs['pl'] = 'Polish';
66
+ $langs['pt'] = 'Portuguese';
67
+ $langs['pt-br'] = 'Portuguese (Brazil)';
68
+ $langs['pt-pt'] = 'Portuguese (Portugal)';
69
+ $langs['ro'] = 'Romanian';
70
+ $langs['ro-mo'] = 'Romanian (Moldova)';
71
+ $langs['ro-ro'] = 'Romanian (Romania)';
72
+ $langs['ru'] = 'Russian';
73
+ $langs['ru-mo'] = 'Russian (Moldova)';
74
+ $langs['ru-ru'] = 'Russian (Russia)';
75
+ $langs['sr'] = 'Serbian';
76
+ $langs['sk'] = 'Slovak';
77
+ $langs['sl'] = 'Slovenian';
78
+ $langs['es'] = 'Spanish';
79
+ $langs['es-ar'] = 'Spanish (Argentina)';
80
+ $langs['es-bo'] = 'Spanish (Bolivia)';
81
+ $langs['es-cl'] = 'Spanish (Chile)';
82
+ $langs['es-co'] = 'Spanish (Colombia)';
83
+ $langs['es-cr'] = 'Spanish (Costa Rica)';
84
+ $langs['es-do'] = 'Spanish (Dominican Republic)';
85
+ $langs['es-ec'] = 'Spanish (Ecuador)';
86
+ $langs['es-sv'] = 'Spanish (El Salvador)';
87
+ $langs['es-gt'] = 'Spanish (Guatemala)';
88
+ $langs['es-hn'] = 'Spanish (Honduras)';
89
+ $langs['es-mx'] = 'Spanish (Mexico)';
90
+ $langs['es-ni'] = 'Spanish (Nicaragua)';
91
+ $langs['es-pa'] = 'Spanish (Panama)';
92
+ $langs['es-py'] = 'Spanish (Paraguay)';
93
+ $langs['es-pe'] = 'Spanish (Peru)';
94
+ $langs['es-pr'] = 'Spanish (Puerto Rico)';
95
+ $langs['es-es'] = 'Spanish (Spain)';
96
+ $langs['es-uy'] = 'Spanish (Uruguay)';
97
+ $langs['es-ve'] = 'Spanish (Venezuela)';
98
+ $langs['sv'] = 'Swedish';
99
+ $langs['sv-fi'] = 'Swedish (Finland)';
100
+ $langs['sv-se'] = 'Swedish (Sweden)';
101
+ $langs['tr'] = 'Turkish';
102
+ $langs['uk'] = 'Ukranian';
103
+ return $langs;
104
+ }
105
  // powerpressadmin_editfeed.php
106
+ function powerpress_admin_editfeed($feed_slug=false, $cat_ID =false)
107
  {
108
  $UploadArray = wp_upload_dir();
109
  $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
126
  }
127
  $FeedSettings = powerpress_default_settings($FeedSettings, 'editfeed_custom');
128
  }
129
+ else if( $cat_ID )
130
+ {
131
+ $FeedSettings = powerpress_get_settings('powerpress_cat_feed_'.$cat_ID);
132
+ $FeedSettings = powerpress_default_settings($FeedSettings, 'editfeed_custom');
133
+ }
134
  else
135
  {
136
  $FeedSettings = powerpress_get_settings('powerpress_feed');
143
  $FeedTitle = sprintf( '%s: %s', $FeedTitle, $General['custom_feeds'][$feed_slug]) ;
144
  echo sprintf('<input type="hidden" name="feed_slug" value="%s" />', $feed_slug);
145
  }
146
+ else if( $cat_ID )
147
+ {
148
+ $category = get_category_to_edit($cat_ID);
149
+ $FeedTitle = sprintf( 'Category %s: %s', $FeedTitle, $category->name) ;
150
+ echo sprintf('<input type="hidden" name="cat" value="%s" />', $cat_ID);
151
+ }
152
+
153
  $AdvancedMode = $General['advanced_mode'];
154
  ?>
155
  <h2><?php echo $FeedTitle; ?></h2>
158
  <p style="margin-bottom: 0;">
159
  <?php _e('Configure your custom podcast feed.'); ?>
160
  </p>
161
+ <?php } else if( $cat_ID ) { ?>
162
+ <input type="hidden" name="action" value="powerpress-save-categoryfeedsettings" />
163
+ <p style="margin-bottom: 0;">
164
+ <?php _e('Configure your category feed to support podcasting.'); ?>
165
+ </p>
166
  <?php } else { ?>
167
  <input type="hidden" name="action" value="powerpress-save-feedsettings" />
168
  <p style="margin-bottom: 0;">
170
  </p>
171
  <?php } ?>
172
  <table class="form-table">
173
+ <?php if( !$feed_slug && !$cat_ID ) { ?>
174
  <?php if( $AdvancedMode ) { ?>
175
  <tr valign="top">
176
  <th scope="row">
221
  <tr valign="top">
222
  <th scope="row">
223
 
224
+ <?php _e("Main Site Feed"); ?></th>
225
  <td>
226
+ <p style="margin-top: 5px; margin-bottom: 0;">Main RSS2 Feed: <a href="<?php echo get_bloginfo('rss2_url'); ?>" title="Main RSS 2 Feed" target="_blank"><?php echo get_bloginfo('rss2_url'); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_bloginfo('rss2_url')); ?>" title="Validate Feed" target="_blank">validate</a></p>
227
+ </td>
228
+ </tr>
229
+
230
 
231
+ <tr valign="top">
232
+ <th scope="row">
233
+
234
+ <?php _e("Custom Podcast Feeds"); ?></th>
235
+ <td>
236
+ <?php
237
+
238
+ $General = get_option('powerpress_general');
239
+ $Feeds = array('podcast'=>'Special Podcast only Feed');
240
+ if( isset($General['custom_feeds']['podcast']) )
241
+ $Feeds = $General['custom_feeds'];
242
+ else if( is_array($General['custom_feeds']) )
243
+ $Feeds += $General['custom_feeds'];
244
+
245
+ while( list($feed_slug, $feed_title) = each($Feeds) )
246
+ {
247
+ $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-editfeed&amp;feed_slug=') . $feed_slug;
248
+ ?>
249
+ <p><?php echo $feed_title; ?>: <a href="<?php echo get_feed_link($feed_slug); ?>" title="<?php echo $feed_title; ?>" target="_blank"><?php echo get_feed_link($feed_slug); ?></a>
250
+ | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link($feed_slug)); ?>" title="Validate Feed" target="_blank">validate</a>
251
+ <?php if( $AdvancedMode ) { ?>
252
+ | <a href="<?php echo $edit_link; ?>" title="Edit Feed">edit</a>
253
+ <?php } ?>
254
+ </p>
255
+ <?php } ?>
256
  </td>
257
  </tr>
258
  <?php } else { // Else if( $feed_slug) ?>
262
  <?php _e("Feed URL"); ?> <br />
263
  </th>
264
  <td>
265
+ <?php if( $cat_ID ) { ?>
266
+ <p style="margin-top: 0;"><a href="<?php echo get_category_feed_link($cat_ID); ?>" target="_blank"><?php echo get_category_feed_link($cat_ID); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_category_feed_link($cat_ID)); ?>" target="_blank"><?php _e('validate'); ?></a></p>
267
+ <?php } else { ?>
268
  <p style="margin-top: 0;"><a href="<?php echo get_feed_link($feed_slug); ?>" target="_blank"><?php echo get_feed_link($feed_slug); ?></a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(get_feed_link($feed_slug)); ?>" target="_blank"><?php _e('validate'); ?></a></p>
269
+ <?php } ?>
270
  </td>
271
  </tr>
272
 
273
+
274
  <tr valign="top">
275
  <th scope="row">
276
  <?php _e("Feed Title"); ?>
277
  </th>
278
  <td>
279
+ <input type="text" name="Feed[title]"style="width: 60%;" value="<?php echo $FeedSettings['title']; ?>" maxlength="250" />
280
+ <?php if( $cat_ID ) { ?>
281
+ (leave blank to use category title)
282
+ <?php } else { ?>
283
+ (leave blank to use blog title)
284
+ <?php } ?>
285
  </td>
286
  </tr>
287
  <tr valign="top">
289
  <?php _e("Feed Description"); ?>
290
  </th>
291
  <td>
292
+ <input type="text" name="Feed[description]"style="width: 60%;" value="<?php echo $FeedSettings['description']; ?>" maxlength="1000" />
293
+ <?php if( $cat_ID ) { ?>
294
+ (leave blank to use category description)
295
+ <?php } else { ?>
296
+ (leave blank to use blog description)
297
+ <?php } ?>
298
  </td>
299
  </tr>
300
 
304
  </th>
305
  <td>
306
  <input type="text" name="Feed[url]"style="width: 60%;" value="<?php echo $FeedSettings['url']; ?>" maxlength="250" /> (optional)
307
+ <?php if( $cat_ID ) { ?>
308
  <p>e.g. <?php echo get_bloginfo('home'); ?>/custom-page/</p>
309
+ <?php } else { ?>
310
+ <p>Leave blank to use category page: <?php echo get_category_link($cat_ID); ?></p>
311
+ <?php } ?>
312
  </td>
313
  </tr>
314
 
 
 
 
 
 
 
 
 
315
 
316
  <tr valign="top">
317
  <th scope="row">
320
  <td>
321
  <input type="text" name="Feed[feed_redirect_url]"style="width: 60%;" value="<?php echo $FeedSettings['feed_redirect_url']; ?>" maxlength="100" /> (leave blank to use current feed)
322
  <p>Use this option to redirect this feed to a hosted feed service such as <a href="http://www.feedburner.com/" target="_blank">FeedBurner</a>.</p>
323
+ <?php
324
+ if( $cat_ID )
325
+ $link = get_category_feed_link($cat_ID);
326
+ else
327
+ $link = get_feed_link($feed_slug);
328
+
329
  if( strstr($link, '?') )
330
  $link .= "&redirect=no";
331
  else
337
 
338
  <?php } // End $feed_slug ?>
339
 
340
+ <tr valign="top">
341
+ <th scope="row">
342
+ <?php _e("Show the most recent"); ?>
343
+ </th>
344
+ <td>
345
+ <input type="text" name="Feed[posts_per_rss]"style="width: 50px;" value="<?php echo $FeedSettings['posts_per_rss']; ?>" maxlength="5" /> episodes / posts per feed (leave blank to use blog default: <?php form_option('posts_per_rss'); ?>)
346
+ <?php if( !$feed_slug && !$cat_ID ) { ?>
347
+ <p style="margin-top: 5px; margin-bottomd: 0;">Note: Setting above applies only to custom podcast feeds</p>
348
+ <?php } ?>
349
+ </td>
350
+ </tr>
351
+
352
  <?php if( $AdvancedMode ) { ?>
353
  <tr valign="top">
354
  <th scope="row" >
386
  <p style="margin-top: 5px;">Your summary may not contain HTML and cannot exceed 4,000 characters in length.</p>
387
 
388
  <textarea name="Feed[itunes_summary]" rows="5" style="width:80%;" ><?php echo $FeedSettings['itunes_summary']; ?></textarea>
389
+ <?php if ( version_compare( '5', phpversion(), '>=' ) ) { ?>
390
+ <div><input type="checkbox" name="Feed[enhance_itunes_summary]" value="1" <?php echo ($FeedSettings['enhance_itunes_summary']?'checked ':''); ?>/> Enhance iTunes Summary from Blog Posts (<a href="http://help.blubrry.com/blubrry-powerpress/settings/enhanced-itunes-summary/" target="_blank">What's this</a>)
391
+ <?php } ?>
392
+ </div>
393
  </td>
394
  </tr>
395
 
538
  </tr>
539
 
540
  <?php if( $AdvancedMode ) { ?>
541
+ <tr valign="top">
542
+ <th scope="row">
543
+
544
+ <?php _e("Feed Language"); ?></th>
545
+ <td>
546
+ <?php
547
+
548
+
549
+
550
+ ?>
551
+ <select name="Feed[rss_language]" class="bpp_input_med">
552
+ <?php
553
+ $Languages = powerpress_languages();
554
+
555
+ echo '<option value="">Blog Default Language</option>';
556
+ while( list($value,$desc) = each($Languages) )
557
+ echo "\t<option value=\"$value\"". ($FeedSettings['rss_language']==$value?' selected':''). ">".htmlspecialchars($desc)."</option>\n";
558
+ ?>
559
+ </select>
560
+ <?php
561
+ $rss_language = get_option('rss_language');
562
+ if( isset($Languages[ $rss_language ]) )
563
+ {
564
+ ?>
565
+ Blog Default: <?php echo $Languages[ $rss_language ]; ?>
566
+ <?php } ?>
567
+ </td>
568
+ </tr>
569
+
570
  <tr valign="top">
571
  <th scope="row">
572
  <?php _e("Talent Name"); ?> <br />
powerpressadmin-jquery.php ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // jQuery specific functions and code go here..
3
+
4
+ // Credits:
5
+ /*
6
+ FOLDER ICON provided by Silk icon set 1.3 by Mark James link: http://www.famfamfam.com/lab/icons/silk/
7
+ */
8
+
9
+ function powerpress_add_blubrry_redirect($program_keyword)
10
+ {
11
+ $Settings = powerpress_get_settings('powerpress_general');
12
+ $RedirectURL = 'http://media.blubrry.com/'.$program_keyword;
13
+ $NewSettings = array();
14
+
15
+ // redirect1
16
+ // redirect2
17
+ // redirect3
18
+ for( $x = 1; $x <= 3; $x++ )
19
+ {
20
+ $field = sprintf('redirect%d', $x);
21
+ if( $Settings[$field] == '' )
22
+ {
23
+ $NewSettings[$field] = $RedirectURL.'/';
24
+ break;
25
+ }
26
+ else if( stristr($Settings[$field], $RedirectURL ) )
27
+ {
28
+ return; // Redirect already implemented
29
+ }
30
+ }
31
+ if( count($NewSettings) > 0 )
32
+ powerpress_save_settings($NewSettings);
33
+ }
34
+
35
+ function powerpress_admin_jquery_init()
36
+ {
37
+ $Error = false;
38
+ $Settings = false; // Important, never remove this
39
+ $Programs = false;
40
+ $Step = 1;
41
+
42
+ $action = (isset($_GET['action'])?$_GET['action']: (isset($_POST['action'])?$_POST['action']:false) );
43
+ if( !$action )
44
+ return;
45
+
46
+ switch($action)
47
+ {
48
+ case 'powerpress-jquery-stats': {
49
+
50
+ $StatsCached = get_option('powerpress_stats');
51
+
52
+ powerpress_admin_jquery_header('Blubrry Media Statistics');
53
+ ?>
54
+ <h2>Blubrry Media Statistics</h2>
55
+ <?php
56
+ echo $StatsCached['content'];
57
+ powerpress_admin_jquery_footer();
58
+ exit;
59
+ }; break;
60
+ case 'powerpress-jquery-media': {
61
+
62
+ $Settings = get_option('powerpress_general');
63
+
64
+
65
+ if( $Settings['blubrry_auth'] == '' )
66
+ {
67
+ powerpress_admin_jquery_header('Select Media');
68
+ ?>
69
+ <p>Wait a sec! This feature is only available to Blubrry Podcast Community members. Join our community to get free podcast statistics and access to other valuable <a href="http://www.blubrry.com/powerpress_services/" target="_blank">services</a>.</p>
70
+ <p>Our <a href="http://www.blubrry.com/powerpress_services/" target="_blank">podcast-hosting integrated</a> PowerPress makes podcast publishing simple. Check out the <a href="http://www.blubrry.com/powerpress_services/" target="_blank">video</a> on our exciting three-step publishing system!</p>
71
+ <?php
72
+ powerpress_admin_jquery_footer();
73
+ exit;
74
+ break;
75
+ }
76
+
77
+ $api_url = sprintf('%s/media/%s/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'] );
78
+ $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
79
+ $results = powerpress_json_decode($json_data);
80
+ // print_r($files);
81
+
82
+ $FeedSlug = $_GET['podcast-feed'];
83
+ powerpress_admin_jquery_header('Select Media');
84
+ ?>
85
+
86
+ <!-- <p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding:0;"><a href="#" onclick="self.parent.tb_remove();" title="Cancel"><img src="<?php echo admin_url(); ?>/images/no.png" /></a></p>
87
+ <h2>Select Media</h2> -->
88
+ <p>
89
+ Select from media files uploaded to blubrry.com:
90
+ </p>
91
+ <!-- <ul class="media"> -->
92
+ <div id="media-items-container">
93
+ <div id="media-items">
94
+ <?php
95
+
96
+ if( isset($results['error']) )
97
+ {
98
+ echo $results['error'];
99
+ }
100
+ else
101
+ {
102
+ while( list($index,$data) = each($results) )
103
+ {
104
+ // old way:
105
+ /*
106
+ ?>
107
+
108
+ <li>
109
+ <a href="#" onclick="self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').value='<?php echo $data['name']; ?>'; self.parent.document.getElementById('powerpress_hosting_<?php echo $FeedSlug; ?>').value='1'; self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').readOnly='true'; self.parent.tb_remove(); return false;"><?php echo $data['name']; ?></a>
110
+ <cite><?php echo powerpress_byte_size($data['length']); ?></cite>
111
+ </li>
112
+ <?php
113
+ */
114
+ // new way:
115
+ ?>
116
+ <div class="media-item">
117
+ <strong class="media-name"><?php echo $data['name']; ?></strong>
118
+ <cite><?php echo powerpress_byte_size($data['length']); ?></cite>
119
+
120
+ <div class="media-item-links">
121
+ <a href="#" onclick="self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').value='<?php echo $data['name']; ?>'; self.parent.document.getElementById('powerpress_hosting_<?php echo $FeedSlug; ?>').value='1'; self.parent.document.getElementById('powerpress_url_<?php echo $FeedSlug; ?>').readOnly='true'; self.parent.tb_remove(); return false;">Select</a>
122
+ </div>
123
+ </div>
124
+ <?php
125
+ }
126
+ }
127
+ ?>
128
+ </div>
129
+ </div>
130
+ <!-- </ul> -->
131
+
132
+ <?php
133
+ powerpress_admin_jquery_footer();
134
+ exit;
135
+ }; break;
136
+ case 'powerpress-jquery-account-save': {
137
+
138
+ check_admin_referer('powerpress-jquery-account');
139
+
140
+ $Password = $_POST['Password'];
141
+ $Settings = $_POST['Settings'];
142
+ $Password = powerpress_stripslashes($Password);
143
+ $General = powerpress_stripslashes($Settings);
144
+
145
+ $Save = false;
146
+ $Close = false;
147
+
148
+ /*
149
+ $Settings['blubrry_hosting'] = 0;
150
+ if( $_POST['Services'] == 'stats_hosting')
151
+ $Settings['blubrry_hosting'] = 1;
152
+ */
153
+
154
+
155
+ if( $_POST['Remove'] )
156
+ {
157
+ $Settings['blubrry_username'] = '';
158
+ $Settings['blubrry_auth'] = '';
159
+ $Settings['blubrry_program_keyword'] = '';
160
+ $Settings['blubrry_hosting'] = 0;
161
+ $Close = true;
162
+ $Save = true;
163
+ }
164
+ else
165
+ {
166
+ $Programs = array();
167
+ //if( isset($_POST['ChangePassword']) )
168
+ //{
169
+ // $Settings['blubrry_program_keyword'] = ''; // Reset the program keyword stored
170
+
171
+ // Anytime we change the password we need to test it...
172
+ $auth = base64_encode( $Settings['blubrry_username'] . ':' . $Password );
173
+ if( $Settings['blubrry_hosting'] == 0 )
174
+ $api_url = sprintf('%s/stats/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
175
+ else
176
+ $api_url = sprintf('%s/media/index.json', rtrim(POWERPRESS_BLUBRRY_API_URL, '/') );
177
+ $json_data = powerpress_remote_fopen($api_url, $auth);
178
+ $results = powerpress_json_decode($json_data);
179
+
180
+ if( isset($results['error']) )
181
+ {
182
+ $Error = $results['error'];
183
+ if( strstr($Error, 'currently not available') )
184
+ $Error = 'Unable to find podcasts for this account.';
185
+ }
186
+ else if( !is_array($results) )
187
+ {
188
+ $Error = $json_data;
189
+ }
190
+ else
191
+ {
192
+ // Get all the programs for this user...
193
+ while( list($null,$row) = each($results) )
194
+ $Programs[ $row['program_keyword'] ] = $row['program_title'];
195
+
196
+ if( count($Programs) > 0 )
197
+ {
198
+ $Settings['blubrry_auth'] = $auth;
199
+
200
+ if( $Settings['blubrry_program_keyword'] != '' )
201
+ {
202
+ powerpress_add_blubrry_redirect($Settings['blubrry_program_keyword']);
203
+ $Save = true;
204
+ $Close = true;
205
+ }
206
+ else if( isset($Settings['blubrry_program_keyword']) )
207
+ {
208
+ $Error = 'You must select a program to continue.';
209
+ }
210
+ else if( count($Programs) == 1 )
211
+ {
212
+ list($keyword, $title) = each($Programs);
213
+ $Settings['blubrry_program_keyword'] = $keyword;
214
+ powerpress_add_blubrry_redirect($keyword);
215
+ $Close = true;
216
+ $Save = true;
217
+ }
218
+ else
219
+ {
220
+ $Error = 'Please select your podcast program to continue.';
221
+ $Step = 2;
222
+ }
223
+ }
224
+ else
225
+ {
226
+ $Error = 'No podcasts for this account are listed on blubrry.com.';
227
+ }
228
+ }
229
+ }
230
+
231
+ if( $Save )
232
+ powerpress_save_settings($Settings);
233
+
234
+ // Clear cached statistics
235
+ delete_option('powerpress_stats');
236
+
237
+ if( $Error )
238
+ powerpress_page_message_add_notice( $Error );
239
+
240
+ if( $Close )
241
+ {
242
+ powerpress_admin_jquery_header('Blubrry Services Integration');
243
+ powerpress_page_message_print();
244
+ ?>
245
+ <p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding:0;"><a href="#" onclick="self.parent.tb_remove(); return false;" title="Close"><img src="<?php echo admin_url(); ?>/images/no.png" alt="Close" /></a></p>
246
+ <h2>Blubrry Services Integration</h2>
247
+ <p style="text-align: center;"><strong>Settings Saved Successfully!</strong></p>
248
+ <p style="text-align: center;">
249
+ <a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_basic.php"); ?>" target="_top" title="Close">Close</a>
250
+ </p>
251
+ <?php
252
+ powerpress_admin_jquery_footer();
253
+ exit;
254
+ }
255
+
256
+
257
+ } // no break here, let the next case catch it...
258
+ case 'powerpress-jquery-account':
259
+ {
260
+ if( !$Settings )
261
+ $Settings = get_option('powerpress_general');
262
+
263
+ if( $Programs == false )
264
+ $Programs = array();
265
+
266
+ // If we have programs to select from, then we're at step 2
267
+ //if( count($Programs) )
268
+ // $Step = 2;
269
+
270
+ powerpress_admin_jquery_header('Blubrry Services Integration');
271
+ powerpress_page_message_print();
272
+ ?>
273
+ <p style="text-align: right; position: absolute; top: 5px; right: 5px; margin: 0; padding: 0;"><a href="#" onclick="self.parent.tb_remove();" title="Cancel"><img src="<?php echo admin_url(); ?>/images/no.png" /></a></p>
274
+ <form action="<?php echo admin_url(); ?>" enctype="multipart/form-data" method="post">
275
+ <?php wp_nonce_field('powerpress-jquery-account'); ?>
276
+ <input type="hidden" name="action" value="powerpress-jquery-account-save" />
277
+ <div id="accountinfo">
278
+ <h2>Blubrry Services Integration</h2>
279
+ <?php if( $Step == 1 ) { ?>
280
+ <p>
281
+ <label>Blubrry User Name</label>
282
+ <input type="text" name="Settings[blubrry_username]" value="<?php echo $Settings['blubrry_username']; ?>" />
283
+ </p>
284
+ <p id="password_row">
285
+ <label>Blubrry Password</label>
286
+ <input type="password" name="Password" value="" />
287
+ </p>
288
+ <p><strong>Select Blubrry Services</strong></p>
289
+ <p style="margin-left: 20px; margin-bottom: 0px;margin-top: 0px;">
290
+ <input type="radio" name="Settings[blubrry_hosting]" value="0" <?php echo ($Settings['blubrry_hosting']==0?'checked':''); ?> />Statistics Integration only
291
+ </p>
292
+ <p style="margin-left: 20px; margin-top: 0px;">
293
+ <input type="radio" name="Settings[blubrry_hosting]" value="1" <?php echo ($Settings['blubrry_hosting']==1?'checked':''); ?> />Statistics and Hosting Integration (Requires Blubrry Hosting Account)
294
+ </p>
295
+ <?php } else { ?>
296
+ <input type="hidden" name="Settings[blubrry_username]" value="<?php echo htmlspecialchars($Settings['blubrry_username']); ?>" />
297
+ <input type="hidden" name="Password" value="<?php echo htmlspecialchars($Password); ?>" />
298
+ <input type="hidden" name="Settings[blubrry_hosting]" value="<?php echo $Settings['blubrry_hosting']; ?>" />
299
+ <p>
300
+ <label>Blubrry Program Keyword</label>
301
+ <select name="Settings[blubrry_program_keyword]">
302
+ <option value="">Select Program</option>
303
+ <?php
304
+ while( list($value,$desc) = each($Programs) )
305
+ echo "\t<option value=\"$value\"". ($Settings['blubrry_program_keyword']==$value?' selected':''). ">$desc</option>\n";
306
+ ?>
307
+ </select>
308
+ </p>
309
+ <?php } ?>
310
+ <p>
311
+ <input type="submit" name="Remove" value="Remove" style="float: right;" onclick="return confirm('Remove Blubrry Services Integration, are you sure?');" />
312
+ <input type="submit" name="Save" value="Save" />
313
+ <input type="button" name="Cancel" value="Cancel" onclick="self.parent.tb_remove();" />
314
+ </p>
315
+ </div>
316
+ </form>
317
+ <?php
318
+ powerpress_admin_jquery_footer();
319
+ exit;
320
+ }; break;
321
+ }
322
+
323
+ }
324
+
325
+ function powerpress_admin_jquery_header($title, $other = false)
326
+ {
327
+ ?>
328
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
329
+ <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
330
+ <head>
331
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
332
+ <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
333
+ <!-- <link rel="stylesheet" href="wp-admin.css" type="text/css" media="screen" /> -->
334
+ <link rel="stylesheet" href="<?php echo powerpress_get_root_url(); ?>css/jquery.css" type="text/css" media="screen" />
335
+ <?php
336
+
337
+ wp_admin_css( 'css/global' );
338
+ wp_admin_css();
339
+ wp_admin_css( 'css/colors' );
340
+ wp_admin_css( 'css/ie' );
341
+
342
+ ?>
343
+ <?php if( $other ) echo $other; ?>
344
+ </head>
345
+ <body>
346
+ <?php
347
+ }
348
+
349
+
350
+ function powerpress_admin_jquery_footer()
351
+ {
352
+ ?>
353
+ </body>
354
+ </html>
355
+ <?php
356
+ }
357
+
358
+
359
+
360
+ ?>
powerpressadmin-metabox.php CHANGED
@@ -83,6 +83,8 @@ function powerpress_meta_box($object, $box)
83
  <label for "Powerpress[<?php echo $FeedSlug; ?>][url]">Media URL</label>
84
  <div class="powerpress_row_content">
85
  <input id="powerpress_url_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][url]" value="<?php echo $EnclosureURL; ?>" onblur="powerpress_check_url(this.value,'powerpress_warning_<?php echo $FeedSlug; ?>')" style="width: 70%; font-size: 90%;" />
 
 
86
  </div>
87
  </div>
88
  <?php
83
  <label for "Powerpress[<?php echo $FeedSlug; ?>][url]">Media URL</label>
84
  <div class="powerpress_row_content">
85
  <input id="powerpress_url_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][url]" value="<?php echo $EnclosureURL; ?>" onblur="powerpress_check_url(this.value,'powerpress_warning_<?php echo $FeedSlug; ?>')" style="width: 70%; font-size: 90%;" />
86
+ <a href="<?php echo admin_url(); ?>?action=powerpress-jquery-media&podcast-feed=<?php echo $FeedSlug; ?>&KeepThis=true&TB_iframe=true" title="Select Media File" class="thickbox"><img src="<?php echo powerpress_get_root_url(); ?>/images/folder.png" alt="Browse Media Files" /></a>
87
+ <input type="hidden" id="powerpress_hosting_<?php echo $FeedSlug; ?>" name="Powerpress[<?php echo $FeedSlug; ?>][hosting]" value="0" />
88
  </div>
89
  </div>
90
  <?php
powerpressadmin-mode.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-mode.php
3
+
4
+ function powerpress_admin_mode()
5
+ {
6
+ ?>
7
+
8
+
9
+ <input type="hidden" name="action" value="powerpress-save-mode" />
10
+ <h2><?php echo __("Welcome to Blubrry PowerPress"); ?></h2>
11
+
12
+ <p style="margin-bottom: 0;">
13
+ Welcome to Blubrry PowerPress. In order to give each user the best experience, we designed two modes; Simple and Advanced. Please select the mode that is most appropriate for your needs.
14
+ </p>
15
+
16
+ <table class="form-table">
17
+ <tr valign="top">
18
+ <th scope="row"><?php echo __("Select Mode"); ?></th>
19
+ <td>
20
+
21
+ <p><input name="General[advanced_mode]" type="radio" value="0" /> <strong>Simple Mode</strong></p>
22
+ <p>Simple Mode is intended for podcasters who are just starting out and feel a bit intimidated by all of the possible options and settings. This mode is perfect for someone who is recording in one format (e.g. mp3) and wants to keep things simple.</p>
23
+ <ul><li>Features Include:<ul>
24
+ <li>Only the bare essential settings</li>
25
+ <li>Important feed and iTunes settings</li>
26
+ <li>Player and download links added to bottom of episode posts</li>
27
+ </ul></li></ul>
28
+
29
+ <p><input name="General[advanced_mode]" type="radio" value="1" /> <strong>Advanced Mode</strong></p>
30
+ <p>Advanced Mode gives you all of the features packaged in Blubrry PowerPress. This mode is perfect for someone who may want to distribute multiple versions of their podcast, customize the web player &amp; download links,
31
+ or import data from a previous podcasting platform.</p>
32
+ <ul><li>Features Include:<ul>
33
+ <li><em>Advanced Settings</em> - Tweak additional basic settings.</li>
34
+ <li><em>Presentation Settings</em> - Customize web player and media download links</li>
35
+ <li><em>Extensive Feed Settings</em> - Tweak all available feed settings</li>
36
+ <li><em>Manage Custom Feeds</em> - Manage and add custom podcast feeds</li>
37
+ <li><em>MP3 ID3 Tags</em> - Blubrry Media Hosting users can configure how their MP3 ID3 tags are written to hosted media</li>
38
+ <li><em>Useful Tools</em> - Import data from previous sites (PodPress, MovableType, Blogger), add Update Sservices to your blog and more</li>
39
+ </ul></li></ul>
40
+
41
+ </td>
42
+ </tr>
43
+
44
+ </table>
45
+ <p class="submit">
46
+ <input type="submit" name="Submit" id="powerpress_save_button" class="button-primary" value="Set Mode and Continue" />
47
+ </p>
48
+
49
+ <!-- start footer -->
50
+ <?php
51
+ }
52
+
53
+ ?>
powerpressadmin-ping-sites.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-ping-sites.php
3
+
4
+ function powerpressadmin_ping_sites_process()
5
+ {
6
+ $PingSites = $_POST['PingSite'];
7
+ if( $PingSites && count($PingSites) > 0 )
8
+ {
9
+ $ping_site_data = get_option('ping_sites');
10
+
11
+ while( list($null,$url) = each($PingSites) )
12
+ $ping_site_data = trim($ping_site_data)."\r\n$url";
13
+
14
+ update_option('ping_sites', $ping_site_data);
15
+ powerpress_page_message_add_notice( __('Update services added successfully.') );
16
+ }
17
+ else
18
+ {
19
+ powerpress_page_message_add_notice( __('No update services selected to add.') );
20
+ }
21
+ }
22
+
23
+ function powerpress_admin_ping_sites()
24
+ {
25
+ $ping_sites = get_option('ping_sites');
26
+ $BlogSites = array('http://rpc.pingomatic.com/'=>'Ping-o-Matic!',
27
+ 'http://blogsearch.google.com/ping/RPC2'=>'Google Blog Search',
28
+ 'http://rssrpc.weblogs.com/RPC2'=>'WebLogs',
29
+ 'http://rpc.technorati.com/rpc/ping'=>'Technorati');
30
+
31
+ $PodcastSites = array('http://audiorpc.weblogs.com/RPC2'=>'WebLogs Audio',
32
+ 'http://www.allpodcasts.com/Ping.aspx'=>'AllPodcasts.com',
33
+ 'http://www.podnova.com/xmlrpc.srf'=>'PodNova.com',
34
+ 'http://ping.podcast.com/ping.php'=>'Podcasts.com',
35
+ 'http://ping.syndic8.com/xmlrpc.php'=>'Syndic8.com');
36
+ ?>
37
+
38
+
39
+ <input type="hidden" name="action" value="powerpress-ping-sites" />
40
+ <h2><?php echo __("Add Update services / Ping Sites"); ?></h2>
41
+
42
+ <p style="margin-bottom: 0;">Notify the following Update Services / Ping Sites when you create a new blog post / podcast episode.</p>
43
+
44
+ <table class="form-table">
45
+ <tr valign="top">
46
+ <th scope="row"><?php echo __("Update Blog Searvices"); ?></th>
47
+ <td>
48
+ <p>Select the blog service you would like to notify.</p>
49
+ <?php
50
+ while( list($url,$name) = each($BlogSites) )
51
+ {
52
+ if( stristr($ping_sites, $url) )
53
+ {
54
+ ?>
55
+ <p><input name="Ignore[]" type="checkbox" checked disabled value="1" /> <?php echo $name; ?></p>
56
+ <?php
57
+ }
58
+ else
59
+ {
60
+ ?>
61
+ <p><input name="PingSite[]" type="checkbox" value="<?php echo $url; ?>" /> <?php echo $name; ?></p>
62
+ <?php
63
+ }
64
+ }
65
+ ?>
66
+ </td>
67
+ </tr>
68
+
69
+ <tr valign="top">
70
+ <th scope="row"><?php echo __("Update Podcast Searvices"); ?></th>
71
+ <td>
72
+ <p>Select the podcasting service you would like to notify.</p>
73
+ <?php
74
+ while( list($url,$name) = each($PodcastSites) )
75
+ {
76
+ if( stristr($ping_sites, $url) )
77
+ {
78
+ ?>
79
+ <p><input name="Ignore[]" type="checkbox" checked disabled value="1" /> <?php echo $name; ?></p>
80
+ <?php
81
+ }
82
+ else
83
+ {
84
+ ?>
85
+ <p><input name="PingSite[]" type="checkbox" value="<?php echo $url; ?>" /> <?php echo $name; ?></p>
86
+ <?php
87
+ }
88
+ }
89
+ ?>
90
+ </td>
91
+ </tr>
92
+
93
+ </table>
94
+ <p>
95
+ You can manually add ping services by going to the to the "Update Services" section found in the <strong>WordPress Settings</strong> &gt; <strong>Writing</strong> page.
96
+ </p>
97
+ <p class="submit">
98
+ <input type="submit" name="Submit" id="powerpress_save_button" class="button-primary" value="Add Selected Update Services" />
99
+ </p>
100
+
101
+ <!-- start footer -->
102
+ <?php
103
+ }
104
+
105
+ ?>
powerpressadmin-tags.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // powerpressadmin-tags.php
3
+
4
+ function powerpress_admin_tags()
5
+ {
6
+
7
+
8
+ $General = powerpress_get_settings('powerpress_general');
9
+ $TagSettings = powerpress_default_settings($General, 'tags');
10
+ ?>
11
+ <script language="javascript">
12
+ function ToggleID3Tags(Obj)
13
+ {
14
+ document.getElementById('edit_id3_tags').style.display=(Obj.checked?'block':'none');
15
+ }
16
+
17
+ </script>
18
+ <style type="text/css">
19
+ items {
20
+
21
+ }
22
+
23
+ .item-row {
24
+ . border-bottom-style: solid;
25
+ border-bottom-width: 1px;
26
+ min-height: 36px;
27
+ position: relative;
28
+ width: 100%;
29
+ }
30
+ </style>
31
+ <input type="hidden" name="action" value="powerpress-save-tags" />
32
+ <h2><?php echo __("MP3 Tags"); ?></h2>
33
+
34
+ <p >Blubrry Hosting users can configure how to have the service write their MP3 ID3 Tags before publishing episodes.</p>
35
+
36
+ <p style="margin-bottomd: 0;">
37
+ ID3 tags contain useful information (title, artist, album, year, etc...) about your podcast as well as an image for display during playback in most media players.
38
+ Please visit the <a href="http://www.podcastfaq.com/creating-podcast/audio/edit-id3-tags/" title="PodcastFAQ.com" target="_blank">ID3 Tags</a>
39
+ section on <a href="http://www.podcastfaq.com/" title="PodcastFAQ.com" target="_blank">PodcastFAQ.com</a>
40
+ to learn more about MP3 ID3 tags.
41
+ </p>
42
+ <?php
43
+ if( !@$General['blubrry_hosting'] )
44
+ {
45
+ ?>
46
+ <table class="form-table">
47
+ <tr valign="top">
48
+ <th scope="row"><?php echo __("Write Tags"); ?></th>
49
+ <td>
50
+ <p>
51
+ <input name="NotAvailable" type="checkbox" value="1" onchange="alert('You must configure your Blubrry Services Account in the Blubrry PowerPress > Basic Settings page in order to utilize this feature.'); this.checked=false; return false;" />
52
+ Use Blubrry Hosting services to write MP3 ID3 tags to your media.
53
+ </p>
54
+ </td>
55
+ </tr>
56
+ </table>
57
+
58
+ <?php
59
+ }
60
+ else
61
+ {
62
+ ?>
63
+ <table class="form-table">
64
+ <tr valign="top">
65
+ <th scope="row"><?php echo __("Write Tags"); ?></th>
66
+ <td>
67
+ <p>
68
+ <input name="General[write_tags]" type="checkbox" value="1" <?php if($General['write_tags']) echo 'checked '; ?> onchange="ToggleID3Tags(this);" />
69
+ Use Blubrry Hosting services to write MP3 ID3 tags to your media.
70
+ </p>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ <?php } ?>
75
+ <table class="form-table" id="edit_id3_tags" style="display:<?php echo ($General['blubrry_hosting']?($General['write_tags']?'block':'none'):'block'); ?>;">
76
+
77
+ <?php
78
+
79
+ powerpressadmin_tag_option('tag_title', $General['tag_title'], 'Title Tag', 'Use blog post title' );
80
+ powerpressadmin_tag_option('tag_artist', $General['tag_artist'], 'Artist Tag', 'Use Feed Talent Name' );
81
+ powerpressadmin_tag_option('tag_album', $General['tag_album'], 'Album Tag', 'Use blog title: '. get_bloginfo('name') .'' );
82
+ powerpressadmin_tag_option('tag_genre', $General['tag_genre'], 'Genre Tag', 'Use genre \'Podcast\'' );
83
+ powerpressadmin_tag_option('tag_year', $General['tag_year'], 'Year Tag', 'Use current year' );
84
+ //powerpressadmin_tag_option('tag_comment', $General['tag_comment'], 'Comment Tag', 'Use iTunes subtitle' ); // too compilcated at this point
85
+ powerpressadmin_tag_option('tag_track', $General['tag_track'], 'Track Tag', 'Do not specify track number' );
86
+ powerpressadmin_tag_option('tag_composer', $General['tag_composer'], 'Composer Tag', 'Use Feed Talent Name' );
87
+ powerpressadmin_tag_option('tag_copyright', $General['tag_copyright'], 'Copyright Tag', 'Use &copy; Talent Name' );
88
+ powerpressadmin_tag_option('tag_url', $General['tag_url'], 'URL Tag', 'Use main blog URL: '. get_bloginfo('url') .'' );
89
+ powerpressadmin_tag_option('tag_coverart', $General['tag_coverart'], 'Coverart Tag', '' );
90
+
91
+ ?>
92
+
93
+ </table>
94
+ <?php
95
+ } // End powerpress_admin_appearance()
96
+
97
+
98
+ function powerpressadmin_tag_option($tag, $value, $label, $default_desc )
99
+ {
100
+ $file = false;
101
+ $other = false;
102
+ $track = false;
103
+ switch( $tag )
104
+ {
105
+ case 'tag_title': {
106
+ $other = false;
107
+ }; break;
108
+ case 'tag_track': {
109
+ $track = true;
110
+ }; break;
111
+ case 'tag_coverart': {
112
+ $other = false;
113
+ $file = true;
114
+ }; break;
115
+ default: {
116
+ $other = true;
117
+ }
118
+ }
119
+ ?>
120
+ <tr valign="top">
121
+ <th scope="row">
122
+ <?php echo $label; ?>
123
+ </th>
124
+ <td>
125
+ <?php
126
+ if( !$file )
127
+ {
128
+ ?>
129
+ <input type="radio" name="General[<?php echo $tag; ?>]" value="0" <?php if( $value == '' ) echo 'checked'; ?> />
130
+ <?php
131
+ echo $default_desc;
132
+ }
133
+
134
+ if( $file )
135
+ {
136
+ $FeedSettings = get_option('powerpress_feed');
137
+ $UploadArray = wp_upload_dir();
138
+ $upload_path = rtrim( substr($UploadArray['path'], 0, 0 - strlen($UploadArray['subdir']) ), '\\/').'/powerpress/';
139
+
140
+ if( !file_exists($upload_path) )
141
+ $SupportUploads = @mkdir($upload_path, 0777);
142
+ else
143
+ $SupportUploads = true;
144
+ ?>
145
+ <input type="radio" name="General[<?php echo $tag; ?>]" value="0" <?php if( $value == '' ) echo 'checked'; ?> />
146
+ Do not add a coverart image.<br />
147
+ <input type="radio" id="<?php echo $tag; ?>_specify" name="General[<?php echo $tag; ?>]" value="1" <?php if( $value != '' ) echo 'checked'; ?> />
148
+
149
+ <input type="text" id="coverart_image" name="TagValues[<?php echo $tag; ?>]" style="width: 50%;" value="<?php echo $value; ?>" maxlength="250" />
150
+ <a href="#" onclick="javascript: window.open( document.getElementById('coverart_image').value ); return false;">preview</a>
151
+
152
+ <p>Place the URL to the Coverart image above. e.g. http://mysite.com/images/coverart.jpg<br /><br />Coverart images may be saved as either .gif, .jpg or .png images of any size,
153
+ though 300 x 300 or 600 x 600 in either png or jpg format is recommended.
154
+ </p>
155
+ <p>
156
+ <?php if( $FeedSettings['itunes_image'] ) { ?>
157
+ <a href="#" title="" onclick="document.getElementById('coverart_image').value='<?php echo $FeedSettings['itunes_image']; ?>';document.getElementById('tag_coverart_specify').checked=true;return false;">Click here</a>
158
+ to use your current iTunes image.
159
+ <?php } ?>
160
+ </p>
161
+ <?php if( $SupportUploads ) { ?>
162
+ <p><input name="coverart_image_checkbox" type="checkbox" onchange="powerpress_show_field('coverart_image_upload', this.checked)" value="1" /> Upload new image </p>
163
+ <div style="display:none" id="coverart_image_upload">
164
+ <label for="coverart_image_file">Choose file:</label> <input type="file" name="coverart_image_file" />
165
+ </div>
166
+ <?php } ?>
167
+
168
+ <?php
169
+ }
170
+
171
+ if( $track )
172
+ {
173
+ ?><br />
174
+ <input type="radio" name="General[<?php echo $tag; ?>]" value="1" <?php if( $value != '' ) echo 'checked'; ?> /> Specify:
175
+ <input type="text" name="TagValues[<?php echo $tag; ?>]" style="width: 50px;" onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, '');" value="<?php echo ($value?$value:'1'); ?>" maxlength="5" />
176
+ <?php
177
+ echo __('(value entered increments every episode)');
178
+ }
179
+
180
+ if( $other )
181
+ {
182
+ ?><br />
183
+ <input type="radio" name="General[<?php echo $tag; ?>]" value="1" <?php if( $value != '' ) echo 'checked'; ?> /> Specify:
184
+ <input type="text" name="TagValues[<?php echo $tag; ?>]" style="width: 300px" value="<?php echo htmlspecialchars($value); ?>" maxlength="250" />
185
+ <?php
186
+ }
187
+
188
+ ?>
189
+ </td>
190
+ </tr>
191
+ <?php
192
+
193
+
194
+
195
+ }
196
+
197
+ ?>
powerpressadmin-tools.php CHANGED
@@ -31,6 +31,18 @@
31
  </td>
32
  </tr>
33
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  <!-- use_caps -->
35
  <tr valign="top">
36
  <th scope="row"><?php echo __("User Capabilities"); ?></th>
31
  </td>
32
  </tr>
33
 
34
+ <!-- ping_sites -->
35
+ <tr valign="top">
36
+ <th scope="row"><?php echo __("Add Update Services"); ?></th>
37
+ <td>
38
+
39
+ <p style="margin-top: 5px;"><strong><a href="<?php echo admin_url("admin.php?page=powerpress/powerpressadmin_tools.php&amp;action=powerpress-ping-sites"); ?>">Add Update Services / Ping Sites</a></strong> (notify podcast directories when you publish new episodes)</p>
40
+ <p>Add Update Services / Ping Sites geared towards podcasting.</p>
41
+
42
+ </td>
43
+ </tr>
44
+
45
+
46
  <!-- use_caps -->
47
  <tr valign="top">
48
  <th scope="row"><?php echo __("User Capabilities"); ?></th>
powerpressadmin.php CHANGED
@@ -49,6 +49,8 @@ function powerpress_admin_init()
49
  if( $VersionDiff < 0 )
50
  powerpress_page_message_add_error( __('Blubrry PowerPress requires Wordpress version 2.6 or greater.') );
51
 
 
 
52
  // Save settings here
53
  if( isset($_POST[ 'Feed' ]) || isset($_POST[ 'General' ]) )
54
  {
@@ -61,6 +63,7 @@ function powerpress_admin_init()
61
  $Feed = $_POST['Feed'];
62
  $General = $_POST['General'];
63
  $FeedSlug = (isset($_POST['feed_slug'])?$_POST['feed_slug']:false);
 
64
 
65
  // New iTunes image
66
  if( @$_POST['itunes_image_checkbox'] == 1 )
@@ -116,6 +119,33 @@ function powerpress_admin_init()
116
  }
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  // Check to see if we need to update the feed title
120
  if( $FeedSlug )
121
  {
@@ -138,6 +168,55 @@ function powerpress_admin_init()
138
  $General['display_player_excerpt'] = 0; // Set it to zero.
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  // Wordpress adds slashes to everything, but since we're storing everything serialized, lets remove them...
142
  $General = powerpress_stripslashes($General);
143
  powerpress_save_settings($General);
@@ -148,7 +227,10 @@ function powerpress_admin_init()
148
  if( !isset($Feed['enhance_itunes_summary']) )
149
  $Feed['enhance_itunes_summary'] = false;
150
  $Feed = powerpress_stripslashes($Feed);
151
- powerpress_save_settings($Feed, 'powerpress_feed'.($FeedSlug?'_'.$FeedSlug:'') );
 
 
 
152
  }
153
 
154
  // Anytime settings are saved lets flush the rewrite rules
@@ -163,9 +245,26 @@ function powerpress_admin_init()
163
  case 'powerpress-save-customfeed': {
164
  powerpress_page_message_add_notice( __('Blubrry PowerPress Custom Feed settings saved.') );
165
  }; break;
 
166
  case 'powerpress-save-feedsettings': {
167
  powerpress_page_message_add_notice( __('Blubrry PowerPress Feed settings saved.') );
168
  }; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  case 'powerpress-save-basic':
170
  default: {
171
  powerpress_page_message_add_notice( __('Blubrry PowerPress settings saved.') );
@@ -225,6 +324,48 @@ function powerpress_admin_init()
225
  $_GET['feed_slug'] = $key;
226
  }
227
  }; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  case 'powerpress-importpodpress': {
229
  check_admin_referer('powerpress-import-podpress');
230
 
@@ -248,6 +389,12 @@ function powerpress_admin_init()
248
  powerpressadmin_podpress_delete_data();
249
 
250
  }; break;
 
 
 
 
 
 
251
  }
252
  }
253
 
@@ -293,6 +440,21 @@ function powerpress_admin_init()
293
  powerpress_page_message_add_notice( 'Feed deleted successfully.' );
294
  }
295
  }; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  case 'powerpress-podpress-settings': {
297
  check_admin_referer('powerpress-podpress-settings');
298
 
@@ -335,10 +497,32 @@ function powerpress_admin_init()
335
  }; break;
336
  }
337
  }
 
 
 
 
338
  }
339
 
340
  add_action('init', 'powerpress_admin_init');
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  function powerpress_save_settings($SettingsNew=false, $field = 'powerpress_general' )
343
  {
344
  // Save general settings
@@ -445,8 +629,11 @@ function powerpress_admin_menu()
445
  add_menu_page(__('PowerPress'), __('PowerPress'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic', powerpress_get_root_url() . 'powerpress_ico.png');
446
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Basic Settings'), __('Basic Settings'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic' );
447
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Appearance Settings'), __('Appearance'), 1, 'powerpress/powerpressadmin_appearance.php', 'powerpress_admin_page_appearance' );
448
- add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Feed Settings'), __('Feed Settings'), 1, 'powerpress/powerpressadmin_feedsettings.php', 'powerpress_admin_page_feedsettings');
449
- add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Custom Feeds'), __('Custom Feeds'), 1, 'powerpress/powerpressadmin_customfeeds.php', 'powerpress_admin_page_customfeeds');
 
 
 
450
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Tools'), __('Tools'), 1, 'powerpress/powerpressadmin_tools.php', 'powerpress_admin_page_tools');
451
  }
452
  else
@@ -492,7 +679,7 @@ function powerpress_edit_post($post_ID, $post)
492
 
493
  // Initialize the important variables:
494
  $MediaURL = $Powerpress['url'];
495
- if( strpos($MediaURL, 'http://') !== 0 ) // If the url entered does not start with a http://
496
  {
497
  $Settings = get_option('powerpress_general');
498
  $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
@@ -536,45 +723,75 @@ function powerpress_edit_post($post_ID, $post)
536
 
537
  if( $Powerpress['set_size'] == 0 || $Powerpress['set_duration'] == 0 )
538
  {
539
- // Lets use the mp3info class:
540
- require_once('mp3info.class.php');
541
-
542
- $Mp3Info = new Mp3Info();
543
- if( $Powerpress['set_duration'] == 0 && $ContentType == 'audio/mpeg' )
544
  {
545
- $Mp3Data = $Mp3Info->GetMp3Info($MediaURL);
546
- if( $Mp3Data )
547
  {
548
- if( @$Powerpress['set_size'] == 0 )
549
- $FileSize = $Mp3Info->GetContentLength();
550
- $Duration = $Mp3Data['playtime_string'];
551
- if( substr_count($Duration, ':' ) == 0 )
552
- {
553
- if( $Duration < 60 )
554
- $Duration = '00:00:'.$Duration;
555
- }
556
- else if( substr_count($Duration, ':' ) == 1 )
557
  {
558
- $Duration = '00:'.$Duration;
 
 
 
 
559
  }
560
- $Duration = powerpress_readable_duration($Duration, true); // Fix so it looks better when viewed for editing
561
  }
562
  }
563
-
564
- // Just get the file size
565
- if( $Powerpress['set_size'] == 0 && $FileSize == '' )
566
  {
567
- $headers = wp_get_http_headers($MediaURL);
568
- if( $headers && $headers['content-length'] )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  {
570
- $FileSize = (int) $headers['content-length'];
 
 
 
 
571
  }
572
  }
573
  }
574
 
 
 
 
 
 
 
575
  $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
576
  $ToSerialize = array();
577
  // iTunes duration
 
 
578
  if( $Duration )
579
  $ToSerialize['duration'] = $Duration; // regular expression '/^(\d{1,2}\:)?\d{1,2}\:\d\d$/i' (examples: 1:23, 12:34, 1:23:45, 12:34:56)
580
  // iTunes Subtitle (FUTURE USE)
@@ -636,17 +853,29 @@ function powerpress_edit_post($post_ID, $post)
636
  // If we're moving from draft to published, maybe we should ping iTunes?
637
  if($_POST['prev_status'] == 'draft' && $_POST['publish'] == 'Publish' )
638
  {
 
 
 
639
  // Next double check we're looking at a podcast episode...
640
  $Enclosure = get_post_meta($post_ID, 'enclosure', true);
641
  if( $Enclosure )
642
  {
643
- $Settings = get_option('powerpress_general');
644
  if( $Settings['ping_itunes'] && $Settings['itunes_url'] )
645
  {
646
  $PingResults = powerpress_ping_itunes($Settings['itunes_url']);
647
  //mail( 'email@host.com', 'Ping iTunes Results', implode("\n", $PingResults) ); // Let me know how the ping went.
648
  }
649
  }
 
 
 
 
 
 
 
 
 
 
650
  }
651
 
652
  // And we're done!
@@ -841,7 +1070,7 @@ function powerpress_admin_page_basic()
841
  powerpress_admin_page_header();
842
  require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
843
  powerpress_admin_basic();
844
- powerpress_admin_page_footer(true, true);
845
  }
846
 
847
  // Admin page, advanced mode: appearance settings
@@ -862,6 +1091,15 @@ function powerpress_admin_page_feedsettings()
862
  powerpress_admin_page_footer();
863
  }
864
 
 
 
 
 
 
 
 
 
 
865
  // Admin page, advanced mode: custom feeds
866
  function powerpress_admin_page_customfeeds()
867
  {
@@ -882,6 +1120,26 @@ function powerpress_admin_page_customfeeds()
882
  }
883
  }
884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
885
  // Admin page, advanced mode: tools
886
  function powerpress_admin_page_tools()
887
  {
@@ -899,6 +1157,12 @@ function powerpress_admin_page_tools()
899
  powerpress_admin_mt();
900
  powerpress_admin_page_footer(false);
901
  }; break;
 
 
 
 
 
 
902
  default: {
903
  powerpress_admin_page_header('powerpress/powerpressadmin_tools.php');
904
  require_once( dirname(__FILE__).'/powerpressadmin-tools.php');
@@ -925,14 +1189,27 @@ function powerpress_podpress_episodes_exist()
925
  function powerpress_admin_page()
926
  {
927
  powerpress_admin_page_header();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
928
 
929
- require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
930
- powerpress_admin_basic();
931
-
932
- require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
933
- powerpress_admin_editfeed();
934
 
935
- powerpress_admin_page_footer(true, true);
 
936
  }
937
 
938
  function powerpress_shutdown()
@@ -974,7 +1251,7 @@ function powerpress_ping_itunes($iTunes_url)
974
  return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
975
  }
976
 
977
- function powerpress_remote_fopen($url, $basic_auth = false)
978
  {
979
  if( function_exists( 'curl_init' ) ) // Preferred method of connecting
980
  {
@@ -986,17 +1263,33 @@ function powerpress_remote_fopen($url, $basic_auth = false)
986
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Follow location redirection
987
  curl_setopt($curl, CURLOPT_MAXREDIRS, 5); // Location redirection limit
988
  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2 ); // Connect time out
989
- curl_setopt($curl, CURLOPT_TIMEOUT, 5); // The maximum number of seconds to execute.
990
  curl_setopt($curl, CURLOPT_USERAGENT, 'Blubrry PowerPress/'.POWERPRESS_VERSION);
991
  if( strtolower(substr($url, 0, 5)) == 'https' )
992
  {
993
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
994
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
995
  }
 
996
  if( $basic_auth )
997
  {
998
  curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$basic_auth) );
999
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1000
 
1001
  $content = curl_exec($curl);
1002
  $error = curl_errno($curl);
@@ -1010,18 +1303,71 @@ function powerpress_remote_fopen($url, $basic_auth = false)
1010
  if( version_compare('2.7', $wp_version, '<=') ) // Lets us specify the user agent and set the basic auth string...
1011
  {
1012
  $options = array();
1013
- $options['timeout'] = 10;
1014
  $options['user-agent'] = 'Blubrry PowerPress/'.POWERPRESS_VERSION;
1015
  if( $basicauth )
1016
  $options['headers'][] = 'Authorization: Basic '.$basic_auth;
 
 
 
 
 
 
 
 
 
1017
 
1018
- $response = wp_remote_get( $uri, $options );
1019
-
1020
  if ( is_wp_error( $response ) )
1021
  return false;
1022
 
1023
  return $response['body'];
1024
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
 
1026
  if( $basic_auth )
1027
  {
@@ -1035,6 +1381,113 @@ function powerpress_remote_fopen($url, $basic_auth = false)
1035
  return wp_remote_fopen($url);
1036
  }
1037
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
  // Import podpress settings
1039
  function powerpress_admin_import_podpress_settings()
1040
  {
@@ -1196,4 +1649,69 @@ function powerpress_default_settings($Settings, $Section='basic')
1196
  return $Settings;
1197
  }
1198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1199
  ?>
49
  if( $VersionDiff < 0 )
50
  powerpress_page_message_add_error( __('Blubrry PowerPress requires Wordpress version 2.6 or greater.') );
51
 
52
+ add_thickbox(); // we use the thckbox for some settings
53
+
54
  // Save settings here
55
  if( isset($_POST[ 'Feed' ]) || isset($_POST[ 'General' ]) )
56
  {
63
  $Feed = $_POST['Feed'];
64
  $General = $_POST['General'];
65
  $FeedSlug = (isset($_POST['feed_slug'])?$_POST['feed_slug']:false);
66
+ $Category = (isset($_POST['cat'])?$_POST['cat']:false);
67
 
68
  // New iTunes image
69
  if( @$_POST['itunes_image_checkbox'] == 1 )
119
  }
120
  }
121
 
122
+ // New RSS2 image
123
+ if( @$_POST['coverart_image_checkbox'] == 1 )
124
+ {
125
+ $filename = str_replace(" ", "_", basename($_FILES['coverart_image_file']['name']) );
126
+ $temp = $_FILES['coverart_image_file']['tmp_name'];
127
+
128
+ if( file_exists($upload_path . $filename ) )
129
+ {
130
+ $filenameParts = pathinfo($filename);
131
+ do {
132
+ $filename_no_ext = substr($filenameParts['basename'], 0, (strlen($filenameParts['extension'])+1) * -1 );
133
+ $filename = sprintf('%s-%03d.%s', $filename_no_ext, rand(0, 999), $filenameParts['extension'] );
134
+ } while( file_exists($upload_path . $filename ) );
135
+ }
136
+
137
+ if( getimagesize($temp) ) // Just check that it is an image, we may add more to this later
138
+ {
139
+ move_uploaded_file($temp, $upload_path . $filename);
140
+ $_POST['TagValues']['tag_coverart'] = $urlImages . $filename;
141
+ }
142
+ else
143
+ {
144
+ powerpress_page_message_add_error( 'Invalid Coverat image: ' . htmlspecialchars($_FILES['coverart_image_file']['name']) );
145
+ }
146
+ }
147
+
148
+
149
  // Check to see if we need to update the feed title
150
  if( $FeedSlug )
151
  {
168
  $General['display_player_excerpt'] = 0; // Set it to zero.
169
  }
170
 
171
+ if( $_POST['action'] == 'powerpress-save-tags' )
172
+ {
173
+ if( !isset($General['write_tags']) ) // If we are modifying appearance settings but this option was not checked...
174
+ $General['write_tags'] = 0; // Set it to zero.
175
+
176
+ $TagValues = $_POST['TagValues'];
177
+ // Set all the tag values...
178
+ while( list($key,$value) = each($General) )
179
+ {
180
+ if( substr($key, 0, 4) == 'tag_' )
181
+ {
182
+ if( $value )
183
+ $General[$key] = $TagValues[$key];
184
+ else
185
+ $General[$key] = '';
186
+ }
187
+ }
188
+
189
+ if( $TagValues['tag_coverart'] != '' )
190
+ {
191
+ $GeneralSettingsTemp = powerpress_get_settings('powerpress_general', false);
192
+ if( $GeneralSettingsTemp['blubrry_hosting'] )
193
+ {
194
+ // Lets try to cache the image onto Blubrry's Server...
195
+ $api_url = sprintf('%s/media/%s/coverart.json?url=%s', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $GeneralSettingsTemp['blubrry_program_keyword'], urlencode($TagValues['tag_coverart']) );
196
+ $json_data = powerpress_remote_fopen($api_url, $GeneralSettingsTemp['blubrry_auth']);
197
+ $results = powerpress_json_decode($json_data);
198
+
199
+ if( is_array($results) && !isset($results['error']) )
200
+ {
201
+ // Good!
202
+ }
203
+ else if( isset($results['error']) )
204
+ {
205
+ $error = 'Blubrry Hosting Error (updating coverart): '. $results['error'];
206
+ }
207
+ else
208
+ {
209
+ $error = 'An error occurred updating the coverart with your Blubrry Services Account.';
210
+ }
211
+
212
+ }
213
+ else
214
+ {
215
+ powerpress_page_message_add_error( 'Coverart Image was not uploaded to your Blubrry Services Account. It will <u>NOT</u> be added to your mp3s.' );
216
+ }
217
+ }
218
+ }
219
+
220
  // Wordpress adds slashes to everything, but since we're storing everything serialized, lets remove them...
221
  $General = powerpress_stripslashes($General);
222
  powerpress_save_settings($General);
227
  if( !isset($Feed['enhance_itunes_summary']) )
228
  $Feed['enhance_itunes_summary'] = false;
229
  $Feed = powerpress_stripslashes($Feed);
230
+ if( $Category )
231
+ powerpress_save_settings($Feed, 'powerpress_cat_feed_'.$Category);
232
+ else
233
+ powerpress_save_settings($Feed, 'powerpress_feed'.($FeedSlug?'_'.$FeedSlug:'') );
234
  }
235
 
236
  // Anytime settings are saved lets flush the rewrite rules
245
  case 'powerpress-save-customfeed': {
246
  powerpress_page_message_add_notice( __('Blubrry PowerPress Custom Feed settings saved.') );
247
  }; break;
248
+
249
  case 'powerpress-save-feedsettings': {
250
  powerpress_page_message_add_notice( __('Blubrry PowerPress Feed settings saved.') );
251
  }; break;
252
+ case 'powerpress-save-categoryfeedsettings': {
253
+ powerpress_page_message_add_notice( __('Blubrry PowerPress Category Feed settings saved.') );
254
+ }; break;
255
+ case 'powerpress-save-tags': {
256
+ $General = get_option('powerpress_general');
257
+ if( !@$General['blubrry_hosting'] )
258
+ powerpress_page_message_add_notice( __('ATTENTION: You must configure your Blubrry Services in the Blubrry PowerPress &gt; Basic Settings page in order to utilize this feature.') );
259
+ else
260
+ powerpress_page_message_add_notice( __('Blubrry PowerPress MP3 Tag settings saved.') );
261
+ }; break;
262
+ case 'powerpress-save-mode': {
263
+ if( $General['advanced_mode'] == 1 )
264
+ powerpress_page_message_add_notice( __('You are now in Advanced Mode.') );
265
+ else
266
+ powerpress_page_message_add_notice( __('You are now in Simple Mode.') );
267
+ }; break;
268
  case 'powerpress-save-basic':
269
  default: {
270
  powerpress_page_message_add_notice( __('Blubrry PowerPress settings saved.') );
324
  $_GET['feed_slug'] = $key;
325
  }
326
  }; break;
327
+ case 'powerpress-addcategoryfeed': {
328
+ check_admin_referer('powerpress-add-category-feed');
329
+ $cat_ID = $_POST['cat'];
330
+ $Settings = get_option('powerpress_general');
331
+ /*
332
+ $key = sanitize_title($_POST['feed_slug']);
333
+ $value = $_POST['feed_name'];
334
+ $value = powerpress_stripslashes($value);
335
+ */
336
+
337
+ $category = get_category($cat_ID);
338
+ /*
339
+ if( isset($Settings['custom_feeds'][ $key ]) && @$_POST['overwrite'] != 1 )
340
+ {
341
+ powerpress_page_message_add_error( sprintf(__('Feed slug "%s" already exists.'), $key) );
342
+ } else */
343
+ if( $category == false )
344
+ {
345
+ powerpress_page_message_add_error( __('Error obtaining category information.') );
346
+ }
347
+ else
348
+ {
349
+ if( !in_array($cat_ID, @$Settings['custom_cat_feeds']) )
350
+ {
351
+ $Settings['custom_cat_feeds'][] = $cat_ID;
352
+ powerpress_save_settings($Settings);
353
+ }
354
+
355
+ powerpress_page_message_add_notice( __('Please configure your category podcast feed now.') );
356
+
357
+ $_GET['action'] = 'powerpress-editcategoryfeed';
358
+ $_GET['cat'] = $cat_ID;
359
+ }
360
+ }; break;
361
+ case 'powerpress-ping-sites': {
362
+ check_admin_referer('powerpress-ping-sites');
363
+
364
+ require_once( dirname(__FILE__) . '/powerpressadmin-ping-sites.php');
365
+ powerpressadmin_ping_sites_process();
366
+
367
+ $_GET['action'] = 'powerpress-ping-sites';
368
+ }; break;
369
  case 'powerpress-importpodpress': {
370
  check_admin_referer('powerpress-import-podpress');
371
 
389
  powerpressadmin_podpress_delete_data();
390
 
391
  }; break;
392
+ case 'powerpress-save-mode': {
393
+
394
+ if( !isset($_POST['General']['advanced_mode']) )
395
+ powerpress_page_message_add_notice( __('You must select a Mode to continue.') );
396
+
397
+ }; break;
398
  }
399
  }
400
 
440
  powerpress_page_message_add_notice( 'Feed deleted successfully.' );
441
  }
442
  }; break;
443
+ case 'powerpress-delete-category-feed': {
444
+ $cat_ID = $_GET['cat'];
445
+ check_admin_referer('powerpress-delete-category-feed-'.$cat_ID);
446
+
447
+ $Settings = get_option('powerpress_general');
448
+ $key = array_search($cat_ID, $Settings['custom_cat_feeds']);
449
+ if( $key !== false )
450
+ {
451
+ unset( $Settings['custom_cat_feeds'][$key] );
452
+ powerpress_save_settings($Settings); // Delete the feed from the general settings
453
+ }
454
+ delete_option('powerpress_cat_feed_'.$cat_ID); // Delete the actual feed settings
455
+
456
+ powerpress_page_message_add_notice( 'Removed podcast settings for category feed successfully.' );
457
+ }; break;
458
  case 'powerpress-podpress-settings': {
459
  check_admin_referer('powerpress-podpress-settings');
460
 
497
  }; break;
498
  }
499
  }
500
+
501
+
502
+ if( function_exists('powerpress_admin_jquery_init') )
503
+ powerpress_admin_jquery_init();
504
  }
505
 
506
  add_action('init', 'powerpress_admin_init');
507
 
508
+ function powerpress_admin_notices()
509
+ {
510
+ $errors = get_option('powerpress_errors');
511
+ if( $errors )
512
+ {
513
+ delete_option('powerpress_errors');
514
+
515
+ while( list($null, $error) = each($errors) )
516
+ {
517
+ ?>
518
+ <div class="updated"><p><strong><?php echo $error; ?></strong></p></div>
519
+ <?php
520
+ }
521
+ }
522
+ }
523
+
524
+ add_action( 'admin_notices', 'powerpress_admin_notices' );
525
+
526
  function powerpress_save_settings($SettingsNew=false, $field = 'powerpress_general' )
527
  {
528
  // Save general settings
629
  add_menu_page(__('PowerPress'), __('PowerPress'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic', powerpress_get_root_url() . 'powerpress_ico.png');
630
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Basic Settings'), __('Basic Settings'), 1, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic' );
631
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Appearance Settings'), __('Appearance'), 1, 'powerpress/powerpressadmin_appearance.php', 'powerpress_admin_page_appearance' );
632
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress General Feed Settings'), __('Feeds General'), 1, 'powerpress/powerpressadmin_feedsettings.php', 'powerpress_admin_page_feedsettings');
633
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Custom Podcast Feeds'), __('Custom Feeds'), 1, 'powerpress/powerpressadmin_customfeeds.php', 'powerpress_admin_page_customfeeds');
634
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Category Podcast Feeds'), __('Category Feeds'), 1, 'powerpress/powerpressadmin_categoryfeeds.php', 'powerpress_admin_page_categoryfeeds');
635
+
636
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress MP3 Tags'), __('MP3 Tags'), 1, 'powerpress/powerpressadmin_tags.php', 'powerpress_admin_page_tags');
637
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Tools'), __('Tools'), 1, 'powerpress/powerpressadmin_tools.php', 'powerpress_admin_page_tools');
638
  }
639
  else
679
 
680
  // Initialize the important variables:
681
  $MediaURL = $Powerpress['url'];
682
+ if( strpos($MediaURL, 'http://') !== 0 && $Powerpress['hosting'] != 1 ) // If the url entered does not start with a http://
683
  {
684
  $Settings = get_option('powerpress_general');
685
  $MediaURL = rtrim(@$Settings['default_url'], '/') .'/'. $MediaURL;
723
 
724
  if( $Powerpress['set_size'] == 0 || $Powerpress['set_duration'] == 0 )
725
  {
726
+ if( $Powerpress['hosting'] == 1 )
 
 
 
 
727
  {
728
+ if( @$Powerpress['set_size'] == 0 || @$Powerpress['set_duration'] == 0 )
 
729
  {
730
+ $Settings = get_option('powerpress_general');
731
+
732
+ // Get meta info via API
733
+ $api_url = sprintf('%s/media/%s/%s?format=json&info=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'], $Powerpress['url'] );
734
+ $content = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
735
+ if( $content )
 
 
 
736
  {
737
+ $MediaInfo = powerpress_json_decode($content);
738
+ if( @$Powerpress['set_size'] == 0 )
739
+ $FileSize = $MediaInfo['length'];
740
+ if( @$Powerpress['set_duration'] == 0 )
741
+ $Duration = $Duration = powerpress_readable_duration($MediaInfo['duration'], true);
742
  }
 
743
  }
744
  }
745
+ else
 
 
746
  {
747
+ // Lets use the mp3info class:
748
+ require_once('mp3info.class.php');
749
+
750
+ $Mp3Info = new Mp3Info();
751
+ if( $Powerpress['set_duration'] == 0 && $ContentType == 'audio/mpeg' )
752
+ {
753
+ $Mp3Data = $Mp3Info->GetMp3Info($MediaURL);
754
+ if( $Mp3Data )
755
+ {
756
+ if( @$Powerpress['set_size'] == 0 )
757
+ $FileSize = $Mp3Info->GetContentLength();
758
+ $Duration = $Mp3Data['playtime_string'];
759
+ if( substr_count($Duration, ':' ) == 0 )
760
+ {
761
+ if( $Duration < 60 )
762
+ $Duration = '00:00:'.$Duration;
763
+ }
764
+ else if( substr_count($Duration, ':' ) == 1 )
765
+ {
766
+ $Duration = '00:'.$Duration;
767
+ }
768
+ $Duration = powerpress_readable_duration($Duration, true); // Fix so it looks better when viewed for editing
769
+ }
770
+ }
771
+
772
+ // Just get the file size
773
+ if( $Powerpress['set_size'] == 0 && $FileSize == '' )
774
  {
775
+ $headers = wp_get_http_headers($MediaURL);
776
+ if( $headers && $headers['content-length'] )
777
+ {
778
+ $FileSize = (int) $headers['content-length'];
779
+ }
780
  }
781
  }
782
  }
783
 
784
+ if( $ContentType == 'audio/mpg' )
785
+ {
786
+ $Results = powerpress_write_tags($MediaURL, $post->post_title);
787
+
788
+ }
789
+
790
  $EnclosureData = $MediaURL . "\n" . $FileSize . "\n". $ContentType;
791
  $ToSerialize = array();
792
  // iTunes duration
793
+ if( $Powerpress['hosting'] )
794
+ $ToSerialize['hosting'] = 1;
795
  if( $Duration )
796
  $ToSerialize['duration'] = $Duration; // regular expression '/^(\d{1,2}\:)?\d{1,2}\:\d\d$/i' (examples: 1:23, 12:34, 1:23:45, 12:34:56)
797
  // iTunes Subtitle (FUTURE USE)
853
  // If we're moving from draft to published, maybe we should ping iTunes?
854
  if($_POST['prev_status'] == 'draft' && $_POST['publish'] == 'Publish' )
855
  {
856
+ //mail('cio@rawvoice.com', 'WordPress Publish Post', print_r($_POST, true) );
857
+ $Settings = get_option('powerpress_general');
858
+
859
  // Next double check we're looking at a podcast episode...
860
  $Enclosure = get_post_meta($post_ID, 'enclosure', true);
861
  if( $Enclosure )
862
  {
 
863
  if( $Settings['ping_itunes'] && $Settings['itunes_url'] )
864
  {
865
  $PingResults = powerpress_ping_itunes($Settings['itunes_url']);
866
  //mail( 'email@host.com', 'Ping iTunes Results', implode("\n", $PingResults) ); // Let me know how the ping went.
867
  }
868
  }
869
+
870
+ if( $Settings['blubrry_hosting'] )
871
+ powerpress_process_hosting($post_ID); // Call anytime blog post is in the published state
872
+ }
873
+ else if( $_POST['post_status'] == 'publish' )
874
+ {
875
+ $Settings = get_option('powerpress_general');
876
+
877
+ if( $Settings['blubrry_hosting'] )
878
+ powerpress_process_hosting($post_ID); // Call anytime blog post is in the published state
879
  }
880
 
881
  // And we're done!
1070
  powerpress_admin_page_header();
1071
  require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
1072
  powerpress_admin_basic();
1073
+ powerpress_admin_page_footer(true);
1074
  }
1075
 
1076
  // Admin page, advanced mode: appearance settings
1091
  powerpress_admin_page_footer();
1092
  }
1093
 
1094
+ // Admin page, advanced mode: feed settings
1095
+ function powerpress_admin_page_tags()
1096
+ {
1097
+ powerpress_admin_page_header('powerpress/powerpressadmin_tags.php');
1098
+ require_once( dirname(__FILE__).'/powerpressadmin-tags.php');
1099
+ powerpress_admin_tags();
1100
+ powerpress_admin_page_footer();
1101
+ }
1102
+
1103
  // Admin page, advanced mode: custom feeds
1104
  function powerpress_admin_page_customfeeds()
1105
  {
1120
  }
1121
  }
1122
 
1123
+ // Category feeds
1124
+ function powerpress_admin_page_categoryfeeds()
1125
+ {
1126
+ switch( @$_GET['action'] )
1127
+ {
1128
+ case 'powerpress-editcategoryfeed' : {
1129
+ powerpress_admin_page_header('powerpress/powerpressadmin_categoryfeeds.php');
1130
+ require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
1131
+ powerpress_admin_editfeed(false, $_GET['cat']);
1132
+ powerpress_admin_page_footer();
1133
+ }; break;
1134
+ default: {
1135
+ powerpress_admin_page_header('powerpress/powerpressadmin_categoryfeeds.php', 'powerpress-add-categoryfeed');
1136
+ require_once( dirname(__FILE__).'/powerpressadmin-categoryfeeds.php');
1137
+ powerpress_admin_categoryfeeds();
1138
+ powerpress_admin_page_footer(false);
1139
+ };
1140
+ }
1141
+ }
1142
+
1143
  // Admin page, advanced mode: tools
1144
  function powerpress_admin_page_tools()
1145
  {
1157
  powerpress_admin_mt();
1158
  powerpress_admin_page_footer(false);
1159
  }; break;
1160
+ case 'powerpress-ping-sites': {
1161
+ powerpress_admin_page_header('powerpress/powerpressadmin_tools.php', 'powerpress-ping-sites');
1162
+ require_once( dirname(__FILE__).'/powerpressadmin-ping-sites.php');
1163
+ powerpress_admin_ping_sites();
1164
+ powerpress_admin_page_footer(false);
1165
+ }; break;
1166
  default: {
1167
  powerpress_admin_page_header('powerpress/powerpressadmin_tools.php');
1168
  require_once( dirname(__FILE__).'/powerpressadmin-tools.php');
1189
  function powerpress_admin_page()
1190
  {
1191
  powerpress_admin_page_header();
1192
+
1193
+ $Settings = get_option('powerpress_general');
1194
+ //print_r($Settings);
1195
+ //exit;
1196
+ if( !isset($Settings['advanced_mode']) )
1197
+ {
1198
+ require_once( dirname(__FILE__).'/powerpressadmin-mode.php');
1199
+ powerpress_admin_mode();
1200
+ powerpress_admin_page_footer(false);
1201
+ }
1202
+ else
1203
+ {
1204
+ // Simple mode:
1205
+ require_once( dirname(__FILE__).'/powerpressadmin-basic.php');
1206
+ powerpress_admin_basic();
1207
 
1208
+ require_once( dirname(__FILE__).'/powerpressadmin-editfeed.php');
1209
+ powerpress_admin_editfeed();
 
 
 
1210
 
1211
+ powerpress_admin_page_footer(true);
1212
+ }
1213
  }
1214
 
1215
  function powerpress_shutdown()
1251
  return array('success'=>true, 'content'=>$tempdata, 'feed_url'=>trim($FeedURL), 'podcast_id'=>trim($PodcastID) );
1252
  }
1253
 
1254
+ function powerpress_remote_fopen($url, $basic_auth = false, $post_args = array(), $timeout = 10 )
1255
  {
1256
  if( function_exists( 'curl_init' ) ) // Preferred method of connecting
1257
  {
1263
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Follow location redirection
1264
  curl_setopt($curl, CURLOPT_MAXREDIRS, 5); // Location redirection limit
1265
  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2 ); // Connect time out
1266
+ curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); // The maximum number of seconds to execute.
1267
  curl_setopt($curl, CURLOPT_USERAGENT, 'Blubrry PowerPress/'.POWERPRESS_VERSION);
1268
  if( strtolower(substr($url, 0, 5)) == 'https' )
1269
  {
1270
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
1271
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
1272
  }
1273
+ // HTTP Authentication
1274
  if( $basic_auth )
1275
  {
1276
  curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$basic_auth) );
1277
  }
1278
+ // HTTP Post:
1279
+ if( count($post_args) > 0 )
1280
+ {
1281
+ $post_query = '';
1282
+ while( list($name,$value) = each($post_args) )
1283
+ {
1284
+ if( $post_query != '' )
1285
+ $post_query .= '&';
1286
+ $post_query .= $name;
1287
+ $post_query .= '=';
1288
+ $post_query .= urlencode($value);
1289
+ }
1290
+ curl_setopt($curl, CURLOPT_POST, 1);
1291
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $post_query);
1292
+ }
1293
 
1294
  $content = curl_exec($curl);
1295
  $error = curl_errno($curl);
1303
  if( version_compare('2.7', $wp_version, '<=') ) // Lets us specify the user agent and set the basic auth string...
1304
  {
1305
  $options = array();
1306
+ $options['timeout'] = $timeout;
1307
  $options['user-agent'] = 'Blubrry PowerPress/'.POWERPRESS_VERSION;
1308
  if( $basicauth )
1309
  $options['headers'][] = 'Authorization: Basic '.$basic_auth;
1310
+ if( count($post_args) > 0 )
1311
+ {
1312
+ $options['body'] = $post_args;
1313
+ $response = wp_remote_post( $uri, $options );
1314
+ }
1315
+ else
1316
+ {
1317
+ $response = wp_remote_get( $uri, $options );
1318
+ }
1319
 
 
 
1320
  if ( is_wp_error( $response ) )
1321
  return false;
1322
 
1323
  return $response['body'];
1324
  }
1325
+
1326
+ if( count($post_args) > 0 )
1327
+ {
1328
+ if( !function_exists('fsockopen') )
1329
+ return false; // This was our last attempt, we failed...
1330
+
1331
+ $post_query = '';
1332
+ while( list($name,$value) = each($post_args) )
1333
+ {
1334
+ if( $post_query != '' )
1335
+ $post_query .= '&';
1336
+ $post_query .= $name;
1337
+ $post_query .= '=';
1338
+ $post_query .= urlencode($value);
1339
+ }
1340
+ $url_parts = parse_url($url);
1341
+ $host = $url_parts['host'];
1342
+ $port = ($url_parts['scheme']=='https'?443:80);
1343
+ if( isset($url_parts['port']) )
1344
+ $port = $url_parts['port'];
1345
+
1346
+ $http_request = "POST /updated-batch/ HTTP/1.0\r\n";
1347
+ $http_request .= "Host: $host\r\n";
1348
+ if( $basic_auth )
1349
+ $http_request .= 'Authorization: Basic '. $basic_auth ."\r\n";
1350
+ $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
1351
+ $http_request .= 'Content-Length: ' . strlen($post_query) . "\r\n";
1352
+ $http_request .= 'User-Agent: Blubrry PowerPress/'.POWERPRESS_VERSION. "\r\n";
1353
+ $http_request .= "\r\n";
1354
+ $http_request .= $post_query;
1355
+
1356
+ $response = '';
1357
+ $fp = @fsockopen($host, $port, $errno, $errstr, 5);
1358
+ if( $fp )
1359
+ {
1360
+ fwrite($fp, $http_request);
1361
+ while ( !feof($fs) )
1362
+ $response .= fgets($fs, 1160); // One TCP-IP packet
1363
+ fclose($fs);
1364
+ }
1365
+
1366
+ $response = explode("\r\n\r\n", $response, 2);
1367
+ if( count($response) > 1 )
1368
+ return $response[1];
1369
+ return false;
1370
+ }
1371
 
1372
  if( $basic_auth )
1373
  {
1381
  return wp_remote_fopen($url);
1382
  }
1383
 
1384
+ // Process any episodes for the specified post that have been marked for hosting and that do not have full URLs...
1385
+ function powerpress_process_hosting($post_ID)
1386
+ {
1387
+ $errors = array();
1388
+ $Settings = get_option('powerpress_general');
1389
+ $CustomFeeds = array('podcast'=>'podcast');
1390
+ if( is_array($Settings['custom_feeds']) )
1391
+ $CustomFeeds = $Settings['custom_feeds'];
1392
+
1393
+ while( list($feed_slug,$null) = each($CustomFeeds) )
1394
+ {
1395
+ $field = 'enclosure';
1396
+ if( $feed_slug != 'podcast' )
1397
+ $field = '_'.$feed_slug.':enclosure';
1398
+ $EnclosureData = get_post_meta($post_ID, $field, true);
1399
+
1400
+ if( $EnclosureData )
1401
+ {
1402
+ list($EnclosureURL, $EnclosureSize, $EnclosureType, $Serialized) = split("\n", $EnclosureData);
1403
+ $EnclosureURL = trim($EnclosureURL);
1404
+ $EnclosureType = trim($EnclosureType);
1405
+ $EnclosureSize = trim($EnclosureSize);
1406
+ $EpisodeData = unserialize($Serialized);
1407
+ if( strtolower(substr($EnclosureURL, 0, 7) ) != 'http://' && $EpisodeData && isset($EpisodeData['hosting']) && $EpisodeData['hosting'] )
1408
+ {
1409
+ $error = false;
1410
+ // First we need to get media information...
1411
+ $api_url = sprintf('%s/media/%s/%s?format=json&info=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), urlencode($Settings['blubrry_program_keyword']), urlencode($EnclosureURL) );
1412
+ $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth']);
1413
+ $results = powerpress_json_decode($json_data);
1414
+
1415
+ if( is_array($results) && !isset($results['error']) )
1416
+ {
1417
+ if( isset($results['duration']) && $results['duration'] )
1418
+ $EpisodeData['duration'] = $results['duration'];
1419
+ if( isset($results['content-type']) && $results['content-type'] )
1420
+ $EnclosureType = $results['content-type'];
1421
+ if( isset($results['length']) && $results['length'] )
1422
+ $EnclosureSize = $results['length'];
1423
+ }
1424
+ else if( isset($results['error']) )
1425
+ {
1426
+ $error = 'Blubrry Hosting Error (media info): '. $results['error'];
1427
+ }
1428
+ else
1429
+ {
1430
+ $error = 'Blubrry Hosting Error: An error occurred obtaining media information from <em>'. $EnclosureURL .'</em>. ';
1431
+ $error = 'Blubrry Hosting Error (publish): An error occurred publishing media '. $EnclosureURL .'.';
1432
+ $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1433
+ $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
1434
+ }
1435
+
1436
+ if( $error == false )
1437
+ {
1438
+ $api_url = sprintf('%s/media/%s/%s?format=json&publish=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), urlencode($Settings['blubrry_program_keyword']), urlencode($EnclosureURL) );
1439
+ $json_data = powerpress_remote_fopen($api_url, $Settings['blubrry_auth'], array(), 60*30); // give this up to 30 minutes, though 3 seocnds to 20 seconds is all one should need.
1440
+ $results = powerpress_json_decode($json_data);
1441
+
1442
+ if( is_array($results) && !isset($results['error']) )
1443
+ {
1444
+ $EnclosureURL = $results['media_url'];
1445
+ $EnclosureData = $EnclosureURL . "\n" . $EnclosureSize . "\n". $EnclosureType . "\n" . serialize($EpisodeData);
1446
+ update_post_meta($post_ID, $field, $EnclosureData);
1447
+ }
1448
+ else if( isset($results['error']) )
1449
+ {
1450
+ $error = 'Blubrry Hosting Error (publish): '. $results['error'];
1451
+
1452
+ }
1453
+ else
1454
+ {
1455
+ $rand_id = rand(100,2000);
1456
+ $error = 'Blubrry Hosting Error (publish): An error occurred publishing media <em>'. $EnclosureURL .'</em>. ';
1457
+ $error .= '<a href="#" onclick="document.getElementById(\'powerpress_error_'. $rand_id .'\');this.style.display=\'none\';return false;">Display Error</a>';
1458
+ $error .= '<div id="powerpress_error_'. $rand_id .'" style="display: none;">'. $json_data .'</div>';
1459
+ }
1460
+ }
1461
+
1462
+ if( $error )
1463
+ {
1464
+ $errors[] = $error;
1465
+ // TODO Need to print an eerror message at the top of the screen
1466
+ //mail('cio@rawvoice.com', 'Publishing From WordPress', print_r( array('file'=>$EnclosureURL, 'episode_data'=>$EpisodeData, 'error'=>$g_powerpress_error), true) );
1467
+ }
1468
+ // Make the API call here to publish media file...
1469
+ //
1470
+ }
1471
+ }
1472
+ }
1473
+
1474
+ if( count($errors) > 0 )
1475
+ {
1476
+ add_option('powerpress_errors', $errors);
1477
+ }
1478
+
1479
+ }
1480
+
1481
+ function powerpress_json_decode($value)
1482
+ {
1483
+ if( function_exists('json_decode') )
1484
+ return json_decode($value, true);
1485
+
1486
+ require_once( dirname(__FILE__).'/3rdparty/JSON.php');
1487
+ $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
1488
+ return $json->decode($value);
1489
+ }
1490
+
1491
  // Import podpress settings
1492
  function powerpress_admin_import_podpress_settings()
1493
  {
1649
  return $Settings;
1650
  }
1651
 
1652
+ function powerpress_write_tags($file, $post_title)
1653
+ {
1654
+ // Use the Blubrry API to write ID3 tags. to the media...
1655
+
1656
+ $Settings = get_option('powerpress_general');
1657
+
1658
+ $PostArgs = array();
1659
+ $Fields = array('title','artist','album','genre','year','track','composer','copyright','url');
1660
+ while( list($null,$field) = each($Fields) )
1661
+ {
1662
+ if( @$Settings[ 'tag_'.$field ] != '' )
1663
+ {
1664
+ $PostArgs[ $field ] = $Settings[ 'tag_'.$field ];
1665
+ if( $field == 'track' )
1666
+ powerpress_save_settings(array('tag_track'=>$NewNumber), 'powerpress_general');
1667
+ }
1668
+ else
1669
+ {
1670
+ switch($field)
1671
+ {
1672
+ case 'title': {
1673
+ $PostArgs['title'] = $post_title;
1674
+ }; break;
1675
+ case 'album': {
1676
+ $PostArgs['album'] = get_bloginfo('name');
1677
+ }; break;
1678
+ case 'genre': {
1679
+ $PostArgs['genre'] = 'Podcast';
1680
+ }; break;
1681
+ case 'year': {
1682
+ $PostArgs['year'] = date('Y');
1683
+ }; break;
1684
+ case 'artist':
1685
+ case 'composer': {
1686
+ if( @$Settings['itunes_talent_name'] )
1687
+ $PostArgs[ $field ] = $Settings['itunes_talent_name'];
1688
+ }; break;
1689
+ case 'copyright': {
1690
+ if( @$Settings['itunes_talent_name'] )
1691
+ $PostArgs['copyright'] = '(c) '.$Settings['itunes_talent_name'];
1692
+ }; break;
1693
+ case 'url': {
1694
+ $PostArgs['url'] = get_bloginfo('url');
1695
+ }; break;
1696
+ }
1697
+ }
1698
+ }
1699
+
1700
+ // Get meta info via API
1701
+ $api_url = sprintf('%s/media/%s/%s?format=json&id3=true', rtrim(POWERPRESS_BLUBRRY_API_URL, '/'), $Settings['blubrry_program_keyword'], $file );
1702
+ $content = powerpress_remote_fopen($api_url, $Settings['blubrry_auth'], $PostArgs );
1703
+ if( $content )
1704
+ {
1705
+ $Results = powerpress_json_decode($content);
1706
+ if( $Results && is_array($Results) )
1707
+ return $Results;
1708
+ }
1709
+
1710
+ return array('error'=>'Error occurred writing MP3 ID3 Tags.');
1711
+ }
1712
+
1713
+ require_once('powerpressadmin-jquery.php');
1714
+ // Only include the dashboard when appropriate.
1715
+ require_once('powerpressadmin-dashboard.php');
1716
+
1717
  ?>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Angelo Mandato, Blubrry.com
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats
4
  Requires at least: 2.6.0
5
  Tested up to: 2.7.1
6
- Stable tag: 0.7.3
7
 
8
  Add podcasting support to your blog.
9
 
@@ -18,6 +18,10 @@ Features:
18
  * Integrated audio/video media player
19
  * Podcast Only Feed
20
  * Custom Podcast Feeds (no limit)
 
 
 
 
21
  * iTunes RSS tags
22
  * Enhanced iTunes summaries from blog posts option
23
  * iTunes album/cover art
@@ -68,6 +72,10 @@ As a alternative, PowerPress allows you to create additional Custom Podcast Feed
68
 
69
  == Changelog ==
70
 
 
 
 
 
71
  0.7.3 released on 4/21/2009
72
  Fixed POWERPRESS _CONTENT _ACTION _PRIORITY define typo, incremented version check (PowerPress now requires WordPress 2.6.x), fixed bug where player.js was not included in the header if simple mode was used, made the enhanced itunes summary set on by default for new installations, detecting additional file types, add new import episodes previously created in Blogger/Movable Type, fix bug where channel link matches image link, no longer including empty duration values in feeds, fixed bug with curl-setopt function printing a PHP warning in some situations, added warning when user enters an unknown media redirect url.
73
 
3
  Tags: podcast, podcasting, itunes, enclosure, zune, iphone, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats
4
  Requires at least: 2.6.0
5
  Tested up to: 2.7.1
6
+ Stable tag: 0.8.0
7
 
8
  Add podcasting support to your blog.
9
 
18
  * Integrated audio/video media player
19
  * Podcast Only Feed
20
  * Custom Podcast Feeds (no limit)
21
+ * Category Podcast Feeds
22
+ * Integrated Media Hosting via Blubrry Services
23
+ * Integrated Media Statistics via Blubrry Services
24
+ * Mp3 ID3 Tagging via Blubrry Services
25
  * iTunes RSS tags
26
  * Enhanced iTunes summaries from blog posts option
27
  * iTunes album/cover art
72
 
73
  == Changelog ==
74
 
75
+ 0.8.0 released on 5/28/2009
76
+ Fixed bug with merging custom feed settings with regular feed settings, fixed bug where exerpt not used as itunes summary, added new error reporting when editing posts/pages and integrated Blubrry Services (optional), Added multi-language support to the custom podcast feeds. Added better listing of custom feeds on the main feed settings page. Add new feature under Tools section for adding Update Services / Ping sites relevant to podcasting. Added new select mode screen for new installations. Added podcast category feeds. Added statistics view to WordPress Dashboard. Write mp3 ID3 edit screen added for Blubrry Hosting users.
77
+
78
+
79
  0.7.3 released on 4/21/2009
80
  Fixed POWERPRESS _CONTENT _ACTION _PRIORITY define typo, incremented version check (PowerPress now requires WordPress 2.6.x), fixed bug where player.js was not included in the header if simple mode was used, made the enhanced itunes summary set on by default for new installations, detecting additional file types, add new import episodes previously created in Blogger/Movable Type, fix bug where channel link matches image link, no longer including empty duration values in feeds, fixed bug with curl-setopt function printing a PHP warning in some situations, added warning when user enters an unknown media redirect url.
81