diff options
author | Damien Lallement <dams@mageia.org> | 2012-08-13 10:45:23 +0000 |
---|---|---|
committer | Damien Lallement <dams@mageia.org> | 2012-08-13 10:45:23 +0000 |
commit | ff32e499745367b816d10f25e63ff3328214c32f (patch) | |
tree | 238d19398f5951d69d32c8ed9a460f5193446981 /common/admin/subscriptions.php | |
parent | 5bed2fb79d7b554dd90d2eb58422cfa649aebe08 (diff) | |
download | planet-ff32e499745367b816d10f25e63ff3328214c32f.tar planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.gz planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.bz2 planet-ff32e499745367b816d10f25e63ff3328214c32f.tar.xz planet-ff32e499745367b816d10f25e63ff3328214c32f.zip |
- Import moonmoon
- Create repo per langs
Diffstat (limited to 'common/admin/subscriptions.php')
-rwxr-xr-x | common/admin/subscriptions.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/common/admin/subscriptions.php b/common/admin/subscriptions.php new file mode 100755 index 0000000..ea2f113 --- /dev/null +++ b/common/admin/subscriptions.php @@ -0,0 +1,64 @@ +<?php +require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once dirname(__FILE__) . '/../app/app.php'; + +function removeSlashes(&$item, $key){ + $item = stripslashes($item); +} + +if (isset($_POST['opml']) || isset($_POST['add'])) { + + // Load config and old OPML + $conf = Spyc::YAMLLoad(dirname(__FILE__).'/../custom/config.yml'); + $PlanetConfig = new PlanetConfig($conf); + if ($PlanetConfig->getName() === '') { + $PlanetConfig->setName($oldOpml->getTitle()); + } + $oldOpml = OpmlManager::load(dirname(__FILE__).'/../custom/people.opml'); + $newOpml = new opml(); + $newOpml->title = $PlanetConfig->getName(); + + // Remove slashes if needed + if (get_magic_quotes_gpc() && isset($_POST['opml'])) { + array_walk_recursive($_POST['opml'], 'removeSlashes'); + } + // Delete/Save feeds + if (isset($_POST['delete']) || isset($_POST['save'])){ + foreach ($_POST['opml'] as $person){ + if (isset($_POST['delete'])) { + //delete mode, check if to be deleted + if (!isset($person['delete'])){ + $newOpml->entries[] = $person; + } + } else { + $newOpml->entries[] = $person; + } + } + } + + // Add feed + if (isset($_POST['add'])){ + if ('http://' != $_POST['url']) { + //autodiscover feed + $feed = new SimplePie(); + $feed->enable_cache(false); + $feed->set_feed_url($_POST['url']); + $feed->init(); + $feed->handle_content_type(); + $person['name'] = $feed->get_title(); + $person['website'] = $feed->get_permalink(); + $person['feed'] = $feed->feed_url; + + $oldOpml->entries[] = $person; + } + $newOpml->entries = $oldOpml->entries; + } + + // Backup old OPML + OpmlManager::backup(dirname(__FILE__).'/../custom/people.opml'); + + // Save new OPML + OpmlManager::save($newOpml, dirname(__FILE__).'/../custom/people.opml'); +} +header("Location: index.php"); +die(); |