corrade-http-templates – Blame information for rev 82
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
15 | eva | 1 | <?php |
2 | |||
3 | ########################################################################### |
||
4 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
||
5 | ########################################################################### |
||
6 | ## This is a script that can be used to download a notecard using ## |
||
7 | ## Corrade and the "download" Corrde command. ## |
||
8 | ########################################################################### |
||
9 | |||
10 | if(!isset($_POST['uuid'])) return; |
||
11 | |||
12 | $uuid = $_POST['uuid']; |
||
13 | |||
14 | ########################################################################### |
||
15 | ## CONFIGURATION ## |
||
16 | ########################################################################### |
||
17 | |||
18 | require_once('config.php'); |
||
72 | office | 19 | require_once('vendor/was/utilities/src/formats/kvp/kvp.php'); |
15 | eva | 20 | |
21 | ########################################################################### |
||
22 | ## INTERNALS ## |
||
23 | ########################################################################### |
||
24 | |||
25 | #### |
||
26 | # I. Download the notecard. |
||
27 | $params = array( |
||
28 | 'command' => 'download', |
||
29 | 'group' => $GROUP, |
||
30 | 'password' => $PASSWORD, |
||
31 | 'item' => $uuid, |
||
32 | 'type' => 'Notecard' |
||
33 | ); |
||
34 | array_walk($params, |
||
35 | function(&$value, $key) { |
||
82 | office | 36 | $value = urlencode($key)."=".urlencode($value); |
15 | eva | 37 | } |
38 | ); |
||
39 | $postvars = implode('&', $params); |
||
40 | if (!($curl = curl_init())) { |
||
41 | print 0; |
||
42 | return; |
||
43 | } |
||
44 | curl_setopt($curl, CURLOPT_URL, $URL); |
||
45 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||
46 | curl_setopt($curl, CURLOPT_POST, true); |
||
47 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); |
||
48 | curl_setopt($curl, CURLOPT_ENCODING, true); |
||
49 | $result = curl_exec($curl); |
||
50 | curl_close($curl); |
||
51 | |||
52 | $success = urldecode( |
||
53 | wasKeyValueGet( |
||
54 | "success", |
||
55 | $result |
||
56 | ) |
||
57 | ); |
||
58 | |||
59 | if($success == 'False') { |
||
60 | echo 'Unable to download notecard: '.urldecode( |
||
61 | wasKeyValueGet( |
||
62 | "error", |
||
63 | $result |
||
64 | ) |
||
65 | ); |
||
66 | die; |
||
67 | } |
||
68 | |||
69 | #### |
||
70 | # II. Return the contents of the notecard. |
||
71 | echo urldecode( |
||
72 | wasKeyValueGet( |
||
73 | "data", |
||
74 | $result |
||
75 | ) |
||
76 | ); |
||
77 | |||
78 | ?> |
||
79 |