/**
  * Formulář pro potvrzení nasazení senzoru
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct('sensor');
     $this->addItem(new EaseHtmlInputHiddenTag('operation', 'confirm'));
     $this->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId()));
     $this->addItem(new EaseTWSubmitButton(_('Senzor je nasazen')));
     $status = $host->getSensorStatus();
     $this->addItem(new IETWBSwitch('confirm', $status == 2));
 }
Ejemplo n.º 2
0
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEService|IEHost $holder
  */
 public function __construct($holder)
 {
     $contactsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Cíle notifikací'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($holder->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $holder->getName();
         $contact = new IEContact();
         $allContacts = $contact->getListing(null, true, array('alias', 'parent_id'));
         foreach ($holder->getDataValue('contacts') as $contactId => $contactName) {
             if (isset($allContacts[$contactId])) {
                 $contactsAssigned[$contactId] = $allContacts[$contactId];
             }
         }
         foreach ($allContacts as $contactID => $contactInfo) {
             if ($contactInfo['register'] != 1) {
                 unset($allContacts[$contactID]);
             }
             if (!$contactInfo['parent_id']) {
                 unset($allContacts[$contactID]);
             }
         }
         foreach ($contactsAssigned as $contactID => $contactInfo) {
             unset($allContacts[$contactID]);
         }
         if (count($allContacts)) {
             foreach ($allContacts as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&contact_id=' . $contactID . '&' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat')))));
             }
         }
         if (count($contactsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($contactsAssigned as $contactID => $contactInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&amp;contact_id=' . $contactID . '&amp;' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&amp;' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&amp;service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $host->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('rodiče hostu'));
     $addparentForm = $initialContent->addItem(new EaseTWBForm('addparent'));
     $addparentForm->addItem(new EaseTWBFormGroup(_('IP nebo Hostname'), new EaseHtmlInputTextTag('newparent')));
     $addparentForm->addItem(new EaseHtmlInputHiddenTag($fieldName, $host->getId()));
     $addparentForm->addItem(new EaseTWSubmitButton(_('Přidat rodiče'), 'success'));
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $allParents = $host->getListing();
         unset($allParents[$host->getID()]);
         //Nenabízet sám sebe jako rodiče
         foreach ($allParents as $parentID => $parentInfo) {
             if ($parentInfo['register'] != 1) {
                 unset($allParents[$parentID]);
             }
         }
         $parentsAssigned = array();
         foreach ($host->getDataValue('parents') as $parentAssigned) {
             $parentID = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->myKeyColumn . '` FROM ' . $host->myTable . ' WHERE `' . $host->nameColumn . '` = \'' . addSlashes($parentAssigned) . '\'');
             $parentsAssigned[$parentID][$host->nameColumn] = $parentAssigned;
             $parentsAssigned[$parentID][$host->myKeyColumn] = $parentID;
             unset($allParents[$parentID]);
         }
         if (count($allParents)) {
             foreach ($allParents as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'plus', $host));
             }
         }
         if (count($parentsAssigned)) {
             $initialContent->addItem('</br>');
             foreach ($parentsAssigned as $parentID => $parentInfo) {
                 $initialContent->addItem($this->parentButton($parentInfo, 'remove', $host));
             }
         }
     }
     $this->addItem($initialContent);
 }
 function getCfgConfirmUrl()
 {
     return IECfg::getBaseURL() . 'cfgconfirm.php?hash=' . $this->host->getConfigHash() . '&host_id=' . $this->host->getId();
 }
Ejemplo n.º 6
0
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$hostId = $oPage->getRequestValue('host_id', 'int');
$host = new IEHost($hostId);
switch ($oPage->getRequestValue('action')) {
    case 'applystemplate':
        $stemplate = new IEStemplate($oPage->getRequestValue('stemplate_id', 'int'));
        $services = $stemplate->getDataValue('services');
        if (count($services)) {
            $service = new IEService();
            foreach ($services as $service_id => $service_name) {
                $service->loadFromMySQL($service_id);
                $service->addMember('host_name', $host->getId(), $host->getName());
                $service->saveToMySQL();
                $service->dataReset();
            }
        }
        $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;
Ejemplo n.º 7
0
 * Icinga Editor služby
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$service = new IEService($oPage->getRequestValue('service_id', 'int'));
$host = new IEHost($oPage->getRequestValue('host_id', 'int'));
switch ($oPage->getRequestValue('action')) {
    case 'clone':
        $service->setDataValue('parent_id', $service->getId());
        $service->unsetDataValue($service->getmyKeyColumn());
        $service->addMember('host_name', $host->getId(), $host->getName());
        $service->setDataValue('hostgroup_name', array());
        $service->setDataValue('user_id', $oUser->getID());
        $service->setDataValue($service->nameColumn, _('Klon') . ' ' . $service->getName());
        if ($service->saveToMySQL()) {
            $oUser->addStatusMessage(_('Služba byla naklonována'), 'success');
            $oPage->redirect('servicetweak.php?service_id=' . $service->getId() . '&host_id=' . $host->getId());
        } else {
            $oUser->addStatusMessage(_('Sužba nebyla naklonována'), 'warning');
        }
        break;
    case 'rename':
        $newname = $oPage->getRequestValue('newname');
        if (strlen($newname)) {
            if ($service->rename($newname)) {
                $oUser->addStatusMessage(_('Služba byla přejmenována'), 'success');
Ejemplo n.º 8
0
 /**
  * Připraví podřízenu službu
  *
  * @param  IEHost $host
  * @param  int    $ownerId
  * @return int    ID nově vytvořené služby
  */
 public function fork($host, $ownerId = null)
 {
     if (is_null($ownerId)) {
         $ownerId = EaseShared::user()->getUserID();
     }
     $this->delMember('host_name', $host->getId(), $host->getName());
     $this->saveToMySQL();
     $this->setDataValue('parent_id', $this->getId());
     $this->unsetDataValue($this->getmyKeyColumn());
     $this->setDataValue('public', 0);
     $this->unsetDataValue('tcp_port');
     $this->unsetDataValue('DatSave');
     $this->unsetDataValue('DatCreate');
     $this->setDataValue('action_url', $_SERVER['REQUEST_URI']);
     $this->setDataValue($this->userColumn, $ownerId);
     $this->setDataValue('contacts', $host->owner->getFirstContact());
     $newname = $this->getName() . ' ' . $host->getName();
     $servcount = $this->myDbLink->queryToCount('SELECT ' . $this->getmyKeyColumn() . ' FROM ' . $this->myTable . ' WHERE ' . $this->nameColumn . ' LIKE \'' . $newname . '%\' ');
     if ($servcount) {
         $newname .= ' ' . ($servcount + 1);
     }
     $this->setDataValue($this->nameColumn, $newname);
     $this->setDataValue('host_name', array());
     $this->addMember('host_name', $host->getId(), $host->getName());
     return $this->saveToMySQL();
 }
Ejemplo n.º 9
0
 /**
  * Stav senzoru a jeho nastavení
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     $commonWell = new EaseTWBWell();
     $commonRow = new EaseTWBRow();
     $hostColumn = $commonRow->addColumn(6, new EaseHtmlATag('host.php?host_id=' . $host->getId(), new EaseHtmlH1Tag($host->getName())));
     $hostColumn->addItem($host);
     $hostColumn->addItem($host->sensorStatusLabel());
     $commonWell->addItem($commonRow);
     $commonRow->addColumn(4, new EaseTWBPanel(_('Ruční nastavení stavu senzoru'), 'info', new IESensorConfirmForm($host)));
     $sensorTabs = new EaseTWBTabs('sensorTabs');
     switch ($host->getDataValue('platform')) {
         case 'windows':
             $pltIco = 'logos/base/win40.gif';
             $cfgGenerator = new IENSCPConfigGenerator($host);
             if ($host->getCfgValue('active_checks_enabled')) {
                 $windowsActiveTab = $sensorTabs->addTab(_('Windows NRPE'));
                 $windowsActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NSC++')));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download')));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
                 $windowsActiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $windowsActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $windowsPassiveTab = $sensorTabs->addTab(_('Windows NSCA'));
                 $windowsPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSC++')));
                 $windowsPassiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download')));
                 $windowsPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $windowsPassiveTab->addItem(new EaseTWBWell('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false), ENT_QUOTES) . '</pre>', array('font-face' => 'fixed')));
             }
             break;
         case 'linux':
             $pltIco = 'logos/base/linux40.gif';
             $preferences = new IEPreferences();
             $prefs = $preferences->getPrefs();
             if ($host->getCfgValue('active_checks_enabled')) {
                 $nrpe_cfgGenerator = new IENRPEConfigGenerator($host);
                 $linuxActiveTab = $sensorTabs->addTab(_('Linux NRPE'));
                 $linuxActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NRPE Server')));
                 $linuxActiveTab->addItem(new EaseHtmlPTag(_('Nainstalujte nejprve senzor tímto příkazem') . ':'));
                 $linuxActiveTab->addItem(new EaseHtmlDiv('<pre>sudo aptitude -y install nagios-nrpe-server</pre>', array('class' => 'code')));
                 $linuxActiveTab->addItem(new EaseTWBLinkButton('nrpecfggen.php?host_id=' . $host->getId(), $host->getName() . '_nrpe.sh ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $linuxActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($nrpe_cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
                 $linuxActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $linuxPassiveTab = $sensorTabs->addTab(_('Linux NSCA'));
                 $linuxPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSCP Senzor')));
                 $linuxPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.sh ' . EaseTWBPart::GlyphIcon('download'), 'success'));
                 $cfgGenerator = new IENSCPConfigGenerator($host);
                 $linuxPassiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed')));
             }
             break;
         default:
             $pltIco = 'logos/unknown.gif';
             if ($host->getCfgValue('active_checks_enabled')) {
                 $genericActiveTab = $sensorTabs->addTab(_('Generic Active'));
                 $genericActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');")));
             }
             if ($host->getCfgValue('passive_checks_enabled')) {
                 $genericPassiveTab = $sensorTabs->addTab(_('Generic Passive'));
             }
             break;
     }
     parent::__construct($commonWell);
     $this->addItem($sensorTabs);
 }
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEPassiveCheckedHostForm.php';
$oPage->onlyForLogged();
$hostName = trim($oPage->getRequestValue('host_name'));
$platform = trim($oPage->getRequestValue('platform'));
$host_group = $oPage->getRequestValue('host_group', 'int');
$host = new IEHost();
$host->owner =& $oUser;
if ($hostName && $platform) {
    $host->setData(array($host->userColumn => $oUser->getUserID(), 'host_name' => $hostName, 'use' => 'generic-host', 'platform' => 'generic', 'register' => true, 'generate' => TRUE, 'platform' => $platform, 'alias' => $hostName, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'check_freshness' => 1, 'freshness_threshold' => 900, 'flap_detection_enabled' => 0, 'check_command' => 'return-unknown'));
    if ($host_group) {
        $hostgroup = new IEHostgroup($host_group);
        $host->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
        $hostgroup->addMember('members', $host->getId(), $host->getName());
        $hostgroup->saveToMySQL();
    }
    if ($host->saveToMysql()) {
        $hostGroup = new IEHostgroup();
        if ($hostGroup->loadDefault()) {
            $hostGroup->setDataValue($hostGroup->nameColumn, EaseShared::user()->getUserLogin());
            $hostGroup->addMember('members', $host->getId(), $host->getName());
            $hostGroup->saveToMySQL();
            $host->addMember('hostgroups', $hostGroup->getId(), $hostGroup->getName());
            $host->saveToMysql();
        }
        $oPage->redirect('host.php?host_id=' . $host->getId());
        exit;
    }
} else {
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     if ($host->getDataValue('platform') == 'generic') {
         $note = '<small><span class="label label-info">Tip:</span> ' . _('Další sledovatelné služby budou nabídnuty po nastavení platformy hosta a vzdáleného senzoru.') . '</small>';
     } else {
         $note = array();
     }
     $initialContent = new EaseTWBPanel(_('Sledované služby'), 'default', null, $note);
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($host->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $hostName = $host->getName();
         $service = new IEService();
         $parentServUsed = array();
         $host_active = (bool) $host->getCfgValue('active_checks_enabled');
         $host_passive = (bool) $host->getCfgValue('passive_checks_enabled');
         $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',display_name,' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . $fieldName . ' LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn);
         $allServices = $service->getListing(null, true, array('platform', 'parent_id', 'passive_checks_enabled', 'active_checks_enabled', 'display_name'));
         foreach ($allServices as $serviceID => $serviceInfo) {
             $servicePassive = (bool) $serviceInfo['passive_checks_enabled'];
             $serviceActive = (bool) $serviceInfo['active_checks_enabled'];
             if ($serviceInfo['register'] != 1) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ($serviceInfo['platform'] != 'generic' && $serviceInfo['platform'] != $host->getDataValue('platform')) {
                 unset($allServices[$serviceID]);
                 continue;
             }
             if ((!$host_passive || !$servicePassive) && (!$host_active || !$serviceActive)) {
                 unset($allServices[$serviceID]);
                 continue;
             }
         }
         foreach ($servicesAssigned as $serviceID => $serviceInfo) {
             if (isset($allServices[$serviceID]) && isset($parentServUsed[$allServices[$serviceID]['parent_id']])) {
                 $parentServUsed[$allServices[$serviceID]['parent_id']] = $allServices[$serviceID]['parent_id'];
             }
             unset($allServices[$serviceID]);
         }
         if (count($allServices)) {
             foreach ($allServices as $serviceID => $serviceInfo) {
                 if (isset($parentServUsed[$serviceInfo['parent_id']])) {
                     continue;
                 }
                 $unchMenu = array();
                 if (intval($serviceInfo['parent_id'])) {
                     $unchMenu[] = new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'));
                 }
                 $unchMenu[] = new EaseHtmlATag('?addservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat'));
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'inverse', 'xs', $unchMenu));
             }
         }
         if (count($servicesAssigned)) {
             $saveAsTemplateButton = new EaseTWBLinkButton('stemplate.php?action=copyhost&host_id=' . $host->getId(), _('Uložit jako předlohu'), 'success');
             $initialContent->footer($saveAsTemplateButton);
             $initialContent->addItem('</br>');
             foreach ($servicesAssigned as $serviceID => $serviceInfo) {
                 if (strlen($serviceInfo['display_name'])) {
                     $serviceName = $serviceInfo['display_name'];
                 } else {
                     $serviceName = $serviceInfo[$service->nameColumn];
                 }
                 $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'success', 'xs', array(new EaseHtmlATag('?delservice=' . $serviceInfo[$service->nameColumn] . '&amp;service_id=' . $serviceID . '&amp;' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&amp;' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&amp;host_id=' . $host->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         } else {
             $presetSelForm = new EaseTWBForm('presetSelForm');
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId()));
             $presetSelForm->addItem(new EaseHtmlInputHiddenTag('action', 'applystemplate'));
             $presetSelForm->addItem(new IEStemplateSelect('stemplate_id'));
             $presetSelForm->addItem(new EaseTWSubmitButton(_('Aplikovat předlohu'), 'success'));
             $presetSelForm->setTagClass('form-inline');
             $initialContent->footer($presetSelForm);
         }
     }
     $this->addItem($initialContent);
 }
Ejemplo n.º 12
0
 /**
  * Volba ikony pro host
  *
  * @param IEHost $host
  */
 public function __construct($host)
 {
     parent::__construct();
     EaseJQueryPart::jQueryze($this);
     $icodirs = array('' => '');
     $icoBox = $this->addItem(new EaseTWBPanel(_('Vyber Ikonu')));
     $icoBox->setTagCss('width: 100%;');
     $icodir = self::$webdir . self::$icodir;
     $d = dir($icodir);
     if (is_object($d)) {
         while (false !== ($entry = $d->read())) {
             if (is_dir(self::$webdir . self::$icodir . '/' . $entry)) {
                 if ($entry[0] == '.') {
                     continue;
                 }
                 $icodirs[$entry] = $entry;
             }
         }
         $d->close();
     }
     $iconTabs = $icoBox->addItem(new EaseTWBTabs('IconTabs'));
     foreach ($icodirs as $subicodir) {
         $default = false;
         $icons = new EaseContainer();
         $customIcos = self::$webdir . self::$icodir . $subicodir;
         $d = dir($customIcos);
         if (is_object($d)) {
             while (false !== ($entry = $d->read())) {
                 if (!is_dir($customIcos . '/' . $entry)) {
                     if (strstr($entry, '.gd2') || $entry[0] == '.') {
                         continue;
                     }
                     if ($entry == 'custom') {
                         list($userid, $imgname) = explode('-', $entry);
                         if ($userid != $host->owner->getId()) {
                             continue;
                         }
                         $default = true;
                     }
                     $hostIcon = new EaseHtmlImgTag(self::$webprefix . self::$icodir . '/' . $subicodir . '/' . $entry);
                     $hostIcon->setTagClass('host_icon');
                     if ($host->getDataValue('icon_image') == 'custom/' . $entry) {
                         $hostIcon->setTagCss('border: 3px red solid;');
                     }
                     $icons->addItem(new EaseHtmlATag('?action=newicon&host_id=' . $host->getId() . '&newicon=' . $subicodir . '/' . $entry, $hostIcon));
                 }
             }
             $d->close();
         }
         if (!$subicodir) {
             $subicodir = 'ico';
         }
         $iconTabs->addTab($subicodir, $icons, $default);
     }
     $uplBox = $this->addItem(new EaseTWBPanel(_('Nahraj vlastní'), 'info'));
     $uplBox->setTagCss('width: 100%;');
     $icoupform = $uplBox->addItem(new EaseTWBForm('icoUp', null, 'POST', null, array('enctype' => 'multipart/form-data')));
     $icoupform->addItem(new EaseHtmlEmTag(_('Obrázek typu GIF,PNG nebo JPG, nejlépe 40x40 px')));
     $icoupform->addItem(new EaseTWBFormGroup(_('Ikona ze souboru'), new EaseHtmlInputFileTag('icofile'), '', _('Soubor v počítači')));
     $icoupform->addItem(new EaseTWBFormGroup(_('Ikona z adresy'), new EaseHtmlInputTextTag('icourl'), '', _('Soubor na internetu')));
     $icoupform->addItem(new EaseTWBFormGroup(_('Titulek obrázku'), new EaseHtmlInputTextTag('icon_image_alt'), '', _('nepovinné')));
     $icoupform->addItem(new EaseTWSubmitButton(_('Odeslat')));
     $icoupform->addItem(new EaseHtmlInputHiddenTag('host_id', $host->getId()));
 }
Ejemplo n.º 13
0
 public function fixHostNameIDs()
 {
     $hostsOK = array();
     $hostsErr = array();
     $host = new IEHost();
     $service = new IEService();
     $services = $service->getColumnsFromMySQL(array($service->myKeyColumn, $service->nameColumn, 'host_name'), null, null, $service->myKeyColumn);
     foreach ($services as $serviceId => $serviceInfo) {
         $service->loadFromMySQL($serviceId);
         foreach ($service->getDataValue('host_name') as $hostId => $hostName) {
             if (!strlen($hostName)) {
                 unset($service->data['host_name'][$hostId]);
                 $hostsOK[] = '(undefined)';
             }
             $hostFound = $host->loadFromMySQL($hostName);
             if ($hostId != $host->getId()) {
                 if ($service->delMember('host_name', $hostId, $hostName) && $service->addMember('host_name', $host->getId(), $hostName)) {
                     $hostsOK[] = $hostName;
                 } else {
                     $hostsErr[] = $hostName;
                 }
             }
         }
         if (count($hostsOK)) {
             if ($service->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $service->getName(), implode(',', $hostsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $service->getName(), implode(',', $hostsOK)), 'success');
                 $hostsOK = array();
             }
         }
     }
     $hostgroup = new IEHostgroup();
     $hostgroups = $hostgroup->getListing();
     foreach ($hostgroups as $hostgroupId => $hostgroupInfo) {
         $hostgroup->loadFromMySQL($hostgroupId);
         foreach ($hostgroup->getDataValue('members') as $hostId => $hostName) {
             $hostFound = $host->loadFromMySQL($hostName);
             if ($hostId != $host->getId()) {
                 if ($hostgroup->delMember('members', $hostId, $hostName) && $hostgroup->addMember('members', $host->getId(), $hostName)) {
                     $hostsOK[] = $hostName;
                 } else {
                     $hostsErr[] = $hostName;
                 }
             }
         }
         if (count($hostsOK)) {
             if ($hostgroup->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $hostgroup->getName(), implode(',', $hostsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $hostgroup->getName(), implode(',', $hostsOK)), 'success');
                 $hostsOK = array();
             }
         }
     }
     $childsAssigned = $host->myDbLink->queryToArray('SELECT ' . $host->myKeyColumn . ',' . $host->nameColumn . ' FROM ' . $host->myTable . ' WHERE ' . 'parents' . ' IS NOT NULL && parents !=\'a:0:{}\'', $host->myKeyColumn);
     foreach ($childsAssigned as $chid_id => $child_info) {
         $child = new IEHost($chid_id);
         $parents = $child->getDataValue('parents');
         foreach ($parents as $parent_id => $parent_name) {
             $parent = new IEHost($parent_name);
             if ($parent->getId()) {
                 //Ok Host toho jména existuje
                 if ($parent->getId() != $parent_id) {
                     //Ale nesedí ID
                     $child->delMember('parents', $parent_id, $parent_name);
                     $child->addMember('parents', $parent->getId(), $parent_name);
                     $child->saveToMySQL();
                     $this->addItemSmart(sprintf(_('Rodič <strong>%s</strong> hosta %s má špatné ID'), $parent_name, $child_info[$host->nameColumn]), array('class' => 'list-group-item'));
                 }
             } else {
                 //Host tohoto jména neexistuje, nemůže být tedy PARENT
                 $this->addItemSmart(sprintf(_('Rodič <strong>%s</strong> hosta %s neexistuje'), $parent_name, $child_info[$host->nameColumn]), array('class' => 'list-group-item'));
                 $child->delMember('parents', $parent->getId(), $parent_name);
                 $child->saveToMySQL();
             }
         }
     }
 }
Ejemplo n.º 14
0
/**
 * Icinga Editor - titulní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$host_name = $oPage->getRequestValue('host_name');
$platform = $oPage->getRequestValue('platform');
$host_group = $oPage->getRequestValue('host_group', 'int');
$check_method = $oPage->getRequestValue('check_method', 'int');
$host = new IEHost($host_name);
if ($host->getId()) {
    $host->addStatusMessage(_('Host tohoto jména již existuje'), 'warning');
} else {
    if ($oPage->isPosted()) {
        if ($host_name) {
            if ($check_method) {
                $oPage->redirect('wizard-active-host.php?host_name=' . urlencode($host_name) . '&host_group=' . $host_group . '&platform=' . $platform);
            } else {
                $oPage->redirect('wizard-passive-host.php?host_name=' . urlencode($host_name) . '&host_group=' . $host_group . '&platform=' . $platform);
            }
        } else {
            $host->addStatusMessage(_('Není zadáno jméno hosta'), 'warning');
        }
    }
}
$oPage->addItem(new IEPageTop(_('Průvodce založením hosta')));