corrade-http-templates – Diff between revs 2 and 14
?pathlinks?
Rev 2 | Rev 14 | |||
---|---|---|---|---|
Line 8... | Line 8... | |||
8 | |
8 | |
|
9 | ########################################################################### |
9 | ########################################################################### |
|
10 | ## CONFIGURATION ## |
10 | ## CONFIGURATION ## |
|
Line 11... | Line -... | |||
11 | ########################################################################### |
- | ||
12 | |
- | ||
13 | # Set this to the name of the group. |
11 | ########################################################################### |
|
14 | $GROUP = 'My Group'; |
12 | |
|
15 | # Set this to the group password. |
- | ||
16 | $PASSWORD = 'mypassword'; |
- | ||
Line 17... | Line 13... | |||
17 | # Set this to Corrade's HTTP Server URL. |
13 | require_once('config.php'); |
|
18 | $URL = 'http://corrade.internal.sever:8080'; |
14 | require_once('functions.php'); |
|
19 | |
15 | |
|
Line 20... | Line 16... | |||
20 | ########################################################################### |
16 | ########################################################################### |
|
21 | ## INTERNALS ## |
17 | ## INTERNALS ## |
|
Line 22... | Line -... | |||
22 | ########################################################################### |
- | ||
23 | |
- | ||
24 | # If no avatars have been sent, then bail. |
- | ||
25 | if(!isset($_POST['avatars'])) return; |
- | ||
26 | |
- | ||
27 | ########################################################################### |
- | ||
28 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
29 | ########################################################################### |
- | ||
30 | function wasKeyValueGet($key, $data) { |
- | ||
31 | return array_reduce( |
- | ||
32 | explode( |
- | ||
33 | "&", |
- | ||
34 | $data |
- | ||
35 | ), |
- | ||
36 | function($o, $p) { |
- | ||
37 | $x = explode("=", $p); |
- | ||
38 | return array_shift($x) != $o ? $o : array_shift($x); |
- | ||
39 | }, |
- | ||
40 | $key |
- | ||
41 | ); |
- | ||
42 | } |
- | ||
43 | |
- | ||
44 | ########################################################################### |
- | ||
45 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
46 | ########################################################################### |
- | ||
47 | function wasArrayToCSV($a) { |
- | ||
48 | return implode( |
- | ||
49 | ',', |
- | ||
50 | array_map( |
- | ||
51 | function($o) { |
- | ||
52 | $o = str_replace('"', '""', $o); |
- | ||
53 | switch( |
- | ||
54 | (strpos($o, ' ') !== FALSE) || |
- | ||
55 | (strpos($o, '"') !== FALSE) || |
- | ||
56 | (strpos($o, ',') !== FALSE) || |
- | ||
57 | (strpos($o, '\r') !== FALSE) || |
- | ||
58 | (strpos($o, '\n') !== FALSE) |
- | ||
59 | ) |
- | ||
60 | { |
- | ||
61 | case TRUE: |
- | ||
62 | return '"' . $o . '"'; |
- | ||
63 | default: |
- | ||
64 | return $o; |
- | ||
65 | } |
- | ||
66 | }, |
- | ||
67 | $a |
- | ||
68 | ) |
- | ||
69 | ); |
- | ||
70 | } |
- | ||
71 | |
- | ||
72 | ########################################################################### |
- | ||
73 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
74 | ########################################################################### |
- | ||
75 | function wasCSVToArray($csv) { |
- | ||
76 | $l = array(); |
- | ||
77 | $s = array(); |
- | ||
78 | $m = ""; |
- | ||
79 | for ($i = 0; $i < strlen($csv); ++$i) { |
- | ||
80 | switch ($csv{$i}) { |
- | ||
81 | case ',': |
- | ||
82 | if (sizeof($s) == 0 || !current($s) == '"') { |
- | ||
83 | array_push($l, $m); |
- | ||
84 | $m = ""; |
- | ||
85 | break; |
- | ||
86 | } |
- | ||
87 | $m .= $csv{$i}; |
- | ||
88 | continue; |
- | ||
89 | case '"': |
- | ||
90 | if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) { |
- | ||
91 | $m .= $csv{$i}; |
- | ||
92 | ++$i; |
- | ||
93 | break; |
- | ||
94 | } |
- | ||
95 | if (sizeof($s) == 0|| !current($s) == $csv[$i]) { |
- | ||
96 | array_push($s, $csv{$i}); |
- | ||
97 | continue; |
- | ||
98 | } |
- | ||
99 | array_pop($s); |
- | ||
100 | break; |
- | ||
101 | default: |
- | ||
102 | $m .= $csv{$i}; |
- | ||
103 | break; |
- | ||
104 | } |
- | ||
105 | } |
18 | ########################################################################### |
|
106 | array_push($l, $m); |
19 | |
|
107 | return $l; |
20 | # If no avatars have been sent, then bail. |
|
108 | } |
21 | if(!isset($_POST['avatars'])) return; |
|
109 | |
22 | |