/** * Oskenuje hosta v argumentu na otevřené porty registrovaných služeb * * @param IEHost $hostToScan */ public function __construct($hostToScan = null) { parent::__construct(); $this->service = new IEService(); if (is_object($hostToScan)) { $this->host =& $hostToScan; $this->performScan(); } }
static function stripServiceName($serviceName) { return str_replace(' ', '_', preg_replace('/[^(\\s:_\\.a-zA-Z0-9)]*/', '', EaseSand::rip($serviceName))); }
/** * Zjistí ikonu, stahne jí z netu, zkonvertuje a použije jako ikonu hosta */ public function favToIcon() { $icoUrl = false; $baseUrl = 'http://' . $this->getDataValue('host_name') . '/'; $indexpage = @file_get_contents($baseUrl); $icoUrls = array(); if (strlen($indexpage)) { $dom = new DOMDocument(); @$dom->loadHTML($indexpage); $links = $dom->getElementsByTagName('link'); foreach ($links as $link) { $urlLink = false; if (isset($link->attributes)) { foreach ($link->attributes as $atribut) { if (isset($atribut->name)) { if ($atribut->name == 'rel' && stristr($atribut->value, 'icon')) { $urlLink = true; $rel = $atribut->value; } if ($atribut->name == 'href') { $url = $atribut->value; } } } if ($urlLink) { if (strstr($url, '://')) { $icoUrls[$rel] = $url; } else { $icoUrls[$rel] = $baseUrl . $url; } } } } } if (!count($icoUrls)) { $icoUrls[] = $baseUrl . '/favicon.ico'; } else { if (count($icoUrls) == 1) { $icoUrl = current($icoUrls); } else { foreach ($icoUrls as $ico) { if (strstr($ico, '.png')) { $icoUrl = $ico; } } if (!$icoUrl) { foreach ($icoUrls as $ico) { if (strstr($ico, '.gif')) { $icoUrl = $ico; } } } if (!$icoUrl) { foreach ($icoUrls as $ico) { if (strstr($ico, '.jpg')) { $icoUrl = $ico; } } } if (!$icoUrl) { $icoUrl = current($icoUrls); } } } $tmpfilename = sys_get_temp_dir() . '/' . EaseSand::randomString(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $icoUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $downloaded = curl_exec($ch); curl_close($ch); file_put_contents($tmpfilename, $downloaded); if (IEIconSelector::imageTypeOK($tmpfilename)) { EaseShared::webPage()->addStatusMessage(sprintf(_('Nalezena ikona %s'), $icoUrl), 'success'); $newicon = IEIconSelector::saveIcon($tmpfilename, $this); if ($newicon) { $this->setDataValue('icon_image', $newicon); $this->setDataValue('statusmap_image', $newicon); return true; } } else { unlink($tmpfilename); } return false; }
} $contacts = $stemplate->getDataValue('contacts'); if (count($contacts)) { foreach ($contacts as $contact_id => $contact_name) { $host->addMember('contacts', $contact_id, $contact_name); } $host->saveToMySQL(); } break; case 'populate': $host->autoPopulateServices(); break; case 'icon': $icourl = $oPage->getRequestValue('icourl'); if (strlen($icourl)) { $tmpfilename = sys_get_temp_dir() . '/' . EaseSand::randomString(); $fp = fopen($tmpfilename, 'w'); $ch = curl_init($icourl); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); $downloadErr = curl_error($ch); if ($downloadErr) { $oPage->addStatusMessage($downloadErr, 'warning'); } curl_close($ch); fclose($fp); if (!file_exists($tmpfilename)) { $oPage->addStatusMessage(sprintf(_('Soubor %s se nepodařilo stahnout'), $icourlurl)); } } else { if (isset($_FILES) && count($_FILES)) {