Skip to content

Commit

Permalink
Correct $GLOBALS directory structure variables
Browse files Browse the repository at this point in the history
Revert code that was proposed in #31, ported to #38, and mistakenly deployed via 9d72b4d that attempts to work with an Apache alias environment.  The proposed code modified the $GLOBALS['basedirWebServer'] and $GLOBALS['appInstallDir'] variables, which resulted in unexpected values in $GLOBALS['scriptName'].  The final result of this code change is that under certain Apache configurations it was not possible to reliably use $GLOBALS['scriptName'] to detect what page was being rendered and thus conditional situations were failing.  The example brought up in #51 is that a javascript file was not being loaded on the reports.php page.
  • Loading branch information
PromInc authored May 24, 2017
1 parent 13ad81f commit ef004f2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions organic-search-analytics/inc/code/globalIncludes.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
$now = time();

$GLOBALS['basedirWebServer'] = ( isset( $_SERVER['CONTEXT_DOCUMENT_ROOT'] ) ? $_SERVER['CONTEXT_DOCUMENT_ROOT'] . "/" : $_SERVER['DOCUMENT_ROOT'] . "/" );
$GLOBALS['aliasdir'] = ( isset( $_SERVER['CONTEXT_PREFIX'] ) ? ltrim( $_SERVER['CONTEXT_PREFIX'], "/" ) . "/" : "" );
$GLOBALS['basedirWebServer'] = $_SERVER['DOCUMENT_ROOT']."/";
$GLOBALS['basedir'] = preg_replace( '/\\\/', '/', realpath(dirname(__FILE__).'/../../').'/' );
$GLOBALS['appInstallDir'] = str_replace( $GLOBALS['basedirWebServer'], "", $GLOBALS['basedir'] ) . $GLOBALS['aliasdir'];
$GLOBALS['appInstallDir'] = str_replace( $GLOBALS['basedirWebServer'], "", $GLOBALS['basedir'] );
$GLOBALS['file_name'] = basename( $_SERVER['SCRIPT_FILENAME'], ".php" );

$isConfigured = file_exists($GLOBALS['basedir'].'config/config.php');
Expand Down Expand Up @@ -42,4 +41,4 @@
} else {
$alert = array("type"=>"warning", "message"=>"Please set your configuration settings before procedding. <a href=\"settings-configure.php\">Configure Now</a>");
}
?>
?>

0 comments on commit ef004f2

Please sign in to comment.