I've written this user auth script that I think sucks donkey D!#K I need some help findong out what the problems are as I cannot send headers after output or some error like that anyways heres the code
<?php
if ((isset($GET['userpg'])) && ($GET['userpg'] == "logout")){
if (isset($COOKIE['loggedin'])){
// do logout
$themodulepage = $SERVER['PHP_SELF']."?page=".$GET['page'];
setcookie("loggedin", "", 0);
$bodycontent = "You Have logged out sucessfully click <a href=".$themodulepage.">here</a> to continue";
}
if (!isset($COOKIE['loggedin'])){
// You aint logged in dickhead
$bodycontent = "You aint logged in dickhead";
}
}
if (isset($COOKIE['loggedin'])){
// One last check
if ((file_exists("./auth/users/".$COOKIE['loggedin'].".usr")) or (file_exists("./auth/admins/".$COOKIE['loggedin'].".usr")) or (file_exists("./auth/godusers/".$COOKIE['loggedin'].".usr"))){
// show the page contents
// this is where authed = true comes into the equation maybe
} if ((!file_exists("./auth/users/".$_COOKIE['loggedin'].".usr")) && (!file_exists("./auth/admins/".$_COOKIE['loggedin'].".usr")) && (!file_exists("./auth/godusers/".$_COOKIE['loggedin'].".usr"))){ // Bugfix For after registration process $bodycontent = " "; } } if ((isset($_COOKIE['loggedin'])) && ($pgauth == "admin")){ // One last check if ((file_exists("./auth/admins/".$_COOKIE['loggedin'].".usr")) or (file_exists("./auth/godusers/".$_COOKIE['loggedin'].".usr"))){ // show the page contents // this is where authed = true comes into the equation maybe } if ((!file_exists("./auth/admins/".$_COOKIE['loggedin'].".usr")) && (!file_exists("./auth/godusers/".$_COOKIE['loggedin'].".usr"))){ // Bugfix For after registration process $bodycontent = "You Have Insufficient Privelages to access this Page Please <a href=\"".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&userpg=logout\">LogOut</a> to Continue"; } } if ((isset($_COOKIE['loggedin'])) && ($pgauth == "god")){ // One last check if (file_exists("./auth/godusers/".$_COOKIE['loggedin'].".usr")){ // show the page contents // this is where authed = true comes into the equation maybe } if (!file_exists("./auth/godusers/".$_COOKIE['loggedin'].".usr")){ // Bugfix For after registration process $bodycontent = "You Have Insufficient Privelages to access this Page Please <a href=\"".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&userpg=logout\">LogOut</a> to Continue"; } } if (!isset($_COOKIE['loggedin'])){ if (($pgauth != "god") && ($pgauth != "admin")){ if ((isset($_GET['userpg'])) && ($_GET['userpg'] == "regform")){ // do registrationform without username and password $bodycontent = "By Clicking on the submit button you are Accepting all of the Terms and Conditions of this website!<Br>". "<form method=POST action=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&userpg=register>". "<p>Registration Form</p>". "<p>Username : <input type=text name=reg-bl-username value=".$_POST['bl-username']." size=20></p>". "<p>Password : <input type=password name=reg-bl-password value=".$_POST['bl-password']." size=20></p>". "<p>Email : <input type=text name=regemail size=40></p>". "<p>User Picture URL : <input type=text name=regpic size=40 value=http://www.urltoimage.com></p>". "<p>Signature : <br><textarea rows=6 name=regsig cols=38>-- Default User Signature --</textarea></p>". "<p><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></p>". "</form>"; } if ((isset($_GET['userpg'])) && ($_GET['userpg'] == "register")){ // do registration through link if ((isset($_POST['reg-bl-username'])) && (isset($_POST['reg-bl-password'])) && (isset($_POST['regemail'])) && (isset($_POST['regpic'])) && (isset($_POST['regsig']))){ // do register $regdata_base = $_POST['reg-bl-password'] . "|" . $_POST['regemail'] . "|" . $_POST['regpic'] . "|" . $_POST['regsig'] . "|"; $regdata = str_replace("http://www.urltoimage.com", "", $regdata_base); $fp = fopen("./auth/users/".$_POST['reg-bl-username'].".usr", "a+"); fwrite($fp, "".$regdata.""); fclose($fp); $themodulepage = $_SERVER['PHP_SELF']."?page=".$_GET['page']; setcookie("loggedin", $_POST['reg-bl-username'], time()+31449600); $bodycontent = "You Have logged in sucessfully click <a href=".$themodulepage.">here</a> to continue"; } if ((!isset($_POST['reg-bl-username'])) or (!isset($_POST['reg-bl-password'])) or (!isset($_POST['regemail'])) or (!isset($_POST['regpic'])) or (!isset($_POST['regsig']))){ // One or more form feilds has not been filled out $theformpage = $_SERVER['PHP_SELF']."?page=".$_GET['page']."&userpg=regform"; $bodycontent = "One or more form feilds has not been filled out please click <a href=".$theformpage."here</a> to go back and complete the form"; } } } if ((isset($_GET['userpg'])) && ($_GET['userpg'] == "login")){ // do login $bodycontent = "<form method=POST action=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].">". "<p>Login Form</p>". "<p>Username : <input type=text name=bl-username size=20></p>". "<p>Password : <input type=password name=bl-password size=20></p>". "<p><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></p>". "</form>"; } if ((!isset($_POST['bl-username'])) or (!isset($_POST['bl-password']))){ // do loginform if (!isset($_GET['userpg'])){ $bodycontent = "<form method=POST action=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].">". "<p>Login Form</p>". "<p>Username : <input type=text name=bl-username size=20></p>". "<p>Password : <input type=password name=bl-password size=20></p>". "<p><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></p>". "</form>"; } if (isset($_GET['userpg'])){ // this should fix a small bug in the code } } if ((isset($_POST['bl-username'])) && (isset($_POST['bl-password']))){ // do loginprocess if ((!file_exists("./auth/users/".$_POST['bl-username'].".usr")) && (!file_exists("./auth/adminusers/".$_POST['bl-username'].".usr")) && (!file_exists("./auth/godusers/".$_POST['bl-username'].".usr"))){ //do registration form if (($pgauth != "god") && ($pgauth != "admin")){ if ((!isset($_POST['reg-bl-username'])) or (!isset($_POST['reg-bl-password'])) or (!isset($_POST['regemail'])) or (!isset($_POST['regpic'])) or (!isset($_POST['regsig']))){ // do register form with username and password $bodycontent = "By Clicking on the submit button you are Accepting all of the Terms and Conditions of this website!<Br>". "<form method=POST action=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&userpg=register>". "<p>Registration Form</p>". "<p>Username : <input type=text name=reg-bl-username value=".$_POST['bl-username']." size=20></p>". "<p>Password : <input type=password name=reg-bl-password value=".$_POST['bl-password']." size=20></p>". "<p>Email : <input type=text name=regemail size=40></p>". "<p>User Picture URL : <input type=text name=regpic size=40 value=http://www.urltoimage.com></p>". "<p>Signature : <br><textarea rows=6 name=regsig cols=38>-- Default User Signature --</textarea></p>". "<p><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></p>". "</form>"; } } if (($pgauth == "god") or ($pgauth == "admin")){ // Wot $bodycontent = "You Must Have An Account to Login"; } } if ((file_exists("./auth/users/".$_POST['bl-username'].".usr")) or (file_exists("./auth/admins/".$_POST['bl-username'].".usr")) or (file_exists("./auth/godusers/".$_POST['bl-username'].".usr"))) { //do login if (file_exists("./auth/users/".$_POST['bl-username'].".usr")){ // this is a normal user $theuserfile = file_get_contents( "./auth/users/".$_POST['bl-username'].".usr"); } if (file_exists("./auth/admins/".$_POST['bl-username'].".usr")){ // this is an administrator $theuserfile = file_get_contents( "./auth/admins/".$_POST['bl-username'].".usr"); } if (file_exists("./auth/godusers/".$_POST['bl-username'].".usr")){ // this is a goduser $theuserfile = file_get_contents( "./auth/godusers/".$_POST['bl-username'].".usr"); } $getuserdetails = explode("|", $theuserfile); $realpass = $getuserdetails[0]; if ($_POST['bl-password'] == $realpass){ // the password check has returned true setcookie("loggedin", $_POST['bl-username'], time()+31449600); $bodycontent = "You Have logged in sucessfully click <a href=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].">here</a> to continue"; } if ($_POST['bl-password'] != $realpass){ // the password check has returned false $bodycontent = "The Password you entered does not correspond to this Username!". "<form method=POST action=".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].">". "<p>Login Form</p>". "<p>Username : <input type=text name=bl-username size=20 value=".$_POST['bl-username']."></p>". "<p>Password : <input type=password name=bl-password size=20></p>". "<p><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></p>". "</form>"; } } } }
?>
All Help & Constructive Criticism are very welcome