+ if ($pubsub_state != 2) {
+
+ $feed_hub_url = false;
+ if ($use_simplepie) {
+ $links = $rss->get_links('hub');
+
+ if ($links && is_array($links)) {
+ foreach ($links as $l) {
+ $feed_hub_url = $l;
+ break;
+ }
+ }
+
+ } else {
+ $atom = $rss->channel['atom'];
+
+ if ($atom) {
+ if ($atom['link@rel'] == 'hub') {
+ $feed_hub_url = $atom['link@href'];
+ }
+
+ if (!$feed_hub_url && $atom['link#'] > 1) {
+ for ($i = 2; $i <= $atom['link#']; $i++) {
+ if ($atom["link#$i@rel"] == 'hub') {
+ $feed_hub_url = $atom["link#$i@href"];
+ break;
+ }
+ }
+ }
+ } else {
+ $feed_hub_url = $rss->channel['link_hub'];
+ }
+ }
+
+ if ($feed_hub_url && function_exists('curl_init')) {
+ $callback_url = get_self_url_prefix() .
+ "/backend.php?op=pubsub&id=$feed";
+
+ $s = new Subscriber($feed_hub_url, $callback_url);
+
+ $s->subscribe($fetch_url);
+
+ db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 1
+ WHERE id = '$feed'");
+ }
+ }
+