Skip to main content
deleted 10 characters in body
Source Link
mickmackusa
  • 8.7k
  • 1
  • 16
  • 31

Your current battery of if conditions needs a re-think. $_SERVER['PHP_SELF'] -- as long as it has a non-falsey value will evauate to true, satisfy the first expression, will never even reach $_SERVER['PHP_URL_PATH'] === "/mainHubV8.1.php", execute echo "Loading Styles for MainHubV8.1.php";, and nothing else will ever get a look.

It is unclear to me if you ever want to load multiple stylesheets. If so this would a second reason to opt for a switch block versus an if-elseif... block.

You probably intend to check if the string is found in $_SERVER['PHP_SELF'] or $_SERVER['PHP_URL_PATH']. Each variable must be separately checked (there are different techniques to perform that process).

I think you should choose one reliable source to make your comparison on.

To streamline your code without abandoning secure practices, I recommend a "whitelist" array of valid css filenames. If the incoming value exists in the whitelist, include the filenamecss file(s) by directly writing the $_SERVER value into a require or include callthe echo line(s).

If you cannot manage to get the 1-to-1 literal variable string to match your css file, then I recommend a lookup array instead of a switch block (because I hate how verbose all those break lines make the script).

Your current battery of if conditions needs a re-think. $_SERVER['PHP_SELF'] -- as long as it has a non-falsey value will evauate to true, satisfy the first expression, will never even reach $_SERVER['PHP_URL_PATH'] === "/mainHubV8.1.php", execute echo "Loading Styles for MainHubV8.1.php";, and nothing else will ever get a look.

It is unclear to me if you ever want to load multiple stylesheets. If so this would a second reason to opt for a switch block versus an if-elseif... block.

You probably intend to check if the string is found in $_SERVER['PHP_SELF'] or $_SERVER['PHP_URL_PATH']. Each variable must be separately checked (there are different techniques to perform that process).

I think you should choose one reliable source to make your comparison on.

To streamline your code without abandoning secure practices, I recommend a "whitelist" array of valid css filenames. If the incoming value exists in the whitelist, include the filename by directly writing the $_SERVER value into a require or include call.

If you cannot manage to get the 1-to-1 literal variable string to match your css file, then I recommend a lookup array instead of a switch block (because I hate how verbose all those break lines make the script).

Your current battery of if conditions needs a re-think. $_SERVER['PHP_SELF'] -- as long as it has a non-falsey value will evauate to true, satisfy the first expression, will never even reach $_SERVER['PHP_URL_PATH'] === "/mainHubV8.1.php", execute echo "Loading Styles for MainHubV8.1.php";, and nothing else will ever get a look.

It is unclear to me if you ever want to load multiple stylesheets. If so this would a second reason to opt for a switch block versus an if-elseif... block.

You probably intend to check if the string is found in $_SERVER['PHP_SELF'] or $_SERVER['PHP_URL_PATH']. Each variable must be separately checked (there are different techniques to perform that process).

I think you should choose one reliable source to make your comparison on.

To streamline your code without abandoning secure practices, I recommend a "whitelist" array of valid css filenames. If the incoming value exists in the whitelist, include the css file(s) by directly writing the $_SERVER value into the echo line(s).

If you cannot manage to get the 1-to-1 literal variable string to match your css file, then I recommend a lookup array instead of a switch block (because I hate how verbose all those break lines make the script).

Source Link
mickmackusa
  • 8.7k
  • 1
  • 16
  • 31

Your current battery of if conditions needs a re-think. $_SERVER['PHP_SELF'] -- as long as it has a non-falsey value will evauate to true, satisfy the first expression, will never even reach $_SERVER['PHP_URL_PATH'] === "/mainHubV8.1.php", execute echo "Loading Styles for MainHubV8.1.php";, and nothing else will ever get a look.

It is unclear to me if you ever want to load multiple stylesheets. If so this would a second reason to opt for a switch block versus an if-elseif... block.

You probably intend to check if the string is found in $_SERVER['PHP_SELF'] or $_SERVER['PHP_URL_PATH']. Each variable must be separately checked (there are different techniques to perform that process).

I think you should choose one reliable source to make your comparison on.

To streamline your code without abandoning secure practices, I recommend a "whitelist" array of valid css filenames. If the incoming value exists in the whitelist, include the filename by directly writing the $_SERVER value into a require or include call.

If you cannot manage to get the 1-to-1 literal variable string to match your css file, then I recommend a lookup array instead of a switch block (because I hate how verbose all those break lines make the script).