LPH
Well-known member
I'm trying to write some code that auto-discovers the location of XF from an external page. This code works on my server but the number of locations for installing could be far greater. How could I improve this array to get a greater probability to get the correct path location?
Again - this works on my server because the XF is installed domain.com/community. It should get someone who installed it in /forums or /forum ...
What other possibilities are there?
Maybe you have a better suggestion instead of the array ...
Thank you in advance.
Update: I realize that this code leaves things hanging if the $xf_paths is not correct and needs to be updated to return a message for the user to input the location. I'm still working on improving that too.
Code:
$xf_paths = array(
'community' ,
'forums',
'forum' );
foreach ( $xf_paths as $xf_path ) {
$startTime = microtime(true);
if( $this->fileDir = ABSPATH . $xf_path ) {
if( !class_exists("XenForo_Autoloader" ) ) {
require($this->fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($this->fileDir . '/library');
XenForo_Application::initialize($this->fileDir . '/library', $this->fileDir);
echo XenForo_Application::getInstance()->getRootDir();
}
}
}
Again - this works on my server because the XF is installed domain.com/community. It should get someone who installed it in /forums or /forum ...
What other possibilities are there?
Maybe you have a better suggestion instead of the array ...
Thank you in advance.
Update: I realize that this code leaves things hanging if the $xf_paths is not correct and needs to be updated to return a message for the user to input the location. I'm still working on improving that too.