|
70 | 70 | 'login_perc' => 0, |
71 | 71 | 'load_perc' => 0, |
72 | 72 | ], |
73 | | - 'count' => 0, |
74 | | - 'data' => [] |
| 73 | + 'count' => 0, |
| 74 | + 'data' => [], |
75 | 75 | ]; |
76 | 76 |
|
77 | 77 | $output_method = 'json'; |
|
106 | 106 | $output_method = $_POST['selected_output_method']; |
107 | 107 | } |
108 | 108 |
|
109 | | - if (empty($params)) { |
110 | | - switch ($method) { |
111 | | - case 'stat_5minutes_gateway': |
112 | | - $params = [null, null, $gateway_stats_attribs]; |
113 | | - break; |
114 | | - case 'stat_hourly_gateway': |
115 | | - $params = [null, null, $gateway_stats_attribs]; |
116 | | - break; |
117 | | - case 'stat_daily_gateway': |
118 | | - $params = [null, null, $gateway_stats_attribs]; |
119 | | - break; |
120 | | - case 'stat_monthly_gateway': |
121 | | - $params = [null, null, $gateway_stats_attribs]; |
122 | | - } |
| 109 | + $gateway_stats_methods = [ |
| 110 | + 'stat_5minutes_gateway', |
| 111 | + 'stat_hourly_gateway', |
| 112 | + 'stat_daily_gateway', |
| 113 | + 'stat_monthly_gateway' |
| 114 | + ]; |
| 115 | + |
| 116 | + if (empty($params) && in_array($method, $gateway_stats_methods)) { |
| 117 | + $params = [null, null, $gateway_stats_attribs]; |
123 | 118 | } |
124 | 119 |
|
125 | 120 | if (!empty($method) && !empty($site_id)) { |
|
129 | 124 | /** |
130 | 125 | * create an instance of the Unifi API client class, log in to the controller and pull the requested data |
131 | 126 | */ |
132 | | - $unifi_connection = new UniFi_API\Client(trim($controller['user']), trim($controller['password']), trim(rtrim($controller['url'], "/")), $site_id); |
| 127 | + $unifi_connection = new UniFi_API\Client(trim($controller['user']), trim($controller['password']), |
| 128 | + trim(rtrim($controller['url'], "/")), $site_id); |
133 | 129 | $loginresults = $unifi_connection->login(); |
134 | 130 |
|
135 | 131 | /** |
|
170 | 166 | * for Kint we need to return the results in a slightly different manner |
171 | 167 | * Rich render mode |
172 | 168 | */ |
173 | | - Kint::$display_called_from = false; |
174 | | - Kint\Renderer\RichRenderer::$folder = false; |
175 | | - $results['data'] = @d($data_array); |
176 | | - } else if ($output_method === 'kint_plain') { |
177 | | - /** |
178 | | - * Plain render mode |
179 | | - */ |
180 | | - Kint::$display_called_from = false; |
| 169 | + Kint::$display_called_from = false; |
181 | 170 | Kint\Renderer\RichRenderer::$folder = false; |
182 | | - Kint\Renderer\TextRenderer::$decorations = false; |
183 | | - $results['data'] = @s($data_array); |
| 171 | + $results['data'] = @d($data_array); |
184 | 172 | } else { |
185 | | - $results['data'] = $data_array; |
| 173 | + if ($output_method === 'kint_plain') { |
| 174 | + /** |
| 175 | + * Plain render mode |
| 176 | + */ |
| 177 | + Kint::$display_called_from = false; |
| 178 | + Kint\Renderer\RichRenderer::$folder = false; |
| 179 | + Kint\Renderer\TextRenderer::$decorations = false; |
| 180 | + $results['data'] = @s($data_array); |
| 181 | + } else { |
| 182 | + $results['data'] = $data_array; |
| 183 | + } |
186 | 184 | } |
187 | 185 | } |
188 | 186 |
|
|
213 | 211 | * output the results with correct JSON formatting |
214 | 212 | */ |
215 | 213 | header('Content-Type: application/json; charset=utf-8'); |
216 | | -echo (json_encode($results)); |
| 214 | +echo(json_encode($results)); |
217 | 215 |
|
218 | 216 | $_SESSION['memory_used'] = round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'MB'; |
0 commit comments