-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajax_autosort_add.php
56 lines (46 loc) · 1.48 KB
/
ajax_autosort_add.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
<?php
$require_petload = 'no';
$invisible = 'yes';
$AJAX = true;
// confirm the session...
require_once 'commons/dbconnect.php';
require_once 'commons/sessions.php';
require_once 'commons/utility.php';
$rooms = take_apart(',', $house['rooms']);
foreach($rooms as $i=>$room)
$real_rooms[$i] = 'home/' . $room;
$real_rooms[] = 'home';
$real_rooms[] = 'storage';
$real_rooms[] = 'storage/locked';
$real_rooms[] = 'storage/mystore';
$itemname = trim($_POST['itemname']);
$target = trim($_POST['target']);
if(!in_array($target, $real_rooms))
{
echo 'failure:room' . "\n";
$failed = true;
}
$command = 'SELECT itemname FROM monster_items WHERE itemname=' . quote_smart($itemname) . ' LIMIT 1';
$item_data = $database->FetchSingle($command, 'fetching item');
if($item_data === false)
{
echo 'failure:item' . "\n";
$failed = true;
}
else
{
$command = 'SELECT idnum FROM psypets_autosort WHERE userid=' . $user['idnum'] . ' AND itemname=' . quote_smart($item_data['itemname']) . ' LIMIT 1';
$existing = $database->FetchSingle($command, 'fetching exiting rule');
if($existing !== false)
{
echo 'hilight:' . $existing['idnum'] . "\n";
$failed = true;
}
}
if(!$failed)
{
$command = 'INSERT INTO psypets_autosort (userid, itemname, room) VALUES (' . $user['idnum'] . ', ' . quote_smart($item_data['itemname']) . ', ' . quote_smart($target) . ')';
$database->FetchNone($command, 'creating rule');
echo 'addrule:' . $database->InsertID() . ';' . $item_data['itemname'] . ';' . $target;
}
?>