Skip to content

Instantly share code, notes, and snippets.

@aorcsik
Forked from gklka/gist:5011530
Last active December 14, 2015 02:09
Show Gist options
  • Save aorcsik/5011587 to your computer and use it in GitHub Desktop.
Save aorcsik/5011587 to your computer and use it in GitHub Desktop.
This is an augmented version of a small script from @gklka for correcting the beszeljukmac.com RSS.
<?php
if (isset($_GET['url'])) {
$url = $_GET['url'];
} else {
$url = "http://beszeljukmac.com/index.php/rss/hirek";
}
$page = file_get_contents($url);
if (function_exists("mb_convert_encoding")) {
$page = mb_convert_encoding($page, "UTF-8", "ISO-8859-2");
} else {
$page = iconv("ISO-8859-2", "UTF-8", $page);
}
$page = preg_replace("'ISO-8859-2'i", "utf-8", $page);
if (empty($_GET['url'])) {
$page = str_replace("<link>http://beszeljukmac.com", "<link>http://gk.lka.hu/beszmacrss.php?url=http://beszeljukmac.com", $page);
$page = str_replace('<guid isPermaLink="true">http://beszeljukmac.com', '<guid isPermaLink="true">http://gk.lka.hu/beszmacrss.php?url=http://beszeljukmac.com', $page);
// bold, italic
$page = preg_replace("'[<]/?(b|i)(\s[^>]*[>]|[>])'", "", $page);
// félbetört linkek, képek, stb.
$page = preg_replace("'[<](img|br|a)[^>]*&#8230;'", "&#8230;", $page);
// hellip előtti szóköz, pont, vessző
$page = preg_replace("'[.,\s]+&#8230;'", "&#8230;", $page);
// hellip előtti sortörések
$page = preg_replace("'([<]br /[>]\s*)+&#8230;'", "&#8230;", $page);
} else {
$tmp = split('<div class="article" style="border-bottom:none;">', $page);
$tmp = $tmp[1];
$tmp = split('<div class="articlecategory">', $tmp);
$tmp = $tmp[0];
$tmp = str_replace('class="commentsSocial"', 'class="commentsSocial" style="display:none;', $tmp);
$tmp = str_replace('class="articleauthor"', 'class="articleauthor" style="display:none;"', $tmp);
$tmp = str_replace('class="articlecomments"', 'class="articlecomments" style="display:none;"', $tmp);
$tmp = str_replace('class="facebookLike"', 'class="facebookLike" style="display:none;"', $tmp);
$tmp = str_replace('class="tweetLike"', 'class="tweetLike" style="display:none;"', $tmp);
$page = "<html><body>" . $tmp . "</div></body></html>";
}
header("Content-Type:text/xml; charset=utf-8");
print $page;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment