<commit_before><?php
/*
	File:		iteminfo.php
	Created: 	4/5/2016 at 12:14AM Eastern Time
	Info: 		Displays detailed information about the item inputted.
	Author:		TheMasterGeneral
	Website: 	https://github.com/MasterGeneral156/chivalry-engine
*/
require('globals.php');
$_GET['ID'] = (isset($_GET['ID']) && is_numeric($_GET['ID'])) ? abs($_GET['ID']) : '';
$itmid = $_GET['ID'];
if (!$itmid) {
    alert('danger', 'Uh Oh!', 'Invalid or non-existent Item ID.', true, 'inventory.php');
} else {
    $q =
        $db->query(
            "SELECT `i`.*, `itmtypename`
                     FROM `items` AS `i`
                     INNER JOIN `itemtypes` AS `it`
                     ON `i`.`itmtype` = `it`.`itmtypeid`
                     WHERE `i`.`itmid` = {$itmid}
                     LIMIT 1");
    if ($db->num_rows($q) == 0) {
        alert('danger', 'Uh Oh!', 'Invalid or non-existent Item ID.', true, 'inventory.php');
    } else {
        $id = $db->fetch_row($q);
        echo "
		<table class='table table-bordered'>
			<tr>
				<th colspan='2'>
					Looking up the item information for {$id['itmname']}.
				</th>
			</tr>
			<tr>
				<th width='33%'>
					Item Type
				</th>
				<td>
					{$id['itmtypename']}
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Information
				</th>
				<td>
					{$id['itmdesc']}
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Buying Price
				</th>
				<td>";
        if ($id['itmbuyprice'] > 0) {
            echo number_format($id['itmbuyprice']);
        } else {
            echo "Unpurchaseable";
        }
        echo "
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Selling Price
				</th>
				<td>";
        if ($id['itmsellprice']) {
            echo number_format($id['itmsellprice']);
        } else {
            echo "Unsellable.";
        }
        echo "
				</td>
			</tr>";
        for ($enum = 1; $enum <= 3; $enum++) {
            if ($id["effect{$enum}_on"] == 'true') {
                $einfo = unserialize($id["effect{$enum}"]);
                $einfo['inc_type'] = ($einfo['inc_type'] == 'percent') ? '%' : '';
                $einfo['dir'] = ($einfo['dir'] == 'pos') ? 'Increases' : 'Decreases';
                $stats =
                    array("energy" => "Energy", "will" => "Will",
                        "brave" => "Bravery", "level" => "Level",
                        "hp" => "Health", "strength" => "Strength",
                        "agility" => "Agility", "guard" => "Guard",
                        "labor" => "Labor", "iq" => "IQ",
                        "infirmary" => "Infirmary Time", "dungeon" => "Dungeon Time",
                        "primary_currency" => "Primary Currency", "secondary_currency"
                    => "Secondary Currency", "crimexp" => "Experience", "vip_days" =>
                        "VIP Days");
                $statformatted = $stats["{$einfo['stat']}"];
                echo "
				<tr>
					<th>
						Item Effect #{$enum}
					</th>
					<td>
					{$einfo['dir']} {$statformatted} by " . number_format($einfo['inc_amount']) . "{$einfo['inc_type']}.
					</td>
				</tr>";
            }
        }
        if ($id['weapon']) {
            echo "<tr>
				<th width='33%'>
					Item Weapon Rating
				</th>
				<td>
					" . number_format($id['weapon']) . "
				</td>
			</tr>";
        }
        if ($id['armor']) {
            echo "<tr>
				<th width='33%'>
					Item Armor Rating
				</th>
				<td>
					" . number_format($id['armor']) . "
				</td>
			</tr>";
        }
        echo "
		</table>";
        $db->free_result($q);
    }<commit_msg>Item info now displays<commit_after><?php
/*
	File:		iteminfo.php
	Created: 	4/5/2016 at 12:14AM Eastern Time
	Info: 		Displays detailed information about the item inputted.
	Author:		TheMasterGeneral
	Website: 	https://github.com/MasterGeneral156/chivalry-engine
*/
require('globals.php');
$_GET['ID'] = (isset($_GET['ID']) && is_numeric($_GET['ID'])) ? abs($_GET['ID']) : '';
$itmid = $_GET['ID'];
if (!$itmid) {
    alert('danger', 'Uh Oh!', 'Invalid or non-existent Item ID.', true, 'inventory.php');
} else {
    $q =
        $db->query(
            "SELECT `i`.*, `itmtypename`
                     FROM `items` AS `i`
                     INNER JOIN `itemtypes` AS `it`
                     ON `i`.`itmtype` = `it`.`itmtypeid`
                     WHERE `i`.`itmid` = {$itmid}
                     LIMIT 1");
    if ($db->num_rows($q) == 0) {
        alert('danger', 'Uh Oh!', 'Invalid or non-existent Item ID.', true, 'inventory.php');
    } else {
        $id = $db->fetch_row($q);
        echo "
		<table class='table table-bordered'>
			<tr>
				<th colspan='2'>
					Looking up the item information for {$id['itmname']}.
				</th>
			</tr>
			<tr>
				<th width='33%'>
					Item Type
				</th>
				<td>
					{$id['itmtypename']}
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Information
				</th>
				<td>
					{$id['itmdesc']}
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Buying Price
				</th>
				<td>";
        if ($id['itmbuyprice'] > 0) {
            echo number_format($id['itmbuyprice']);
        } else {
            echo "Unpurchaseable";
        }
        echo "
				</td>
			</tr>
			<tr>
				<th width='33%'>
					Item Selling Price
				</th>
				<td>";
        if ($id['itmsellprice']) {
            echo number_format($id['itmsellprice']);
        } else {
            echo "Unsellable.";
        }
        echo "
				</td>
			</tr>";
        $iterations=count(json_decode($id['itmeffects_toggle']));
        $toggle=json_decode($id['itmeffects_toggle']);
        $stat=json_decode($id['itmeffects_stat']);
        $dir=json_decode($id['itmeffects_dir']);
        $type=json_decode($id['itmeffects_type']);
        $amount=json_decode($id['itmeffects_amount']);
        $usecount=0;
        var_dump($iterations);
        while ($usecount != $iterations)
        {
            if ($toggle[$usecount] == 1)
            {
                $type[$usecount] = ($type[$usecount] == 'percent') ? '%' : '';
                $dir[$usecount] = ($dir[$usecount] == 'pos') ? 'Increases' : 'Decreases';
                $stats =
                    array("energy" => "Energy", "will" => "Will",
                        "brave" => "Bravery", "level" => "Level",
                        "hp" => "Health", "strength" => "Strength",
                        "agility" => "Agility", "guard" => "Guard",
                        "labor" => "Labor", "iq" => "IQ",
                        "infirmary" => "Infirmary Time", "dungeon" => "Dungeon Time",
                        "primary_currency" => "Primary Currency", 
                        "secondary_currency" => "Secondary Currency", 
                        "crimexp" => "Experience", "vip_days" =>
                        "VIP Days");
                $statformatted = $stats["{$stat[$usecount]}"];
                 echo "
				<tr>
					<th>
						Item Effect
					</th>
					<td>
					{$dir[$usecount]} {$statformatted} by " . number_format($amount[$usecount]) . "{$type[$usecount]}.
					</td>
				</tr>";
            }
            $usecount=$usecount+1;
        }
        if ($id['weapon']) {
            echo "<tr>
				<th width='33%'>
					Item Weapon Rating
				</th>
				<td>
					" . number_format($id['weapon']) . "
				</td>
			</tr>";
        }
        if ($id['armor']) {
            echo "<tr>
				<th width='33%'>
					Item Armor Rating
				</th>
				<td>
					" . number_format($id['armor']) . "
				</td>
			</tr>";
        }
        echo "
		</table>";
        $db->free_result($q);
    }
{'fraction_non_alphanumeric': 0.19794276671502045, 'fraction_numerical': 0.008308057497032837, 'mean_word_length': 1.69701280227596, 'pattern_counts': {'":': 0, '<': 102, '<?xml version=': 0, '>': 141, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1262772', 'n_tokens_mistral': 2985, 'n_tokens_neox': 2515, 'n_words': 520}