Location: PHPKode > projects > Guild DKP System > dkpsystem1.4/includes/admin/awardloot.php
<?php
$award = $_POST[Award];
$loottype = $_GET[loottype];
$userid = $_GET[userid];
$raidid = $_GET[raidid];
$sessionid = $_GET[sessionid];
$sql = $db->query("SELECT * FROM dkp_users WHERE id=\"$userid\"");
if($db->count_rows($sql) < 1) {
	systemMessage("Loot Error", "Unfortunately, the user that you are trying to award loot to, does not exist.");
}
else {
	//get player details
	while($row = mysql_fetch_array($sql)) {
		$character = $row[name];
		$temp_class = $row['class'];
		$class = @mysql_result($db->query("SELECT class FROM dkp_classes WHERE id=\"$temp_class\""), 0);
		$class_points = $row[class_points];
		$general_points = $row[class_points_general];
	}
	//raid information
	if(isset($raidid)) {
		$sql = $db->query("SELECT raid FROM dkp_sessions WHERE id=\"$raidid\"");
		if($db->count_rows($sql) > 0) {
			$raid = @mysql_result($sql, 0);
		}
		else {
			$raid = "Unknown";
		}
	}
	else {
		$raid = "Unknown";
	}
	//award loot
	if(isset($Award)) {
		$itemid = $_POST[selectItem];
		$option = $_POST[option];
		$itemname = @mysql_result($db->query("SELECT name FROM dkp_items WHERE id=\"$itemid\""), 0);
		$itemvalue = @mysql_result($db->query("SELECT value FROM dkp_items WHERE id=\"$itemid\""), 0);
		$txtItemValue = $_POST[txtItemValue];
		if(isset($txtItemValue) && !empty($txtItemValue)) { $itemvalue = $txtItemValue; }
		//general
		if($option == 0) {
			$general_points = $general_points - $itemvalue;
			$sql = $db->query("UPDATE dkp_users SET class_points_general=\"$general_points\" WHERE id=\"$userid\"");
		}
		//class
		elseif($option == 1) {
			$class_points = $class_points - $itemvalue;
			$sql = $db->query("UPDATE dkp_users SET class_points=\"$class_points\" WHERE id=\"$userid\"");
		}
		//both
		elseif($option == 2) {
			$general_points = $general_points - $itemvalue;
			$class_points = $class_points - $itemvalue;
			$sql = $db->query("UPDATE dkp_users SET class_points=\"$class_points\", class_points_general=\"$general_points\" WHERE id=\"$userid\"");
		}
		else {
			die(systemMessage("Loot Error", "Could not verify loot type."));
		}
		$value = (-1)*$itemvalue;
		$reason = $raid . ": ". $itemname;
		$sql2 = $db->query("INSERT INTO dkp_realadjustments (userid, raidid, pool, reason, value) ".
		                   "VALUES (\"$userid\", \"$raidid\", \"$loottype\", \"$reason\", \"$value\")");
		if($sql && $sql2) {
			systemMessage("Award Loot", "You have successfully awarded loot to this player.", "?d=admin&s=continueraid&sessionid=$sessionid");
		}
		else {
			systemMessage("Loot Error", mysql_error());
		}
	}
	else {
?>
<script language="JavaScript">
function lootType(option) {
	var url = "?d=admin&s=awardloot&userid=<?php echo $userid; ?>&raidid=<?php echo $raidid; ?>&loottype=" + option + "&sessionid=<?php echo $sessionid; ?>";
	location.href=url;
	return false;
}
</script>

<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td bgcolor="#003366"><font color="#FFFFFF" size="2" face="Tahoma"><strong>Award 
      Loot</strong></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Player 
      Details </strong></font></td>
  </tr>
  <tr> 
    <td width="15%" bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Character</font></strong></u></td>
    <td bgcolor="#CCCCCC"><strong><font size="1" face="Tahoma"><?php echo $character; ?></font></strong></td>
  </tr>
  <tr> 
    <td bgcolor="#999999"><strong><font color="#000000" size="1" face="Tahoma"><u>Class</u></font></strong></td>
    <td bgcolor="#CCCCCC"><strong><font color="#000000" size="1" face="Tahoma"><?php echo $class; ?></font></strong></td>
  </tr>
  <tr> 
    <td bgcolor="#999999"><u><strong><font size="1" face="Tahoma">Class Points</font></strong></u></td>
    <td bgcolor="#CCCCCC"><strong><font size="1" face="Tahoma"><?php echo $class_points; ?></font></strong></td>
  </tr>
  <tr> 
    <td bgcolor="#999999"><u><strong><font size="1" face="Tahoma">General Points</font></strong></u></td>
    <td bgcolor="#CCCCCC"><strong><font size="1" face="Tahoma"><?php echo $general_points; ?></font></strong></td>
  </tr>
  <tr>
    <td bgcolor="#999999"><font color="#000000" size="1" face="Tahoma"><strong><u>Raid</u></strong></font></td>
    <td bgcolor="#CCCCCC"><font color="#000000" size="1" face="Tahoma"><strong><?php echo $raid; ?></strong></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><form action="" method="post" name="formAwardLoot" id="formAwardLoot">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Loot 
              Details</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><strong><font size="1" face="Tahoma"><u>Options</u></font></strong></td>
            <td bgcolor="#CCCCCC"><strong><font size="1" face="Tahoma">
              <input name="option" type="radio" value="0" onChange="return lootType(0)" <?php if(isset($loottype) && $loottype == 0) echo "checked"; ?>>
              General 
              <input name="option" type="radio" value="1" onChange="return lootType(1)" <?php if(isset($loottype) && $loottype == 1) echo "checked"; ?>>
              Class
              <input name="option" type="radio" value="2" onChange="return lootType(2)" <?php if(isset($loottype) && $loottype == 2) echo "checked"; ?>>
              Both</font></strong></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><font size="1" face="Tahoma"><strong><u>Items</u></strong></font></td>
            <td bgcolor="#CCCCCC">
			  <select name="selectItem">
			  	<?php
				if(isset($loottype)) {
					//general
					if($loottype == 0) {
						$sql = $db->query("SELECT * FROM dkp_items WHERE type=0 ORDER BY name ASC");
						echo "<option>General Items</option>\n";
						echo "<option>--</option>\n";
					}
					//class
					elseif($loottype == 1) {
						$sql = $db->query("SELECT * FROM dkp_items WHERE type=1 ORDER BY name ASC");
						echo "<option>Class Items</option>\n";
						echo "<option>--</option>\n";
					}
					//both
					elseif($loottype == 2) {
						$sql = $db->query("SELECT * FROM dkp_items ORDER BY name ASC");
						echo "<option>All Items</option>\n";
						echo "<option>--</option>\n";
					}
					while($row = mysql_fetch_array($sql)) {
						$itemid = $row[id];
						$itemname = $row[name];
						$itemvalue = $row[value];
						echo "<option value=\"$itemid\">$itemname ($itemvalue)</option>";
					}
				}
				else {
					echo "<option>Please choose loot options</option>";
				}
				?>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><font color="#000000" size="1" face="Tahoma"><strong><u>Custom 
              Value</u></strong></font></td>
            <td bgcolor="#CCCCCC"><input name="txtItemValue" type="text" id="txtItemValue" size="10" maxlength="10"></td>
          </tr>
          <tr>
            <td bgcolor="#999999">&nbsp;</td>
            <td bgcolor="#CCCCCC"><input name="Award" type="submit" id="Award" value="Award"></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Return 
      to raid</strong></font></td>
  </tr>
  <tr>
    <td bgcolor="#999999"><a href="?d=admin&s=continueraid&sessionid=<?php echo $sessionid; ?>"><font color="#000000" size="1" face="Tahoma"><strong>Go 
      back to managing your raid</strong></font></a></td>
  </tr>
</table>
<?php
	}
}
?>
Return current item: Guild DKP System