<?php require 'inc.config.php'; header('Content-type: text/plain; charset=utf-8'); user::check('admin feeds'); // delete blogs $db->delete('blogs', '1'); // delete subscriptions $db->delete('subscriptions', '1'); // delete blog posts $db->delete('blog_posts', '1'); // insert from hard coded feeds foreach (require 'inc.rss-feeds.php' as $feedName => $feedUrl) { var_dump($feedName); $feed = RSSReader::parse($feedUrl); $data = array('name' => $feedName, 'title' => $feed['title'], 'url' => $feed['url'], 'feed' => $feed['feed']); var_dump($db->insert('blogs', $data)); }
<?php require 'inc.config.php'; user::check('add feed'); $feedUrl = ''; $feedExists = false; if (isset($_POST['url'])) { $feedUrl = $_POST['url']; // Parse feed $feed = RSSReader::parse($feedUrl, $error); // Show feed to user if (empty($_POST['confirm'])) { echo '<p>This is what I got:</p>'; if ($feed) { echo '<pre>' . h(print_r($feed, 1)) . '</pre>'; } else { var_dump($feed, $error); } } // May exist already $blog = $db->select('blogs', array('feed' => $feedUrl), null, array('first' => true, 'class' => 'Blog')); if (!$blog) { if (!empty($_POST['confirm'])) { // save into db $data = array('name' => '', 'title' => $feed['title'], 'url' => $feed['url'], 'updated' => 0, 'checked' => 0, 'feed' => $feed['feed'], 'added_by_user_id' => USER_ID, 'private' => (int) (!empty($_POST['private']))); $db->insert('blogs', $data); $id = $db->insert_id(); user::success('Blog added: ' . h($data['title'])); redirect('index.php?blog=' . $id); } echo '<h1>Looks good? Resubmit!</h1>';