|
|
@ -1810,15 +1810,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
$update_method = 0;
|
|
|
|
$update_method = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (!fetch_file_contents($url, false, $auth_login, $auth_pass))
|
|
|
|
$contents = @fetch_file_contents($url, false, $auth_login, $auth_pass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$contents) {
|
|
|
|
return array("code" => 5, "message" => $fetch_last_error);
|
|
|
|
return array("code" => 5, "message" => $fetch_last_error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_html($contents)) {
|
|
|
|
|
|
|
|
$feedUrls = get_feeds_from_html($url, $contents);
|
|
|
|
|
|
|
|
|
|
|
|
if (url_is_html($url, $auth_login, $auth_pass)) {
|
|
|
|
|
|
|
|
$feedUrls = get_feeds_from_html($url, $auth_login, $auth_pass);
|
|
|
|
|
|
|
|
if (count($feedUrls) == 0) {
|
|
|
|
if (count($feedUrls) == 0) {
|
|
|
|
return array("code" => 3);
|
|
|
|
return array("code" => 3);
|
|
|
|
} else if (count($feedUrls) > 1) {
|
|
|
|
} else if (count($feedUrls) > 1) {
|
|
|
|
return array("code" => 4);
|
|
|
|
return array("code" => 4, "feeds" => $feedUrls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//use feed url as new URL
|
|
|
|
//use feed url as new URL
|
|
|
|
$url = key($feedUrls);
|
|
|
|
$url = key($feedUrls);
|
|
|
@ -4758,22 +4762,13 @@
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
function get_feeds_from_html($url, $content)
|
|
|
|
* Extracts RSS/Atom feed URLs from the given HTML URL.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $url HTML page URL
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return array Array of feeds. Key is the full URL, value the title
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function get_feeds_from_html($url, $login = false, $pass = false)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$url = fix_url($url);
|
|
|
|
$url = fix_url($url);
|
|
|
|
$baseUrl = substr($url, 0, strrpos($url, '/') + 1);
|
|
|
|
$baseUrl = substr($url, 0, strrpos($url, '/') + 1);
|
|
|
|
|
|
|
|
|
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
|
|
|
|
|
|
|
|
$content = @fetch_file_contents($url, false, $login, $pass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
$doc->loadHTML($content);
|
|
|
|
$doc->loadHTML($content);
|
|
|
|
$xpath = new DOMXPath($doc);
|
|
|
|
$xpath = new DOMXPath($doc);
|
|
|
@ -4794,23 +4789,12 @@
|
|
|
|
return $feedUrls;
|
|
|
|
return $feedUrls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
function is_html($content) {
|
|
|
|
* Checks if the content behind the given URL is a HTML file
|
|
|
|
return preg_match("/<html|DOCTYPE html/i", $content) !== 0;
|
|
|
|
*
|
|
|
|
}
|
|
|
|
* @param string $url URL to check
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return boolean True if the URL contains HTML content
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function url_is_html($url, $login = false, $pass = false) {
|
|
|
|
|
|
|
|
$content = substr(fetch_file_contents($url, false, $login, $pass), 0, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stripos($content, '<html>') === false
|
|
|
|
|
|
|
|
&& stripos($content, '<html ') === false
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
function url_is_html($url, $login = false, $pass = false) {
|
|
|
|
|
|
|
|
return is_html(fetch_file_contents($url, false, $login, $pass));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function print_label_select($link, $name, $value, $attributes = "") {
|
|
|
|
function print_label_select($link, $name, $value, $attributes = "") {
|
|
|
|