session_start();
//***********************************************************************
// Display "First/Prev/Next/Last", "Delete", "Feature", "Unfeature",
// "Select All Scores", "Showing x to y of z"
function tableHeaderFooter ($srt, $key, $allChecked, $totalRows, $startNum, $endNum) {
echo "
";
}
//***********************************************************************
// display 'showing x to y of z'
function display_counts ($key, $totalRows, $startNum, $endNum)
{
$query = "SELECT user_id FROM users LIMIT $key, ".USERADMINDISPLAYNUM."";
$result = mysql_query($query) or die("Invalid query");
$numberOfRows = @mysql_num_rows($result);
$startNum = $key + 1;
$endNum = $startNum + $numberOfRows - 1;
if ($endNum == 0) {
$startNum = 0;
}
echo "showing ".$startNum." to ".$endNum." of ".$totalRows." ";
}
//***********************************************************************
function column_header ($header)
{
// display column headers:
// 1)as a hyperlink if the column is NOT currently sorted
// 2)in italics if the column IS currently sorted
global $srt;
echo "
");
// don't allow the admin user (or her scores) to be deleted
if ($row["user_name"]<>"admin") {
echo "
";
}
else {
echo " ";
}
echo "
"
.$row["user_id"]."
";
echo "
"
.stripslashes($row["user_name"])."
";
echo "
"
.stripslashes($row["user_password"])."
";
echo "
"
.stripslashes($row["user_email"])."
";
echo "
"
.$row["user_country"]."
";
//echo "
";
echo "
"
.$row["user_admin"]."
";
echo("
");
}
echo "
";
}
if ( isset($sessUserName) && isset($sessUserId) && @$sessAdmin==1 ) {
include("db_fns.php"); // Sdb functions
include("constants.php");
global $srt; // column sort
global $key; // what record to start displaying from
global $scroll; //
global $numberOfRows; //
global $ticked; // array of selected checkboxes
global $startNum;
global $endNum;
?>
USER - ADMIN PAGE
USER - ADMIN PAGE
Score AdminReturn to Featured Scores
$entry = 0;
if (isset($buttAction)) {
if ($buttAction=="Delete") {
if (isset($ticked)) {
foreach($ticked as $entry) {
// delete the user's scores
$result = mysql_query("DELETE FROM users WHERE user_id=".$entry."") or die("Invalid query");
//Delete the user's scores
$result = mysql_query("DELETE FROM scores WHERE user_id=".$entry."") or die("Invalid query");
}
}
$allChecked = "";
$key = 0; // reset the key to 0
}
else if ($buttAction=="Select All Users") {
// select all users
$allChecked = "checked";
}
elseif ($buttAction=="Deselect All Users") {
$allChecked = "";
}
}
else {
// if this is the first time that this page is being displayed, then don't select all the users
$allChecked = "" ;
}
//Get the number of rows for the NEXT and LAST links
$result = mysql_query("SELECT user_id FROM users") or die("Invalid query");
$totalRows = @mysql_num_rows($result);
if ($scroll) {
switch ($scroll) {
case "first":
$key = 0;
break;
case "prev":
$key -= USERADMINDISPLAYNUM;
if ($key < 0) {
$key = 0;
}
break;
case "next":
if (USERADMINDISPLAYNUM > $totalRows) {
$key = 0;
}
elseif (!($key+USERADMINDISPLAYNUM >= $totalRows)) {
$key += USERADMINDISPLAYNUM;
}
break;
case "last":
if (USERADMINDISPLAYNUM > $totalRows) {
$key = 0;
}
else {
$key = $totalRows - USERADMINDISPLAYNUM;
}
break;
// if Select All was hit, then keep the key the same as it was
default:
}
} else {
//When the user visits the page for the first time
//there is no key selected so give them the first record.
$key = 0;
}
if (!isset($srt)) {
$srt = "user_id";
}
?>
* Note: Deleting a user will also delete their scores.
}
else {
// user wasn't logged in isn't an Admin when he/she tried to view this page so they
// were sent back to the main page
header("Location: featured_scores.php");
}
?>