コード例 #1
0
 /**
  * @param int $state
  * @return DownloadImport[]
  */
 public function getDownloadImportsByState($state)
 {
     $disdb = $this->database->table(self::TABLE)->where('state', intval($state))->fetchAll();
     $dis = array();
     foreach ($disdb as $didb) {
         $di = new DownloadImport();
         $di->setId($didb->id);
         $di->setIdWigleAps($didb->id_wigle_aps);
         $di->setMac($didb->mac);
         $di->setState($didb->state);
         $di->setIdGoogleRequest($didb->id_google_request);
         $dis[] = $di;
     }
     return $dis;
 }
コード例 #2
0
 /**
  * create request with filter set
  *
  * @param Coords $coords
  * @param array $filter
  * @param int $sourceDownloadFrom
  * @return string
  */
 private function addFilteredRequest($coords, $filter, $sourceDownloadFrom)
 {
     $mode = isset($filter["mode"]) ? $mode = $filter["mode"] : WifiPresenter::MODE_ALL;
     $params = $this->getParamsArray($coords, $mode, $filter);
     $nets = $this->oWifiManager->getNetsByParams($params, array('id,mac'));
     $macAddresses = array();
     foreach ($nets as $net) {
         $macAddresses[$net['mac']] = $net;
     }
     $notifyEmail = null;
     if ($this->getHttpRequest()->getQuery("notifyEmail") != "") {
         $notifyEmail = $this->notifyEmailService->addNotifyEmail($this->getHttpRequest()->getQuery("notifyEmail"));
         setcookie("notify_email", $this->getHttpRequest()->getQuery("notifyEmail"), time() + 3600);
     }
     if ($sourceDownloadFrom == Service\WigleDownload::ID_SOURCE) {
         // only from wigle - add to wigle_aps
         foreach (array_keys($macAddresses) as $macaddr) {
             $row = $this->wigleDownload->save2WigleAps(null, $macaddr, 2);
             if ($notifyEmail) {
                 $this->notifyEmailService->addNotifyEmailWigleAps($notifyEmail, $row->getPrimary(true));
             }
         }
     } elseif ($sourceDownloadFrom == Service\GoogleDownload::ID_SOURCE) {
         // from Wigle and Google -> add to wigle_aps and download_import
         foreach (array_keys($macAddresses) as $macaddr) {
             $downloadImport = new DownloadImport();
             $downloadImport->setMac($macaddr);
             // pridani do wigle fronty
             $row = $this->wigleDownload->save2WigleAps(null, $macaddr, 2);
             // nastaveni importu
             $downloadImport->setIdWigleAps($row->getPrimary(true));
             if ($notifyEmail) {
                 $this->notifyEmailService->addNotifyEmailWigleAps($notifyEmail, $row->getPrimary(true));
             }
             $downloadImport->setState(DownloadImport::ADDED_WIGLE);
             // ulozeni importu
             $importId = $this->downloadImportService->addImport($downloadImport);
             if ($notifyEmail) {
                 $this->notifyEmailService->addNotifyEmailDownloadImport($notifyEmail, $importId->getPrimary(true));
             }
         }
     }
     return Service\DownloadRequest::STATE_SUCCESS_ADDED_TO_QUEUE;
 }
コード例 #3
0
ファイル: ApiPresenter.php プロジェクト: romanvlcek/wifimap
 /**
  * @param string $data
  * @param int    $priority
  * @throws \Nette\Application\AbortException
  */
 public function actionAddRequests($data = '../temp/data.mac', $priority = 2)
 {
     // parse data
     if (!file_exists($data)) {
         $this->logger->addLog(new Log(Log::TYPE_ERROR, "import", "file " . $data . " not found"));
         $this->terminate();
     }
     $fh = fopen($data, 'r');
     $macAddresses = array();
     $count = 0;
     while (!feof($fh)) {
         $mac = fgets($fh);
         if (MyUtils::isMacAddress($mac)) {
             $mac = MyUtils::macSeparator2Colon($mac);
             $macAddresses[] = trim($mac);
             $count++;
         }
     }
     fclose($fh);
     $before = $this->wigleDownload->getWigleApsCount($priority);
     foreach ($macAddresses as $macaddr) {
         // create import
         $downloadImport = new DownloadImport();
         $downloadImport->setMac($macaddr);
         // add to wigle queue
         $row = $this->wigleDownload->save2WigleAps(null, $macaddr, $priority);
         // set import state
         $downloadImport->setIdWigleAps($row->getPrimary());
         $downloadImport->setState(DownloadImport::ADDED_WIGLE);
         // save import
         $this->downloadImportService->addImport($downloadImport);
     }
     echo "bude trvat: " . $count * 30 . '+' . $before * 30 . 'minut';
     $this->terminate();
 }