From b84b865d45b00600d982fef18991398cb655c7e9 Mon Sep 17 00:00:00 2001 From: nashe Date: Tue, 11 Aug 2015 12:04:53 +0200 Subject: Clean code Replace dirname(__FILE__) by __DIR__. --- admin/administration.php | 8 ++++---- admin/changepassword.php | 4 ++-- admin/index.php | 10 +++++----- admin/login.php | 4 ++-- admin/purgecache.php | 4 ++-- admin/subscriptions.php | 12 ++++++------ app/app.php | 4 ++-- app/classes/Planet.php | 4 ++-- app/classes/PlanetFeed.php | 2 +- app/classes/Simplel10n.php | 2 +- app/l10n/extract.php | 2 +- atom.php | 6 +++--- cron.php | 4 ++-- custom/views/archive/index.tpl.php | 8 ++++---- custom/views/default/index.tpl.php | 8 ++++---- index.php | 12 ++++++------ install.php | 12 ++++++------ postload.php | 4 ++-- 18 files changed, 55 insertions(+), 55 deletions(-) diff --git a/admin/administration.php b/admin/administration.php index d3a8fdf..34afe73 100755 --- a/admin/administration.php +++ b/admin/administration.php @@ -1,10 +1,10 @@ getPeople(); $page_id = 'admin-admin'; $header_extra = <<<"HTML" @@ -40,4 +40,4 @@ FRAGMENT; $footer_extra = ''; $admin_access = 1; -require_once dirname(__FILE__) . '/template.php'; +require_once __DIR__ . '/template.php'; diff --git a/admin/changepassword.php b/admin/changepassword.php index 1fa505e..8c38769 100644 --- a/admin/changepassword.php +++ b/admin/changepassword.php @@ -1,9 +1,9 @@ '; - file_put_contents(dirname(__FILE__).'/inc/pwd.inc.php', $out); + file_put_contents(__DIR__.'/inc/pwd.inc.php', $out); die("Password changed. Login"); } else { die('Can not change password'); diff --git a/admin/index.php b/admin/index.php index 25b337b..42ddf19 100755 --- a/admin/index.php +++ b/admin/index.php @@ -1,10 +1,10 @@ loadOpml(dirname(__FILE__) . '/../custom/people.opml')) { +if (0 < $Planet->loadOpml(__DIR__ . '/../custom/people.opml')) { $Planet->loadFeeds(); $items = $Planet->getItems(); } @@ -136,4 +136,4 @@ $page_content = ob_get_contents(); ob_end_clean(); $admin_access = 1; -require_once dirname(__FILE__) . '/template.php'; +require_once __DIR__ . '/template.php'; diff --git a/admin/login.php b/admin/login.php index 796011f..3ba4d2b 100755 --- a/admin/login.php +++ b/admin/login.php @@ -4,7 +4,7 @@ if (isset($_POST['password'])) { header('Location: index.php'); } -require_once dirname(__FILE__) . '/../app/app.php'; +require_once __DIR__ . '/../app/app.php'; $page_content = <<
@@ -31,4 +31,4 @@ FRAGMENT; $page_id = 'admin-login'; $admin_access = 0; -require_once dirname(__FILE__) . '/template.php'; +require_once __DIR__ . '/template.php'; diff --git a/admin/purgecache.php b/admin/purgecache.php index 8657938..23a5712 100644 --- a/admin/purgecache.php +++ b/admin/purgecache.php @@ -1,10 +1,10 @@ getName() === '') { $PlanetConfig->setName($oldOpml->getTitle()); } - $oldOpml = OpmlManager::load(dirname(__FILE__).'/../custom/people.opml'); + $oldOpml = OpmlManager::load(__DIR__.'/../custom/people.opml'); $newOpml = new opml(); $newOpml->title = $PlanetConfig->getName(); @@ -57,10 +57,10 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { } // Backup old OPML - OpmlManager::backup(dirname(__FILE__).'/../custom/people.opml'); + OpmlManager::backup(__DIR__.'/../custom/people.opml'); // Save new OPML - OpmlManager::save($newOpml, dirname(__FILE__).'/../custom/people.opml'); + OpmlManager::save($newOpml, __DIR__.'/../custom/people.opml'); } header("Location: index.php"); die(); diff --git a/app/app.php b/app/app.php index eb6d6cf..269d99c 100755 --- a/app/app.php +++ b/app/app.php @@ -10,8 +10,8 @@ if ($debug) { require_once __DIR__.'/../vendor/autoload.php'; -$savedConfig = dirname(__FILE__).'/../custom/config.yml'; -$moon_version = file_get_contents(dirname(__FILE__).'/../VERSION'); +$savedConfig = __DIR__.'/../custom/config.yml'; +$moon_version = file_get_contents(__DIR__.'/../VERSION'); if (is_file($savedConfig)){ diff --git a/app/classes/Planet.php b/app/classes/Planet.php index f502d7a..baba7c1 100644 --- a/app/classes/Planet.php +++ b/app/classes/Planet.php @@ -169,7 +169,7 @@ class Planet public function download($max_load=0.1) { $max_load_feeds = ceil(count($this->people) * $max_load); - $opml = OpmlManager::load(dirname(__FILE__).'/../../custom/people.opml'); + $opml = OpmlManager::load(__DIR__.'/../../custom/people.opml'); foreach ($this->people as $feed) { //Avoid mass loading with variable cache duration @@ -203,7 +203,7 @@ class Planet } } } - OpmlManager::save($opml, dirname(__FILE__).'/../../custom/people.opml'); + OpmlManager::save($opml, __DIR__.'/../../custom/people.opml'); } public function sort() diff --git a/app/classes/PlanetFeed.php b/app/classes/PlanetFeed.php index 7c79471..f63ac5a 100644 --- a/app/classes/PlanetFeed.php +++ b/app/classes/PlanetFeed.php @@ -19,7 +19,7 @@ class PlanetFeed extends SimplePie $this->isDown = $isDown; parent::__construct(); $this->set_item_class('PlanetItem'); - $this->set_cache_location(dirname(__FILE__).'/../../cache'); + $this->set_cache_location(__DIR__.'/../../cache'); $this->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE); $this->set_feed_url($this->getFeed()); $this->set_timeout(5); diff --git a/app/classes/Simplel10n.php b/app/classes/Simplel10n.php index 7af8564..79313b3 100755 --- a/app/classes/Simplel10n.php +++ b/app/classes/Simplel10n.php @@ -9,7 +9,7 @@ class Simplel10n { public function __construct($locale='en') { $GLOBALS['locale'] = array(); $this->locale = $locale; - $this->l10nFolder = dirname(__FILE__) . '/../l10n/'; + $this->l10nFolder = __DIR__ . '/../l10n/'; $this->load($this->l10nFolder . $this->locale); } diff --git a/app/l10n/extract.php b/app/l10n/extract.php index 3f1ef33..878de4e 100755 --- a/app/l10n/extract.php +++ b/app/l10n/extract.php @@ -16,7 +16,7 @@ // released versions of moonmoon should immediately return for security // return; -$root = dirname(__FILE__) . '/../../'; +$root = __DIR__ . '/../../'; require_once $root.'/vendors/autoload.php'; diff --git a/atom.php b/atom.php index 5122158..feeffe3 100644 --- a/atom.php +++ b/atom.php @@ -1,8 +1,8 @@ loadOpml(dirname(__FILE__).'/custom/people.opml') == 0) exit; +if ($Planet->loadOpml(__DIR__.'/custom/people.opml') == 0) exit; $Planet->loadFeeds(); $items = $Planet->getItems(); diff --git a/cron.php b/cron.php index f8fc8ce..ead1a1e 100644 --- a/cron.php +++ b/cron.php @@ -1,8 +1,8 @@ loadOpml(dirname(__FILE__).'/custom/people.opml')) { +if (0 < $Planet->loadOpml(__DIR__.'/custom/people.opml')) { $Planet->download(1.0); } diff --git a/custom/views/archive/index.tpl.php b/custom/views/archive/index.tpl.php index 2bb8f36..16bc6ab 100755 --- a/custom/views/archive/index.tpl.php +++ b/custom/views/archive/index.tpl.php @@ -29,12 +29,12 @@ header('Content-type: text/html; charset=UTF-8'); <?php echo $PlanetConfig->getName(); ?> - +
- +
@@ -106,9 +106,9 @@ header('Content-type: text/html; charset=UTF-8');
- + - +
diff --git a/custom/views/default/index.tpl.php b/custom/views/default/index.tpl.php index 1bf037a..2a5827f 100755 --- a/custom/views/default/index.tpl.php +++ b/custom/views/default/index.tpl.php @@ -12,7 +12,7 @@ header('Content-type: text/html; charset=UTF-8'); <?php echo $PlanetConfig->getName(); ?> - + @@ -20,7 +20,7 @@ header('Content-type: text/html; charset=UTF-8'); document.body.className += 'js';
- +
@@ -65,9 +65,9 @@ header('Content-type: text/html; charset=UTF-8');
- + - +
diff --git a/index.php b/index.php index 60d5e77..a58d32c 100755 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ loadOpml(dirname(__FILE__).'/custom/people.opml')) { +if (0 < $Planet->loadOpml(__DIR__.'/custom/people.opml')) { $Planet->loadFeeds(); $items = $Planet->getItems(); } @@ -21,7 +21,7 @@ $cache_key = (count($items)) ? $items[0]->get_id() : ''; $last_modified = (count($items)) ? $items[0]->get_date() : ''; $cache_duration = $PlanetConfig->getOutputTimeout()*60; -Cache::setStore(dirname(__FILE__) . '/' . $conf['cachedir'] . '/'); +Cache::setStore(__DIR__ . '/' . $conf['cachedir'] . '/'); if (isset($_GET['type']) && $_GET['type'] == 'atom10') { /* XXX: Redirect old ATOM feeds to new url to make sure our users don't @@ -35,13 +35,13 @@ if (isset($_GET['type']) && $_GET['type'] == 'atom10') { //Go display if (!isset($_GET['type']) || - !is_file(dirname(__FILE__).'/custom/views/'.$_GET['type'].'/index.tpl.php') || + !is_file(__DIR__.'/custom/views/'.$_GET['type'].'/index.tpl.php') || strpos($_GET['type'], DIRECTORY_SEPARATOR)){ $_GET['type'] = 'default'; } if (!OutputCache::Start($_GET['type'], $cache_key, $cache_duration)) { - include_once(dirname(__FILE__).'/custom/views/'.$_GET['type'].'/index.tpl.php'); + include_once(__DIR__.'/custom/views/'.$_GET['type'].'/index.tpl.php'); OutputCache::End(); } diff --git a/install.php b/install.php index addf819..e0c23bd 100755 --- a/install.php +++ b/install.php @@ -1,6 +1,6 @@ toYaml()); + $save['config'] = file_put_contents(__DIR__.'/custom/config.yml', $CreatePlanetConfig->toYaml()); //Save password - $save['password'] = file_put_contents(dirname(__FILE__).'/admin/inc/pwd.inc.php', ''); + $save['password'] = file_put_contents(__DIR__.'/admin/inc/pwd.inc.php', ''); if (0 != ($save['config'] + $save['password'])) { $status = 'installed'; @@ -58,7 +58,7 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') // We now test that all required files are writable foreach ($tests as $v) { - if(is_writable(dirname(__FILE__) . $v)) { + if(is_writable(__DIR__ . $v)) { $strInstall .= installStatus("$v is writable", 'OK', true); } else { $strInstall .= installStatus("$v is writable", 'FAIL',false); diff --git a/postload.php b/postload.php index 8f18678..ba37a29 100644 --- a/postload.php +++ b/postload.php @@ -1,5 +1,5 @@ addPerson( new PlanetFeed( @@ -12,5 +12,5 @@ $Planet->addPerson( //Load feeds $Planet->download(1); header("Content-type: image/png"); -readfile(dirname(__FILE__)."/custom/img/feed.png"); +readfile(__DIR__."/custom/img/feed.png"); die(); -- cgit v1.2.1