|
159 | 159 | $proxiedApp = $starr->getAppFromProxiedKey($apikey); |
160 | 160 | $app = $starr->getStarrInterfaceNameFromId($proxiedApp['starrAppDetails']['starr']); |
161 | 161 |
|
162 | | - if (!$proxiedApp) { |
| 162 | + if (!$proxiedApp || !$proxiedApp['starrApp']) { |
163 | 163 | logger($logfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $endpoint, 'proxyCode' => 401]); |
164 | 164 | apiResponse(401, ['error' => sprintf(APP_API_ERROR, 'provided apikey is not valid or has no access')]); |
165 | 165 | } |
|
177 | 177 | header('Content-disposition: attachment; filename="' . $proxyBackup . '"'); |
178 | 178 | readfile($proxyBackup); |
179 | 179 | } |
| 180 | + } elseif (!$endpoint && $_GET['feed']) { //-- iCal links, let them through |
| 181 | + unset($variables['feed'], $variables['apikey']); |
| 182 | + $starrUrl = $proxiedApp['starrAppDetails']['url'] . $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : ''); |
| 183 | + $request = curl($starrUrl, ['X-Api-Key:' . $proxiedApp['starrAppDetails']['apikey']], $method, $json); |
| 184 | + |
| 185 | + logger($logfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : ''), 'proxyCode' => 200, 'starrCode' => $request['code']]); |
| 186 | + logger($proxiedAppLogfile, ['req' => $requestCounter, 'apikey' => $apikey, 'endpoint' => $_GET['feed'] . ($variables ? '?' . http_build_query($variables) : ''), 'proxyCode' => 200, 'starrCode' => $request['code'], 'starrRequest' => $request]); |
| 187 | + |
| 188 | + $usageDb->adjustAppUsage($proxiedApp['proxiedAppDetails']['id'], $request['code']); |
| 189 | + |
| 190 | + echo $request['response']; |
| 191 | + exit(); |
180 | 192 | } else { |
181 | 193 | $isAllowedEndpoint = $starr->isAllowedEndpoint($app, $proxiedApp['access'], $endpoint); |
182 | 194 | $starrEndpoint = $isAllowedEndpoint['starrEndpoint']; |
|
0 commit comments