diff options
author | rdalverny <rdalverny@gmail.com> | 2022-01-22 18:54:11 +0100 |
---|---|---|
committer | rdalverny <rdalverny@gmail.com> | 2022-01-22 18:54:11 +0100 |
commit | c27c9d1d359828a071159995689c9c3b28d99891 (patch) | |
tree | 8aa8e0e2ea11935c34cee67f2a8f44201329b7e8 /public/admin/subscriptions.php | |
parent | 58ce95a255c04e1b6ecac0d794bc4dbeb23871de (diff) | |
download | planet-c27c9d1d359828a071159995689c9c3b28d99891.tar planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.gz planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.bz2 planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.xz planet-c27c9d1d359828a071159995689c9c3b28d99891.zip |
Move public resources under public/ directory
Existing setups need to update their server config to point (or link to)
public/ directory instead of the root of the code repo.
Configuration (and password) location also changes from custom/ and
admin/inc to custom/config/.
That way, config and code library move out of the publicly served
file tree.
Apart from the change of the web root, config should be migrated
seamlessly.
Diffstat (limited to 'public/admin/subscriptions.php')
-rwxr-xr-x | public/admin/subscriptions.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/public/admin/subscriptions.php b/public/admin/subscriptions.php new file mode 100755 index 0000000..418e354 --- /dev/null +++ b/public/admin/subscriptions.php @@ -0,0 +1,84 @@ +<?php + +require_once __DIR__ . '/../../app/app.php'; +require_once __DIR__ . '/inc/auth.inc.php'; + +function removeSlashes(&$item, $key) +{ + $item = stripslashes($item); +} + +if (!$csrf->verify($_POST['_csrf'], 'feedmanage')) { + die('Invalid CSRF token!'); +} + +$opmlFile = $PlanetConfig->getOpmlFile(); + +if (isset($_POST['upload']) && + isset($_FILES['opml']) && + is_uploaded_file($_FILES['opml']['tmp_name']) && + $_FILES['opml']['size'] > 0) { + OpmlManager::backup($opmlFile); + $newOpml = new Opml(); + $newOpml->parse(file_get_contents($_FILES['opml']['tmp_name'])); + OpmlManager::save($newOpml, $opmlFile); +} elseif (isset($_POST['opml']) || isset($_POST['add'])) { + // Load old OPML + $oldOpml = OpmlManager::load($opmlFile); + if ($PlanetConfig->getName() === '') { + $PlanetConfig->setName($oldOpml->getTitle()); + } + $newOpml = new Opml(); + $newOpml->title = $PlanetConfig->getName(); + + // Remove slashes if needed + if (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']); + if (!$PlanetConfig->checkCertificates()) { + $feed->set_curl_options([ + CURLOPT_SSL_VERIFYHOST => false, + CURLOPT_SSL_VERIFYPEER => false + ]); + } + $feed->init(); + $feed->handle_content_type(); + $person['name'] = html_entity_decode($feed->get_title()); + $person['website'] = $feed->get_permalink(); + $person['feed'] = $feed->feed_url; + $person['isDown'] = '0'; + + $oldOpml->entries[] = $person; + } + $newOpml->entries = $oldOpml->entries; + } + + // Backup old OPML + OpmlManager::backup($opmlFile); + + // Save new OPML + OpmlManager::save($newOpml, $opmlFile); +} +header("Location: index.php"); +die(); |