-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajax_trashinventory2.php
110 lines (90 loc) · 3.04 KB
/
ajax_trashinventory2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
$require_petload = 'no';
$invisible = 'yes';
$AJAX = true;
// confirm the session...
require_once 'commons/dbconnect.php';
require_once 'commons/sessions.php';
require_once 'commons/rpgfunctions.php';
require_once 'commons/inventory.php';
require_once 'commons/houselib.php';
require_once 'commons/itemstats.php';
if(!array_key_exists('ids', $_POST))
{
echo 'message:No items were selected...';
exit();
}
$itemids = explode(',', $_POST['ids']);
$house = get_house_byuser($user['idnum']);
if($house === false)
{
echo 'message:Error loading your house. If this problem persists (especially if there\'s nothing about it in the City Hall), please report it to <a href="admincontact.php">an administrator</a>.' . "\n" .
'failure:' . implode(',', $itemids);
exit();
}
$failed_ids = array();
$moved_ids = array();
$tossed = array();
foreach($itemids as $id)
{
$item = get_inventory_byid($id);
if($item['user'] == $user['user'] && $item['location'] != 'pet' && $item['location'] != 'storage/outgoing')
{
$item_details = get_item_byname($item['itemname']);
if($item_details === false)
continue;
if($item_details['cursed'] == 'yes' || $item_details['questitem'] == 'yes')
{
$failed_ids[] = $id;
}
else if($item_details['custom'] == 'yes' || $item_details['custom'] == 'monthly' || $item_details['custom'] == 'recurring' || $item_details['custom'] == 'limited')
{
$failed_ids[] = $id;
$reveal_volcano = true;
}
else
{
$moved_ids[] = $id;
$tossed[$item['itemname']]++;
}
}
else
$failed_ids[] = $id;
}
if(count($tossed) > 0)
{
foreach($tossed as $item=>$quantity)
record_item_disposal($item, 'tossed', $quantity);
}
if(count($moved_ids) > 0)
{
$command = 'DELETE FROM monster_inventory WHERE idnum IN (' . implode(',', $moved_ids) . ') LIMIT ' . count($moved_ids);
$database->FetchNone($command, 'deleting items');
$new_bulk = recount_house_bulk($user, $house);
$house['curbulk'] = $new_bulk;
echo 'newbulk:' . render_house_bulk($house) . "\n";
}
if(count($moved_ids) > 0)
{
echo 'message:<span class="success">' . count($moved_ids) . ' item' . (count($moved_ids) == 1 ? ' was' : 's were') . ' thrown away.';
if(count($failed_ids) > 0)
echo ' ' . count($failed_ids) . ' item' . (count($failed_ids) == 1 ? '' : 's') . ' could not be moved.';
echo '</span>' . "\n" .
'success:' . implode(',', $moved_ids);
}
if(count($failed_ids) > 0)
{
if(count($moved_ids) == 0)
echo 'message:<span class="failure">The selected item' . (count($failed_ids) == 1 ? '' : 's') . ' could not be thrown away!</span>';
echo "\n" . 'failure:' . implode(',', $failed_ids);
}
if($reveal_volcano === true)
{
if($user['show_volcano'] == 'no')
{
$command = 'UPDATE monster_users SET show_volcano=\'yes\' WHERE idnum=' . $user['idnum'] . ' LIMIT 1';
$database->FetchNone($command, 'revealing volcano');
echo "\n" . 'message:<span class="success">(<a href="volcano.php">The Volcano</a> has been revealed to you! Find it in the Services menu.)</i>';
}
}
?>