corrade-http-templates – Diff between revs 2 and 11
?pathlinks?
Rev 2 | Rev 11 | |||
---|---|---|---|---|
Line 5... | Line 5... | |||
5 | ########################################################################### |
5 | ########################################################################### |
|
6 | ## This is a script that can be used to download a texture using Corrade ## |
6 | ## This is a script that can be used to download a texture using Corrade ## |
|
7 | ## and the "download" Corrde command. ## |
7 | ## and the "download" Corrde command. ## |
|
8 | ########################################################################### |
8 | ########################################################################### |
|
Line 9... | Line -... | |||
9 | |
- | ||
10 | if(!isset($_POST['uuid'])) return; |
- | ||
11 | |
- | ||
12 | $uuid = $_POST['uuid']; |
- | ||
13 | |
9 | |
|
14 | ########################################################################### |
10 | ########################################################################### |
|
15 | ## CONFIGURATION ## |
11 | ## CONFIGURATION ## |
|
Line 16... | Line -... | |||
16 | ########################################################################### |
- | ||
17 | |
- | ||
18 | # Set this to the name of the group. |
12 | ########################################################################### |
|
19 | $GROUP = 'My Group'; |
13 | |
|
20 | # Set this to the group password. |
- | ||
21 | $PASSWORD = 'mypassword'; |
- | ||
Line 22... | Line 14... | |||
22 | # Set this to Corrade's HTTP Server URL. |
14 | require_once('config.php'); |
|
23 | $URL = 'http://corrade.hostname:8080'; |
15 | require_once('functions.php'); |
|
24 | |
16 | |
|
Line 25... | Line -... | |||
25 | ########################################################################### |
- | ||
26 | ## INTERNALS ## |
- | ||
27 | ########################################################################### |
- | ||
28 | |
17 | ########################################################################### |
|
29 | ########################################################################### |
18 | ## INTERNALS ## |
|
30 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
31 | ########################################################################### |
- | ||
32 | function wasKeyValueGet($key, $data) { |
- | ||
33 | return array_reduce( |
- | ||
34 | explode( |
- | ||
35 | "&", |
- | ||
36 | $data |
- | ||
37 | ), |
- | ||
38 | function($o, $p) { |
- | ||
39 | $x = explode("=", $p); |
- | ||
40 | return array_shift($x) != $o ? $o : array_shift($x); |
- | ||
Line 41... | Line 19... | |||
41 | }, |
19 | ########################################################################### |
|
42 | $key |
20 | |
|
43 | ); |
21 | if(!isset($_POST['uuid'])) return; |
|
44 | } |
22 | $uuid = $_POST['uuid']; |
|
45 | |
23 | |
|
46 | #### |
24 | #### |
|
47 | # II. Download the map image as a PNG file. |
25 | # I. Download the map image as a PNG file. |
|
Line 86... | Line 64... | |||
86 | ); |
64 | ); |
|
87 | die; |
65 | die; |
|
88 | } |
66 | } |
|
Line 89... | Line 67... | |||
89 | |
67 | |
|
90 | #### |
68 | #### |
|
91 | # III. Convert the image data to a PNG of size 512x512 |
69 | # II. Convert the image data to a PNG of size 512x512 |
|
92 | $im = imagescale( |
70 | $im = imagescale( |
|
93 | imagecreatefromstring( |
71 | imagecreatefromstring( |
|
94 | base64_decode( |
72 | base64_decode( |
|
95 | rawurldecode( |
73 | rawurldecode( |
|
Line 103... | Line 81... | |||
103 | 512, |
81 | 512, |
|
104 | 512 |
82 | 512 |
|
105 | ); |
83 | ); |
|
Line 106... | Line 84... | |||
106 | |
84 | |
|
107 | #### |
85 | #### |
|
108 | # IV. Output the Base64 encoded image for AJAX. |
86 | # III. Output the Base64 encoded image for AJAX. |
|
109 | ob_start(); |
87 | ob_start(); |
|
110 | imagepng($im); |
88 | imagepng($im); |
|
111 | $png = ob_get_contents(); |
89 | $png = ob_get_contents(); |
|
112 | imagedestroy($im); |
90 | imagedestroy($im); |