Ejemplo n.º 1
0
 /**
  * Determine if the user's operating system is BeOS.
  *
  * @param Os $os
  * @param UserAgent $userAgent
  *
  * @return bool
  */
 private static function checkBeOS(Os $os, UserAgent $userAgent)
 {
     if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
         $os->setVersion($os::VERSION_UNKNOWN);
         $os->setName($os::BEOS);
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 public function getHostFromReport(Host &$host, &$pkgs)
 {
     Utils::log(LOG_DEBUG, "Getting the host from the report", __FILE__, __LINE__);
     if ($host == null) {
         Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
         throw new Exception("Host object is not valid or Host.id is not set");
     }
     # Get the osId
     $host->setOsName($this->guessOs($host, $pkgs));
     $osDao = $this->getPakiti()->getDao("Os");
     $osId = $osDao->getIdByName($host->getOsName());
     if ($osId == -1) {
         # Os is missing, so store it
         $os = new Os();
         $os->setName($host->getOsName());
         $osDao->create($os);
         $osId = $os->getId();
     } else {
         $os = $osDao->getById($osId);
     }
     $host->setOsId($osId);
     $host->setOs($os);
     # Get the archId
     $archDao = $this->getPakiti()->getDao("Arch");
     $archId = $archDao->getIdByName($host->getArchName());
     if ($archId == -1) {
         # Arch is missing, so store it
         $arch = new Arch();
         $arch->setName($host->getArchName());
         $archDao->create($arch);
         $archId = $arch->getId();
     } else {
         $arch = $archDao->getById($archId);
     }
     $host->setArchId($archId);
     $host->setArch($arch);
     # Get the domainId
     # Guess the domain name from the reporterHostname
     $domainName = $this->guessDomain($host->getHostname());
     $domainDao = $this->getPakiti()->getDao("Domain");
     $domainId = $domainDao->getIdByName($domainName);
     if ($domainId == -1) {
         # Domain is missing, so store it
         $domain = new Domain();
         $domain->setName($domainName);
         $domainDao->create($domain);
         $domainId = $domain->getId();
     } else {
         $domain = $domainDao->getById($domainId);
     }
     $host->setDomainId($domainId);
     $host->setDomain($domain);
     # Try to find the host in the DB
     $host->setId($this->getHostId($host));
     if ($host->getId() != -1) {
         # Update entries
         $this->getPakiti()->getDao("Host")->update($host);
         return $host;
     } else {
         return $this->storeHostFromReport($host);
     }
 }