corrade-http-templates – Diff between revs 72 and 82
?pathlinks?
Rev 72 | Rev 82 | |||
---|---|---|---|---|
1 | <?php |
1 | <?php |
|
2 | |
2 | |
|
3 | ########################################################################### |
3 | ########################################################################### |
|
4 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
4 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
|
5 | ########################################################################### |
5 | ########################################################################### |
|
6 | ## This is a script that gives an inventory item by UUID to an agent ## |
6 | ## This is a script that gives an inventory item by UUID to an agent ## |
|
7 | ## specified by firstname and lastname. ## |
7 | ## specified by firstname and lastname. ## |
|
8 | ########################################################################### |
8 | ########################################################################### |
|
9 | |
9 | |
|
10 | if(!isset($_POST['uuid']) || |
10 | if(!isset($_POST['uuid']) || |
|
11 | !isset($_POST['firstname']) || |
11 | !isset($_POST['firstname']) || |
|
12 | !isset($_POST['lastname'])) return; |
12 | !isset($_POST['lastname'])) return; |
|
13 | |
13 | |
|
14 | $uuid = $_POST['uuid']; |
14 | $uuid = $_POST['uuid']; |
|
15 | $firstname = $_POST['firstname']; |
15 | $firstname = $_POST['firstname']; |
|
16 | $lastname = $_POST['lastname']; |
16 | $lastname = $_POST['lastname']; |
|
17 | |
17 | |
|
18 | ########################################################################### |
18 | ########################################################################### |
|
19 | ## CONFIGURATION ## |
19 | ## CONFIGURATION ## |
|
20 | ########################################################################### |
20 | ########################################################################### |
|
21 | |
21 | |
|
22 | require_once('config.php'); |
22 | require_once('config.php'); |
|
23 | require_once('vendor/was/utilities/src/formats/kvp/kvp.php'); |
23 | require_once('vendor/was/utilities/src/formats/kvp/kvp.php'); |
|
24 | |
24 | |
|
25 | ########################################################################### |
25 | ########################################################################### |
|
26 | ## INTERNALS ## |
26 | ## INTERNALS ## |
|
27 | ########################################################################### |
27 | ########################################################################### |
|
28 | |
28 | |
|
29 | |
29 | |
|
30 | #### |
30 | #### |
|
31 | # I. Send the command to give the avatar the item. |
31 | # I. Send the command to give the avatar the item. |
|
32 | $params = array( |
32 | $params = array( |
|
33 | 'command' => 'give', |
33 | 'command' => 'give', |
|
34 | 'group' => $GROUP, |
34 | 'group' => $GROUP, |
|
35 | 'password' => $PASSWORD, |
35 | 'password' => $PASSWORD, |
|
36 | 'item' => $uuid, |
36 | 'item' => $uuid, |
|
37 | 'entity' => 'avatar', |
37 | 'entity' => 'avatar', |
|
38 | 'firstname' => $firstname, |
38 | 'firstname' => $firstname, |
|
39 | 'lastname' => $lastname |
39 | 'lastname' => $lastname |
|
40 | ); |
40 | ); |
|
41 | array_walk($params, |
41 | array_walk($params, |
|
42 | function(&$value, $key) { |
42 | function(&$value, $key) { |
|
43 | $value = rawurlencode($key)."=".rawurlencode($value); |
43 | $value = urlencode($key)."=".urlencode($value); |
|
44 | } |
44 | } |
|
45 | ); |
45 | ); |
|
46 | $postvars = implode('&', $params); |
46 | $postvars = implode('&', $params); |
|
47 | if (!($curl = curl_init())) { |
47 | if (!($curl = curl_init())) { |
|
48 | print 0; |
48 | print 0; |
|
49 | return; |
49 | return; |
|
50 | } |
50 | } |
|
51 | curl_setopt($curl, CURLOPT_URL, $URL); |
51 | curl_setopt($curl, CURLOPT_URL, $URL); |
|
52 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
52 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
53 | curl_setopt($curl, CURLOPT_POST, true); |
53 | curl_setopt($curl, CURLOPT_POST, true); |
|
54 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); |
54 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); |
|
55 | curl_setopt($curl, CURLOPT_ENCODING, true); |
55 | curl_setopt($curl, CURLOPT_ENCODING, true); |
|
56 | $result = curl_exec($curl); |
56 | $result = curl_exec($curl); |
|
57 | curl_close($curl); |
57 | curl_close($curl); |
|
58 | |
58 | |
|
59 | #### |
59 | #### |
|
60 | # II. Process the success status and display any error. |
60 | # II. Process the success status and display any error. |
|
61 | $success = urldecode( |
61 | $success = urldecode( |
|
62 | wasKeyValueGet( |
62 | wasKeyValueGet( |
|
63 | "success", |
63 | "success", |
|
64 | $result |
64 | $result |
|
65 | ) |
65 | ) |
|
66 | ); |
66 | ); |
|
67 | |
67 | |
|
68 | if($success == 'False') { |
68 | if($success == 'False') { |
|
69 | echo 'Unable to give inventory item: '.urldecode( |
69 | echo 'Unable to give inventory item: '.urldecode( |
|
70 | wasKeyValueGet( |
70 | wasKeyValueGet( |
|
71 | "error", |
71 | "error", |
|
72 | $result |
72 | $result |
|
73 | ) |
73 | ) |
|
74 | ); |
74 | ); |
|
75 | die; |
75 | die; |
|
76 | } |
76 | } |
|
77 | |
77 | |
|
78 | ?> |
78 | ?> |
|
79 | |
79 | |
|
80 | |
80 | |