@@ -180,7 +180,7 @@ |
||
180 | 180 | { |
181 | 181 | $response = []; |
182 | 182 | |
183 | - foreach($this->bm->versions as $version) { |
|
183 | + foreach ($this->bm->versions as $version) { |
|
184 | 184 | $response[] = new BeatMapVersion($version); |
185 | 185 | } |
186 | 186 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $l_Handles = []; |
32 | 32 | foreach ($p_URLs as $l_URL) |
33 | 33 | { |
34 | - $l_CURL = curl_init($this->apiUrl.$apiUrlExt.$l_URL); |
|
34 | + $l_CURL = curl_init($this->apiUrl . $apiUrlExt . $l_URL); |
|
35 | 35 | curl_setopt($l_CURL, CURLOPT_USERAGENT, $this->userAgent); |
36 | 36 | curl_setopt($l_CURL, CURLOPT_RETURNTRANSFER, true); |
37 | 37 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | mkdir($targetDir, 0777, true); |
88 | 88 | } |
89 | 89 | |
90 | - if(substr($targetDir, -1) !== "/") |
|
90 | + if (substr($targetDir, -1) !== "/") |
|
91 | 91 | $targetDir .= "/"; |
92 | 92 | |
93 | 93 | //The path & filename to save to. |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | |
102 | 102 | $result = curl_exec($ch); |
103 | 103 | |
104 | - if(curl_errno($ch) === 0) { |
|
104 | + if (curl_errno($ch) === 0) { |
|
105 | 105 | $allFailed = false; |
106 | 106 | echo "Ok "; |
107 | 107 | } else { |
108 | 108 | $anyError[] = $hash; |
109 | 109 | $error = true; |
110 | - if(is_null($allFailed)) $allFailed = true; |
|
110 | + if (is_null($allFailed)) $allFailed = true; |
|
111 | 111 | echo "Error "; |
112 | 112 | } |
113 | 113 | |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | |
122 | 122 | $status = ""; |
123 | 123 | |
124 | - if($allFailed) { |
|
124 | + if ($allFailed) { |
|
125 | 125 | $status = "All failed"; |
126 | 126 | $response->setErrorStatus(true)->setErrorMessage("Can't download all/some maps"); |
127 | 127 | } else { |
128 | - if(count($anyError) !== 0) { |
|
128 | + if (count($anyError) !== 0) { |
|
129 | 129 | $response->setErrorStatus(true)->setErrorMessage("Can't download all/some maps"); |
130 | 130 | |
131 | 131 | foreach ($anyError as $hash) { |
@@ -38,8 +38,9 @@ discard block |
||
38 | 38 | $l_Handles[] = $l_CURL; |
39 | 39 | } |
40 | 40 | |
41 | - foreach ($l_Handles as $l_Current) |
|
42 | - curl_multi_add_handle($l_Multi, $l_Current); |
|
41 | + foreach ($l_Handles as $l_Current) { |
|
42 | + curl_multi_add_handle($l_Multi, $l_Current); |
|
43 | + } |
|
43 | 44 | |
44 | 45 | $l_RunningHandles = null; |
45 | 46 | |
@@ -54,10 +55,11 @@ discard block |
||
54 | 55 | { |
55 | 56 | $l_Error = curl_error($l_Current); |
56 | 57 | |
57 | - if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200) |
|
58 | - $l_Result[] = false; |
|
59 | - else |
|
60 | - $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current))); |
|
58 | + if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200) { |
|
59 | + $l_Result[] = false; |
|
60 | + } else { |
|
61 | + $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current))); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | curl_multi_remove_handle($l_Multi, $l_Current); |
63 | 65 | } |
@@ -87,8 +89,9 @@ discard block |
||
87 | 89 | mkdir($targetDir, 0777, true); |
88 | 90 | } |
89 | 91 | |
90 | - if(substr($targetDir, -1) !== "/") |
|
91 | - $targetDir .= "/"; |
|
92 | + if(substr($targetDir, -1) !== "/") { |
|
93 | + $targetDir .= "/"; |
|
94 | + } |
|
92 | 95 | |
93 | 96 | //The path & filename to save to. |
94 | 97 | $saveTo = $targetDir . $hash . $extension; |
@@ -107,7 +110,9 @@ discard block |
||
107 | 110 | } else { |
108 | 111 | $anyError[] = $hash; |
109 | 112 | $error = true; |
110 | - if(is_null($allFailed)) $allFailed = true; |
|
113 | + if(is_null($allFailed)) { |
|
114 | + $allFailed = true; |
|
115 | + } |
|
111 | 116 | echo "Error "; |
112 | 117 | } |
113 | 118 |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | private function autoload($directory) { |
33 | - if(is_dir($directory)) { |
|
33 | + if (is_dir($directory)) { |
|
34 | 34 | $scan = scandir($directory); |
35 | 35 | unset($scan[0], $scan[1]); //unset . and .. |
36 | - foreach($scan as $file) { |
|
37 | - if(is_dir($directory."/".$file)) { |
|
38 | - $this->autoload($directory."/".$file); |
|
36 | + foreach ($scan as $file) { |
|
37 | + if (is_dir($directory . "/" . $file)) { |
|
38 | + $this->autoload($directory . "/" . $file); |
|
39 | 39 | } else { |
40 | - if(strpos($file, '.php') !== false) { |
|
41 | - include_once($directory."/".$file); |
|
40 | + if (strpos($file, '.php') !== false) { |
|
41 | + include_once($directory . "/" . $file); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $apiResult = $this->callAPI($endpoint); |
84 | 84 | |
85 | - if($apiResult === false || $apiResult == "Not Found") { |
|
85 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
86 | 86 | $response->setErrorStatus(true)->setErrorStatus("[getMap] Something went wrong with the API call."); |
87 | 87 | return $response; |
88 | 88 | } |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | $maps = []; |
143 | 143 | |
144 | 144 | // Latest |
145 | - if($numberOfPage === 0 && $startPage === 0){ |
|
145 | + if ($numberOfPage === 0 && $startPage === 0) { |
|
146 | 146 | $apiResult = json_decode($this->callAPI($endpoint)); |
147 | 147 | |
148 | - if($apiResult === false || $apiResult == "Not Found") { |
|
148 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
149 | 149 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling the first page."); |
150 | 150 | return $response; |
151 | - } else{ |
|
151 | + } else { |
|
152 | 152 | foreach ($apiResult->docs as $beatmap) { |
153 | 153 | $maps[] = new BeatMap($beatmap); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | } else { |
157 | - for($i = $startPage; $i < ($i + $numberOfPage); $i++){ |
|
157 | + for ($i = $startPage; $i < ($i + $numberOfPage); $i++) { |
|
158 | 158 | $apiResult = json_decode($this->callAPI(str_ireplace("page", $i, $endpoint))); |
159 | 159 | |
160 | - if($apiResult === false || $apiResult == "Not Found") { |
|
160 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
161 | 161 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
162 | 162 | |
163 | - if($apiResult == "Not Found") |
|
163 | + if ($apiResult == "Not Found") |
|
164 | 164 | return $response; |
165 | 165 | } |
166 | 166 | |
@@ -239,23 +239,23 @@ discard block |
||
239 | 239 | |
240 | 240 | $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
241 | 241 | |
242 | - if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
243 | - if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
244 | - if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
245 | - if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
246 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
247 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
248 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
249 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
250 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
251 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
252 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
253 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
254 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
255 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
256 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
257 | - if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
258 | - if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
242 | + if ($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
243 | + if ($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
244 | + if ($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
245 | + if ($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
246 | + if ($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
247 | + if ($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
248 | + if ($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
249 | + if ($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
250 | + if ($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
251 | + if ($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
252 | + if ($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
253 | + if ($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
254 | + if ($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
255 | + if ($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
256 | + if ($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
257 | + if ($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
258 | + if ($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
259 | 259 | |
260 | 260 | return $this->getMaps($endpoint, $limit); |
261 | 261 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | $apiResult = $this->callAPI($endpoint); |
277 | 277 | |
278 | - if($apiResult === false || $apiResult == "Not Found") { |
|
278 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
279 | 279 | $response->setErrorStatus(true)->setErrorStatus("[getMap] Something went wrong with the API call."); |
280 | 280 | return $response; |
281 | 281 | } |
@@ -160,8 +160,9 @@ discard block |
||
160 | 160 | if($apiResult === false || $apiResult == "Not Found") { |
161 | 161 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
162 | 162 | |
163 | - if($apiResult == "Not Found") |
|
164 | - return $response; |
|
163 | + if($apiResult == "Not Found") { |
|
164 | + return $response; |
|
165 | + } |
|
165 | 166 | } |
166 | 167 | |
167 | 168 | foreach ($apiResult->docs as $beatmap) { |
@@ -239,23 +240,57 @@ discard block |
||
239 | 240 | |
240 | 241 | $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
241 | 242 | |
242 | - if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
243 | - if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
244 | - if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
245 | - if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
246 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
247 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
248 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
249 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
250 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
251 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
252 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
253 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
254 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
255 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
256 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
257 | - if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
258 | - if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
243 | + if($mapName) { |
|
244 | + $endpoint .= "&q=" . urlencode($mapName); |
|
245 | + } |
|
246 | + if($startDate) { |
|
247 | + $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
248 | + } |
|
249 | + if($endDate) { |
|
250 | + $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
251 | + } |
|
252 | + if($ranked) { |
|
253 | + $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
254 | + } |
|
255 | + if($automapper) { |
|
256 | + $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
257 | + } |
|
258 | + if($chroma) { |
|
259 | + $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
260 | + } |
|
261 | + if($noodle) { |
|
262 | + $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
263 | + } |
|
264 | + if($cinema) { |
|
265 | + $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
266 | + } |
|
267 | + if($fullSpread) { |
|
268 | + $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
269 | + } |
|
270 | + if($minBpm) { |
|
271 | + $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
272 | + } |
|
273 | + if($maxBpm) { |
|
274 | + $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
275 | + } |
|
276 | + if($minNps) { |
|
277 | + $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
278 | + } |
|
279 | + if($maxNps) { |
|
280 | + $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
281 | + } |
|
282 | + if($minRating) { |
|
283 | + $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
284 | + } |
|
285 | + if($maxRating) { |
|
286 | + $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
287 | + } |
|
288 | + if($minDuration !== null) { |
|
289 | + $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
290 | + } |
|
291 | + if($maxDuration !== null) { |
|
292 | + $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
293 | + } |
|
259 | 294 | |
260 | 295 | return $this->getMaps($endpoint, $limit); |
261 | 296 | } |