Location: PHPKode > projects > Guild DKP System > dkpsystem1.4/includes/admin/userconfiguration.php
<?php
$option = $_GET[option];
$Update = $_POST[Update];
$Create = $_POST[Create];
$Remove = $_POST[Remove];
$Save = $_POST[Save];
if($option == "resetpoints") {
	$db->query("UPDATE dkp_users SET class_points=0, class_points_general=0, last_raid_date=\"---\"");
	$db->query("TRUNCATE dkp_realadjustments");
	$db->query("TRUNCATE dkp_tempadjustments");
	$db->query("TRUNCATE dkp_sessionhistory");
	$db->query("TRUNCATE dkp_userhistory");
	$db->query("UPDATE dkp_stats SET occurances=0");
	$db->query("UPDATE dkp_users SET events=0");
	die(systemMessage("Points Reset", "You have successfully reset everyone's points to zero."));
}
if(isset($Create)) {
	$txtName = $_POST[txtName];
	$selectClass = $_POST[selectClass];
	$txtClassPoints = $_POST[txtClassPoints];
	$txtGeneralPoints = $_POST[txtGeneralPoints];
	$sql = $db->query("INSERT INTO dkp_users (name, class, class_points, class_points_general, last_raid_date) ".
					  "VALUES (\"$txtName\", \"$selectClass\", \"$txtClassPoints\", \"$txtGeneralPoints\", \"---\")");
	if($sql) { die(systemMessage("Player Created", "You have successfully added a new player.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
}
elseif(isset($Save)) {
	$userid = $_POST[userid];
	$txtName = $_POST[txtName];
	$class = $_POST[selectClass];
	$txtClassPoints = $_POST[txtClassPoints];
	$txtGeneralPoints = $_POST[txtGeneralPoints];
	$sql = $db->query("UPDATE dkp_users SET name=\"$txtName\", class=\"$class\", class_points=\"$txtClassPoints\", class_points_general=\"$txtGeneralPoints\" WHERE id=\"$userid\"");
	if($sql) { die(systemMessage("Player Update", "You have successfully updated this player.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
}
elseif(isset($Remove)) {
	$userid = $_POST[selectCharacter];
	$sql = $db->query("DELETE FROM dkp_users WHERE id=\"$userid\"");
	if($sql) { die(systemMessage("Player Deleted", "You have successfully deleted this player.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
}
else {
?>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td bgcolor="#003366"><font color="#FFFFFF" size="2" face="Tahoma"><strong>User Configuration</strong></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><form action="" method="post" name="formSelectPlayer">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Players</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><font color="#000000" size="1" face="Tahoma"><strong><u>Character</u></strong></font></td>
            <td bgcolor="#CCCCCC">
			<select name="selectCharacter">
			<option>Please select a player to update</option>
			<option>--</option>
            <?php
			$sql = $db->query("SELECT id, name FROM dkp_users ORDER BY name ASC");
			if($db->count_rows($sql) > 0) {
				while($row = mysql_fetch_array($sql)) {
					$name = $row[name];
					$id = $row[id];
					echo "<option value=\"$id\">$name</option>";
				}
			}
			else {
				echo "<option>There are no players in the database.</option>";
			}
			?>
			</select>
              <input name="Update" type="submit" id="Update" value="Update">
              <input name="Remove" type="submit" id="Remove" value="Remove"> </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td bgcolor="#003366"><strong><font color="#CCCCCC" size="1" face="Tahoma">Other 
      Options</font></strong></td>
  </tr>
  <tr> 
    <td bgcolor="#999999"><font size="1" face="Tahoma"><strong><a href="?d=admin&s=userconfiguration&option=create"><font color="#000000">Create 
      Player</font></a> <a href="?d=admin&s=userconfiguration&option=resetpoints" onClick="return verify('Are you sure you want to clear all points?')"><font color="#000000">Reset 
      Points</font></a></strong></font></td>
  </tr>
</table>
<?php
if(isset($Update)) {
	$userid = $_POST[selectCharacter];
	$sql = $db->query("SELECT * FROM dkp_users WHERE id=\"$userid\"");
	while($row = mysql_fetch_array($sql)) {
		$name = $row[name];
		$classid = $row['class'];
		$class = @mysql_result($db->query("SELECT class FROM dkp_classes WHERE id=\"$classid\""), 0);
		$class_points = $row[class_points];
		$general_points = $row[class_points_general];
	}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><form action="" method="post" name="formUpdatePlayer">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Details</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Name</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtName" type="text" value="<?php echo $name; ?>" size="35">
              <input name="userid" type="hidden" id="userid" value="<?php echo $userid; ?>"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Class</font></strong></u></td>
            <td bgcolor="#CCCCCC">
			<select name="selectClass">
            <option value="<?php echo $classid; ?>"><?php echo $class; ?></option>
			<option>--</option>
			<?php
			$sql = $db->query("SELECT * FROM dkp_classes ORDER BY class ASC");
			while($row = mysql_fetch_array($sql)) {
				$classid = $row[id];
				$class = $row['class'];
				echo "<option value=\"$classid\">$class</option>\n";
			}
			?>
			</select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Class 
              Points</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtClassPoints" type="text" value="<?php echo $class_points; ?>" size="35"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">General 
              Points</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtGeneralPoints" type="text" value="<?php echo $general_points; ?>" size="35"></td>
          </tr>
          <tr>
            <td bgcolor="#999999">&nbsp;</td>
            <td bgcolor="#CCCCCC"><input name="Save" type="submit" value="Save"></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td colspan="4" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Player 
      History</strong></font></td>
  </tr>
  <tr> 
    <td width="25%" bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Description</font></strong></u></td>
    <td width="25%" bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Value</font></strong></u></td>
    <td width="25%" bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Date</font></strong></u></td>
    <td width="25%" bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Action</font></strong></u></td>
  </tr>
  <tr bgcolor="#CCCCCC"> 
    <td><strong><font color="#000000" size="1" face="Tahoma">[reason]</font></strong></td>
    <td><strong><font color="#000000" size="1" face="Tahoma">[value]</font></strong></td>
    <td><strong><font color="#000000" size="1" face="Tahoma">[date]</font></strong></td>
    <td><a href="?d=admin&s=userconfiguration&userid=&eventid=&action=delete"><font color="#000000" size="1" face="Tahoma"><strong>delete</strong></font></a></td>
  </tr>
</table>
<?php
	}
}
if($option == "create" && !isset($Update)) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="00">
  <tr>
    <td><form action="" method="post" name="formCreatePlayer" id="formCreatePlayer">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Details</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Name</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtName" type="text" id="txtName" size="35"> 
              <input name="userid2" type="hidden" id="userid22" value="<?php echo $userid; ?>"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Class</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <select name="selectClass" id="selectClass">
                <option value="0">Class</option>
                <option value="0">--</option>
                <?php
			$sql = $db->query("SELECT * FROM dkp_classes ORDER BY class ASC");
			while($row = mysql_fetch_array($sql)) {
				$classid = $row[id];
				$class = $row['class'];
				echo "<option value=\"$classid\">$class</option>\n";
			}
			?>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Class 
              Points</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtClassPoints" type="text" size="10"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">General 
              Points</font></strong></u></td>
            <td bgcolor="#CCCCCC"><input name="txtGeneralPoints" type="text" size="10"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999">&nbsp;</td>
            <td bgcolor="#CCCCCC"><input name="Create" type="submit" id="Create" value="Create"></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<?php
}
?>
Return current item: Guild DKP System