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/index.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/index.php')
-rwxr-xr-x | public/admin/index.php | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/public/admin/index.php b/public/admin/index.php new file mode 100755 index 0000000..37939ea --- /dev/null +++ b/public/admin/index.php @@ -0,0 +1,149 @@ +<?php + +require_once __DIR__ . '/../../app/app.php'; +require_once __DIR__ . '/inc/auth.inc.php'; + +if (!$PlanetConfig::isInstalled()) { + die('<p>' . _g('You might want to <a href="../install.php">install moonmoon</a>.') . '</p>'); +} + +//Instantiate app +$Planet = new Planet($PlanetConfig); + +//Load +if (0 < $Planet->loadOpml($PlanetConfig->getOpmlFile())) { + $Planet->loadFeeds(); + $items = $Planet->getItems(); +} + +$everyone = $Planet->getPeople(); +$count_feeds = count($everyone); +$page_id = 'admin-feed'; +$footer_extra = <<<FRAGMENT + <script> + var allCheckboxes = function(status){ + var form = document.getElementById('feedmanage'); + var selectboxes = form.getElementsByTagName('input'); + for (var i=0; i<selectboxes.length; i++){ + if ('checkbox' == selectboxes[i].type){ + selectboxes[i].checked = status; + } + } + } + + window.onload = function(){ + //Select/unselect rows + var form = document.getElementById('feedmanage'); + var selectboxes = form.getElementsByTagName('input'); + for (var i=0; i<selectboxes.length; i++){ + if ('checkbox' == selectboxes[i].type) { + selectboxes[i].onchange = function() { + var tr = this.parentNode.parentNode; + if (this.checked) { + tr.className += ' selected'; + } else { + tr.className = tr.className.replace('selected',''); + } + } + } + } + + var btSelectall = document.getElementById('selectall'); + btSelectall.onclick = function(){ + allCheckboxes('checked'); + } + + var btSelectnone = document.getElementById('selectnone'); + btSelectnone.onclick = function(){ + allCheckboxes(''); + } + } + </script> +FRAGMENT; + +ob_start(); +?> + + <div class="widget"> + <h3><?=_g('Add Feed')?></h3> + <form action="subscriptions.php" method="post" id="feedimport"> + <fieldset> + <label for="url"><?=_g('Link:')?></label> + <input type="text" class="text" name="url" id="url" placeholder="http://" class="text" size="50" /> + <input type="submit" class="submit add" name="add" value="<?=_g('Add Feed')?>" /> + </fieldset> + <p class="help"><?=_g('Accepted formats are RSS and ATOM. If the link is not a feed, moonmoon will try to autodiscover the feed.')?></p> + <input type="hidden" value="<?php echo $csrf->generate('feedmanage'); ?>" name="_csrf"> + </form> + </div> + + <div class="widget"> + <h3><?=_g('Manage existing feeds')?></h3> + <form action="subscriptions.php" method="post" id="feedmanage"> + <p class="action"> + <span class="count"><?php echo sprintf(_g('Number of feeds: %s'), $count_feeds)?></span> + <input type="hidden" value="<?php echo $csrf->generate('feedmanage'); ?>" name="_csrf"> + <input type="submit" class="submit save" name="save" id="save" value="<?=_g('Save changes')?>" /> + <input type="submit" class="submit delete" name="delete" id="delete" value="<?=_g('Delete selected Feeds')?>" /> + </p> + <p class="select"><?=_g('Select :')?> <a href="javascript:void(0);" id="selectall"><?=_g('All')?></a>, <a href="javascript:void(0);" id="selectnone"><?=_g('None')?></a></p> + <table> + <thead> + <tr> + <th><span><?=_g('Selection')?></span></th> + <th><?=_g('Name')?></th> + <th><?=_g('Last entry')?></th> + <th><?=_g('Website link')?></th> + <th><?=_g('Feed link')?></th> + <th><?=_g('Unavailable')?></th> + </tr> + </thead> + <tbody> + <?php + $i = 0; + foreach ($everyone as $opml_person) { + $i++; + ?> + <tr class="<?=($i%2)?'odd':'even'; ?>"> + <td><input type="checkbox" class="checkbox" name="opml[<?=$i; ?>][delete]" /></td> + <td><input type="text" size="10" class="text" name="opml[<?=$i; ?>][name]" value="<?=$opml_person->getName(); ?>" /></td> + <td> + <?php + $items = $opml_person->get_items(); + if (count($items) > 0) { + echo $items[0]->get_date(); + } else { + echo _g('Not in cache'); + } + $check_is_down = $opml_person->getIsDown() === '1' ? 'checked="checked"' : ''; + ?> + </td> + <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][website]" value="<?=$opml_person->getWebsite(); ?>" /></td> + <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][feed]" value="<?=$opml_person->getFeed(); ?>" /></td> + <td><input type="checkbox" readonly="readonly" name="opml[<?=$i; ?>][isDown]" <?=$check_is_down?> value="1" /></td> + </tr> + <?php } ?> + </tbody> + </table> + </form> + </div> + + <div class="widget"> + <h3><?=_g('Upload OPML file')?></h3> + <form action="subscriptions.php" method="post" id="opmlimport" enctype="multipart/form-data"> + <p>Beware! This will totally erase and replace the list of your feeds just above.</p> + <fieldset> + <label for="url"><?=_g('File:')?></label> + <input type="file" class="text" name="opml" id="opml" class="text" size="50" /> + <input type="submit" class="submit add" name="upload" value="<?=_g('Upload OPML file and replace existing feeds')?>" /> + </fieldset> + <input type="hidden" value="<?php echo $csrf->generate('feedmanage'); ?>" name="_csrf"> + </form> + </div> + +<?php +$page_content = ob_get_contents(); +ob_end_clean(); + +$admin_access = 1; +require_once __DIR__ . '/template.php'; |