Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Update rss.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AnzenKodo authored Nov 26, 2022
1 parent b7aa767 commit b68af4a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/rss.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
error_reporting(0);
ini_set('display_errors', 0);

class RSS {
public static $useragent = "FeedFetcher-Google";
Expand Down Expand Up @@ -50,6 +52,12 @@ public static function getFeed(string $url): object {
}

$content = self::getContent($url);

try {
$xml = new SimpleXmlElement($content, true);
} catch(Exception $e) {
return (object)array();
}

$xml = new SimpleXmlElement($content, true);
$data = (object)array();
Expand Down Expand Up @@ -213,9 +221,24 @@ private static function getFeedUrl(string $content): string {
private static function checkContentType(string $url, string
$type_name): bool {
// Get $url header
$header = get_headers($url, true);

stream_context_set_default( [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);

$header = "";
$content_type = "";

$validhost = filter_var(gethostbyname(parse_url($url,PHP_URL_HOST)), FILTER_VALIDATE_IP);
if ($validhost) {
$header = get_headers($url, true);
} else {
return false;
}

// Find $type_name in header
if (isset($header["Content-Type"]))
$content_type = $header["Content-Type"];
Expand Down

0 comments on commit b68af4a

Please sign in to comment.