示例#1
0
 /**
  * Zpracování formuláře
  *
  * @return boolean
  */
 public function reconfigureService()
 {
     $config = array();
     $page = EaseShared::webPage();
     foreach ($page->getRequestValues() as $key => $value) {
         switch ($key) {
             case 'ShowAll':
                 if ($value) {
                     $config[] = 'ShowAll';
                 }
                 break;
             case 'MaxWarn':
             case 'MaxCrit':
             case 'MinWarn':
             case 'MinCrit':
             case 'warn':
             case 'crit':
             case 'type':
                 if ($value) {
                     $config[] = $key . '=' . $value;
                 }
                 break;
             default:
                 break;
         }
     }
     if (count($config)) {
         $this->tweaker->service->setDataValue('check_command-params', implode(' ', $config));
         return parent::reconfigureService();
     }
     return FALSE;
 }
    public function finalize()
    {
        parent::finalize();
        reset($this->platforms);
        foreach ($this->pageParts as $optionName => $option) {
            $platform = current($this->platforms);
            if (isset($platform['image'])) {
                $this->pageParts[$optionName]->setTagProperties(array('data-image' => $platform['image']));
            }
            next($this->platforms);
        }
        EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true);
        EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").change(function() {
            var oDropdown = $("#' . $this->getTagID() . '").msDropdown().data("dd");
            var text = oDropdown.get("selectedText");
            console.log(text);

        var saverClass = $("[name=\'class\']").val();
        var keyId = $(".keyId").val();
        var columnName = $(this).attr("name");

var jqxhr = $.post( "datasaver.php?SaverClass=" + saverClass , { Field: columnName, Value: text, Key: keyId }  ,   function() {
    console.log( "success" );
})
.done(function() {
    console.log( "second success" );
})
.fail(function() {
    console.log( "error" );
});
        });', null, true);
        EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js');
        EaseShared::webPage()->includeCss('css/msdropdown/dd.css');
    }
 function afterAdd()
 {
     $this->addItem(new EaseTWBFormGroup(_('Jméno'), new EaseHtmlInputTextTag('host_name', EaseShared::webPage()->getRequestValue('host_name')), _('hostname'), _('DOMAIN\\machine'), _('Název sledovaného stroje')));
     $this->addItem(new EaseTWBFormGroup(_('Platforma'), new IEPlatformSelector('platform'), null, _('Platforma sledovaného stroje')));
     $this->addItem(new EaseTWSubmitButton(_('Založit') . '&nbsp' . EaseTWBPart::GlyphIcon('forward'), 'success'));
     $this->addItem(new EaseHtmlInputHiddenTag('host_group', EaseShared::webPage()->getRequestValue('host_group')));
 }
示例#4
0
 /**
  * Nastavuje titulek
  *
  * @param string $pageTitle
  */
 public function __construct($pageTitle = null)
 {
     parent::__construct('header');
     if (!is_null($pageTitle)) {
         EaseShared::webPage()->setPageTitle($pageTitle);
     }
 }
 public function finalize()
 {
     parent::finalize();
     EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true);
     EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js');
     EaseShared::webPage()->includeCss('css/msdropdown/dd.css');
 }
示例#6
0
 /**
  * Pouze pro admina
  *
  * @param string $loginPage
  */
 public function onlyForAdmin($loginPage = 'login.php')
 {
     if (!$this->user->getSettingValue('admin')) {
         EaseShared::user()->addStatusMessage(_('Nejprve se prosím přihlašte jako admin'), 'warning');
         $this->redirect($loginPage);
         exit;
     }
 }
示例#7
0
 public function loadItems()
 {
     $user = new IEUser();
     $ui = array('0' => _('Systémový uživatel'));
     foreach ($user->getAllFromMySQL(EaseShared::user()->getMyTable(), array('id', 'login'), null, 'login', 'id') as $UserInfo) {
         $ui[$UserInfo['id']] = $UserInfo['login'];
     }
     return $ui;
 }
示例#8
0
/**
 * Formulář cíle cesty pro hosta
 * @param IEHost $host
 * @return \EaseTWBPanel
 */
function endRouteForm($host)
{
    $form = new EaseTWBForm('traceto');
    $form->addInput(new IEHostSelect('dest_host_id'), _('Gateway'), null, _('Zvolte již definovanou gateway, nabo zadejte konkrétní adresu.'));
    $form->addInput(new EaseHtmlInputTextTag('ip'), _('IP Adresa'), null, _('První pingnutelná veřejá adresa po cestě z hostu na monitorovací server'));
    $form->addItem(new EaseTWSubmitButton(_('Sledovat cestu'), 'success', array('onClick' => "\$('#preload').css('visibility', 'visible');")));
    EaseShared::webPage()->addItem(new EaseHtmlDivTag('preload', new IEFXPreloader(), array('class' => 'fuelux')));
    return new EaseTWBPanel(_('Volba cíle sledování') . ': ' . $host->getName(), 'default', $form, _('Vyberte hosta nebo zadejte IP adresu'));
}
 /**
  * Zpracování formuláře
  *
  * @return boolean
  */
 public function reconfigureService()
 {
     $config = array();
     $page = EaseShared::webPage();
     foreach ($page->getRequestValues() as $key => $value) {
         switch ($key) {
             case 'NetDrive':
             case 'Drive':
                 if ($value == 'CheckAll') {
                     $config['Drive'] = 'CheckAll';
                     $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Všechny jednotky'));
                 } else {
                     if (strlen(trim($value)) && $value != '\\\\') {
                         if (strstr($value, '\\\\')) {
                             $config['Drive'] = 'Drive=' . $value;
                             $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, IENSCPConfigGenerator::stripServiceName(_('NetDisk') . ' ' . $value));
                             $this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo síťové jednotky %s: '), $value));
                         } else {
                             $config['Drive'] = 'Drive=' . $value . ':';
                             $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Disk') . ' ' . strtoupper($value) . ':');
                             $this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo disku %s: '), strtoupper($value)));
                         }
                     }
                 }
                 break;
             case 'ShowAll':
                 if ($value) {
                     $config[] = 'ShowAll';
                 }
                 break;
             case 'MaxWarn':
             case 'MaxCrit':
             case 'MinWarn':
             case 'MinCrit':
             case 'MaxWarnFree':
             case 'MaxCritFree':
             case 'MinWarnFree':
             case 'MinCritFree':
             case 'MaxWarnUsed':
             case 'MaxCritUsed':
             case 'MinWarnUsed':
             case 'MinCritUsed':
                 if ($value) {
                     $config[] = $key . '=' . $value;
                 }
                 break;
             default:
                 break;
         }
     }
     if (count($config)) {
         $this->tweaker->service->setDataValue('check_command-params', implode(' ', $config));
         return parent::reconfigureService();
     }
     return FALSE;
 }
示例#10
0
 function finalize()
 {
     EaseShared::webPage()->includeCss('css/slider.css');
     EaseShared::webPage()->includeJavaScript('js/bootstrap-slider.js');
     $id = $this->getTagID();
     if ($id) {
         $me = '#' . $id;
     } else {
         $me = "input[name='" . $this->getTagName() . "']";
     }
     $this->addJavaScript('$("' . $me . '").slider();', null, true);
 }
示例#11
0
 /**
  * Zpracování formuláře
  * 
  * @return boolean
  */
 public function reconfigureService()
 {
     $page = EaseShared::webPage();
     $wt = $page->getRequestValue('wt', 'float');
     $ct = $page->getRequestValue('ct', 'float');
     $wp = str_replace('%', '', $page->getRequestValue('wp'));
     $cp = str_replace('%', '', $page->getRequestValue('cp'));
     if ($wt && $ct && $wp && $cp) {
         $command = $wt . ',' . $wp . '%!' . $ct . ',' . $cp . '%';
         $this->tweaker->service->setDataValue('check_command-params', $command);
         return parent::reconfigureService();
     }
     return FALSE;
 }
示例#12
0
 /**
  * Editor k přidávání členů skupiny
  *
  * @param IEServices $service
  */
 public function __construct($service)
 {
     $hostsAssigned = array();
     parent::__construct();
     $fieldName = $this->getmyKeyColumn();
     $initialContent = new EaseTWBPanel(_('Sledované hosty služby'), 'default');
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($service->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         $serviceName = $service->getName();
         $host = new IEHost();
         if (EaseShared::user()->getSettingValue('admin')) {
             $allHosts = $host->getAllFromMySQL(NULL, array($host->myKeyColumn, $host->nameColumn, 'platform', 'register'), null, $host->nameColumn, $host->myKeyColumn);
         } else {
             $allHosts = $host->getListing(null, true, array('platform', 'register'));
         }
         if ($service->getDataValue('host_name')) {
             foreach ($service->getDataValue('host_name') as $hostId => $hostName) {
                 if (isset($allHosts[$hostId])) {
                     $hostsAssigned[$hostId] = $allHosts[$hostId];
                 }
             }
         }
         foreach ($allHosts as $hostID => $hostInfo) {
             if ($hostInfo['register'] != 1) {
                 unset($allHosts[$hostID]);
             }
             if ($hostInfo['platform'] != 'generic' && $hostInfo['platform'] != $service->getDataValue('platform')) {
                 unset($allHosts[$hostID]);
             }
         }
         foreach ($hostsAssigned as $hostID => $hostInfo) {
             unset($allHosts[$hostID]);
         }
         if (count($allHosts)) {
             foreach ($allHosts as $hostID => $hostInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('host.php?host_id=' . $hostID . '&service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addhost=' . $hostInfo[$host->nameColumn] . '&host_id=' . $hostID . '&' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat')))));
             }
         }
         if (count($hostsAssigned)) {
             $initialContent->addItem('<br/>');
             foreach ($hostsAssigned as $hostID => $hostInfo) {
                 $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delhost=' . $hostInfo[$host->nameColumn] . '&amp;host_id=' . $hostID . '&amp;' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&amp;' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('host.php?host_id=' . $hostID . '&amp;service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')))));
             }
         }
     }
     $this->addItem($initialContent);
 }
 public function finalize()
 {
     parent::finalize();
     reset($this->services);
     foreach ($this->pageParts as $optionName => $option) {
         $platform = current($this->services);
         if (isset($platform['image'])) {
             $this->pageParts[$optionName]->setTagProperties(array('data-image' => $platform['image']));
         }
         next($this->services);
     }
     EaseShared::webPage()->addJavaScript('$("#' . $this->getTagID() . '").msDropDown();', null, true);
     EaseShared::webPage()->includeJavaScript('js/msdropdown/jquery.dd.min.js');
     EaseShared::webPage()->includeCss('css/msdropdown/dd.css');
 }
示例#14
0
    public function finalize()
    {
        EaseShared::webPage()->includeCss('twitter-bootstrap/css/fuelux.css', true);
        EaseShared::webPage()->includeJavascript("/javascript/twitter-bootstrap/fuelux.js");
        EaseShared::webPage()->addJavascript("\$('#" . $this->getTagID() . "').loader();");
        EaseShared::webPage()->addCSS('
#' . $this->getTagID() . '{
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -50px;
    margin-left: -50px;
    width: 100px;
    height: 100px;
    visibility: hidden;
}​
            ');
    }
示例#15
0
 /**
  * Přejmenuje hosta
  *
  * @param string $oldname
  * @param string $newname
  */
 public function renameHost($oldname, $newname)
 {
     $memberOf = EaseShared::myDbLink()->queryToArray('SELECT ' . $this->getmyKeyColumn() . ',' . $this->nameColumn . ' FROM ' . $this->myTable . ' WHERE members LIKE \'%"' . $oldname . '"%\' ', $this->getmyKeyColumn());
     foreach ($memberOf as $groupID => $group) {
         $found = false;
         $this->loadFromMySQL($groupID);
         foreach ($this->data['members'] as $id => $member) {
             if ($member == $oldname) {
                 $found = true;
                 $this->data['members'][$id] = $newname;
                 $this->addStatusMessage(sprintf(_(' %s byl přejmenován na %s ve skupině %s '), $oldname, $newname, $group[$this->nameColumn]));
             }
         }
         if ($found) {
             $this->saveToMySQL();
         }
     }
 }
 public function finalize()
 {
     $subcontatcts = $this->contact->getChilds();
     foreach ($subcontatcts as $subcontatctID => $subcontatctInfo) {
         $this->addItem(new EaseTWBButtonDropdown($subcontatctInfo['type'] . ' ' . $subcontatctInfo['contact'], 'success', 'xs', array(new EaseHtmlATag('contact.php?parent_id=' . $this->contact->getId() . '&contact_id=' . $subcontatctID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Vlastnosti')), new EaseHtmlATag('?contact_id=' . $this->contact->getId() . '&delsubcont_id=' . $subcontatctID, EaseTWBPart::GlyphIcon('minus') . ' ' . _('smazat') . ' ' . $subcontatctInfo['type']))));
         unset($this->subcontactTypes[$subcontatctInfo['type']]);
         $this->addItem('<br/>');
     }
     if (count($this->subcontactTypes)) {
         $form = new EaseTWBForm('ContatctTweak', 'contacttweak.php');
         $form->addItem(new EaseHtmlSelect('contact', $this->subcontactTypes));
         $form->addItem(new EaseHtmlInputHiddenTag('contact_id', $this->contact->getId()));
         $form->addItem(new EaseTWBFormGroup(_('Kontakt'), new EaseHtmlInputTextTag('cnt', $this->cnt), EaseShared::webPage()->getRequestValue('cnt'), _('telefonní číslo, email či jabberová adresa dle druhu kontaktu')));
         $form->addItem(new EaseTWSubmitButton(_('Uložit'), 'success'));
         $this->addItem(new EaseTWBPanel(_('Přidat kontaktní údaj'), 'default', $form));
     } else {
         $this->addItem(new EaseHtmlDivTag('plno', _('K tomuto kontaktu již není možné přidávat další údaje.'), array('class' => 'well warning', 'style' => 'margin: 10px')));
     }
 }
示例#17
0
    /**
     * Hlavní menu aplikace
     *
     * @param string $name
     * @param mixed  $content
     * @param array  $properties
     */
    public function __construct($name = null, $content = null, $properties = null)
    {
        parent::__construct("Menu", new \Ease\Html\ImgTag('images/LinkQuickTwitterLogo.png', 'NetspotAdmin', 20, 20, ['class' => 'img-rounded']), ['class' => 'navbar-fixed-top']);
        $user = \Ease\Shared::user();
        \Ease\TWB\Part::twBootstrapize();
        if (!$user->getUserID()) {
            //            $this->addMenuItem('<a href="createaccount.php">' . \Ease\TWB\Part::GlyphIcon('leaf') . ' ' . _('Register') . '</a>', 'right');
            $this->addMenuItem('
<li class="divider-vertical"></li>
<li class="dropdown">
<a class="dropdown-toggle" href="login.php" data-toggle="dropdown"><i class="icon-circle-arrow-left"></i> ' . _('Logon') . '<strong class="caret"></strong></a>
<div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px; left: -120px;">
<form method="post" class="navbar-form navbar-left" action="login.php" accept-charset="UTF-8">
<input class="form-control" style="margin-bottom: 15px;" type="text" placeholder="' . _('Username') . '" id="username" name="login">
<input class="form-control" style="margin-bottom: 15px;" type="password" placeholder="' . _('Password') . '" id="password" name="password">
<!-- input style="float: left; margin-right: 10px;" type="checkbox" name="remember-me" id="remember-me" value="1">
<label class="string optional" for="remember-me"> ' . _('zapamatuj si mne') . '</label -->
<input class="btn btn-primary btn-block" type="submit" id="sign-in" value="' . _('Log in') . '">
</form>
</div>', 'right');
        } else {
            $userID = EaseShared::user()->getUserID();
            if ($userID) {
                $myLinksCount = EaseShared::myDbLink()->queryToValue('SELECT COUNT(*) FROM entry WHERE owner=' . $userID);
            } else {
                $myLinksCount = EaseShared::myDbLink()->queryToValue('SELECT COUNT(*) FROM entry');
            }
            $brand = new \Ease\HtmlDivTag('sitelogo', $myLinksCount, ['class' => 'brand']);
            $this->addMenuItem($brand);
            $userMenu = '<li class="dropdown" style="width: 120px; text-align: right; background-image: url( ' . $user->getIcon() . ' ) ;  background-repeat: no-repeat; background-position: left center; background-size: 40px 40px;"><a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $user->getLogin() . ' <b class="caret"></b></a>
<ul class="dropdown-menu" style="text-align: left; left: -60px;">
<li><a href="settings.php">' . \Ease\TWB\Part::GlyphIcon('wrench') . '<i class="icon-cog"></i> ' . _('Settings') . '</a></li>
';
            $this->addMenuItem($userMenu . '
<li><a href="http://v.s.cz/ease.php">' . \Ease\TWB\Part::GlyphIcon('envelope') . ' ' . _('Developer support') . '</a></li>
<li class="divider"></li>
<li><a href="logout.php">' . \Ease\TWB\Part::GlyphIcon('off') . ' ' . _('Logout') . '</a></li>
</ul>
</li>
', 'right');
        }
    }
 /**
  * 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);
 }
    /**
     * Hlavní menu aplikace
     *
     * @param string $name
     * @param mixed  $content
     * @param array  $properties
     */
    public function __construct($name = null, $content = null, $properties = null)
    {
        parent::__construct("Menu", new EaseHtmlImgTag('img/vsmonitoring.png', 'VSMonitoring', 20, 20, array('class' => 'img-rounded')), array('class' => 'navbar-fixed-top'));
        $user = EaseShared::user();
        EaseTWBPart::twBootstrapize();
        if (!$user->getUserID()) {
            $this->addMenuItem('<a href="createaccount.php">' . EaseTWBPart::GlyphIcon('leaf') . ' ' . _('Registrace') . '</a>', 'right');
            $this->addMenuItem('
<li class="divider-vertical"></li>
<li class="dropdown">
<a class="dropdown-toggle" href="login.php" data-toggle="dropdown"><i class="icon-circle-arrow-left"></i> ' . _('Přihlášení') . '<strong class="caret"></strong></a>
<div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px; left: -120px;">
<form method="post" class="navbar-form navbar-left" action="login.php" accept-charset="UTF-8">
<input class="form-control" style="margin-bottom: 15px;" type="text" placeholder="' . _('login') . '" id="username" name="login">
<input class="form-control" style="margin-bottom: 15px;" type="password" placeholder="' . _('Heslo') . '" id="password" name="password">
<!-- input style="float: left; margin-right: 10px;" type="checkbox" name="remember-me" id="remember-me" value="1">
<label class="string optional" for="remember-me"> ' . _('zapamatuj si mne') . '</label -->
<input class="btn btn-primary btn-block" type="submit" id="sign-in" value="' . _('přihlásit') . '">
</form>
</div>', 'right');
        } else {
            $userMenu = '<li class="dropdown" style="width: 120px; text-align: right; background-image: url( ' . $user->getIcon() . ' ) ;  background-repeat: no-repeat; background-position: left center; background-size: 40px 40px;"><a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $user->getUserLogin() . ' <b class="caret"></b></a>
<ul class="dropdown-menu" style="text-align: left; left: -60px;">
<li><a href="settings.php">' . EaseTWBPart::GlyphIcon('wrench') . '<i class="icon-cog"></i> ' . _('Nastavení') . '</a></li>
';
            if ($user->getSettingValue('admin')) {
                $userMenu .= '<li><a href="overview.php">' . EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled konfigurací') . '</a></li>';
            }
            $this->addMenuItem($userMenu . '
<li><a href="http://v.s.cz/kontakt.php">' . EaseTWBPart::GlyphIcon('envelope') . ' ' . _('Uživatelská podpora') . '</a></li>
<li class="divider"></li>
<li><a href="logout.php">' . EaseTWBPart::GlyphIcon('off') . ' ' . _('Odhlášení') . '</a></li>
</ul>
</li>
', 'right');
        }
    }
 /**
  * Zpracování formuláře
  * 
  * @return boolean
  */
 public function reconfigureService()
 {
     $page = EaseShared::webPage();
     $testUrl = $page->getRequestValue('testUrl');
     $reqText = $page->getRequestValue('reqText');
     $errText = $page->getRequestValue('errText');
     if ($testUrl && $reqText) {
         if (substr($testUrl, 0, 4) != 'http') {
             $testUrl = 'http://' . $testUrl;
         }
         $regex = "((https?|ftp)\\:\\/\\/)?";
         // SCHEME
         $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?";
         // User and Pass
         $regex .= "([a-z0-9-.]*)\\.([a-z]{2,3})";
         // Host or IP
         $regex .= "(\\:[0-9]{2,5})?";
         // Port
         $regex .= "(\\/([a-z0-9+\$_-]\\.?)+)*\\/?";
         // Path
         $regex .= "(\\?[a-z+&\$_.-][a-z0-9;:@&%=+\\/\$_.-]*)?";
         // GET Query
         $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?";
         // Anchor
         if (!preg_match("/^{$regex}\$/", $testUrl)) {
             $page->addStatusMessage(_('Neplatné url'), 'error');
             return false;
         }
         $command = $testUrl . '!' . $reqText;
         $command .= '!' . $errText;
         $command .= '!10';
         //Timeout
         $this->tweaker->service->setDataValue('check_command-params', $command);
         return parent::reconfigureService();
     }
     return FALSE;
 }
示例#21
0
 /**
  * Editor běžného uživatele
  */
 public function lightEditor()
 {
     if (!(int) $this->objectEdited->getDataValue('generate')) {
         $this->addStatusMessage(_('tento záznam se nebude generovat do konfigurace'));
     }
     if ($this->objectEdited->publicRecords) {
         if ((int) $this->objectEdited->getDataValue('public')) {
             $this->addStatusMessage(_('tento záznam je veřejný'));
         }
     }
     $this->addItem('<div class="error" style=""><span></span><br clear="all"></div>');
     $use = $this->objectEdited->getDataValue('use');
     if (!is_null($use)) {
         $template = clone $this->objectEdited;
         $template->loadFromMySQL((int) $use);
     }
     foreach ($this->objectEdited->useKeywords as $fieldName => $fieldType) {
         $keywordInfo = $this->objectEdited->keywordsInfo[$fieldName];
         if ($fieldName == $this->objectEdited->nameColumn) {
             if ($this->objectEdited->getId()) {
                 continue;
             }
         }
         if (!count($keywordInfo)) {
             continue;
         }
         if (isset($keywordInfo['hidden'])) {
             continue;
         }
         if (!strlen($keywordInfo['title'])) {
             continue;
         }
         if (isset($keywordInfo['required']) && $keywordInfo['required']) {
             $this->reqFields[$fieldName] = $fieldType;
             $required = true;
         } else {
             if (!isset($keywordInfo['mandatory']) || !$keywordInfo['mandatory']) {
                 $required = false;
                 continue;
             }
         }
         $value = $this->objectEdited->getDataValue($fieldName);
         if (is_null($value)) {
             if (!EaseShared::webPage()->isPosted()) {
                 $value = '';
             } else {
                 continue;
             }
         }
         if ($value == 'NULL') {
             $value = null;
         }
         if ($this->objectEdited->allowTemplating) {
             if ($this->objectEdited->isTemplate()) {
                 if (EaseShared::webPage()->isPosted() && is_null($value) && $required) {
                     $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning');
                 }
             }
         } else {
             if (EaseShared::webPage()->isPosted() && is_null($value) && $required) {
                 $this->addStatusMessage(_('Není vyplněna povinná položka') . ' ' . $keywordInfo['title'], 'warning');
             }
         }
         $mainFieldBlock = $this->addItem(new EaseHtmlDivTag($fieldName . '-block', null, array('class' => 'fieldblock')));
         /*
         
          $fieldLabel = $mainFieldBlock->addItem(new EaseHtmlDivTag(null, '<a name="' . $fieldName . '">' . $fieldName . '</a>&nbsp;', array('class' => 'FieldLabel mandatory', 'onClick' => "$('#" . $fieldName . "-controls').toggle('slow');")));
         
          if (!$required || !(int) $this->objectEdited->getDataValue('register')) {
          $fieldLabel->addItem(new EaseHtmlATag('#', EaseTWBPart::GlyphIcon('icon-remove'), array('onClick' => '$(\'#' . $fieldName . '-block\').empty().html(\'<input type=hidden name=' . $fieldName . ' value=NULL><div class=FieldLabel>' . $fieldName . '</div>\'); return false;')));
          $fieldLabel->setTagClass('FieldLabel');
          } else {
          $mainFieldBlock->setTagClass('fieldblock req');
          }
         */
         $fieldBlock = $mainFieldBlock->addItem(new EaseHtmlDivTag($fieldName . '-controls'));
         if (!$this->objectEdited->isOwnedBy() && !EaseShared::user()->getSettingValue('admin')) {
             //Editovat může pouze vlastník
             if ($this->objectEdited->getId()) {
                 if (is_array($value)) {
                     $value = implode(',', $value);
                 }
                 $fieldBlock->addItem($value);
                 continue;
             }
         }
         if (isset($template)) {
             $tempValue = $template->getDataValue($fieldName);
             if (!is_null($tempValue) && $fieldName != $this->objectEdited->nameColumn && !$required) {
                 //Skrýt nedůležité položky
                 EaseShared::webPage()->addJavaScript("\$('#" . $fieldName . "-controls').hide();", null, true);
             }
         }
         $this->insertWidget($fieldBlock, $fieldName, $value);
     }
 }
示例#22
0
    $oPage->Redirect('LogOut.php');
    // already got some credentials stored?
} elseif (isset($_SESSION['access_token'])) {
    $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
    $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
    if ($code == 200) {
        $resp = json_decode($tmhOAuth->response['response']);
        EaseShared::user(new LQTwitterUser($resp->id, $resp->screen_name));
        if (!EaseShared::user()->getSettingValue('icon')) {
            EaseShared::user()->setSettingValue('icon', $resp->profile_image_url);
            EaseShared::user()->UserLogin = $resp->screen_name;
            EaseShared::user()->save();
        }
        EaseShared::user()->LoginSuccess();
        EaseShared::webPage()->Redirect('index.php');
        exit;
    } else {
        outputError($tmhOAuth);
    }
    // we're being called back by Twitter
} elseif (isset($_REQUEST['oauth_verifier'])) {
    $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
    $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), ['oauth_verifier' => $_REQUEST['oauth_verifier']]);
    if ($code == 200) {
        $_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
        unset($_SESSION['oauth']);
        header("Location: {$here}");
        exit;
    } else {
示例#23
0
    $class_file = 'classes/' . $class_name . '.php';
    if (file_exists($class_file)) {
        include $class_file;
        return TRUE;
    }
    return FALSE;
}
$language = "cs_CZ";
$codeset = "cs_CZ.UTF-8";
$domain = "messages";
putenv("LANGUAGE=" . $language);
putenv("LANG=" . $language);
bind_textdomain_codeset($domain, "UTF8");
setlocale(LC_ALL, $codeset);
bindtextdomain($domain, realpath("./locale"));
textdomain($domain);
require_once 'classes/IEUser.php';
require_once 'classes/IEPreferences.php';
session_start();
if (!isset($_SESSION['User']) || !is_object($_SESSION['User'])) {
    EaseShared::user(new EaseAnonym());
}
/**
 * Objekt uživatele VSUser nebo VSAnonym
 * @global EaseUser|IEUser
 */
$oUser =& EaseShared::user();
$oUser->SettingsColumn = 'settings';
require_once 'classes/IEWebPage.php';
/* @var $oPage IEWebPage */
$oPage = new IEWebPage();
示例#24
0
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IESearcher.php';
$oPage->onlyForLogged();
$query = $oPage->getRequestValue('search', 'string');
$found = array();
$searcher = new IESearcher($oPage->getRequestValue('table', 'string'), $oPage->getRequestValue('column', 'string'));
if (strlen($query) < 2) {
    $oPage->addStatusMessage(_('Vyheldávaný řetězec je příliš krátký'), 'warning');
} else {
    $results = $searcher->searchAll(EaseShared::db()->EaseAddslashes($query));
    foreach ($results as $rectype => $records) {
        foreach ($records as $recid => $record) {
            $found[] = array('url' => $rectype . '.php?' . $rectype . '_id=' . $recid, 'name' => current($record), 'type' => $rectype, 'what' => $record['what']);
        }
    }
    if (count($found) == 1) {
        $oPage->addStatusMessage(_('Nalezen pouze jeden výsledek', 'success'));
        header('Location: ' . $found[0]['url'] . '&search=' . $query);
        exit;
    }
}
$oPage->addItem(new IEPageTop(_('Výsledky hledání')));
$listing = new EaseHtmlUlTag(null, array('class' => 'list-group'));
foreach ($found as $foundItem) {
    $listing->addItem(new EaseHtmlLiTag(new EaseHtmlATag($foundItem['url'], $foundItem['type'] . '&nbsp;<h4>' . $foundItem['name'] . '</h4>&nbsp;' . str_replace($query, '<strong>' . $query . '</strong>', $foundItem['what'])), array('class' => 'list-group-item')));
示例#25
0
     }
     break;
 case 'rename':
     $newname = $oPage->getRequestValue('newname');
     if (strlen($newname)) {
         if ($host->rename($newname)) {
             $oUser->addStatusMessage(_('Host byl přejmenován'), 'success');
         } else {
             $oUser->addStatusMessage(_('Host nebyl přejmenován'), 'warning');
         }
     }
     break;
 case 'parent':
     $np = $oPage->getRequestValue('newparent');
     if ($np) {
         $newParent = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->nameColumn . '` FROM ' . $host->myTable . ' ' . 'WHERE `' . $host->nameColumn . '` = \'' . addSlashes($np) . '\' ' . 'OR `alias` = \'' . addSlashes($np) . '\' ' . 'OR `address` = \'' . addSlashes($np) . '\' ' . 'OR `address6` = \'' . addSlashes($np) . '\' ');
         if (!$newParent) {
             $oUser->addStatusMessage(_('Rodič nebyl nalezen'), 'warning');
             $oPage->redirect('watchroute.php?action=parent&host_id=' . $host->getId() . '&ip=' . $np);
             exit;
         } else {
             $currentParents = $host->getDataValue('parents');
             $currentParents[] = $newParent;
             $host->setDataValue('parents', $currentParents);
             $hostID = $host->saveToMySQL();
             if (is_null($hostID)) {
                 $oUser->addStatusMessage(_('Rodič nebyl přidán'), 'warning');
             } else {
                 $oUser->addStatusMessage(_('Rodič byl přidán'), 'success');
             }
         }
示例#26
0
 /**
  * Vrací mazací tlačítko
  *
  * @param  string                     $name   jméno objektu
  * @param  string                     $urlAdd Předávaná část URL
  * @return \EaseJQConfirmedLinkButton
  */
 public function deleteButton($name = null, $urlAdd = '')
 {
     //        return new EaseJQConfirmedLinkButton('?user_id=' . $this->getID() . '&delete=true' . '&' . $urlAdd, _('Smazat ') . ' ' . $this->getUserLogin() . ' ' . EaseTWBPart::GlyphIcon('remove-sign'));
     EaseShared::webPage()->addItem(new IEConfirmationDialog('delete' . $this->getId(), '?user_id=' . $this->getID() . '&delete=true' . '&' . $urlAdd, _('Smazat') . ' ' . $name, sprintf(_('Opravdu smazat %s ?'), '<strong>' . $this->getUserName() . '</strong>')));
     return new EaseHtmlButtonTag(array(EaseTWBPart::GlyphIcon('remove'), _('Smazat') . ' ' . $this->keyword . ' ' . $this->getUserName()), array('style' => 'cursor: default', 'class' => 'btn btn-danger', 'id' => 'triggerdelete' . $this->getId(), 'data-id' => $this->getId()));
 }
示例#27
0
 /**
  * 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;
 }
 function cfgServices()
 {
     $service = new IEService();
     $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',' . $service->nameColumn . ',`use` FROM ' . $service->myTable . ' WHERE host_name LIKE \'%"' . $this->host->getName() . '"%\'', $service->myKeyColumn);
     $allServices = $service->getListing(null, true, array('platform', 'check_command-remote', 'check_command-params', 'passive_checks_enabled', 'active_checks_enabled', 'use', 'check_interval', 'check_command-remote'));
     foreach ($allServices as $serviceID => $serviceInfo) {
         if (!array_key_exists($serviceID, $servicesAssigned)) {
             unset($allServices[$serviceID]);
             continue;
             //Služba není přiřazena k hostu
         }
     }
     /* Naplní hodnoty z předloh */
     $usedCache = array();
     $commandsCache = array();
     foreach ($allServices as $rowId => $service) {
         if (isset($service['use'])) {
             $remote = $service['check_command-remote'];
             if (!isset($commandsCache[$remote])) {
                 $command = new IECommand($remote);
                 $script_id = $command->getDataValue('script_id');
                 if ($script_id) {
                     $this->scriptsToDeploy[$command->getName()] = $script_id;
                 }
                 $commandsCache[$remote] = $command->getData();
             }
         }
         if (isset($service['use'])) {
             $use = $service['use'];
             if (!isset($usedCache[$use])) {
                 $used = new IEService();
                 $used->nameColumn = 'name';
                 if ($used->loadFromMySQL($use)) {
                     $used->resetObjectIdentity();
                     $usedCache[$use] = $used->getData();
                 }
             }
             if (isset($usedCache[$use])) {
                 foreach ($usedCache[$use] as $templateKey => $templateValue) {
                     if ($templateKey != 'check_interval') {
                         continue;
                     }
                     if (!is_null($templateValue) && !isset($allServices[$rowId][$templateKey])) {
                         $allServices[$rowId][$templateKey] = $templateValue;
                     }
                 }
             }
         }
     }
     foreach ($allServices as $serviceId => $service) {
         $serviceName = $service['service_description'];
         $serviceCmd = $service['check_command-remote'];
         if (is_null($serviceCmd)) {
             continue;
         }
         $serviceParams = $service['check_command-params'];
         switch ($this->platform) {
             case 'windows':
                 $this->nscBatArray[] = "\n\nREM #" . $service['service_id'] . ' ' . $serviceName . "\n";
                 break;
             case 'linux':
                 $this->nscBatArray[] = "\n\n# #" . $service['service_id'] . ' ' . $serviceName . "\n";
                 break;
             default:
                 break;
         }
         if (isset($commandsCache[$serviceCmd])) {
             $cmdline = $commandsCache[$serviceCmd]['command_line'];
         } else {
             $cmdline = $serviceCmd;
         }
         $checkCommand = str_replace('\\', '\\\\', $cmdline . ' ' . $serviceParams);
         if (preg_match("/\\.(vbs|bat|ps1|wsf)/", $cmdline)) {
             $this->addCfg('/settings/external scripts/wrapped scripts', $this->stripServiceName($serviceName), $checkCommand);
         } else {
             $this->addCfg('/settings/external scripts/alias', $this->stripServiceName($serviceName), $checkCommand);
         }
         if ($this->hostPassiveMode) {
             $this->addCfg('/settings/scheduler/schedules/' . $this->stripServiceName($serviceName) . '-' . EaseShared::user()->getUserLogin(), 'command', $this->stripServiceName($serviceName));
             $this->addCfg('/settings/scheduler/schedules/' . $this->stripServiceName($serviceName) . '-' . EaseShared::user()->getUserLogin(), 'interval', $service['check_interval'] . 'm');
         }
     }
 }
示例#29
0
 /**
  * Zkontroluje splnění podmínek pro smazání záznamu
  *
  * @return boolean
  */
 public function controlDeleteColumns()
 {
     $id = EaseShared::webPage()->getRequestValue('id');
     if ($id) {
         $this->setMyKey($id);
         return true;
     }
     return false;
 }
示例#30
0
 /**
  * Vytovří odvozený kontakt
  * @param  array $changes
  * @return type
  */
 public function fork($changes)
 {
     $chType = key($changes);
     $chVal = current($changes);
     switch ($chType) {
         case 'twitter':
             $change = array('address2' => $chVal);
             break;
         case 'jabber':
             if (!$this->checkEmailAddress($chVal)) {
                 $this->addStatusMessage(_('Toto není platná jabberová adresa'), 'warning');
                 return false;
             }
             $change = array('address1' => $chVal);
             break;
         case 'email':
             if (!$this->checkEmailAddress($chVal)) {
                 $this->addStatusMessage(_('Toto není platná mailová adresa'), 'warning');
                 return false;
             }
             $change = $changes;
             break;
         case 'sms':
             if (!preg_match("/^(\\+420)? ?\\d{3} ?\\d{3} ?\\d{3}\$/i", $chVal)) {
                 $this->addStatusMessage(_('Toto není platné telefoní číslo'), 'warning');
                 return false;
             }
             $change = array('pager' => $chVal);
             break;
         default:
             $change = $changes;
             break;
     }
     $ownerId = EaseShared::user()->getUserID();
     $this->setDataValue('alias', $chType);
     $this->setDataValue('parent_id', $this->getId());
     $this->unsetDataValue($this->getmyKeyColumn());
     $this->setDataValue('public', 0);
     $this->unsetDataValue('DatSave');
     $this->unsetDataValue('DatCreate');
     $this->setDataValue($this->userColumn, $ownerId);
     $this->setData($change);
     $newname = $this->getName() . ' ' . $chType;
     $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);
     return $this->saveToMySQL();
 }