Skip to content

Commit

Permalink
Remove $rootPath where possible
Browse files Browse the repository at this point in the history
Plugins will fail to load if the web server doesn't have executable access to all the parent directories.

The realpath PHP function requires special permissions. dirname is a safer option because it's not file system aware.
  • Loading branch information
stickz committed Apr 22, 2023
1 parent 51bd6e8 commit cac8205
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion php/util.php
Expand Up @@ -2,7 +2,9 @@

// Include our base configuration file
$rootPath = realpath(dirname(__FILE__)."/..");
require_once( $rootPath.'/conf/config.php' );
// Avoid reusing $rootPath here becuase it calls realpath
// dirname is a more stable option becuase it's not file system aware
require_once( dirname(__FILE__).'/../conf/config.php' );

// Automatically include only the used utility classes
spl_autoload_register(function ($class)
Expand Down
2 changes: 1 addition & 1 deletion plugins/extratio/init.php
@@ -1,6 +1,6 @@
<?php

require_once( $rootPath.'/plugins/extratio/rules.php' );
require_once( 'rules.php' );

$mngr = rRatioRulesList::load();
if($mngr->setHandlers())
Expand Down
2 changes: 1 addition & 1 deletion plugins/history/init.php
@@ -1,6 +1,6 @@
<?php

require_once( $rootPath.'/plugins/history/history.php' );
require_once( 'history.php' );

$mngr = rHistory::load();
if($mngr->setHandlers())
Expand Down
4 changes: 2 additions & 2 deletions plugins/loginmgr/accounts.php
@@ -1,8 +1,8 @@
<?php

require_once( dirname(__FILE__)."/../../php/util.php" );
require_once( $rootPath.'/php/cache.php');
require_once( $rootPath.'/php/Snoopy.class.inc');
require_once( dirname(__FILE__)."/../../php/cache.php" );
require_once( dirname(__FILE__)."/../../php/Snoopy.class.inc");
eval( FileUtil::getPluginConf( 'loginmgr' ) );

class privateData
Expand Down
4 changes: 2 additions & 2 deletions plugins/ratio/ratio.php
@@ -1,8 +1,8 @@
<?php

require_once( dirname(__FILE__)."/../../php/xmlrpc.php" );
require_once( $rootPath.'/php/cache.php');
require_once( $rootPath.'/php/settings.php');
require_once( dirname(__FILE__)."/../../php/cache.php" );
require_once( dirname(__FILE__)."/../../php/settings.php" );
eval(FileUtil::getPluginConf('ratio'));

@define('RAT_STOP',0);
Expand Down
4 changes: 2 additions & 2 deletions plugins/retrackers/update.php
Expand Up @@ -4,8 +4,8 @@
$_SERVER['REMOTE_USER'] = $argv[2];

require_once( 'retrackers.php' );
require_once( $rootPath.'/php/xmlrpc.php' );
require_once( $rootPath.'/php/rtorrent.php' );
require_once( dirname(__FILE__)."/../../php/xmlrpc.php" );
require_once( dirname(__FILE__)."/../../php/cache.php" );

function clearTracker($addition,$tracker)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/scheduler/scheduler.php
@@ -1,7 +1,7 @@
<?php

require_once( dirname(__FILE__)."/../../php/xmlrpc.php" );
require_once( $rootPath.'/php/cache.php');
require_once( dirname(__FILE__)."/../../php/cache.php" );
eval(FileUtil::getPluginConf('scheduler'));

@define('SCH_FAST', 0);
Expand Down
2 changes: 1 addition & 1 deletion plugins/throttle/throttle.php
@@ -1,6 +1,6 @@
<?php
require_once( dirname(__FILE__)."/../../php/xmlrpc.php" );
require_once( $rootPath.'/php/cache.php');
require_once( dirname(__FILE__)."/../../php/cache.php" );
eval(FileUtil::getPluginConf('throttle'));

class rThrottle
Expand Down

0 comments on commit cac8205

Please sign in to comment.