Edit File by line
/home/barbar84/www/wp-inclu.../SimplePi...
File: Parser.php
if (isset($entry['properties']['name'][0])) {
[500] Fix | Delete
$title = $entry['properties']['name'][0];
[501] Fix | Delete
if (isset($title['value'])) $title = $title['value'];
[502] Fix | Delete
$item['title'] = array(array('data' => $title));
[503] Fix | Delete
}
[504] Fix | Delete
if (isset($entry['properties']['author'][0]) || isset($feed_author)) {
[505] Fix | Delete
// author is a special case, it can be plain text or an h-card array.
[506] Fix | Delete
// If it's plain text it can also be a url that should be followed to
[507] Fix | Delete
// get the actual h-card.
[508] Fix | Delete
$author = isset($entry['properties']['author'][0]) ?
[509] Fix | Delete
$entry['properties']['author'][0] : $feed_author;
[510] Fix | Delete
if (!is_string($author)) {
[511] Fix | Delete
$author = $this->parse_hcard($author);
[512] Fix | Delete
}
[513] Fix | Delete
else if (strpos($author, 'http') === 0) {
[514] Fix | Delete
if (isset($author_cache[$author])) {
[515] Fix | Delete
$author = $author_cache[$author];
[516] Fix | Delete
}
[517] Fix | Delete
else {
[518] Fix | Delete
$mf = Mf2\fetch($author);
[519] Fix | Delete
foreach ($mf['items'] as $hcard) {
[520] Fix | Delete
// Only interested in an h-card by itself in this case.
[521] Fix | Delete
if (!in_array('h-card', $hcard['type'])) {
[522] Fix | Delete
continue;
[523] Fix | Delete
}
[524] Fix | Delete
// It must have a url property matching what we fetched.
[525] Fix | Delete
if (!isset($hcard['properties']['url']) ||
[526] Fix | Delete
!(in_array($author, $hcard['properties']['url']))) {
[527] Fix | Delete
continue;
[528] Fix | Delete
}
[529] Fix | Delete
// Save parse_hcard the trouble of finding the correct url.
[530] Fix | Delete
$hcard['properties']['url'][0] = $author;
[531] Fix | Delete
// Cache this h-card for the next h-entry to check.
[532] Fix | Delete
$author_cache[$author] = $this->parse_hcard($hcard);
[533] Fix | Delete
$author = $author_cache[$author];
[534] Fix | Delete
break;
[535] Fix | Delete
}
[536] Fix | Delete
}
[537] Fix | Delete
}
[538] Fix | Delete
$item['author'] = array(array('data' => $author));
[539] Fix | Delete
}
[540] Fix | Delete
if (isset($entry['properties']['photo'][0])) {
[541] Fix | Delete
// If a photo is also in content, don't need to add it again here.
[542] Fix | Delete
$content = '';
[543] Fix | Delete
if (isset($entry['properties']['content'][0]['html'])) {
[544] Fix | Delete
$content = $entry['properties']['content'][0]['html'];
[545] Fix | Delete
}
[546] Fix | Delete
$photo_list = array();
[547] Fix | Delete
for ($j = 0; $j < count($entry['properties']['photo']); $j++) {
[548] Fix | Delete
$photo = $entry['properties']['photo'][$j];
[549] Fix | Delete
if (!empty($photo) && strpos($content, $photo) === false) {
[550] Fix | Delete
$photo_list[] = $photo;
[551] Fix | Delete
}
[552] Fix | Delete
}
[553] Fix | Delete
// When there's more than one photo show the first and use a lightbox.
[554] Fix | Delete
// Need a permanent, unique name for the image set, but don't have
[555] Fix | Delete
// anything unique except for the content itself, so use that.
[556] Fix | Delete
$count = count($photo_list);
[557] Fix | Delete
if ($count > 1) {
[558] Fix | Delete
$image_set_id = preg_replace('/[[:^alnum:]]/', '', $photo_list[0]);
[559] Fix | Delete
$description = '<p>';
[560] Fix | Delete
for ($j = 0; $j < $count; $j++) {
[561] Fix | Delete
$hidden = $j === 0 ? '' : 'class="hidden" ';
[562] Fix | Delete
$description .= '<a href="'.$photo_list[$j].'" '.$hidden.
[563] Fix | Delete
'data-lightbox="image-set-'.$image_set_id.'">'.
[564] Fix | Delete
'<img src="'.$photo_list[$j].'"></a>';
[565] Fix | Delete
}
[566] Fix | Delete
$description .= '<br><b>'.$count.' photos</b></p>';
[567] Fix | Delete
}
[568] Fix | Delete
else if ($count == 1) {
[569] Fix | Delete
$description = '<p><img src="'.$photo_list[0].'"></p>';
[570] Fix | Delete
}
[571] Fix | Delete
}
[572] Fix | Delete
if (isset($entry['properties']['content'][0]['html'])) {
[573] Fix | Delete
// e-content['value'] is the same as p-name when they are on the same
[574] Fix | Delete
// element. Use this to replace title with a strip_tags version so
[575] Fix | Delete
// that alt text from images is not included in the title.
[576] Fix | Delete
if ($entry['properties']['content'][0]['value'] === $title) {
[577] Fix | Delete
$title = strip_tags($entry['properties']['content'][0]['html']);
[578] Fix | Delete
$item['title'] = array(array('data' => $title));
[579] Fix | Delete
}
[580] Fix | Delete
$description .= $entry['properties']['content'][0]['html'];
[581] Fix | Delete
if (isset($entry['properties']['in-reply-to'][0])) {
[582] Fix | Delete
$in_reply_to = '';
[583] Fix | Delete
if (is_string($entry['properties']['in-reply-to'][0])) {
[584] Fix | Delete
$in_reply_to = $entry['properties']['in-reply-to'][0];
[585] Fix | Delete
}
[586] Fix | Delete
else if (isset($entry['properties']['in-reply-to'][0]['value'])) {
[587] Fix | Delete
$in_reply_to = $entry['properties']['in-reply-to'][0]['value'];
[588] Fix | Delete
}
[589] Fix | Delete
if ($in_reply_to !== '') {
[590] Fix | Delete
$description .= '<p><span class="in-reply-to"></span> '.
[591] Fix | Delete
'<a href="'.$in_reply_to.'">'.$in_reply_to.'</a><p>';
[592] Fix | Delete
}
[593] Fix | Delete
}
[594] Fix | Delete
$item['description'] = array(array('data' => $description));
[595] Fix | Delete
}
[596] Fix | Delete
if (isset($entry['properties']['category'])) {
[597] Fix | Delete
$category_csv = '';
[598] Fix | Delete
// Categories can also contain h-cards.
[599] Fix | Delete
foreach ($entry['properties']['category'] as $category) {
[600] Fix | Delete
if ($category_csv !== '') $category_csv .= ', ';
[601] Fix | Delete
if (is_string($category)) {
[602] Fix | Delete
// Can't have commas in categories.
[603] Fix | Delete
$category_csv .= str_replace(',', '', $category);
[604] Fix | Delete
}
[605] Fix | Delete
else {
[606] Fix | Delete
$category_csv .= $this->parse_hcard($category, true);
[607] Fix | Delete
}
[608] Fix | Delete
}
[609] Fix | Delete
$item['category'] = array(array('data' => $category_csv));
[610] Fix | Delete
}
[611] Fix | Delete
if (isset($entry['properties']['published'][0])) {
[612] Fix | Delete
$timestamp = strtotime($entry['properties']['published'][0]);
[613] Fix | Delete
$pub_date = date('F j Y g:ia', $timestamp).' GMT';
[614] Fix | Delete
$item['pubDate'] = array(array('data' => $pub_date));
[615] Fix | Delete
}
[616] Fix | Delete
// The title and description are set to the empty string to represent
[617] Fix | Delete
// a deleted item (which also makes it an invalid rss item).
[618] Fix | Delete
if (isset($entry['properties']['deleted'][0])) {
[619] Fix | Delete
$item['title'] = array(array('data' => ''));
[620] Fix | Delete
$item['description'] = array(array('data' => ''));
[621] Fix | Delete
}
[622] Fix | Delete
$items[] = array('child' => array('' => $item));
[623] Fix | Delete
}
[624] Fix | Delete
}
[625] Fix | Delete
// Mimic RSS data format when storing microformats.
[626] Fix | Delete
$link = array(array('data' => $url));
[627] Fix | Delete
$image = '';
[628] Fix | Delete
if (!is_string($feed_author) &&
[629] Fix | Delete
isset($feed_author['properties']['photo'][0])) {
[630] Fix | Delete
$image = array(array('child' => array('' => array('url' =>
[631] Fix | Delete
array(array('data' => $feed_author['properties']['photo'][0]))))));
[632] Fix | Delete
}
[633] Fix | Delete
// Use the name given for the h-feed, or get the title from the html.
[634] Fix | Delete
if ($feed_title !== '') {
[635] Fix | Delete
$feed_title = array(array('data' => htmlspecialchars($feed_title)));
[636] Fix | Delete
}
[637] Fix | Delete
else if ($position = strpos($data, '<title>')) {
[638] Fix | Delete
$start = $position < 200 ? 0 : $position - 200;
[639] Fix | Delete
$check = substr($data, $start, 400);
[640] Fix | Delete
$matches = array();
[641] Fix | Delete
if (preg_match('/<title>(.+)<\/title>/', $check, $matches)) {
[642] Fix | Delete
$feed_title = array(array('data' => htmlspecialchars($matches[1])));
[643] Fix | Delete
}
[644] Fix | Delete
}
[645] Fix | Delete
$channel = array('channel' => array(array('child' => array('' =>
[646] Fix | Delete
array('link' => $link, 'image' => $image, 'title' => $feed_title,
[647] Fix | Delete
'item' => $items)))));
[648] Fix | Delete
$rss = array(array('attribs' => array('' => array('version' => '2.0')),
[649] Fix | Delete
'child' => array('' => $channel)));
[650] Fix | Delete
$this->data = array('child' => array('' => array('rss' => $rss)));
[651] Fix | Delete
return true;
[652] Fix | Delete
}
[653] Fix | Delete
[654] Fix | Delete
private function declare_html_entities() {
[655] Fix | Delete
// This is required because the RSS specification says that entity-encoded
[656] Fix | Delete
// html is allowed, but the xml specification says they must be declared.
[657] Fix | Delete
return '<!DOCTYPE html [ <!ENTITY nbsp "&#x00A0;"> <!ENTITY iexcl "&#x00A1;"> <!ENTITY cent "&#x00A2;"> <!ENTITY pound "&#x00A3;"> <!ENTITY curren "&#x00A4;"> <!ENTITY yen "&#x00A5;"> <!ENTITY brvbar "&#x00A6;"> <!ENTITY sect "&#x00A7;"> <!ENTITY uml "&#x00A8;"> <!ENTITY copy "&#x00A9;"> <!ENTITY ordf "&#x00AA;"> <!ENTITY laquo "&#x00AB;"> <!ENTITY not "&#x00AC;"> <!ENTITY shy "&#x00AD;"> <!ENTITY reg "&#x00AE;"> <!ENTITY macr "&#x00AF;"> <!ENTITY deg "&#x00B0;"> <!ENTITY plusmn "&#x00B1;"> <!ENTITY sup2 "&#x00B2;"> <!ENTITY sup3 "&#x00B3;"> <!ENTITY acute "&#x00B4;"> <!ENTITY micro "&#x00B5;"> <!ENTITY para "&#x00B6;"> <!ENTITY middot "&#x00B7;"> <!ENTITY cedil "&#x00B8;"> <!ENTITY sup1 "&#x00B9;"> <!ENTITY ordm "&#x00BA;"> <!ENTITY raquo "&#x00BB;"> <!ENTITY frac14 "&#x00BC;"> <!ENTITY frac12 "&#x00BD;"> <!ENTITY frac34 "&#x00BE;"> <!ENTITY iquest "&#x00BF;"> <!ENTITY Agrave "&#x00C0;"> <!ENTITY Aacute "&#x00C1;"> <!ENTITY Acirc "&#x00C2;"> <!ENTITY Atilde "&#x00C3;"> <!ENTITY Auml "&#x00C4;"> <!ENTITY Aring "&#x00C5;"> <!ENTITY AElig "&#x00C6;"> <!ENTITY Ccedil "&#x00C7;"> <!ENTITY Egrave "&#x00C8;"> <!ENTITY Eacute "&#x00C9;"> <!ENTITY Ecirc "&#x00CA;"> <!ENTITY Euml "&#x00CB;"> <!ENTITY Igrave "&#x00CC;"> <!ENTITY Iacute "&#x00CD;"> <!ENTITY Icirc "&#x00CE;"> <!ENTITY Iuml "&#x00CF;"> <!ENTITY ETH "&#x00D0;"> <!ENTITY Ntilde "&#x00D1;"> <!ENTITY Ograve "&#x00D2;"> <!ENTITY Oacute "&#x00D3;"> <!ENTITY Ocirc "&#x00D4;"> <!ENTITY Otilde "&#x00D5;"> <!ENTITY Ouml "&#x00D6;"> <!ENTITY times "&#x00D7;"> <!ENTITY Oslash "&#x00D8;"> <!ENTITY Ugrave "&#x00D9;"> <!ENTITY Uacute "&#x00DA;"> <!ENTITY Ucirc "&#x00DB;"> <!ENTITY Uuml "&#x00DC;"> <!ENTITY Yacute "&#x00DD;"> <!ENTITY THORN "&#x00DE;"> <!ENTITY szlig "&#x00DF;"> <!ENTITY agrave "&#x00E0;"> <!ENTITY aacute "&#x00E1;"> <!ENTITY acirc "&#x00E2;"> <!ENTITY atilde "&#x00E3;"> <!ENTITY auml "&#x00E4;"> <!ENTITY aring "&#x00E5;"> <!ENTITY aelig "&#x00E6;"> <!ENTITY ccedil "&#x00E7;"> <!ENTITY egrave "&#x00E8;"> <!ENTITY eacute "&#x00E9;"> <!ENTITY ecirc "&#x00EA;"> <!ENTITY euml "&#x00EB;"> <!ENTITY igrave "&#x00EC;"> <!ENTITY iacute "&#x00ED;"> <!ENTITY icirc "&#x00EE;"> <!ENTITY iuml "&#x00EF;"> <!ENTITY eth "&#x00F0;"> <!ENTITY ntilde "&#x00F1;"> <!ENTITY ograve "&#x00F2;"> <!ENTITY oacute "&#x00F3;"> <!ENTITY ocirc "&#x00F4;"> <!ENTITY otilde "&#x00F5;"> <!ENTITY ouml "&#x00F6;"> <!ENTITY divide "&#x00F7;"> <!ENTITY oslash "&#x00F8;"> <!ENTITY ugrave "&#x00F9;"> <!ENTITY uacute "&#x00FA;"> <!ENTITY ucirc "&#x00FB;"> <!ENTITY uuml "&#x00FC;"> <!ENTITY yacute "&#x00FD;"> <!ENTITY thorn "&#x00FE;"> <!ENTITY yuml "&#x00FF;"> <!ENTITY OElig "&#x0152;"> <!ENTITY oelig "&#x0153;"> <!ENTITY Scaron "&#x0160;"> <!ENTITY scaron "&#x0161;"> <!ENTITY Yuml "&#x0178;"> <!ENTITY fnof "&#x0192;"> <!ENTITY circ "&#x02C6;"> <!ENTITY tilde "&#x02DC;"> <!ENTITY Alpha "&#x0391;"> <!ENTITY Beta "&#x0392;"> <!ENTITY Gamma "&#x0393;"> <!ENTITY Epsilon "&#x0395;"> <!ENTITY Zeta "&#x0396;"> <!ENTITY Eta "&#x0397;"> <!ENTITY Theta "&#x0398;"> <!ENTITY Iota "&#x0399;"> <!ENTITY Kappa "&#x039A;"> <!ENTITY Lambda "&#x039B;"> <!ENTITY Mu "&#x039C;"> <!ENTITY Nu "&#x039D;"> <!ENTITY Xi "&#x039E;"> <!ENTITY Omicron "&#x039F;"> <!ENTITY Pi "&#x03A0;"> <!ENTITY Rho "&#x03A1;"> <!ENTITY Sigma "&#x03A3;"> <!ENTITY Tau "&#x03A4;"> <!ENTITY Upsilon "&#x03A5;"> <!ENTITY Phi "&#x03A6;"> <!ENTITY Chi "&#x03A7;"> <!ENTITY Psi "&#x03A8;"> <!ENTITY Omega "&#x03A9;"> <!ENTITY alpha "&#x03B1;"> <!ENTITY beta "&#x03B2;"> <!ENTITY gamma "&#x03B3;"> <!ENTITY delta "&#x03B4;"> <!ENTITY epsilon "&#x03B5;"> <!ENTITY zeta "&#x03B6;"> <!ENTITY eta "&#x03B7;"> <!ENTITY theta "&#x03B8;"> <!ENTITY iota "&#x03B9;"> <!ENTITY kappa "&#x03BA;"> <!ENTITY lambda "&#x03BB;"> <!ENTITY mu "&#x03BC;"> <!ENTITY nu "&#x03BD;"> <!ENTITY xi "&#x03BE;"> <!ENTITY omicron "&#x03BF;"> <!ENTITY pi "&#x03C0;"> <!ENTITY rho "&#x03C1;"> <!ENTITY sigmaf "&#x03C2;"> <!ENTITY sigma "&#x03C3;"> <!ENTITY tau "&#x03C4;"> <!ENTITY upsilon "&#x03C5;"> <!ENTITY phi "&#x03C6;"> <!ENTITY chi "&#x03C7;"> <!ENTITY psi "&#x03C8;"> <!ENTITY omega "&#x03C9;"> <!ENTITY thetasym "&#x03D1;"> <!ENTITY upsih "&#x03D2;"> <!ENTITY piv "&#x03D6;"> <!ENTITY ensp "&#x2002;"> <!ENTITY emsp "&#x2003;"> <!ENTITY thinsp "&#x2009;"> <!ENTITY zwnj "&#x200C;"> <!ENTITY zwj "&#x200D;"> <!ENTITY lrm "&#x200E;"> <!ENTITY rlm "&#x200F;"> <!ENTITY ndash "&#x2013;"> <!ENTITY mdash "&#x2014;"> <!ENTITY lsquo "&#x2018;"> <!ENTITY rsquo "&#x2019;"> <!ENTITY sbquo "&#x201A;"> <!ENTITY ldquo "&#x201C;"> <!ENTITY rdquo "&#x201D;"> <!ENTITY bdquo "&#x201E;"> <!ENTITY dagger "&#x2020;"> <!ENTITY Dagger "&#x2021;"> <!ENTITY bull "&#x2022;"> <!ENTITY hellip "&#x2026;"> <!ENTITY permil "&#x2030;"> <!ENTITY prime "&#x2032;"> <!ENTITY Prime "&#x2033;"> <!ENTITY lsaquo "&#x2039;"> <!ENTITY rsaquo "&#x203A;"> <!ENTITY oline "&#x203E;"> <!ENTITY frasl "&#x2044;"> <!ENTITY euro "&#x20AC;"> <!ENTITY image "&#x2111;"> <!ENTITY weierp "&#x2118;"> <!ENTITY real "&#x211C;"> <!ENTITY trade "&#x2122;"> <!ENTITY alefsym "&#x2135;"> <!ENTITY larr "&#x2190;"> <!ENTITY uarr "&#x2191;"> <!ENTITY rarr "&#x2192;"> <!ENTITY darr "&#x2193;"> <!ENTITY harr "&#x2194;"> <!ENTITY crarr "&#x21B5;"> <!ENTITY lArr "&#x21D0;"> <!ENTITY uArr "&#x21D1;"> <!ENTITY rArr "&#x21D2;"> <!ENTITY dArr "&#x21D3;"> <!ENTITY hArr "&#x21D4;"> <!ENTITY forall "&#x2200;"> <!ENTITY part "&#x2202;"> <!ENTITY exist "&#x2203;"> <!ENTITY empty "&#x2205;"> <!ENTITY nabla "&#x2207;"> <!ENTITY isin "&#x2208;"> <!ENTITY notin "&#x2209;"> <!ENTITY ni "&#x220B;"> <!ENTITY prod "&#x220F;"> <!ENTITY sum "&#x2211;"> <!ENTITY minus "&#x2212;"> <!ENTITY lowast "&#x2217;"> <!ENTITY radic "&#x221A;"> <!ENTITY prop "&#x221D;"> <!ENTITY infin "&#x221E;"> <!ENTITY ang "&#x2220;"> <!ENTITY and "&#x2227;"> <!ENTITY or "&#x2228;"> <!ENTITY cap "&#x2229;"> <!ENTITY cup "&#x222A;"> <!ENTITY int "&#x222B;"> <!ENTITY there4 "&#x2234;"> <!ENTITY sim "&#x223C;"> <!ENTITY cong "&#x2245;"> <!ENTITY asymp "&#x2248;"> <!ENTITY ne "&#x2260;"> <!ENTITY equiv "&#x2261;"> <!ENTITY le "&#x2264;"> <!ENTITY ge "&#x2265;"> <!ENTITY sub "&#x2282;"> <!ENTITY sup "&#x2283;"> <!ENTITY nsub "&#x2284;"> <!ENTITY sube "&#x2286;"> <!ENTITY supe "&#x2287;"> <!ENTITY oplus "&#x2295;"> <!ENTITY otimes "&#x2297;"> <!ENTITY perp "&#x22A5;"> <!ENTITY sdot "&#x22C5;"> <!ENTITY lceil "&#x2308;"> <!ENTITY rceil "&#x2309;"> <!ENTITY lfloor "&#x230A;"> <!ENTITY rfloor "&#x230B;"> <!ENTITY lang "&#x2329;"> <!ENTITY rang "&#x232A;"> <!ENTITY loz "&#x25CA;"> <!ENTITY spades "&#x2660;"> <!ENTITY clubs "&#x2663;"> <!ENTITY hearts "&#x2665;"> <!ENTITY diams "&#x2666;"> ]>';
[658] Fix | Delete
}
[659] Fix | Delete
}
[660] Fix | Delete
[661] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function