diff options
author | nashe <contact@nashe.fr> | 2015-08-11 12:04:53 +0200 |
---|---|---|
committer | nashe <contact@nashe.fr> | 2015-08-11 12:04:53 +0200 |
commit | b84b865d45b00600d982fef18991398cb655c7e9 (patch) | |
tree | 5f3d0432facd74395d029c480bb79d9e0669eb01 | |
parent | f2788a4ed2eae7f0056ab200b8fc787ed20a32da (diff) | |
download | planet-b84b865d45b00600d982fef18991398cb655c7e9.tar planet-b84b865d45b00600d982fef18991398cb655c7e9.tar.gz planet-b84b865d45b00600d982fef18991398cb655c7e9.tar.bz2 planet-b84b865d45b00600d982fef18991398cb655c7e9.tar.xz planet-b84b865d45b00600d982fef18991398cb655c7e9.zip |
Clean code
Replace dirname(__FILE__) by __DIR__.
-rwxr-xr-x | admin/administration.php | 8 | ||||
-rw-r--r-- | admin/changepassword.php | 4 | ||||
-rwxr-xr-x | admin/index.php | 10 | ||||
-rwxr-xr-x | admin/login.php | 4 | ||||
-rw-r--r-- | admin/purgecache.php | 4 | ||||
-rwxr-xr-x | admin/subscriptions.php | 12 | ||||
-rwxr-xr-x | app/app.php | 4 | ||||
-rw-r--r-- | app/classes/Planet.php | 4 | ||||
-rw-r--r-- | app/classes/PlanetFeed.php | 2 | ||||
-rwxr-xr-x | app/classes/Simplel10n.php | 2 | ||||
-rwxr-xr-x | app/l10n/extract.php | 2 | ||||
-rw-r--r-- | atom.php | 6 | ||||
-rw-r--r-- | cron.php | 4 | ||||
-rwxr-xr-x | custom/views/archive/index.tpl.php | 8 | ||||
-rwxr-xr-x | custom/views/default/index.tpl.php | 8 | ||||
-rwxr-xr-x | index.php | 12 | ||||
-rwxr-xr-x | install.php | 12 | ||||
-rw-r--r-- | 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 @@ <?php -require_once dirname(__FILE__) . '/../app/app.php'; -require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once __DIR__ . '/../app/app.php'; +require_once __DIR__ . '/inc/auth.inc.php'; -$opml = OpmlManager::load(dirname(__FILE__) . '/../custom/people.opml'); +$opml = OpmlManager::load(__DIR__ . '/../custom/people.opml'); $opml_people = $opml->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 @@ <?php -require_once dirname(__FILE__).'/inc/auth.inc.php'; +require_once __DIR__.'/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); + file_put_contents(__DIR__.'/inc/pwd.inc.php', $out); die("Password changed. <a href='administration.php'>Login</a>"); } 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 @@ <?php -require_once dirname(__FILE__) . '/../app/app.php'; -require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once __DIR__ . '/../app/app.php'; +require_once __DIR__ . '/inc/auth.inc.php'; //Load configuration -$config_file = dirname(__FILE__) . '/../custom/config.yml'; +$config_file = __DIR__ . '/../custom/config.yml'; if (is_file($config_file)){ $conf = Spyc::YAMLLoad($config_file); @@ -17,7 +17,7 @@ if (is_file($config_file)){ $Planet = new Planet($PlanetConfig); //Load -if (0 < $Planet->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 = <<<FRAGMENT <form action="" method="post" class="login"> <fieldset> @@ -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 @@ <?php require_once __DIR__.'/../app/app.php'; -require_once dirname(__FILE__).'/inc/auth.inc.php'; +require_once __DIR__.'/inc/auth.inc.php'; if (isset($_POST['purge'])){ - $dir = dirname(__FILE__).'/../cache/'; + $dir = __DIR__.'/../cache/'; $dh = opendir($dir); diff --git a/admin/subscriptions.php b/admin/subscriptions.php index 8367a16..f2d51f5 100755 --- a/admin/subscriptions.php +++ b/admin/subscriptions.php @@ -1,7 +1,7 @@ <?php -require_once dirname(__FILE__) . '/../app/app.php'; -require_once dirname(__FILE__) . '/inc/auth.inc.php'; +require_once __DIR__ . '/../app/app.php'; +require_once __DIR__ . '/inc/auth.inc.php'; function removeSlashes(&$item, $key){ $item = stripslashes($item); @@ -10,12 +10,12 @@ function removeSlashes(&$item, $key){ if (isset($_POST['opml']) || isset($_POST['add'])) { // Load config and old OPML - $conf = Spyc::YAMLLoad(dirname(__FILE__).'/../custom/config.yml'); + $conf = Spyc::YAMLLoad(__DIR__.'/../custom/config.yml'); $PlanetConfig = new PlanetConfig($conf); if ($PlanetConfig->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'; @@ -1,8 +1,8 @@ <?php -include_once(dirname(__FILE__).'/app/app.php'); -include_once(dirname(__FILE__).'/app/lib/Cache.php'); +include_once(__DIR__.'/app/app.php'); +include_once(__DIR__.'/app/lib/Cache.php'); -if ($Planet->loadOpml(dirname(__FILE__).'/custom/people.opml') == 0) exit; +if ($Planet->loadOpml(__DIR__.'/custom/people.opml') == 0) exit; $Planet->loadFeeds(); $items = $Planet->getItems(); @@ -1,8 +1,8 @@ <?php -include_once(dirname(__FILE__).'/app/app.php'); +include_once(__DIR__.'/app/app.php'); //Load OPML -if (0 < $Planet->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'); <meta http-equiv="Content-Style-Type" content="text/css" /> <title><?php echo $PlanetConfig->getName(); ?></title> - <?php include(dirname(__FILE__).'/head.tpl.php'); ?> + <?php include(__DIR__.'/head.tpl.php'); ?> </head> <body> <div id="page"> - <?php include(dirname(__FILE__).'/top.tpl.php'); ?> + <?php include(__DIR__.'/top.tpl.php'); ?> <div id="content"> <?php if (0 == count($items)) :?> @@ -106,9 +106,9 @@ header('Content-type: text/html; charset=UTF-8'); <?php endif; ?> </div> - <?php include_once(dirname(__FILE__).'/sidebar.tpl.php'); ?> + <?php include_once(__DIR__.'/sidebar.tpl.php'); ?> - <?php include(dirname(__FILE__).'/footer.tpl.php'); ?> + <?php include(__DIR__.'/footer.tpl.php'); ?> </div> </body> </html> 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'); <meta http-equiv="Content-Style-Type" content="text/css" /> <title><?php echo $PlanetConfig->getName(); ?></title> - <?php include(dirname(__FILE__).'/head.tpl.php'); ?> + <?php include(__DIR__.'/head.tpl.php'); ?> </head> <body> @@ -20,7 +20,7 @@ header('Content-type: text/html; charset=UTF-8'); document.body.className += 'js'; </script> <div id="page"> - <?php include(dirname(__FILE__).'/top.tpl.php'); ?> + <?php include(__DIR__.'/top.tpl.php'); ?> <div id="content"> <?php if (0 == count($items)) : ?> @@ -65,9 +65,9 @@ header('Content-type: text/html; charset=UTF-8'); <?php endif; ?> </div> - <?php include_once(dirname(__FILE__).'/sidebar.tpl.php'); ?> + <?php include_once(__DIR__.'/sidebar.tpl.php'); ?> - <?php include(dirname(__FILE__).'/footer.tpl.php'); ?> + <?php include(__DIR__.'/footer.tpl.php'); ?> </div> </body> </html> @@ -1,6 +1,6 @@ <?php -include_once(dirname(__FILE__).'/app/app.php'); -include_once(dirname(__FILE__).'/app/lib/Cache.php'); +include_once(__DIR__.'/app/app.php'); +include_once(__DIR__.'/app/lib/Cache.php'); //Installed ? if (!isset($Planet)) { @@ -10,7 +10,7 @@ if (!isset($Planet)) { //Load from cache $items = Array(); -if (0 < $Planet->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 @@ <?php -require_once dirname(__FILE__) . '/app/app.php'; +require_once __DIR__ . '/app/app.php'; // This is an helper function returning an html table row to avoid code duplication function installStatus($str, $msg, $result) { @@ -9,8 +9,8 @@ function installStatus($str, $msg, $result) { } // If the password and config files exist, moonmoon is already installed -if (file_exists(dirname(__FILE__) . '/custom/config.yml') - && file_exists(dirname(__FILE__) . '/admin/inc/pwd.inc.php')) { +if (file_exists(__DIR__ . '/custom/config.yml') + && file_exists(__DIR__ . '/admin/inc/pwd.inc.php')) { $status = 'installed'; } elseif (isset($_REQUEST['url'])) { $save = array(); @@ -29,10 +29,10 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') ); $CreatePlanetConfig = new PlanetConfig($config); - $save['config'] = file_put_contents(dirname(__FILE__).'/custom/config.yml', $CreatePlanetConfig->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', '<?php $login="admin"; $password="'.md5($_REQUEST['password']).'"; ?>'); + $save['password'] = file_put_contents(__DIR__.'/admin/inc/pwd.inc.php', '<?php $login="admin"; $password="'.md5($_REQUEST['password']).'"; ?>'); 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("<code>$v</code> is writable", 'OK', true); } else { $strInstall .= installStatus("<code>$v</code> 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 @@ <?php -include_once(dirname(__FILE__).'/app/app.php'); +include_once(__DIR__.'/app/app.php'); $Planet->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(); |