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 | |
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')
-rwxr-xr-x | common/admin/administration.php | 42 | ||||
-rw-r--r-- | common/admin/changepassword.php | 10 | ||||
-rwxr-xr-x | common/admin/default.css | 232 | ||||
-rw-r--r-- | common/admin/img/button-add.png | bin | 0 -> 244 bytes | |||
-rw-r--r-- | common/admin/img/button-delete.png | bin | 0 -> 201 bytes | |||
-rw-r--r-- | common/admin/img/button-h.png | bin | 0 -> 212 bytes | |||
-rw-r--r-- | common/admin/img/button.png | bin | 0 -> 212 bytes | |||
-rw-r--r-- | common/admin/img/h3.png | bin | 0 -> 212 bytes | |||
-rw-r--r-- | common/admin/img/moonmoon.png | bin | 0 -> 564 bytes | |||
-rw-r--r-- | common/admin/img/nav-admin.png | bin | 0 -> 1519 bytes | |||
-rw-r--r-- | common/admin/img/nav-feed.png | bin | 0 -> 1090 bytes | |||
-rw-r--r-- | common/admin/inc/auth.inc.php | 11 | ||||
-rw-r--r-- | common/admin/inc/pwd.inc.php | 1 | ||||
-rwxr-xr-x | common/admin/index.php | 136 | ||||
-rwxr-xr-x | common/admin/login.php | 34 | ||||
-rw-r--r-- | common/admin/logout.php | 5 | ||||
-rw-r--r-- | common/admin/purgecache.php | 21 | ||||
-rwxr-xr-x | common/admin/subscriptions.php | 64 | ||||
-rwxr-xr-x | common/admin/template.php | 53 |
19 files changed, 609 insertions, 0 deletions
diff --git a/common/admin/administration.php b/common/admin/administration.php new file mode 100755 index 0000000..1202e91 --- /dev/null +++ b/common/admin/administration.php @@ -0,0 +1,42 @@ +<?php + +require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once dirname(__FILE__) . '/../app/app.php'; + +$opml = OpmlManager::load(dirname(__FILE__) . '/../custom/people.opml'); +$opml_people = $opml->getPeople(); +$page_id = 'admin-admin'; +$header_extra = <<<"HTML" + <script> + window.onload = function(){ + var formManage = document.getElementById('frmPurge'); + formManage.onsubmit = function(){ + return confirm("{$l10n->getString('Are you sure you want to purge the cache?')}"); + } + } + </script> + +HTML; + +$page_content = <<<"FRAGMENT" + + <div class="widget"> + <h3>{$l10n->getString('Clear cache')}</h3> + <form action="purgecache.php" method="post" id="frmPurge"> + <p><label>{$l10n->getString('Clear cache:')}</label><input type="submit" class="submit delete" name="purge" id="purge" value="{$l10n->getString('Clear')}" /></p> + <p class="help">{$l10n->getString('Clearing the cache will make moonmoon reload all feeds.')}</p> + </form> + </div> + + <div class="widget"> + <h3>{$l10n->getString('Change administrator password')}</h3> + <form action="changepassword.php" method="post" id="frmPassword"> + <p><label for="password">{$l10n->getString('New password:')}</label> <input type="password" class="text" value="" name="password" id="password" size="20" /> <input type="submit" class="submit delete" name="changepwd" id="changepwd" value="{$l10n->getString('Change password')}" /></p> + </form> + </div> + +FRAGMENT; + +$footer_extra = ''; +$admin_access = 1; +require_once dirname(__FILE__) . '/template.php'; diff --git a/common/admin/changepassword.php b/common/admin/changepassword.php new file mode 100644 index 0000000..1fa505e --- /dev/null +++ b/common/admin/changepassword.php @@ -0,0 +1,10 @@ +<?php +require_once dirname(__FILE__).'/inc/auth.inc.php'; + +if (isset($_POST['password']) && ('' != $_POST['password'])){ + $out = '<?php $login="admin"; $password="'.md5($_POST['password']).'"; ?>'; + file_put_contents(dirname(__FILE__).'/inc/pwd.inc.php', $out); + die("Password changed. <a href='administration.php'>Login</a>"); +} else { + die('Can not change password'); +} diff --git a/common/admin/default.css b/common/admin/default.css new file mode 100755 index 0000000..fcba3f4 --- /dev/null +++ b/common/admin/default.css @@ -0,0 +1,232 @@ +html, body{ + margin: 0; + padding: 0; +} +html{ + font-size: 62.5%; +} +body{ + background: #FFF; + color: #333; + font: 1.1em/1.6em "Lucida Grande", Tahoma, Arial, sans-serif; +} + + +fieldset{ + border: 0; + padding: 0; + margin: 1em 0; +} +input.text{ + border: 1px solid #BBB; + padding: 4px; +} +input.submit{ + font-size: 1em; + padding: 4px; + background: #D1D1D1 url(img/button.png) repeat-x left center; + border: 1px solid #FFF; + border-bottom: 1px solid #CECECE; + border-right: 1px solid #CECECE; + cursor: pointer; +} +input.submit:hover{ + background: #D1D1D1 url(img/button-h.png) repeat-x left center; + color: #000; + border: 1px solid #FFF; + border-bottom: 1px solid #C6C6C6; + border-right: 1px solid #C6C6C6; +} +input.delete{ + margin-left: 1em; +} +input.delete:hover{ + background: #ffabab url(img/button-delete.png) repeat-x left center; + color: #C00; + border: 1px solid #FCC; + border-bottom: 1px solid #F99; + border-right: 1px solid #F99; +} +input.add{ + font-weight: bold; +} +input.add:hover{ + background: #65a5e1 url(img/button-add.png) repeat-x left center; + color: #20466a; + border: 1px solid #a6c7e5; + border-bottom: 1px solid #4f90cd; + border-right: 1px solid #4f90cd; +} +p.help{ + font-size: 0.8em; + color: #999; + margin: 0; +} + +#page{ +} + + header{ + background: #E0E0E0 url(img/moonmoon.png) no-repeat right center; + border-top: 5px solid #D0D0D0; + margin: 0; + padding: 10px; + } + header h1{ + display: none; + margin: 0 0 0 20px; + padding: 0; + height: 14px; + width: 95px; + background: transparent url(img/moonmoon.png) no-repeat left center; + + overflow: hidden; + text-indent: -1000em; + } + header p{ + margin: 0 0 0 20px; + padding: 0; + } + header p a{ + color: #AAA; + } + header p a:hover{ + color: #111; + } + + + nav ul{ + margin: 20px 30px; + padding: 0; + list-style: none; + } + nav ul:after {content: "."; display: block; height: 0; clear: both; visibility: hidden; } + nav ul {display: inline-table;} + /* Hides from IE-mac \*/ + * html nav ul {height: 1%;} + nav ul {display: block;} + /* End hide from IE-mac */ + + nav ul li{ + display: block; + float: left; + } + nav ul li a{ + display: block; + border: 1px solid #DDD; + padding: 8px 8px 8px 36px; + margin-right: 8px; + text-decoration: none; + color: #666; + background-repeat: no-repeat; + background-position: 6px center; + } + nav ul li a:hover, + body#admin-feed #nav-feed a, + body#admin-admin #nav-admin a { + background-color: #f0f2f6; + border-color: #AAA; + color: #111; + } + #nav-feed a{ + background-image: url(img/nav-feed.png); + } + #nav-admin a{ + background-image: url(img/nav-admin.png); + } + + #content{ + margin: 20px 30px; + } + + .widget{ + margin: 20px 0; + } + .widget h3{ + background: #3e4350 url(img/h3.png) repeat-x left center; + color: #FFF; + text-transform: uppercase; + margin: 0; + padding: 10px; + } + .widget form{ + padding: 10px; + border: 1px solid #EEE; + border-top: 0; + } + + #feedmanage p.select{ + margin: 3px 0; + } + #feedmanage p.action span.count{ + float: right; + padding-right: 10px; + font-size: 1.3em; + } + #feedmanage table{ + width: 99%; + border-collapse: collapse; + border: 1px solid #f0f2f6; + } + #feedmanage thead th{ + background: #f0f2f6; + text-align: left; + padding: 6px; + } + #feedmanage thead span{ + display: none; + } + #feedmanage tr{ + border-bottom: 1px solid #e8ebf1; + } + #feedmanage tr.even td{ + background: #f0f2f6; + width: auto; + } + #feedmanage .text{ + background: transparent; + border: 1px solid #FFF; + width: 90%; + } + #feedmanage tr.even td .text{ + border: 1px solid #f0f2f6; + } + #feedmanage tr td input.text:focus{ + background: #FFF; + border: 1px solid #4392b7; + } + + #feedmanage tr.selected td{ + background: #ffabab; + background: #4392b7; + color: #FFF; + } + #feedmanage tr.selected td .text{ + color: #FFF; + border: 1px solid #4392b7; + } + #feedmanage tr td input.text:focus{ + background: #FFF; + color: #000; + border: 1px solid #4392b7; + } + +/* Login form +*******************************************************************************/ +form.login { + width: 400px; + margin: 0 auto; +} +form.login fieldset { + border: 1px solid #CCC; + text-align: center; +} + +p.logout { + float: right; + margin: 20px 30px 0 0; +} + p.logout a { + padding: 8px; + display: block; + } diff --git a/common/admin/img/button-add.png b/common/admin/img/button-add.png Binary files differnew file mode 100644 index 0000000..859364a --- /dev/null +++ b/common/admin/img/button-add.png diff --git a/common/admin/img/button-delete.png b/common/admin/img/button-delete.png Binary files differnew file mode 100644 index 0000000..7bfebc2 --- /dev/null +++ b/common/admin/img/button-delete.png diff --git a/common/admin/img/button-h.png b/common/admin/img/button-h.png Binary files differnew file mode 100644 index 0000000..0a43a6a --- /dev/null +++ b/common/admin/img/button-h.png diff --git a/common/admin/img/button.png b/common/admin/img/button.png Binary files differnew file mode 100644 index 0000000..fad6ccc --- /dev/null +++ b/common/admin/img/button.png diff --git a/common/admin/img/h3.png b/common/admin/img/h3.png Binary files differnew file mode 100644 index 0000000..0c86748 --- /dev/null +++ b/common/admin/img/h3.png diff --git a/common/admin/img/moonmoon.png b/common/admin/img/moonmoon.png Binary files differnew file mode 100644 index 0000000..26cc8f4 --- /dev/null +++ b/common/admin/img/moonmoon.png diff --git a/common/admin/img/nav-admin.png b/common/admin/img/nav-admin.png Binary files differnew file mode 100644 index 0000000..3077a54 --- /dev/null +++ b/common/admin/img/nav-admin.png diff --git a/common/admin/img/nav-feed.png b/common/admin/img/nav-feed.png Binary files differnew file mode 100644 index 0000000..00c896b --- /dev/null +++ b/common/admin/img/nav-feed.png diff --git a/common/admin/inc/auth.inc.php b/common/admin/inc/auth.inc.php new file mode 100644 index 0000000..d21467b --- /dev/null +++ b/common/admin/inc/auth.inc.php @@ -0,0 +1,11 @@ +<?php +include (dirname(__FILE__).'/pwd.inc.php'); + +if ( isset($_COOKIE['auth']) && $_COOKIE['auth'] == $password ) { + //ok, cool +} else { + setcookie('auth','', time()-3600); + header('Location: login.php'); + die; +} +?>
\ No newline at end of file diff --git a/common/admin/inc/pwd.inc.php b/common/admin/inc/pwd.inc.php new file mode 100644 index 0000000..10d9225 --- /dev/null +++ b/common/admin/inc/pwd.inc.php @@ -0,0 +1 @@ +<?php $login="admin"; $password=md5("admin"); ?>
\ No newline at end of file diff --git a/common/admin/index.php b/common/admin/index.php new file mode 100755 index 0000000..28f7198 --- /dev/null +++ b/common/admin/index.php @@ -0,0 +1,136 @@ +<?php + +require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once dirname(__FILE__) . '/../app/app.php'; + +//Load configuration +$config_file = dirname(__FILE__) . '/../custom/config.yml'; + +if (is_file($config_file)){ + $conf = Spyc::YAMLLoad($config_file); + $PlanetConfig = new PlanetConfig($conf); +} else { + die('Config file (custom/config.yml) is missing.'); +} + +//Instantiate app +$Planet = new Planet($PlanetConfig); + +//Load +if (0 < $Planet->loadOpml(dirname(__FILE__) . '/../custom/people.opml')) { + $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> + </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="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> + </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'); + } + ?> + </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> + </tr> + <?php } ?> + </tbody> + </table> + </form> + </div> +<?php +$page_content = ob_get_contents(); +ob_end_clean(); + +$admin_access = 1; +require_once dirname(__FILE__) . '/template.php'; diff --git a/common/admin/login.php b/common/admin/login.php new file mode 100755 index 0000000..796011f --- /dev/null +++ b/common/admin/login.php @@ -0,0 +1,34 @@ +<?php +if (isset($_POST['password'])) { + setcookie('auth',md5($_POST['password'])); + header('Location: index.php'); +} + +require_once dirname(__FILE__) . '/../app/app.php'; +$page_content = <<<FRAGMENT + <form action="" method="post" class="login"> + <fieldset> + <p class="field"> + <label for="password">{$l10n->getString('Password:')}</label> + <input type="password" name="password" id="password"/> + <input type="submit" class="submit" value="{$l10n->getString('OK')}"/> + </p> + </fieldset> + </form> +FRAGMENT; + +$footer_extra = <<<FRAGMENT + <script type="text/javascript"> + <!-- + window.onload = function() { + document.getElementById('password').focus(); + } + --> + </script> + +FRAGMENT; + +$page_id = 'admin-login'; +$admin_access = 0; + +require_once dirname(__FILE__) . '/template.php'; diff --git a/common/admin/logout.php b/common/admin/logout.php new file mode 100644 index 0000000..6dd32aa --- /dev/null +++ b/common/admin/logout.php @@ -0,0 +1,5 @@ +<?php +setcookie('auth','', time()-3600); +header('Location: login.php'); +die; +?>
\ No newline at end of file diff --git a/common/admin/purgecache.php b/common/admin/purgecache.php new file mode 100644 index 0000000..a5af5cf --- /dev/null +++ b/common/admin/purgecache.php @@ -0,0 +1,21 @@ +<?php +require_once dirname(__FILE__).'/inc/auth.inc.php'; + +if (isset($_POST['purge'])){ + $dir = dirname(__FILE__).'/../cache/'; + + $dh = opendir($dir); + + while ($filename = readdir($dh)) { + if ($filename == '.' OR $filename == '..') { + continue; + } + + if (filemtime($dir . DIRECTORY_SEPARATOR . $filename) < time()) { + @unlink($dir . DIRECTORY_SEPARATOR . $filename); + } + } +} + +header('Location: administration.php'); +die();
\ No newline at end of file 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(); diff --git a/common/admin/template.php b/common/admin/template.php new file mode 100755 index 0000000..7818bef --- /dev/null +++ b/common/admin/template.php @@ -0,0 +1,53 @@ +<?php if(!isset($admin_access)) return; ?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title> + +<?php + echo _g('Administration') . ' — '; + printf(_g('moonmoon %s', '%s is the version number for moonmoon, this string appears as the tab title in the admin panel'), $moon_version); +?> + </title> + <link rel="stylesheet" media="screen" type="text/css" href="default.css"> +<!--[if lte IE 9]> +<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> +<![endif]--> + + <?=@$header_extra ?: ''; ?> + +</head> + +<body id="<?=@$page_id ?: ''; ?>"> + <div id="page"> + <header> + <h1>moonmoon</h1> + <p><a href="../"><?=_g('Back to main page')?></a></p> + </header> + + <?php if($admin_access == 1) : ?> + + <p class="logout"><a href="logout.php"><?=_g('Logout')?></a></p> + <nav> + <ul> + <li id="nav-feed"><a href="index.php"><?=_g('Feeds')?></a></li> + <li id="nav-admin"><a href="administration.php"><?=_g('Administration')?></a></li> + </ul> + </nav> + + <?php endif; ?> + + + + <div id="content"> + + <?=@$page_content ?: ''; ?> + + </div> + </div> + +<?=@$footer_extra ?: ''; ?> + +</body> +</html> |