| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php declare(strict_types = 0);
- /*
- ** L2 Topology - GET controller.
- ** Renders either the live snapshot or any stored snapshot chosen by ?ts=<epoch>.
- */
- namespace Modules\WecomCenter\Actions;
- use CController;
- use CControllerResponseData;
- use CWebUser;
- use Modules\WecomCenter\Lib\L2Store;
- class L2TopologyView extends CController {
- protected function init() {
- $this->disableCsrfValidation();
- }
- protected function checkInput() {
- return true;
- }
- protected function checkPermissions() {
- return CWebUser::getType() >= USER_TYPE_ZABBIX_USER;
- }
- protected function doAction() {
- L2Store::ensureSchema();
- $cfg = L2Store::getConfig();
- $ts_raw = $_REQUEST['ts'] ?? '';
- $ts = ($ts_raw === '' || $ts_raw === null) ? null : (int) $ts_raw;
- $snap = L2Store::snapshotAt($ts);
- $json = $snap['json'] ?? null;
- $used_ts = $snap['ts'];
- $this->setResponse(new CControllerResponseData([
- 'title' => _('L2 Topology'),
- 'snap_json' => ($json !== null && $json !== '') ? $json : 'null',
- 'cfg_json' => json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
- 'history' => L2Store::listHistory(500),
- 'used_ts' => $used_ts,
- 'is_live' => ($ts === null),
- 'cfg_refresh'=> (int) $cfg['refresh_seconds']
- ]));
- }
- }
|