Edit File by line
/home/barbar84/www/wp-inclu.../SimplePi...
File: Enclosure.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* SimplePie
[2] Fix | Delete
*
[3] Fix | Delete
* A PHP-Based RSS and Atom Feed Framework.
[4] Fix | Delete
* Takes the hard work out of managing a complete RSS/Atom solution.
[5] Fix | Delete
*
[6] Fix | Delete
* Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
[7] Fix | Delete
* All rights reserved.
[8] Fix | Delete
*
[9] Fix | Delete
* Redistribution and use in source and binary forms, with or without modification, are
[10] Fix | Delete
* permitted provided that the following conditions are met:
[11] Fix | Delete
*
[12] Fix | Delete
* * Redistributions of source code must retain the above copyright notice, this list of
[13] Fix | Delete
* conditions and the following disclaimer.
[14] Fix | Delete
*
[15] Fix | Delete
* * Redistributions in binary form must reproduce the above copyright notice, this list
[16] Fix | Delete
* of conditions and the following disclaimer in the documentation and/or other materials
[17] Fix | Delete
* provided with the distribution.
[18] Fix | Delete
*
[19] Fix | Delete
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
[20] Fix | Delete
* to endorse or promote products derived from this software without specific prior
[21] Fix | Delete
* written permission.
[22] Fix | Delete
*
[23] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
[24] Fix | Delete
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
[25] Fix | Delete
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
[26] Fix | Delete
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
[27] Fix | Delete
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
[28] Fix | Delete
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[29] Fix | Delete
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
[30] Fix | Delete
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
[31] Fix | Delete
* POSSIBILITY OF SUCH DAMAGE.
[32] Fix | Delete
*
[33] Fix | Delete
* @package SimplePie
[34] Fix | Delete
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
[35] Fix | Delete
* @author Ryan Parman
[36] Fix | Delete
* @author Sam Sneddon
[37] Fix | Delete
* @author Ryan McCue
[38] Fix | Delete
* @link http://simplepie.org/ SimplePie
[39] Fix | Delete
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
[40] Fix | Delete
*/
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Handles everything related to enclosures (including Media RSS and iTunes RSS)
[44] Fix | Delete
*
[45] Fix | Delete
* Used by {@see SimplePie_Item::get_enclosure()} and {@see SimplePie_Item::get_enclosures()}
[46] Fix | Delete
*
[47] Fix | Delete
* This class can be overloaded with {@see SimplePie::set_enclosure_class()}
[48] Fix | Delete
*
[49] Fix | Delete
* @package SimplePie
[50] Fix | Delete
* @subpackage API
[51] Fix | Delete
*/
[52] Fix | Delete
class SimplePie_Enclosure
[53] Fix | Delete
{
[54] Fix | Delete
/**
[55] Fix | Delete
* @var string
[56] Fix | Delete
* @see get_bitrate()
[57] Fix | Delete
*/
[58] Fix | Delete
var $bitrate;
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* @var array
[62] Fix | Delete
* @see get_captions()
[63] Fix | Delete
*/
[64] Fix | Delete
var $captions;
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* @var array
[68] Fix | Delete
* @see get_categories()
[69] Fix | Delete
*/
[70] Fix | Delete
var $categories;
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* @var int
[74] Fix | Delete
* @see get_channels()
[75] Fix | Delete
*/
[76] Fix | Delete
var $channels;
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* @var SimplePie_Copyright
[80] Fix | Delete
* @see get_copyright()
[81] Fix | Delete
*/
[82] Fix | Delete
var $copyright;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* @var array
[86] Fix | Delete
* @see get_credits()
[87] Fix | Delete
*/
[88] Fix | Delete
var $credits;
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* @var string
[92] Fix | Delete
* @see get_description()
[93] Fix | Delete
*/
[94] Fix | Delete
var $description;
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* @var int
[98] Fix | Delete
* @see get_duration()
[99] Fix | Delete
*/
[100] Fix | Delete
var $duration;
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* @var string
[104] Fix | Delete
* @see get_expression()
[105] Fix | Delete
*/
[106] Fix | Delete
var $expression;
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* @var string
[110] Fix | Delete
* @see get_framerate()
[111] Fix | Delete
*/
[112] Fix | Delete
var $framerate;
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* @var string
[116] Fix | Delete
* @see get_handler()
[117] Fix | Delete
*/
[118] Fix | Delete
var $handler;
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* @var array
[122] Fix | Delete
* @see get_hashes()
[123] Fix | Delete
*/
[124] Fix | Delete
var $hashes;
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* @var string
[128] Fix | Delete
* @see get_height()
[129] Fix | Delete
*/
[130] Fix | Delete
var $height;
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* @deprecated
[134] Fix | Delete
* @var null
[135] Fix | Delete
*/
[136] Fix | Delete
var $javascript;
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* @var array
[140] Fix | Delete
* @see get_keywords()
[141] Fix | Delete
*/
[142] Fix | Delete
var $keywords;
[143] Fix | Delete
[144] Fix | Delete
/**
[145] Fix | Delete
* @var string
[146] Fix | Delete
* @see get_language()
[147] Fix | Delete
*/
[148] Fix | Delete
var $lang;
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* @var string
[152] Fix | Delete
* @see get_length()
[153] Fix | Delete
*/
[154] Fix | Delete
var $length;
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* @var string
[158] Fix | Delete
* @see get_link()
[159] Fix | Delete
*/
[160] Fix | Delete
var $link;
[161] Fix | Delete
[162] Fix | Delete
/**
[163] Fix | Delete
* @var string
[164] Fix | Delete
* @see get_medium()
[165] Fix | Delete
*/
[166] Fix | Delete
var $medium;
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* @var string
[170] Fix | Delete
* @see get_player()
[171] Fix | Delete
*/
[172] Fix | Delete
var $player;
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* @var array
[176] Fix | Delete
* @see get_ratings()
[177] Fix | Delete
*/
[178] Fix | Delete
var $ratings;
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* @var array
[182] Fix | Delete
* @see get_restrictions()
[183] Fix | Delete
*/
[184] Fix | Delete
var $restrictions;
[185] Fix | Delete
[186] Fix | Delete
/**
[187] Fix | Delete
* @var string
[188] Fix | Delete
* @see get_sampling_rate()
[189] Fix | Delete
*/
[190] Fix | Delete
var $samplingrate;
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* @var array
[194] Fix | Delete
* @see get_thumbnails()
[195] Fix | Delete
*/
[196] Fix | Delete
var $thumbnails;
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* @var string
[200] Fix | Delete
* @see get_title()
[201] Fix | Delete
*/
[202] Fix | Delete
var $title;
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* @var string
[206] Fix | Delete
* @see get_type()
[207] Fix | Delete
*/
[208] Fix | Delete
var $type;
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* @var string
[212] Fix | Delete
* @see get_width()
[213] Fix | Delete
*/
[214] Fix | Delete
var $width;
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Constructor, used to input the data
[218] Fix | Delete
*
[219] Fix | Delete
* For documentation on all the parameters, see the corresponding
[220] Fix | Delete
* properties and their accessors
[221] Fix | Delete
*
[222] Fix | Delete
* @uses idna_convert If available, this will convert an IDN
[223] Fix | Delete
*/
[224] Fix | Delete
public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
[225] Fix | Delete
{
[226] Fix | Delete
$this->bitrate = $bitrate;
[227] Fix | Delete
$this->captions = $captions;
[228] Fix | Delete
$this->categories = $categories;
[229] Fix | Delete
$this->channels = $channels;
[230] Fix | Delete
$this->copyright = $copyright;
[231] Fix | Delete
$this->credits = $credits;
[232] Fix | Delete
$this->description = $description;
[233] Fix | Delete
$this->duration = $duration;
[234] Fix | Delete
$this->expression = $expression;
[235] Fix | Delete
$this->framerate = $framerate;
[236] Fix | Delete
$this->hashes = $hashes;
[237] Fix | Delete
$this->height = $height;
[238] Fix | Delete
$this->keywords = $keywords;
[239] Fix | Delete
$this->lang = $lang;
[240] Fix | Delete
$this->length = $length;
[241] Fix | Delete
$this->link = $link;
[242] Fix | Delete
$this->medium = $medium;
[243] Fix | Delete
$this->player = $player;
[244] Fix | Delete
$this->ratings = $ratings;
[245] Fix | Delete
$this->restrictions = $restrictions;
[246] Fix | Delete
$this->samplingrate = $samplingrate;
[247] Fix | Delete
$this->thumbnails = $thumbnails;
[248] Fix | Delete
$this->title = $title;
[249] Fix | Delete
$this->type = $type;
[250] Fix | Delete
$this->width = $width;
[251] Fix | Delete
[252] Fix | Delete
if (class_exists('idna_convert'))
[253] Fix | Delete
{
[254] Fix | Delete
$idn = new idna_convert();
[255] Fix | Delete
$parsed = SimplePie_Misc::parse_url($link);
[256] Fix | Delete
$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
[257] Fix | Delete
}
[258] Fix | Delete
$this->handler = $this->get_handler(); // Needs to load last
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* String-ified version
[263] Fix | Delete
*
[264] Fix | Delete
* @return string
[265] Fix | Delete
*/
[266] Fix | Delete
public function __toString()
[267] Fix | Delete
{
[268] Fix | Delete
// There is no $this->data here
[269] Fix | Delete
return md5(serialize($this));
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Get the bitrate
[274] Fix | Delete
*
[275] Fix | Delete
* @return string|null
[276] Fix | Delete
*/
[277] Fix | Delete
public function get_bitrate()
[278] Fix | Delete
{
[279] Fix | Delete
if ($this->bitrate !== null)
[280] Fix | Delete
{
[281] Fix | Delete
return $this->bitrate;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
return null;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Get a single caption
[289] Fix | Delete
*
[290] Fix | Delete
* @param int $key
[291] Fix | Delete
* @return SimplePie_Caption|null
[292] Fix | Delete
*/
[293] Fix | Delete
public function get_caption($key = 0)
[294] Fix | Delete
{
[295] Fix | Delete
$captions = $this->get_captions();
[296] Fix | Delete
if (isset($captions[$key]))
[297] Fix | Delete
{
[298] Fix | Delete
return $captions[$key];
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
return null;
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
/**
[305] Fix | Delete
* Get all captions
[306] Fix | Delete
*
[307] Fix | Delete
* @return array|null Array of {@see SimplePie_Caption} objects
[308] Fix | Delete
*/
[309] Fix | Delete
public function get_captions()
[310] Fix | Delete
{
[311] Fix | Delete
if ($this->captions !== null)
[312] Fix | Delete
{
[313] Fix | Delete
return $this->captions;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
return null;
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
/**
[320] Fix | Delete
* Get a single category
[321] Fix | Delete
*
[322] Fix | Delete
* @param int $key
[323] Fix | Delete
* @return SimplePie_Category|null
[324] Fix | Delete
*/
[325] Fix | Delete
public function get_category($key = 0)
[326] Fix | Delete
{
[327] Fix | Delete
$categories = $this->get_categories();
[328] Fix | Delete
if (isset($categories[$key]))
[329] Fix | Delete
{
[330] Fix | Delete
return $categories[$key];
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
return null;
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
/**
[337] Fix | Delete
* Get all categories
[338] Fix | Delete
*
[339] Fix | Delete
* @return array|null Array of {@see SimplePie_Category} objects
[340] Fix | Delete
*/
[341] Fix | Delete
public function get_categories()
[342] Fix | Delete
{
[343] Fix | Delete
if ($this->categories !== null)
[344] Fix | Delete
{
[345] Fix | Delete
return $this->categories;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
return null;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Get the number of audio channels
[353] Fix | Delete
*
[354] Fix | Delete
* @return int|null
[355] Fix | Delete
*/
[356] Fix | Delete
public function get_channels()
[357] Fix | Delete
{
[358] Fix | Delete
if ($this->channels !== null)
[359] Fix | Delete
{
[360] Fix | Delete
return $this->channels;
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
return null;
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
/**
[367] Fix | Delete
* Get the copyright information
[368] Fix | Delete
*
[369] Fix | Delete
* @return SimplePie_Copyright|null
[370] Fix | Delete
*/
[371] Fix | Delete
public function get_copyright()
[372] Fix | Delete
{
[373] Fix | Delete
if ($this->copyright !== null)
[374] Fix | Delete
{
[375] Fix | Delete
return $this->copyright;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
return null;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* Get a single credit
[383] Fix | Delete
*
[384] Fix | Delete
* @param int $key
[385] Fix | Delete
* @return SimplePie_Credit|null
[386] Fix | Delete
*/
[387] Fix | Delete
public function get_credit($key = 0)
[388] Fix | Delete
{
[389] Fix | Delete
$credits = $this->get_credits();
[390] Fix | Delete
if (isset($credits[$key]))
[391] Fix | Delete
{
[392] Fix | Delete
return $credits[$key];
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
return null;
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
/**
[399] Fix | Delete
* Get all credits
[400] Fix | Delete
*
[401] Fix | Delete
* @return array|null Array of {@see SimplePie_Credit} objects
[402] Fix | Delete
*/
[403] Fix | Delete
public function get_credits()
[404] Fix | Delete
{
[405] Fix | Delete
if ($this->credits !== null)
[406] Fix | Delete
{
[407] Fix | Delete
return $this->credits;
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
return null;
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
/**
[414] Fix | Delete
* Get the description of the enclosure
[415] Fix | Delete
*
[416] Fix | Delete
* @return string|null
[417] Fix | Delete
*/
[418] Fix | Delete
public function get_description()
[419] Fix | Delete
{
[420] Fix | Delete
if ($this->description !== null)
[421] Fix | Delete
{
[422] Fix | Delete
return $this->description;
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
return null;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
/**
[429] Fix | Delete
* Get the duration of the enclosure
[430] Fix | Delete
*
[431] Fix | Delete
* @param bool $convert Convert seconds into hh:mm:ss
[432] Fix | Delete
* @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
[433] Fix | Delete
*/
[434] Fix | Delete
public function get_duration($convert = false)
[435] Fix | Delete
{
[436] Fix | Delete
if ($this->duration !== null)
[437] Fix | Delete
{
[438] Fix | Delete
if ($convert)
[439] Fix | Delete
{
[440] Fix | Delete
$time = SimplePie_Misc::time_hms($this->duration);
[441] Fix | Delete
return $time;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
return $this->duration;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
return null;
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
/**
[451] Fix | Delete
* Get the expression
[452] Fix | Delete
*
[453] Fix | Delete
* @return string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full'
[454] Fix | Delete
*/
[455] Fix | Delete
public function get_expression()
[456] Fix | Delete
{
[457] Fix | Delete
if ($this->expression !== null)
[458] Fix | Delete
{
[459] Fix | Delete
return $this->expression;
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
return 'full';
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
/**
[466] Fix | Delete
* Get the file extension
[467] Fix | Delete
*
[468] Fix | Delete
* @return string|null
[469] Fix | Delete
*/
[470] Fix | Delete
public function get_extension()
[471] Fix | Delete
{
[472] Fix | Delete
if ($this->link !== null)
[473] Fix | Delete
{
[474] Fix | Delete
$url = SimplePie_Misc::parse_url($this->link);
[475] Fix | Delete
if ($url['path'] !== '')
[476] Fix | Delete
{
[477] Fix | Delete
return pathinfo($url['path'], PATHINFO_EXTENSION);
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
return null;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* Get the framerate (in frames-per-second)
[485] Fix | Delete
*
[486] Fix | Delete
* @return string|null
[487] Fix | Delete
*/
[488] Fix | Delete
public function get_framerate()
[489] Fix | Delete
{
[490] Fix | Delete
if ($this->framerate !== null)
[491] Fix | Delete
{
[492] Fix | Delete
return $this->framerate;
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
return null;
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
/**
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function