/** * Index Action * * @package las * @version 1.0 */ public function indexAction() { $this->tag->setTitle(__('Home')); $this->site_desc = __('Home'); $ip = \Las\Library\Info::ip(); $this->view->setVar('ip', $ip); if ($device = Devices::findFirst(['IP = :ip:', 'bind' => ['ip' => ip2long($ip)]])) { $client = $device->getClient(); $this->view->setVars(['device' => $device, 'client' => $client, 'tariff' => $client->getTariff(), 'balance' => Payments::sum(['conditions' => 'status=' . Payments::SUCCESS . ' AND client_id=' . $client->id, 'column' => 'amount'])]); } }
/** * Refresh action - refresh info at admin panel * * @package las * @version 1.0 */ public function refreshAction() { switch ($this->request->getPost('type')) { case 'loadavg': echo Info::loadavg(); break; case 'time': echo date('Y-m-d H:i:s'); break; case 'uptime': echo Info::uptime(); break; } }
/** * Index Action * * @package las * @version 1.0 */ public function temporarilyAction() { $params = $this->router->getParams(); if (isset($params[0]) && ($id = $params[0])) { $ip = \Las\Library\Info::ip(); if ($device = Devices::findFirst(['IP = :ip:', 'bind' => ['ip' => ip2long($ip)]])) { $client = $device->getClient(); if ($client->id == $id && $client->status == Clients::INDEBTED) { $client->status = Clients::ACTIVE; $client->save(); } } $this->response->redirect('tasks/tmp'); } }
/** * Ping Action - ping all active devices * * @package las * @version 1.0 */ public function pingAction() { $devices = Devices::find('status=' . Devices::ACTIVE); foreach ($devices as $device) { $ping = \Las\Library\Info::ping(long2ip($device->IP)); if ($ping) { $device->lastActive = time(); $device->update(); } } }