Fixed and improved the function rss_error_handler for to show others errors
This commit is contained in:
parent
e91c832172
commit
46e2286bf8
|
@ -28,6 +28,9 @@ $ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
// Uncoment this to activate ACL on RSS Events
|
// Uncoment this to activate ACL on RSS Events
|
||||||
if (!isInACL($ipOrigin)) {
|
if (!isInACL($ipOrigin)) {
|
||||||
|
rss_error_handler(null, null, null, null,
|
||||||
|
__("Your IP is not into the IP list with API access."));
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,25 +42,52 @@ $pss = get_user_info($user);
|
||||||
$hashup2 = md5($user.$pss['password']);
|
$hashup2 = md5($user.$pss['password']);
|
||||||
|
|
||||||
if ($hashup != $hashup2) {
|
if ($hashup != $hashup2) {
|
||||||
|
rss_error_handler(null, null, null, null,
|
||||||
|
__("The URL of your feed has bad hash."));
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output
|
header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output
|
||||||
|
|
||||||
function rss_error_handler ($errno, $errstr, $errfile, $errline) {
|
function rss_error_handler ($errno, $errstr, $errfile, $errline, $error_human_description = null) {
|
||||||
$url = ui_get_full_url(false);
|
$url = ui_get_full_url(false);
|
||||||
$selfurl = ui_get_full_url('?' . $_SERVER['QUERY_STRING'], false, true);
|
$selfurl = ui_get_full_url('?' . $_SERVER['QUERY_STRING'], false, true);
|
||||||
|
|
||||||
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'; //' Fixes certain highlighters freaking out on the PHP closing tag
|
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'; //' Fixes certain highlighters freaking out on the PHP closing tag
|
||||||
|
$rss_feed .= "\n";
|
||||||
$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
|
$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
|
||||||
$rss_feed .= '<channel><title>Pandora RSS Feed</title><description>Latest events on Pandora</description>';
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<channel>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<title>Pandora RSS Feed</title>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<description>Latest events on Pandora</description>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
$rss_feed .= '<lastBuildDate>'.date (DATE_RFC822, 0).'</lastBuildDate>';
|
$rss_feed .= '<lastBuildDate>'.date (DATE_RFC822, 0).'</lastBuildDate>';
|
||||||
$rss_feed .= '<link>'.$url.'</link>'; //Link back to the main Pandora page
|
$rss_feed .= "\n";
|
||||||
$rss_feed .= '<atom:link href="'.io_safe_input ($selfurl).'" rel="self" type="application/rss+xml" />'; //Alternative for Atom feeds. It's the same.
|
$rss_feed .= '<link>' . $url . '</link>'; //Link back to the main Pandora page
|
||||||
|
$rss_feed .= "\n";
|
||||||
$rss_feed .= '<item><guid>'.$url.'/index.php?sec=eventos&sec2=operation/events/events</guid><title>Error creating feed</title>';
|
$rss_feed .= '<atom:link href="' . io_safe_input ($selfurl) . '" rel="self" type="application/rss+xml" />'; //Alternative for Atom feeds. It's the same.
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<item>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<guid>'.$url.'/index.php?sec=eventos&sec2=operation/events/events</guid>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<title>Error creating feed</title>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
if (empty($error_human_description)) {
|
||||||
$rss_feed .= '<description>There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.'</description>';
|
$rss_feed .= '<description>There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.'</description>';
|
||||||
$rss_feed .= '<link>'.$url.'/index.php?sec=eventos&sec2=operation/events/events</link></item>';
|
}
|
||||||
|
else {
|
||||||
|
$rss_feed .= '<description>' . io_safe_input($error_human_description) .'</description>';
|
||||||
|
}
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '<link>'.$url.'/index.php?sec=eventos&sec2=operation/events/events</link>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '</item>';
|
||||||
|
$rss_feed .= "\n";
|
||||||
|
$rss_feed .= '</rss>';
|
||||||
|
|
||||||
exit ($rss_feed); //Exit by displaying the feed
|
exit ($rss_feed); //Exit by displaying the feed
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue