Ejemplo n.º 1
0
 /**
  * Přiřadí služby k hostům podle výsledků scannu
  */
 public function assignServices()
 {
     $success = 0;
     $hostmod = false;
     foreach ($this->results as $port) {
         switch ($port) {
             case 80:
                 if ($this->host->favToIcon()) {
                     $hostmod = true;
                 }
                 break;
             case 5666:
                 $this->host->setDataValue('platform', 'linux');
                 $hostmod = true;
                 break;
             case 12489:
                 $this->host->setDataValue('platform', 'windows');
                 $hostmod = true;
                 break;
             default:
                 break;
         }
         $this->service->setmyKeyColumn('tcp_port');
         $this->service->loadFromMySQL($port);
         $this->service->setmyKeyColumn('service_id');
         $this->service->addMember('host_name', $this->host->getId(), $this->host->getName());
         if ($this->service->saveToMySQL()) {
             $this->addStatusMessage(sprintf(_('Přidána sledovaná služba: %s'), $this->service->getName()), 'success');
             $success++;
         } else {
             $this->addStatusMessage(sprintf(_('Přidání sledované služby: %s se nezdařilo'), $this->service->getName()), 'error');
         }
     }
     if ($hostmod) {
         $this->host->saveToMySQL();
     }
     return $success;
 }