0

I have following text in file settings.php :

etc... //USTAWIENIA PODSTAWOWE 
define("P2_PAGE_CLOSED", "true"); // przerwa techniczna - prawidłowe wartości = true lub false
define("P2_PAGE_CLSTXT", "Przepraszamy za utrudnienia - strona tymczasowo nieczynna"); //opis wyświetlany w przypadku przerwy technicznej
define("P2_PAGE_BGCOLOR", ""); //inny niż biały kolor tła - należy zapisać w postaci heksadecymalnej (musi zawierać # !)
define("P2_PAGE_TITLE", "Portal Uczniowski 2.0 - {title}"); // tytuł strony - {title} = nazwa aktualnie przeglądanej strony
define("P2_PAGE_INDEX", "true"); // czy strona ma być indeksowna przez wyszukiwarki internetowe - prawidłowe wartości = true lub false
define("P2_PAGE_KEYWORDS","portal uczniowski 2.0"); // słowa kluczowe dla wyszukiwarki - może pozostać puste w przypadku gdy wartość pola P2_PAGE_INDEX jest równa false
define("P2_PAGE_DESC","Portal Uczniowski"); // opis strony w wyszukiwarce - - może pozostać puste w przypadku gdy wartość pola P2_PAGE_INDEX jest równa false
define("P2_PAGE_ONLYREG", "true"); //tylko zarejstrowani użytkownicy mogą odwiedzić stronę - prawidłowe wartości = true lub false
// etc...

I have got a function (in file core.inc), which validates correctness of settings.php :

function core_validateSettings()
{
include_once("settings.php");

if(P2_PAGE_CLOSED != "false" && P2_PAGE_CLOSED != "true") { echo "Błąd w stałej ustawień P2_PAGE_CLOSED"; return false;}
if(P2_PAGE_INDEX != "false" && P2_PAGE_INDEX != "true") { echo "Błąd w stałej ustawień P2_PAGE_INDEX"; return false;}
if(P2_PAGE_ONLYREG != "false" && P2_PAGE_ONLYREG != "true") { echo "Błąd w stałej ustawień P2_PAGE_ONLYREG"; return false;}
if(P2_SEC_HOTLINK != "false" && P2_SEC_HOTLINK != "true") { echo "Błąd w stałej ustawień P2_SEC_HOTLINK"; return false;}
if(P2_SEC_REQMAIL != "false" && P2_SEC_REQMAIL != "true") { echo "Błąd w stałej ustawień P2_SEC_REQMAIL"; return false;}
if(P2_SEC_RECPASS != "false" && P2_SEC_RECPASS != "true") { echo "Błąd w stałej ustawień P2_SEC_RECPASS"; return false;}

if(!is_int(P2_SEC_MINPASS)) { echo "Błąd w stałej ustawień P2_SEC_MINPASS"; return false;} 
if(!is_int(P2_SEC_MAXPASS)) { echo "Błąd w stałej ustawień P2_SEC_MAXPASS"; return false;} 
if(!is_int(P2_SEC_FLOGIN)) { echo "Błąd w stałej ustawień P2_SEC_FLOGIN"; return false;} 

return true;
}

I don't know why, but the result of my program (in index.php I have only that function implemented) is

"Błąd w stałej ustawień P2_PAGE_CLOSED"

Is there any error in conditional statements ? It should display nothing ! I analyzed that code three times, but I didn't see anything.

TN888
  • 7,659
  • 9
  • 48
  • 84

2 Answers2

1

I'm assuming you don't want your conditionals to be mutually exclusive. If so, you need to remove the returns out of them, because they jump out of the whole function and thus skip subsequent conditionals.

R. Barzell
  • 666
  • 5
  • 24
1

Because the first condition is evaluating to true, we can logically assume that P2_PAGE_CLOSED != "true" is evaluating to true, which means that there must be an issue with the include_once method that is causing the define calls to not be executed (assuming there are no issues with the if statements).

Also, it might be helpful to turn on PHP's more verbose error handling.

Community
  • 1
  • 1
Alex W
  • 37,233
  • 13
  • 109
  • 109