From c27c9d1d359828a071159995689c9c3b28d99891 Mon Sep 17 00:00:00 2001 From: rdalverny Date: Sat, 22 Jan 2022 18:54:11 +0100 Subject: 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. --- .gitignore | 9 +- Makefile | 12 +- admin/administration.php | 59 --------- admin/changepassword.php | 12 -- admin/default.css | 232 ------------------------------------ admin/img/button-add.png | Bin 244 -> 0 bytes admin/img/button-delete.png | Bin 201 -> 0 bytes admin/img/button-h.png | Bin 212 -> 0 bytes admin/img/button.png | Bin 212 -> 0 bytes admin/img/h3.png | Bin 212 -> 0 bytes admin/img/moonmoon.png | Bin 564 -> 0 bytes admin/img/nav-admin.png | Bin 1519 -> 0 bytes admin/img/nav-feed.png | Bin 1090 -> 0 bytes admin/inc/auth.inc.php | 13 -- admin/index.php | 149 ----------------------- admin/login.php | 51 -------- admin/logout.php | 10 -- admin/purgecache.php | 24 ---- admin/subscriptions.php | 84 ------------- admin/template.php | 54 --------- app/classes/PlanetConfig.php | 76 ++++++++++-- app/helpers.php | 41 ++++++- atom.php | 41 ------- cron.php | 13 -- custom/img/feed.png | Bin 484 -> 0 bytes custom/img/moonmoon.png | Bin 73408 -> 0 bytes custom/img/moonmoon@128w.png | Bin 8671 -> 0 bytes custom/img/moonmoon@256w.png | Bin 24255 -> 0 bytes custom/img/opml.png | Bin 31542 -> 0 bytes custom/style/dark.css | 125 ------------------- custom/style/default.css | 158 ------------------------ custom/style/green.css | 132 -------------------- custom/style/light.css | 124 ------------------- custom/style/mobile.css | 8 -- index.php | 40 ------- install.php | 100 ---------------- phpcs.xml | 4 +- phpunit.xml | 4 +- postload.php | 28 ----- public/admin/administration.php | 59 +++++++++ public/admin/changepassword.php | 12 ++ public/admin/default.css | 232 ++++++++++++++++++++++++++++++++++++ public/admin/img/button-add.png | Bin 0 -> 244 bytes public/admin/img/button-delete.png | Bin 0 -> 201 bytes public/admin/img/button-h.png | Bin 0 -> 212 bytes public/admin/img/button.png | Bin 0 -> 212 bytes public/admin/img/h3.png | Bin 0 -> 212 bytes public/admin/img/moonmoon.png | Bin 0 -> 564 bytes public/admin/img/nav-admin.png | Bin 0 -> 1519 bytes public/admin/img/nav-feed.png | Bin 0 -> 1090 bytes public/admin/inc/auth.inc.php | 9 ++ public/admin/index.php | 149 +++++++++++++++++++++++ public/admin/login.php | 51 ++++++++ public/admin/logout.php | 10 ++ public/admin/purgecache.php | 24 ++++ public/admin/subscriptions.php | 84 +++++++++++++ public/admin/template.php | 54 +++++++++ public/atom.php | 4 + public/cron.php | 13 ++ public/custom/img/feed.png | Bin 0 -> 484 bytes public/custom/img/moonmoon.png | Bin 0 -> 73408 bytes public/custom/img/moonmoon@128w.png | Bin 0 -> 8671 bytes public/custom/img/moonmoon@256w.png | Bin 0 -> 24255 bytes public/custom/img/opml.png | Bin 0 -> 31542 bytes public/custom/style/dark.css | 125 +++++++++++++++++++ public/custom/style/default.css | 158 ++++++++++++++++++++++++ public/custom/style/green.css | 132 ++++++++++++++++++++ public/custom/style/light.css | 124 +++++++++++++++++++ public/custom/style/mobile.css | 8 ++ public/feed/index.php | 43 +++++++ public/index.php | 40 +++++++ public/install.php | 98 +++++++++++++++ public/postload.php | 28 +++++ tests/InstallTest.php | 47 +++++++- 74 files changed, 1622 insertions(+), 1485 deletions(-) delete mode 100755 admin/administration.php delete mode 100644 admin/changepassword.php delete mode 100755 admin/default.css delete mode 100644 admin/img/button-add.png delete mode 100644 admin/img/button-delete.png delete mode 100644 admin/img/button-h.png delete mode 100644 admin/img/button.png delete mode 100644 admin/img/h3.png delete mode 100644 admin/img/moonmoon.png delete mode 100644 admin/img/nav-admin.png delete mode 100644 admin/img/nav-feed.png delete mode 100644 admin/inc/auth.inc.php delete mode 100755 admin/index.php delete mode 100755 admin/login.php delete mode 100644 admin/logout.php delete mode 100644 admin/purgecache.php delete mode 100755 admin/subscriptions.php delete mode 100755 admin/template.php delete mode 100644 atom.php delete mode 100644 cron.php delete mode 100644 custom/img/feed.png delete mode 100644 custom/img/moonmoon.png delete mode 100644 custom/img/moonmoon@128w.png delete mode 100644 custom/img/moonmoon@256w.png delete mode 100644 custom/img/opml.png delete mode 100644 custom/style/dark.css delete mode 100644 custom/style/default.css delete mode 100644 custom/style/green.css delete mode 100644 custom/style/light.css delete mode 100644 custom/style/mobile.css delete mode 100755 index.php delete mode 100755 install.php delete mode 100644 postload.php create mode 100755 public/admin/administration.php create mode 100644 public/admin/changepassword.php create mode 100755 public/admin/default.css create mode 100644 public/admin/img/button-add.png create mode 100644 public/admin/img/button-delete.png create mode 100644 public/admin/img/button-h.png create mode 100644 public/admin/img/button.png create mode 100644 public/admin/img/h3.png create mode 100644 public/admin/img/moonmoon.png create mode 100644 public/admin/img/nav-admin.png create mode 100644 public/admin/img/nav-feed.png create mode 100644 public/admin/inc/auth.inc.php create mode 100755 public/admin/index.php create mode 100755 public/admin/login.php create mode 100644 public/admin/logout.php create mode 100644 public/admin/purgecache.php create mode 100755 public/admin/subscriptions.php create mode 100755 public/admin/template.php create mode 100644 public/atom.php create mode 100644 public/cron.php create mode 100644 public/custom/img/feed.png create mode 100644 public/custom/img/moonmoon.png create mode 100644 public/custom/img/moonmoon@128w.png create mode 100644 public/custom/img/moonmoon@256w.png create mode 100644 public/custom/img/opml.png create mode 100644 public/custom/style/dark.css create mode 100644 public/custom/style/default.css create mode 100644 public/custom/style/green.css create mode 100644 public/custom/style/light.css create mode 100644 public/custom/style/mobile.css create mode 100644 public/feed/index.php create mode 100755 public/index.php create mode 100755 public/install.php create mode 100644 public/postload.php diff --git a/.gitignore b/.gitignore index 5101c47..a1813f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,16 @@ +.DS_Store +.idea +.phpunit.* /cache /custom/config.yml /custom/people.opml /custom/people.opml.bak +/custom/config /admin/inc/pwd.inc.php /vendor/ /tests/_output/* /nbproject/private/ -/.idea/ tmp/ - -.phpunit.result.cache - +public/tests diff --git a/Makefile b/Makefile index 00506fa..7548027 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,13 @@ VENDOR=./vendor/bin/ PHPUNIT=php -dxdebug.enabled=1 -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text test: - { php -S 127.0.0.1:8081 >& /dev/null & }; \ + rm -f public/tests && ln -s ../tests public/tests + { php -S 127.0.0.1:8081 -t public/ >& /dev/null & }; \ PID=$$!; \ $(PHPUNIT); \ RES=$$?; \ kill $$PID; \ + rm public/tests exit $$RES fmt: @@ -24,9 +26,13 @@ stan: report: $(VENDOR)phpmd \ - admin,app,custom,docs,tests,atom.php,cron.php,index.php,install.php,postload.php \ + app,custom,docs,tests,public \ html \ cleancode,codesize,controversial,design,naming,unusedcode > tmp/report.html serve: - php -S localhost:5555 -t . + php -S localhost:5555 -t public/ + +clean: + rm -fr ./cache/* + rm -fr ./custom/config/* \ No newline at end of file diff --git a/admin/administration.php b/admin/administration.php deleted file mode 100755 index e6236fd..0000000 --- a/admin/administration.php +++ /dev/null @@ -1,59 +0,0 @@ -getOpmlFile()); -$opml_people = $opml->getPeople(); -$page_id = 'admin-admin'; -$header_extra = <<<"HTML" - - -HTML; - -$repo_url = 'https://github.com/moonmoon/moonmoon'; -$releases_url = "$repo_url/releases"; -$link_url = "$releases_url"; -$version_current = str_replace('%s', $moon_version, $l10n->getString('Your moonmoon instance version is %s.')); -$version_action = str_replace('%s', $link_url, $l10n->getString('You can check for a more recent version on: %s.')); - -$page_content = <<<"FRAGMENT" - -
-

{$l10n->getString('Clear cache')}

-
- -

-

{$l10n->getString('Clearing the cache will make moonmoon reload all feeds.')}

-
-
- -
-

{$l10n->getString('Change administrator password')}

-
- -

-
-
- -
-

{$l10n->getString('Upgrade moonmoon')}

-
-

{$version_current}

-

{$version_action}

-
-
- -FRAGMENT; - -$footer_extra = ''; -$admin_access = 1; -require_once __DIR__ . '/template.php'; diff --git a/admin/changepassword.php b/admin/changepassword.php deleted file mode 100644 index c1e61ff..0000000 --- a/admin/changepassword.php +++ /dev/null @@ -1,12 +0,0 @@ -verify($_POST['_csrf'], 'frmPassword') && isset($_POST['password']) && ('' != $_POST['password'])) { - $out = sprintf('', hash('sha256', $_POST['password'])); - file_put_contents(__DIR__.'/inc/pwd.inc.php', $out); - die("Password changed. Login"); -} else { - die('Can not change password'); -} diff --git a/admin/default.css b/admin/default.css deleted file mode 100755 index fcba3f4..0000000 --- a/admin/default.css +++ /dev/null @@ -1,232 +0,0 @@ -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/admin/img/button-add.png b/admin/img/button-add.png deleted file mode 100644 index 859364a..0000000 Binary files a/admin/img/button-add.png and /dev/null differ diff --git a/admin/img/button-delete.png b/admin/img/button-delete.png deleted file mode 100644 index 7bfebc2..0000000 Binary files a/admin/img/button-delete.png and /dev/null differ diff --git a/admin/img/button-h.png b/admin/img/button-h.png deleted file mode 100644 index 0a43a6a..0000000 Binary files a/admin/img/button-h.png and /dev/null differ diff --git a/admin/img/button.png b/admin/img/button.png deleted file mode 100644 index fad6ccc..0000000 Binary files a/admin/img/button.png and /dev/null differ diff --git a/admin/img/h3.png b/admin/img/h3.png deleted file mode 100644 index 0c86748..0000000 Binary files a/admin/img/h3.png and /dev/null differ diff --git a/admin/img/moonmoon.png b/admin/img/moonmoon.png deleted file mode 100644 index 26cc8f4..0000000 Binary files a/admin/img/moonmoon.png and /dev/null differ diff --git a/admin/img/nav-admin.png b/admin/img/nav-admin.png deleted file mode 100644 index 3077a54..0000000 Binary files a/admin/img/nav-admin.png and /dev/null differ diff --git a/admin/img/nav-feed.png b/admin/img/nav-feed.png deleted file mode 100644 index 00c896b..0000000 Binary files a/admin/img/nav-feed.png and /dev/null differ diff --git a/admin/inc/auth.inc.php b/admin/inc/auth.inc.php deleted file mode 100644 index 0305b13..0000000 --- a/admin/inc/auth.inc.php +++ /dev/null @@ -1,13 +0,0 @@ -' . _g('You might want to install moonmoon.') . '

'); -} - -//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 = << - var allCheckboxes = function(status){ - var form = document.getElementById('feedmanage'); - var selectboxes = form.getElementsByTagName('input'); - for (var i=0; i -FRAGMENT; - -ob_start(); -?> - -
-

-
-
- - - -
-

- -
-
- -
-

-
-

- - - - -

-

,

- - - - - - - - - - - - - - - - - - - - - - - -
- 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"' : ''; - ?> - value="1" />
-
-
- -
-

-
-

Beware! This will totally erase and replace the list of your feeds just above.

-
- - - -
- -
-
- -', $hash_pwd)); - } - - setcookie('auth', $hash_pwd); - header('Location: index.php'); -} - -$page_content = <<