mirror of
https://github.com/rekryt/iplist.git
synced 2025-10-14 01:09:37 +03:00
Initial commit
This commit is contained in:
32
src/App/Controller/JsonController.php
Normal file
32
src/App/Controller/JsonController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace OpenCCK\App\Controller;
|
||||
|
||||
class JsonController extends AbstractIPListController {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBody(): string {
|
||||
$this->setHeaders(['content-type' => 'application/json']);
|
||||
|
||||
$site = $this->request->getQueryParameter('site') ?? '';
|
||||
$data = $this->request->getQueryParameter('data') ?? '';
|
||||
if ($site == '') {
|
||||
if ($data == '') {
|
||||
return json_encode($this->service->sites);
|
||||
} else {
|
||||
$result = [];
|
||||
foreach ($this->service->sites as $site) {
|
||||
$result[$site->name] = $site->$data;
|
||||
}
|
||||
return json_encode($result);
|
||||
}
|
||||
} else {
|
||||
if ($data == '') {
|
||||
return json_encode($this->service->sites[$site]);
|
||||
} else {
|
||||
return json_encode($this->service->sites[$site]->$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user