/** Statistics page */ public function renderDefault() { $this->template->allSecurityTypes = $this->wsservice->getAllWifiSecurityTypes(); $this->template->actualStatistics = $this->statisticsManager->getLatestStatistics(); $this->template->secondLatestStatistics = $this->statisticsManager->getSecondLatestStatistics(); $this->template->allStatistics = $this->statisticsManager->getAllStatistics(); }
/** * export to CSV by filter * * @throws \Nette\Application\AbortException */ public function actionDownload() { $params = array(); $parameters = $this->request->getParameters(); foreach ($parameters as $k => $p) { switch ($k) { case 'ssidmac': if (MyUtils::isMacAddress($p)) { $params['mac'] = $p; } else { $params['ssid'] = $p; } break; case 'channel': if ($p != null && $p != '') { $params['channel'] = intval($p); } break; case 'security': if ($p != null && $p != '') { $params['sec'] = intval($p); } break; case 'source': if ($p != null && $p != '') { $params['id_source'] = intval($p); } break; } } $netsCount = $this->wifiManager->getNetsCountByParams($params); // FILENAME = DATETIME_SSID|MAC_CHANNEL_SECURITY_SOURCE // vygenerovat nazev podle parametru $filename = date('YmdHis'); foreach ($params as $k => $v) { $filename .= '_' . $v; } $filename = '../temp/' . $filename . '.csv'; $file = fopen($filename, "w"); $array = array('Zdroj', 'Datum pridani', 'MAC', 'SSID', 'latitude', 'longitude', 'altitude', 'zabezpeceni', 'kanal', 'presnost', 'wigle komentar', 'wigle nazev', 'typ', 'wigle poprve', 'wigle naposledy', 'flags', 'bcninterval'); fputcsv($file, $array, ';'); $sources = $this->sourceManager->getAllSourcesAsKeyVal(); $securities = $this->wifiSecurityService->getAllWifiSecurityTypes(false); for ($i = 0; $i <= $netsCount; $i += 1000) { $nets = $this->wifiManager->getNetsByParams($params, 1000, $i); foreach ($nets as $net) { $array = array('zdroj' => $sources[$net->id_source], 'pridano' => $net->date_added, 'mac' => $net->mac, 'ssid' => $net->ssid, 'latitude' => $net->latitude, 'longitude' => $net->longitude, 'altitude' => $net->altitude, 'zabezpeceni' => $securities[$net->sec], 'kanal' => $net->channel, 'presnost' => $net->accuracy, 'comment' => $net->comment, 'name' => $net->name, 'type' => $net->type, 'firsttime' => $net->firsttime, 'lasttime' => $net->lasttime, 'flags' => $net->flags, 'bcninterval' => $net->bcninterval); fputcsv($file, $array, ';'); } } fclose($file); // stazeni souboru $this->payload->file = $filename; $this->sendPayload(); $this->terminate(); }
/** * search form * @return UI\Form */ protected function createComponentSearchForm() { $form = new UI\Form(); $form->getElementPrototype()->class = "form-horizontal"; $ssidmacTxt = $form->addText('ssidmac', 'SSID/MAC:'); $ssidmacTxt->getControlPrototype()->class = 'form-control'; $channelsQ = $this->wifiManager->getAllChannels(); $channels = array(); foreach ($channelsQ as $ch) { $channels[$ch->channel] = $ch->channel; } $form->addSelect('channel', 'Kanál:', $channels)->setPrompt('Všechny kanály')->getControlPrototype()->addAttributes(array('class' => 'form-control')); $form->addSelect('security', 'Zabezpečení:', $this->wifiSecurityService->getAllWifiSecurityTypes(false))->setPrompt("Všechny typy")->getControlPrototype()->addAttributes(array('class' => 'form-control')); $sourcesfdb = $this->sourceManager->getAllSourcesAsKeyVal(); $sources = array(); foreach ($sourcesfdb as $k => $s) { $sources[$k] = ucfirst($s); } $form->addSelect('source', 'Zdroj:', $sources)->setPrompt("Všechny zdroje")->getControlPrototype()->addAttributes(array('class' => 'form-control')); $form->addSubmit('search', 'Vyhledat')->getControlPrototype()->addAttributes(array('class' => 'form-control btn btn-info btn-sm')); return $form; }