<?php
if(!$logged[username] && !$logged[userlevel]){ //check if user is logged in
echo "You Are Not Logged In!"; //echo this if they are not
}elseif($logged[username] && $logged[userlevel] != "6"){ //check if user is an admin
echo "You Are Not An Admin!"; //echo this if they aren't
}else{ //or if everything is ok..
if(!isset($_GET[edit])){ //check if ?edit is in the address bar
$get = mysql_query("SELECT * FROM `site_stats` WHERE sid = '1';"); //select data from the table
if(mysql_error()){ //if there is an error
echo "You have an error in the SQL Query on line: 18"; //echo this
}else{ //or not
$r = mysql_fetch_array($get); //array the info to be echoed.
echo "<p align=\"center\"><a href=\"stats.php?edit\">Edit Site Status</a>
<b>Website Status</b>: $r[stats]<Br />
<b>Admin Immunity</b>: $r[immunity]
<b>Immunity Level</b>: $r[immunelvl]
<b>Forum Status</b>:"; //echo part of the information
if($r[forums] == "1"){ //check if the forums are online
echo " Online"; //if they are
}else{ //if they are something else..
echo " Offline"; //if they are of
} //end forums check
echo "<b>Sign-up Status</b>:"; //signup status
if($r[signups] == "1"){ //if its online
echo " Online"; //say thing
}else{ //or if it is something else
echo " Offline"; //echo this
} //end check
echo "</p>"; //end paragraph
} //end error check
}else{ //or if it is in the address bar
$get = mysql_query("SELECT * FROM `site_stats` WHERE sid = '1';"); //get info
if(mysql_error()){ //check if thers an error
echo "You have an error in the SQL Query on line: 18"; //if there is echo that
}else{ //or not...
$r = mysql_fetch_array($get);
if(!$_POST[edit]){ //check if the form was submitted
echo "<form method=\"post\" action=\"\">
<table width=\"150\" cellpadding=\"0\" cellspacing=\"2\">
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Site Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"stats\">"; //Yay tables forms and data inputs =O!!!
if($r[stats] == "Online"){ //if status is online
echo "<option value=\"Online\" selected=\"selected\">Online</option"; //online is selected
}else{ //but if it isn't
echo "<option value=\"Online\">Online</option>"; //its not
} //end online field
if($r[stats] == "Offline"){ //or if its offline
echo "<option value=\"Offline\" selected=\"selected\">Offline</option>"; //offline is selected
}else{ //maybe its not....
echo "<option value=\"Offline\">Offline</option>"; //its not selected
} //end offline check
echo "</select>
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Admin Immunity</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"immunity\">"; //continue data
if($r[immunity] == "Yes"){ //check if admin immunty is on
echo "<option value=\"Yes\" selected=\"selected\">Yes</option>"; //if it is...yes is selected
}else{ //or if its no
echo "<optiong value=\"Yes\">Yes</option>"; //its not selected
} //end yes check
if($r[immunity] == "No"){ //immunity check :P
echo "<option value=\"No\" selected=\"selected\">No</option>"; //it is YAY
}else{ //or if it isint No
echo "<option value=\"No\">No</option>"; //if not
} //end no check
echo "</select>
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Immune Level</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<input type=\"text\" name=\"level\" value=\"$r[immunelvl]\" size=\"15\" maxlength=\"2\">
</td>
</tr>
<tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Forums Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"forums\">"; //continue with some more information...
if($r[forums] == "1"){ //check if forums are online
echo "<option value=\"1\" selected=\"selected\">Online</option>"; //if they are
}else{ //or if they aren't
echo "option value=\"1\">Online</option>"; //echo online field not selcted
} //end check
if($r[forums] == "0"){ //check if forums are offline
echo "<option value=\"0\" selected=\"selected\">Offline</option>"; //if they are
}else{ //or if they aren't
echo "option value=\"0\">Offline</option>"; //echo offline field not selcted
} //end check
echo "</select>
</td>
</tr>
</tr>
<td width=\"150\" align=\"center\" valign=\"middle\">
<b>Sign-up Status</b>:
</td>
<td width=\"150\" align=\"center\" valign=\"middle\">
<select name=\"signups\">"; //more information and some moer table :)
if($r[signups] == "1"){ //if signups is online
echo "<option value=\"1\" selected=\"selected\">Online</option>"; //if it is
}else{ //or not
echo "<option value=\"1\">Online</option>"; //its not checked
} //end check
if($r[signups] == "0"){ //or maybe offine?
echo "<option value=\"0\" selected=\"selected\">Offline</option>"; //checked
}else{ //if it isint 0
echo "<option value=\"0\">Offline</option>"; //its not checked :O
} //end check
echo "</select>
</td>
</tr>
<td>
<td width=\"300\" colspan=\"3\" align=\"center\" valign=\"middle\">
<input type=\"submit\" name=\"edit\" value=\"Update Stats\">
</td>
</tr>
</table>
</form>"; //finish up the form and information
}else{ //or if the form was submitted
$stats = strip_tags(htmlspecialchars($_POST[stats])); //clean stats
$immunity = strip_tags(htmlspecialchars($_POST[immunity])); //clean immunity
$imunelvl = (int) strip_tags(htmlspecialchars($_POST[level])); //clean immune level
$forums = strip_tags(htmlspecialchars($_POST[forums])); //clean forums
$signups = strip_tags(htmlspecialchars($_POST[signups])); //cheak signups
$mysql = mysql_query("UPDATE `site_stats` SET `stats` = '$stats', immunity = '$immunity', `immunelvl` = '$immunelvl', `forums` = '$forums', `signups` = '$signups' WHERE sid = '1';");
if(!mysql_error()){ //if no error encountered
echo "Site Status Updated!"; //success
}else{ //or not?
echo "There is an error in the syntax of line 137! please check it out!"; //error
} //end error
} //end form check
} //end error check
} //end edit check
} //end login check
?>
i cant fix this.. can anyone help?