コード例 #1
0
ファイル: IndexController.php プロジェクト: RobBickel/las
 /**
  * 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'])]);
     }
 }
コード例 #2
0
ファイル: AjaxController.php プロジェクト: RobBickel/las
 /**
  * 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;
     }
 }
コード例 #3
0
ファイル: ClientController.php プロジェクト: RobBickel/las
 /**
  * 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');
     }
 }
コード例 #4
0
ファイル: CronTask.php プロジェクト: RobBickel/las
 /**
  * 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();
         }
     }
 }