corrade-http-templates – Diff between revs 2 and 7

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 7
Line 12... Line 12...
12   12  
13 ########################################################################### 13 ###########################################################################
14 ## CONFIGURATION ## 14 ## CONFIGURATION ##
Line 15... Line -...
15 ########################################################################### -  
16   -  
17 # Set this to the name of the group. 15 ###########################################################################
18 $GROUP = 'My Group'; 16  
19 # Set this to the group password. -  
20 $PASSWORD = 'mypassword'; -  
Line 21... Line 17...
21 # Set this to Corrade's HTTP Server URL. 17 require_once('config.php');
22 $URL = 'http://corrade.internal.site:8080'; 18 require_once('functions.php');
23   19  
Line 24... Line -...
24 ########################################################################### -  
25 ## INTERNALS ## -  
26 ########################################################################### -  
27   -  
28 ########################################################################### -  
29 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## -  
30 ########################################################################### -  
31 function wasKeyValueGet($key, $data) { -  
32 return array_reduce( -  
33 explode( -  
34 "&", -  
35 $data -  
36 ), -  
37 function($o, $p) { -  
38 $x = explode("=", $p); -  
39 return array_shift($x) != $o ? $o : array_shift($x); -  
40 }, -  
41 $key -  
42 ); -  
43 } -  
44 /////////////////////////////////////////////////////////////////////////// -  
45 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // -  
46 /////////////////////////////////////////////////////////////////////////// -  
47 function wasCSVToArray($csv) { -  
48 $l = array(); -  
49 $s = array(); -  
50 $m = ""; -  
51 for ($i = 0; $i < strlen($csv); ++$i) { -  
52 switch ($csv{$i}) { -  
53 case ',': -  
54 if (sizeof($s) == 0 || !current($s) == '"') { -  
55 array_push($l, $m); -  
56 $m = ""; -  
57 break; -  
58 } -  
59 $m .= $csv{$i}; -  
60 continue; -  
61 case '"': -  
62 if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) { -  
63 $m .= $csv{$i}; -  
64 ++$i; -  
65 break; -  
66 } -  
67 if (sizeof($s) == 0|| !current($s) == $csv[$i]) { -  
68 array_push($s, $csv{$i}); -  
69 continue; -  
70 } -  
71 array_pop($s); -  
72 break; -  
73 default: -  
74 $m .= $csv{$i}; -  
75 break; -  
76 } -  
77 } -  
78 array_push($l, $m); -  
79 return $l; -  
80 } -  
81   -  
82 ########################################################################## -  
83 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## -  
84 ########################################################################### -  
85 function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) { -  
86 return $yMin + ( -  
87 ( -  
88 $yMax - $yMin -  
89 ) -  
90 * -  
91 ( -  
92 $value - $xMin -  
93 ) -  
94 / -  
95 ( -  
96 $xMax - $xMin -  
97 ) -  
98 ); -  
99 } -  
100   -  
101 ########################################################################### -  
102 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## -  
103 ########################################################################### -  
104 function wasLSLVectorToArray($vector) { -  
105 $components = array(); -  
106 if(!preg_match( -  
107 "/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/", -  
108 $vector, -  
109 $components -  
110 )) return; -  
111 array_shift($components); 20 ###########################################################################
112 return $components; 21 ## INTERNALS ##
113 } 22 ###########################################################################
114   23  
115 #### 24 ####
Line 133... Line 42...
133   42  
134 curl_setopt($curl, CURLOPT_URL, $URL); 43 curl_setopt($curl, CURLOPT_URL, $URL);
135 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 44 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
136 curl_setopt($curl, CURLOPT_POST, true); 45 curl_setopt($curl, CURLOPT_POST, true);
-   46 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
137 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); 47 curl_setopt($curl, CURLOPT_ENCODING, true);
138 $return = curl_exec($curl); 48 $return = curl_exec($curl);
Line 139... Line 49...
139 curl_close($curl); 49 curl_close($curl);
140   50  
Line 181... Line 91...
181 } 91 }
182 curl_setopt($curl, CURLOPT_URL, $URL); 92 curl_setopt($curl, CURLOPT_URL, $URL);
183 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 93 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
184 curl_setopt($curl, CURLOPT_POST, true); 94 curl_setopt($curl, CURLOPT_POST, true);
185 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); 95 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
-   96 curl_setopt($curl, CURLOPT_ENCODING, true);
186 $return = curl_exec($curl); 97 $return = curl_exec($curl);
187 curl_close($curl); 98 curl_close($curl);
Line 188... Line 99...
188   99  
189 if($success == 'False') { 100 if($success == 'False') {
Line 229... Line 140...
229 } 140 }
230 curl_setopt($curl, CURLOPT_URL, $URL); 141 curl_setopt($curl, CURLOPT_URL, $URL);
231 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 142 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
232 curl_setopt($curl, CURLOPT_POST, true); 143 curl_setopt($curl, CURLOPT_POST, true);
233 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars); 144 curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
-   145 curl_setopt($curl, CURLOPT_ENCODING, true);
234 $return = curl_exec($curl); 146 $return = curl_exec($curl);
235 curl_close($curl); 147 curl_close($curl);
Line 236... Line 148...
236   148  
237 $success = urldecode( 149 $success = urldecode(