From 97279fe6ece1453857e0031700854ddac2beaeac Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 22 Jun 2011 15:05:49 +0400 Subject: [PATCH] backend/pubsub: better 404 handling, do not cause PHP warning when invalid feed id is being requested --- backend.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/backend.php b/backend.php index ef2c42fb..113c2832 100644 --- a/backend.php +++ b/backend.php @@ -553,34 +553,41 @@ $result = db_query($link, "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); - $check_feed_url = db_fetch_result($result, 0, "feed_url"); + if (db_num_rows($result) != 0) { - if ($check_feed_url && ($check_feed_url == $feed_url || !$feed_url)) { - if ($mode == "subscribe") { + $check_feed_url = db_fetch_result($result, 0, "feed_url"); - db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 2 - WHERE id = '$feed_id'"); + if ($check_feed_url && ($check_feed_url == $feed_url || !$feed_url)) { + if ($mode == "subscribe") { - print $_REQUEST['hub_challenge']; - return; + db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 2 + WHERE id = '$feed_id'"); - } else if ($mode == "unsubscribe") { + print $_REQUEST['hub_challenge']; + return; - db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 - WHERE id = '$feed_id'"); + } else if ($mode == "unsubscribe") { - print $_REQUEST['hub_challenge']; - return; + db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 + WHERE id = '$feed_id'"); - } else if (!$mode) { + print $_REQUEST['hub_challenge']; + return; - // Received update ping, schedule feed update. + } else if (!$mode) { - update_rss_feed($link, $feed_id, true, true); + // Received update ping, schedule feed update. + update_rss_feed($link, $feed_id, true, true); + + } + } else { + header('HTTP/1.0 404 Not Found'); + echo "404 Not found"; } } else { header('HTTP/1.0 404 Not Found'); + echo "404 Not found"; } break; // pubsub -- 2.39.5