Пример #1
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;
     }
 }
Пример #2
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;
 }
Пример #3
0
 public function loadDefault()
 {
     $groupID = EaseShared::myDbLink()->queryToValue('SELECT ' . $this->getmyKeyColumn() . ' FROM ' . $this->myTable . ' WHERE ' . $this->userColumn . '= ' . EaseShared::user()->getUserID() . ' ORDER BY ' . $this->getmyKeyColumn() . ' DESC LIMIT 1');
     if ($groupID) {
         $this->loadFromMySQL((int) $groupID);
         return true;
     }
     return false;
 }
 /**
  * Editor k přidávání členů skupiny
  *
  * @param string $fieldName    název políčka formuláře
  * @param string $fieldCaption popisek políčka
  * @param IEcfg  $dataSource   editovaný objekt
  */
 public function __construct($fieldName, $fieldCaption, $dataSource, $members)
 {
     $iDColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['idcolumn'];
     $nameColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['captioncolumn'];
     $sTable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
     if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['condition'])) {
         $conditions = $dataSource->keywordsInfo[$fieldName]['refdata']['condition'];
     } else {
         $conditions = array();
     }
     if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['public']) && intval($dataSource->keywordsInfo[$fieldName]['refdata']['public'])) {
         $sqlConds = " ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID()))) . " ) OR ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array('public' => 1))) . ")  ";
     } else {
         $sqlConds = $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID())));
     }
     $initialContent = new EaseTWBPanel($fieldCaption);
     $initialContent->setTagCss(array('width' => '100%'));
     if (is_null($dataSource->getMyKey())) {
         $initialContent->addItem(_('Nejprve je potřeba uložit záznam'));
     } else {
         if ($sTable == $dataSource->myTable) {
             $tmpKey = $dataSource->getMyKey();
             if ($tmpKey) {
                 $members[$tmpKey] = true;
             }
         }
         if ($members && count($members)) {
             $aviavbleCond = 'AND ' . $iDColumn . ' NOT IN (' . join(',', array_keys($members)) . ') ';
         } else {
             $aviavbleCond = '';
         }
         $membersAviableArray = EaseShared::myDbLink()->queryToArray('SELECT ' . $nameColumn . ', ' . $iDColumn . ' ' . 'FROM `' . $sTable . '` ' . 'WHERE (' . $sqlConds . ') ' . $aviavbleCond . 'ORDER BY ' . $nameColumn, $iDColumn);
         if ($sTable == $dataSource->myTable) {
             unset($members[$dataSource->getMyKey()]);
         }
         $addText = _('Přiřadit');
         $delText = _('Odebrat');
         if (count($membersAviableArray)) {
             foreach ($membersAviableArray as $memberID => $memberName) {
                 $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
                 $initialContent->addItem(new EaseTWBButtonDropdown($memberName[$nameColumn], 'inverse', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('plus-sign') . ' ' . $addText, array('onClick' => "addGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName[$nameColumn] . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;')));
             }
         }
         if ($members && count($members)) {
             $initialContent->addItem('</br>');
             foreach ($members as $memberID => $memberName) {
                 $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table'];
                 $initialContent->addItem(new EaseTWBButtonDropdown($memberName, 'success', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('remove') . ' ' . _('Odebrat'), array('onClick' => "delGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;')));
             }
         }
     }
     parent::__construct($initialContent);
 }
Пример #5
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 . '&amp;service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addhost=' . $hostInfo[$host->nameColumn] . '&amp;host_id=' . $hostID . '&amp;' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&amp;' . $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);
 }
Пример #6
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');
        }
    }
Пример #7
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 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');
        }
    }
Пример #8
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);
     }
 }
Пример #9
0
<?php

/**
 * Odhlašovací stránka
 *
 * @author    Vitex <*****@*****.**>
 * @copyright Vitex@hippy.cz (G) 2009,2011
 * @package IcingaEditor
 */
require_once 'includes/IEInit.php';
unset($_SESSION['access_token']);
//Twitter OAuth
if ($oUser->getUserID()) {
    $oUser->logout();
    $MessagesBackup = $oUser->getStatusMessages(TRUE);
    EaseShared::user(new EaseAnonym());
    $oUser->addStatusMessages($MessagesBackup);
}
$oPage->addItem(new IEPageTop(_('Odhlášení')));
$oPage->addPageColumns();
$oPage->heroUnit = $oPage->container->addItem(new EaseHtmlDivTag('heroUnit', null, array('class' => 'jumbotron')));
$oPage->heroUnit->addItem(new EaseHtmlDivTag(NULL, _('Děkujeme za vaši přízeň a těšíme se na další návštěvu')));
$oPage->addItem(new IEPageBottom());
$oPage->draw();
Пример #10
0
 /**
  * Naimportuje konfiguraci ze souboru
  *
  * @param  string $cfg
  * @return int    počet uložených konfigurací
  */
 public function importCfg($cfg)
 {
     $doneCount = 0;
     if (count($cfg)) {
         $this->addStatusMessage(sprintf(_('Načteno %s řádek konfigurace'), count($cfg)), 'success');
     } else {
         $this->addStatusMessage(sprintf(_('konfigurace nebyla načtena'), count($cfg)), 'warning');
         return 0;
     }
     if ($this->userColumn) {
         $this->setDataValue($this->userColumn, EaseShared::user()->getUserID());
     }
     if (is_null($this->getDataValue('register'))) {
         $this->setDataValue('register', 1);
     }
     foreach ($this->IEClasses as $IEClass) {
         $doneCount += $IEClass->importArray($cfg, $this->getData());
     }
     if ($doneCount) {
         $this->addStatusMessage(sprintf(_('Bylo naimportováno %s konfigurací'), $doneCount), 'success');
     } else {
         $this->addStatusMessage(_('Nic se nenaimportovalo'), 'warning');
     }
     return $doneCount;
 }
Пример #11
0
    unset($_SESSION['access_token']);
    $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;
$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 {
    if ($oPage->isPosted()) {
        $oPage->addStatusMessage(_('Prosím zastejte název sledovaného hosta'), 'warning');
    }
}
$oPage->addItem(new IEPageTop(_('Průvodce založením hosta')));
$oPage->container->addItem(new EaseTWBPanel(_('Nový pasivně sledovaný host'), 'info', new IEPassiveCheckedHostForm('passive')));
Пример #13
0
 /**
  * Reloadne icingu
  */
 public static function reloadIcinga()
 {
     $testing = popen("sudo /etc/init.d/icinga reload", 'r');
     if ($testing) {
         while (!feof($testing)) {
             $line = fgets($testing);
             EaseShared::user()->addStatusMessage('Reload: ' . $line);
         }
         fclose($testing);
     }
     return TRUE;
 }
Пример #14
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();
 }
Пример #15
0
 /**
  * Init PDF exportu
  *
  * @param string $title nadpis stránky
  * @param char $orientation P|L
  */
 public function pdfInit($title = null, $orientation = 'P')
 {
     $this->filename .= $title;
     // pdf object
     $this->pdf = new TCPDF($orientation);
     // set document information
     $this->pdf->SetCreator(PDF_CREATOR);
     $this->pdf->SetAuthor(EaseShared::user()->getUsername());
     $this->pdf->SetTitle($title);
     $this->pdf->SetSubject('');
     $this->pdf->SetKeywords($title);
     // set default header data
     $this->pdf->SetHeaderData('logo.png', 45, $title, "DB Finance s.r.o - nezávislý investiční zprostředkovatel a pojišťovací makléř\n" . "✉ dbfinance@dbfinance.cz ☎ 222 541 990 – 995 ⌨ www.dbfinance.cz ");
     // set header and footer fonts
     $this->pdf->setHeaderFont(array('dejavusans', '', 8));
     $this->pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // ---------------------------------------------------------
     // set default font subsetting mode
     $this->pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $this->pdf->SetFont('dejavusans', '', 8, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $this->pdf->AddPage();
     // ---------------------------------------------------------
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
 }
 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');
         }
     }
 }
Пример #17
0
 }
 system('sudo htpasswd -b /etc/icinga/htpasswd.users ' . $newOUser->getUserLogin() . ' ' . $password);
 $newOUser->loginSuccess();
 $email = $oPage->addItem(new EaseMail($newOUser->getDataValue('email'), _('Potvrzení registrace')));
 $email->setMailHeaders(array('From' => EMAIL_FROM));
 $email->addItem(new EaseHtmlDivTag(null, "Právě jste byl/a zaregistrován/a do Aplikace Monitoring s těmito přihlašovacími údaji:\n"));
 $email->addItem(new EaseHtmlDivTag(null, ' Login: '******' Heslo: ' . $_POST['password'] . "\n"));
 $email->send();
 $email = $oPage->addItem(new EaseMail(SEND_INFO_TO, sprintf(_('Nová registrace do Monitoringu: %s'), $newOUser->GetUserLogin())));
 $email->setMailHeaders(array('From' => EMAIL_FROM));
 $email->addItem(new EaseHtmlDivTag(null, _("Právě byl zaregistrován nový uživatel:\n")));
 $email->addItem(new EaseHtmlDivTag('login', ' Login: '******'contact_name' => $login, 'use' => 'generic-contact', $contact->userColumn => $userID, 'generate' => true, 'host_notifications_enabled' => true, 'service_notifications_enabled' => true, 'host_notification_period' => '24x7', 'service_notification_period' => '24x7', 'service_notification_options' => ' w,u,c,r', 'host_notification_options' => 'd,u,r', 'service_notification_commands' => 'notify-service-by-email', 'host_notification_commands' => 'notify-host-by-email', 'register' => 1));
 $contactID = $contact->saveToMySQL();
 if ($contactID) {
     $oUser->addStatusMessage(_('Výchozí kontakt byl založen'), 'success');
 } else {
     $oUser->addStatusMessage(_('Výchozí kontakt nebyl založen'), 'warning');
 }
 $mailID = $contact->fork(array('email' => $emailAddress));
 if ($mailID) {
     $oUser->addStatusMessage(_('Mailový kontakt byl založen'), 'success');
 } else {
     $oUser->addStatusMessage(_('Mailový kontakt nebyl založen'), 'warning');
 }
 $contactGroup = new IEContactgroup();
Пример #18
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();
Пример #19
0
 /**
  * Vložení menu
  */
 public function afterAdd()
 {
     $nav = $this->addItem(new IEBootstrapMenu());
     $user = EaseShared::user();
     $userID = $user->getUserID();
     if ($userID) {
         //Authenticated user
         $nav->addMenuItem(new IENavBarSearchBox('search', 'search.php'));
         if ($user->getSettingValue('admin')) {
             $users = $user->getColumnsFromMySQL(array('id', 'login'), array('id' => '!0'), 'login', $user->getmyKeyColumn());
             $userList = array();
             if ($users) {
                 foreach ($users as $uID => $uInfo) {
                     $userList['userinfo.php?user_id=' . $uInfo['id']] = EaseTWBPart::GlyphIcon('user') . '&nbsp;' . $uInfo['login'];
                 }
                 if (count($userList)) {
                     $userList[] = '';
                 }
             }
             //                $usergroups = $this->myDbLink->queryToArray('SELECT * FROM user_groups' . 'usergroup_id');
             $nav->addDropDownMenu(_('Uživatelé'), array_merge($userList, array('createaccount.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový uživatel'), 'users.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled uživatelů'), 'usergroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina uživatelů'), 'usergroups.php' => EaseTWBPart::GlyphIcon('list') . '&nbsp;' . _('Přehled skupin uživatelů'))));
         }
         $this->changesButton($nav);
         $this->groupsHostsMenu($nav);
         //            $nav->addDropDownMenu(_('Hosti'), $hostGroupHostsMenuItem);
         if (EaseShared::user()->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Služby'), array('wizard-service.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením služby'), 'service.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová služba'), 'services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'), 'servicegroup.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina služeb'), 'servicegroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin služeb'), '' => '', 'stemplate.php?action=new' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová předloha sledované služby'), 'stemplates.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled předloh sled. sl.')));
         } else {
             $service = new IEService();
             $services = $service->getListing(null, null, array('icon_image', 'platform'));
             if (count($services)) {
                 $services_menu = array('services.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled služeb'));
                 foreach ($services as $serviceID => $serviceInfo) {
                     $services_menu['servicetweak.php?service_id=' . $serviceID] = $serviceInfo[$service->nameColumn];
                 }
                 $nav->addDropDownMenu(_('Služby'), $services_menu);
             }
         }
         $contact = new IEContact();
         $contacts = $contact->getListing(null, null, array('parent_id'));
         foreach ($contacts as $contactID => $contactInfo) {
             //Vyfiltrovat pouze primární kontakty
             if ($contactInfo['parent_id']) {
                 unset($contacts[$contactID]);
             }
         }
         if (count($contacts)) {
             $contacts_menu = array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled Kontaktů'));
             foreach ($contacts as $contactID => $contactInfo) {
                 $contacts_menu['contacttweak.php?contact_id=' . $contactID] = $contactInfo[$contact->nameColumn];
             }
             $contacts_menu[] = '';
         } else {
             $contacts_menu = array();
         }
         $nav->addDropDownMenu(_('Kontakty'), array_merge($contacts_menu, array('contacts.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled kontaktů'), 'newcontact.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nový kontakt'), 'contactgroups.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled skupin kontaktů'), 'contactgroup.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nová skupina kontaktů'))));
         if ($user->getSettingValue('admin')) {
             $nav->addDropDownMenu(_('Příkaz'), array('command.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový příkaz'), 'commands.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled příkazů'), 'importcommand.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat'), '', 'script.php' => EaseTWBPart::GlyphIcon('edit') . ' ' . _('Nový skript'), 'scripts.php' => EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skriptů')));
             $nav->addDropDownMenu(_('Rozšířené'), array('timeperiods.php' => EaseTWBPart::GlyphIcon('list') . ' ' . _('Přehled časových period'), 'timeperiod.php' => EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová časová perioda'), 'preferences.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Nastavení icingy'), 'regenall.php' => EaseTWBPart::GlyphIcon('ok') . ' ' . _('Přegenerovat všechny konfiguráky'), 'reset.php' => EaseTWBPart::GlyphIcon('cog') . ' ' . _('Reset Objektů'), 'dbrecreate.php' => EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Reinicializovat databázi'), 'fixer.php' => EaseTWBPart::GlyphIcon('ok-circle') . ' ' . _('Opravit databázi'), 'import.php' => EaseTWBPart::GlyphIcon('import') . ' ' . _('Importovat')));
         }
         $results = array('nagstamon.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('PC Lin/Win/Mac'), 'anag.php' => EaseTWBPart::GlyphIcon('info') . ' ' . _('Android'), 'wpnag.php' => EaseTWBPart::GlyphIcon('Info') . ' ' . _('Win Phone'));
         if (file_exists('/etc/apache2/conf-enabled/icinga-web.conf')) {
             $results['/icinga-web/'] = EaseTWBPart::GlyphIcon('Info') . ' ' . _('Web');
         }
         $nav->addDropDownMenu(_('Výsledky testů'), $results);
     }
 }
Пример #20
0
 /**
  * Přehodí
  * @param type $swapToID
  * @return boolean
  */
 public function swapTo($swapToID)
 {
     $newService = new IEService($swapToID);
     $thisName = $this->getName();
     $hostsOK = array();
     $hostsErr = array();
     $hostsAssigned = array();
     $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'));
     }
     $hosts = $this->getDataValue('host_name');
     foreach ($hosts as $hostId => $hostName) {
         if (isset($allHosts[$hostId])) {
             $hostsAssigned[$hostId] = $allHosts[$hostId];
         }
     }
     foreach ($hostsAssigned as $host_id => $hostAssigned) {
         if ($this->delMember('host_name', $host_id, $hostAssigned['host_name']) && $newService->addMember('host_name', $host_id, $hostAssigned['host_name'])) {
             $hostsOK[] = $hostAssigned['host_name'];
         } else {
             $hostsErr[] = $hostAssigned['host_name'];
         }
     }
     if ($this->saveToMySQL() && $newService->saveToMySQL() && count($hostsOK)) {
         $this->addStatusMessage(sprintf(_('%s byl přesunut z %s/%s do %s'), implode(',', $hostsOK), $this->keyword, $this->getName(), $newService->getName()), 'success');
         return true;
     } else {
         $this->addStatusMessage(sprintf(_(' %s nebyl přesunut z %s/%s do %s'), implode(',', $hostsErr), $this->keyword, $this->getName(), $newService->getName()), 'warning');
         return false;
     }
 }