im making a chat room. of course it's setup so that on each run it checks session id's etc to make sure it's valid. but rather than store all my command files in the main script, to cut out unecessary opcode compiling (even though im using xcache) i'm curious if this is safe enough.
so at one point in the execuction, it checks to see if a /command has been executed. if so, it requires $command.php from a secure directory that requires authentication to access. but also, i put this line in the top of each of my php files that are in their own seperate command files. assuming that i start the database connection in the MAIN script after session ID's have been confirmed and validated, if i put the following line (and it seems to work so far? im just not super hacker smart yet) at the top of each of the individual command files, the only way they should be able to get past this is if they know my database information and can create a fake database connection from remotely right? here is the code i have put at the top of each command file
if (!$link){
header("location:login.php");
exit;
}
$link of course, is the variable in the main script containing the mysql_connect(localhost, username, password)
if $link is not valid, it redirects them to the login page.
is this safe enough. or should i be securing these individual php files in a different, better way?