franga2000 / BungeeStatus

A PHP powered website to show players the status of your BungeeCord network
GNU General Public License v2.0
9 stars 7 forks source link

Invalid Headers / Already Set #16

Closed Fabricio20 closed 9 years ago

Fabricio20 commented 9 years ago

Hello, when I join my /admin page and log in, I get 2 "Invalid Headers" notifications on my screen.

Warning: Cannot modify header information - headers already sent by (output started at public_html/status/include/header.php:8) in public_html/status/include/password_protect.php on line 50

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at public_html/status/include/header.php:8) in public_html/status/admin/index.php on line 11

Also on the Logout page:

Warning: Cannot modify header information - headers already sent by (output started at public_html/status/include/header.php:8) in public_html/status/include/password_protect.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at public_html/status/include/header.php:8) in public_html/status/include/password_protect.php on line 10

And those mean you cant add servers nor save the config. If I set CHMOD for those directories they simply give me an 500 ( ISE ).

Thanks in advance!

franga2000 commented 9 years ago

All of these are caused by the same problem: some servers being weird and sending headers before all of the code is finished running.

Try setting the option session_fix to true in the config.json.

Fabricio20 commented 9 years ago

I've set Session fix to true and I'm still getting errors, but now only the second one is displaying:

Warning: Cannot modify header information - headers already sent by (output started at public_html/status/include/header.php:8) in public_html/status/include/password_protect.php on line 50

Also I still can't change any config nor add servers ( It redirects me to the login page ).

franga2000 commented 9 years ago

Try editing the header file (/include/header.php) and add ob_start(); to the end of line 5.

Keep in mind, this is a very hacky way of fixing this. I recommend updating your PHP if possible.

Fabricio20 commented 9 years ago

Ok, those errors are fixed, but now this:

Warning: Invalid argument supplied for foreach() in public_html/status/index.php on line 11

Currently running PHP 5.2.17 Edit: Also found this one:

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in public_html/status/config.php on line 10
franga2000 commented 9 years ago

There's something wrong with your config.json. Can you give me the URL of your site so I can take a look?

Fabricio20 commented 9 years ago

Http://voltugames.com/status

franga2000 commented 9 years ago

Your servers.json and config,json files aren't accessible (or empty).

Fabricio20 commented 9 years ago

I've CHMOD 777 on both files now, and I just get more errors ._. They are not empty, if I download them, everything seems ok ;/

franga2000 commented 9 years ago

Try to access them from your browser: http://voltugames.com/status/config.json The webserver (and probably PHP) sees it as empty

Fabricio20 commented 9 years ago

Yeah, I know, I just don't get why its empty, directory access are granted ;/

franga2000 commented 9 years ago

Put the following code in a .php file and open it in your browser:

<?php
if (!file_exists("config.json")) {
    file_put_contents("config.json", file_get_contents("https://raw.githubusercontent.com/franga2000/BungeeStatus/master/config.json"));
    echo("config.json downloaded! \n");
}
if (!file_exists("servers.json")) {
    file_put_contents("servers.json", "[]");
    echo("servers.json created! \n");
}
echo("Config: \n");
var_dump(file_get_contents("config.json"));
echo("\nServers: ");
var_dump(file_get_contents("servers.json"));
?>

If you see something like Config: bool(false) Servers: bool(false) then delete both of the config files and run the script again. It should now say Downloaded config.json! Created servers.json!. Then you should see a dump of the files (it's easier to read if you open the source (CTRL+U)).

Fabricio20 commented 9 years ago

Well, I did what you said and run the script, it first outputted null values so I removed both files and ran it again, the files were downloaded but they still show as empty on web browser. Edit: Warning: Invalid argument supplied for foreach() in public_html/status/index.php on line 11 This is happening againg, and the files are not empty anymore ( you can now see content ).

franga2000 commented 9 years ago

Well the PHP Manual says that the functioun outputs null only if it's somehow disabled (php.ini maybe?).

Make another php file containing the following and send me the link:

<?php phpinfo(); ?>

It's probably some kind of weid config option set by your host.

Fabricio20 commented 9 years ago

http://voltugames.com/status/info.php

franga2000 commented 9 years ago

This doesn't make any sense. There's nothing wrong with my script and I can't find anything wrong with your server either. Honestly, I have no idea what's going on.

I'd recommend you to contact your hosting provider and ask them to take a look at it.

Fabricio20 commented 9 years ago

Ok, I'll see what I can do about it ;/