Exemplo n.º 1
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // if screen is defined in template, then 'real_resourceid' is defined and should be used
     if (!empty($this->screenitem['real_resourceid'])) {
         $this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
     }
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
         $this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
     }
     if ($this->screenitem['resourceid'] == 0) {
         $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Item')]);
         return $this->getOutput($table);
     }
     $items = CMacrosResolverHelper::resolveItemNames([get_item_by_itemid($this->screenitem['resourceid'])]);
     $item = reset($items);
     switch ($item['value_type']) {
         case ITEM_VALUE_TYPE_TEXT:
         case ITEM_VALUE_TYPE_LOG:
             $orderField = 'id';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         case ITEM_VALUE_TYPE_UINT64:
         default:
             $orderField = ['itemid', 'clock'];
     }
     $host = get_host_by_itemid($this->screenitem['resourceid']);
     $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Value')]);
     $stime = zbxDateToTime($this->timeline['stime']);
     $histories = API::History()->get(['history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']]);
     foreach ($histories as $history) {
         switch ($item['value_type']) {
             case ITEM_VALUE_TYPE_FLOAT:
                 sscanf($history['value'], '%f', $value);
                 break;
             case ITEM_VALUE_TYPE_TEXT:
             case ITEM_VALUE_TYPE_STR:
             case ITEM_VALUE_TYPE_LOG:
                 $value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
                 break;
             default:
                 $value = $history['value'];
                 break;
         }
         if ($item['valuemapid'] > 0) {
             $value = applyValueMap($value, $item['valuemapid']);
         }
         if ($this->screenitem['style'] == 0) {
             $value = new CPre($value);
         }
         $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), $value]);
     }
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader($host['name'] . NAME_DELIMITER . $item['name_expanded']));
 }
Exemplo n.º 2
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // if screen is defined in template, then 'real_resourceid' is defined and should be used
     if (!empty($this->screenitem['real_resourceid'])) {
         $this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
     }
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
         $this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
     }
     if ($this->screenitem['resourceid'] == 0) {
         $table = new CTableInfo(_('No values found.'));
         $table->setHeader(array(_('Timestamp'), _('Item')));
         return $this->getOutput($table);
     }
     $items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($this->screenitem['resourceid'])));
     $item = reset($items);
     switch ($item['value_type']) {
         case ITEM_VALUE_TYPE_TEXT:
         case ITEM_VALUE_TYPE_LOG:
             $orderField = 'id';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         case ITEM_VALUE_TYPE_UINT64:
         default:
             $orderField = array('itemid', 'clock');
     }
     $host = get_host_by_itemid($this->screenitem['resourceid']);
     $table = new CTableInfo(_('No values found.'));
     $table->setHeader(array(_('Timestamp'), $host['name'] . NAME_DELIMITER . $item['name_expanded']));
     $stime = zbxDateToTime($this->timeline['stime']);
     $histories = API::History()->get(array('history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']));
     foreach ($histories as $history) {
         switch ($item['value_type']) {
             case ITEM_VALUE_TYPE_FLOAT:
                 sscanf($history['value'], '%f', $value);
                 break;
             case ITEM_VALUE_TYPE_TEXT:
             case ITEM_VALUE_TYPE_STR:
             case ITEM_VALUE_TYPE_LOG:
                 $value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
                 break;
             default:
                 $value = $history['value'];
                 break;
         }
         if ($item['valuemapid'] > 0) {
             $value = applyValueMap($value, $item['valuemapid']);
         }
         $class = $this->screenitem['style'] ? null : 'pre';
         $table->addRow(array(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), new CCol($value, $class)));
     }
     return $this->getOutput($table);
 }
function get_timeperiod_form()
{
    $tblPeriod = new CTableInfo();
    // init new_timeperiod variable
    $new_timeperiod = get_request('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod)) {
        if (isset($new_timeperiod['id'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id']));
        }
        if (isset($new_timeperiod['timeperiodid'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid']));
        }
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // start time
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // period
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // daysofweek
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    // months
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    $bit_dayofweek = zbx_str_revert($dayofweek);
    $bit_month = zbx_str_revert($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only'));
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $tblPeriod->addRow(array(_('Period type'), $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
        $tabDays = new CTable();
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
        $tblPeriod->addRow(array(_('Day of week'), $tabDays));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tabMonths = new CTable();
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December')));
        $tblPeriod->addRow(array(_('Month'), $tabMonths));
        $radioDaily = new CTag('input');
        $radioDaily->setAttribute('type', 'radio');
        $radioDaily->setAttribute('name', 'new_timeperiod[month_date_type]');
        $radioDaily->setAttribute('value', '0');
        $radioDaily->setAttribute('onclick', 'submit()');
        $radioDaily2 = new CTag('input');
        $radioDaily2->setAttribute('type', 'radio');
        $radioDaily2->setAttribute('name', 'new_timeperiod[month_date_type]');
        $radioDaily2->setAttribute('value', '1');
        $radioDaily2->setAttribute('onclick', 'submit()');
        if ($new_timeperiod['month_date_type']) {
            $radioDaily2->setAttribute('checked', 'checked');
        } else {
            $radioDaily->setAttribute('checked', 'checked');
        }
        $tblPeriod->addRow(array(_('Date'), array($radioDaily, _('Day'), SPACE, SPACE, $radioDaily2, _('Day of week'))));
        if ($new_timeperiod['month_date_type'] > 0) {
            $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
            $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
            $cmbCount->addItem(1, _('First'));
            $cmbCount->addItem(2, _('Second'));
            $cmbCount->addItem(3, _('Third'));
            $cmbCount->addItem(4, _('Fourth'));
            $cmbCount->addItem(5, _('Last'));
            $td = new CCol($cmbCount);
            $td->setColSpan(2);
            $tabDays = new CTable();
            $tabDays->addRow($td);
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
            $tblPeriod->addRow(array(_('Day of week'), $tabDays));
        } else {
            $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
            $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
        }
    } else {
        $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
        $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); pos.top += 10; pos.left += 16; CLNDR["new_timeperiod_date"].clndr.clndrshow(pos.top, pos.left);');
        $filtertimetab = new CTable(null, 'calendar');
        $filtertimetab->setAttribute('width', '10%');
        $filtertimetab->setCellPadding(0);
        $filtertimetab->setCellSpacing(0);
        $startDate = zbxDateToTime($new_timeperiod['start_date']);
        if (isset($_REQUEST['add_timeperiod'])) {
            $newTimePeriodYear = get_request('new_timeperiod_year');
            $newTimePeriodMonth = get_request('new_timeperiod_month');
            $newTimePeriodDay = get_request('new_timeperiod_day');
            $newTimePeriodHours = get_request('new_timeperiod_hour');
            $newTimePeriodMinutes = get_request('new_timeperiod_minute');
        } elseif ($startDate > 0) {
            $newTimePeriodYear = date('Y', $startDate);
            $newTimePeriodMonth = date('m', $startDate);
            $newTimePeriodDay = date('d', $startDate);
            $newTimePeriodHours = date('H', $startDate);
            $newTimePeriodMinutes = date('i', $startDate);
        } else {
            $newTimePeriodYear = '';
            $newTimePeriodMonth = '';
            $newTimePeriodDay = '';
            $newTimePeriodHours = '';
            $newTimePeriodMinutes = '';
        }
        $filtertimetab->addRow(array(new CNumericBox('new_timeperiod_day', $newTimePeriodDay, 2), '/', new CNumericBox('new_timeperiod_month', $newTimePeriodMonth, 2), '/', new CNumericBox('new_timeperiod_year', $newTimePeriodYear, 4), SPACE, new CNumericBox('new_timeperiod_hour', $newTimePeriodHours, 2), ':', new CNumericBox('new_timeperiod_minute', $newTimePeriodMinutes, 2), $clndr_icon));
        zbx_add_post_js('create_calendar(null, ["new_timeperiod_day", "new_timeperiod_month", "new_timeperiod_year", "new_timeperiod_hour", "new_timeperiod_minute"], "new_timeperiod_date", "new_timeperiod_start_date");');
        $tblPeriod->addRow(array(_('Date'), $filtertimetab));
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tabTime = new CTable(null, 'calendar');
        $tabTime->addRow(array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)));
        $tblPeriod->addRow(array(_('At (hour:minute)'), $tabTime));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours']);
    for ($i = 0; $i < 24; $i++) {
        $perHours->addItem($i, $i);
    }
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes']);
    for ($i = 0; $i < 60; $i++) {
        $perMinutes->addItem($i, $i);
    }
    $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, SPACE . _('Hours'), $perMinutes, SPACE . _('Minutes'))));
    $td = new CCol(array(new CSubmit('add_timeperiod', $new ? _('Save') : _('Add')), SPACE, new CSubmit('cancel_new_timeperiod', _('Cancel'))));
    $td->setAttribute('colspan', '3');
    $td->setAttribute('style', 'text-align: right;');
    $tblPeriod->setFooter($td);
    return $tblPeriod;
}
        case AUDIT_ACTION_ENABLE:
            $action = _('Enabled');
            break;
        case AUDIT_ACTION_DISABLE:
            $action = _('Disabled');
            break;
        default:
            $action = _('Unknown action');
    }
    $audit['action'] = $action;
    $audit['resourcetype'] = audit_resource2str($audit['resourcetype']);
    if (empty($audit['details'])) {
        $audit['details'] = DBfetchArray(DBselect('SELECT ad.table_name,ad.field_name,ad.oldvalue,ad.newvalue' . ' FROM auditlog_details ad' . ' WHERE ad.auditid=' . $audit['auditid']));
    }
    $data['actions'][$audit['auditid']] = $audit;
}
if (!empty($data['actions'])) {
    order_result($data['actions'], 'clock', ZBX_SORT_DOWN);
}
// get paging
$data['paging'] = getPagingLine($data['actions']);
// get timeline
unset($sqlWhere['from'], $sqlWhere['till']);
$sql = 'SELECT a.auditid,a.clock' . ' FROM auditlog a,users u' . ' WHERE u.userid=a.userid' . implode('', $sqlWhere) . ' AND ' . DBin_node('u.userid', get_current_nodeid(null, PERM_READ_ONLY)) . ' ORDER BY a.clock';
$firstAudit = DBfetch(DBselect($sql, $config['search_limit'] + 1));
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date('YmdHis', !empty($firstAudit) ? $firstAudit['clock'] : null), 'usertime' => isset($_REQUEST['stime']) ? date('YmdHis', zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditlogs.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemplo n.º 5
0
function get_timeperiod_form()
{
    $tblPeriod = new CTable(null, 'formElementTable');
    // init new_timeperiod variable
    $new_timeperiod = getRequest('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod)) {
        if (isset($new_timeperiod['id'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id']));
        }
        if (isset($new_timeperiod['timeperiodid'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid']));
        }
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // start time
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // period
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // daysofweek
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    // months
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    $bit_dayofweek = strrev($dayofweek);
    $bit_month = strrev($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only'));
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $tblPeriod->addRow(array(_('Period type'), $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
        $tabDays = new CTable();
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
        $tblPeriod->addRow(array(_('Day of week'), $tabDays));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tabMonths = new CTable();
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December')));
        $tblPeriod->addRow(array(_('Month'), $tabMonths));
        $tblPeriod->addRow(array(_('Date'), array(new CRadioButton('new_timeperiod[month_date_type]', '0', null, null, !$new_timeperiod['month_date_type'], 'submit()'), _('Day'), SPACE, new CRadioButton('new_timeperiod[month_date_type]', '1', null, null, $new_timeperiod['month_date_type'], 'submit()'), _('Day of week'))));
        if ($new_timeperiod['month_date_type'] > 0) {
            $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
            $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
            $cmbCount->addItem(1, _('First'));
            $cmbCount->addItem(2, _('Second'));
            $cmbCount->addItem(3, _('Third'));
            $cmbCount->addItem(4, _('Fourth'));
            $cmbCount->addItem(5, _('Last'));
            $td = new CCol($cmbCount);
            $td->setColSpan(2);
            $tabDays = new CTable();
            $tabDays->addRow($td);
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
            $tblPeriod->addRow(array(_('Day of week'), $tabDays));
        } else {
            $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
            $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
        }
    } else {
        $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        if (isset($_REQUEST['add_timeperiod'])) {
            $date = array('y' => getRequest('new_timeperiod_start_date_year'), 'm' => getRequest('new_timeperiod_start_date_month'), 'd' => getRequest('new_timeperiod_start_date_day'), 'h' => getRequest('new_timeperiod_start_date_hour'), 'i' => getRequest('new_timeperiod_start_date_minute'));
        } else {
            $date = zbxDateToTime($new_timeperiod['start_date'] ? $new_timeperiod['start_date'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time()));
        }
        $tblPeriod->addRow(array(_('Date'), createDateSelector('new_timeperiod_start_date', $date)));
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tblPeriod->addRow(array(_('At (hour:minute)'), array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2))));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours'], null, range(0, 23));
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes'], null, range(0, 59));
    $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, _('Hours') . SPACE . SPACE, $perMinutes, _('Minutes'))));
    return $tblPeriod;
}
} else {
    $fromDate = zbxDateToTime($this->data['active_since']);
    $activeSince = $this->data['active_since'];
}
$maintenanceForm->addVar('active_since', $activeSince);
// active till
if (isset($_REQUEST['active_till'])) {
    $toYear = get_request('active_till_year');
    $toMonth = get_request('active_till_month');
    $toDay = get_request('active_till_day');
    $toHours = get_request('active_till_hour');
    $toMinutes = get_request('active_till_minute');
    $toDate = array('y' => $toYear, 'm' => $toMonth, 'd' => $toDay, 'h' => $toHours, 'i' => $toMinutes);
    $activeTill = $toYear . $toMonth . $toDay . $toHours . $toMinutes;
} else {
    $toDate = zbxDateToTime($this->data['active_till']);
    $activeTill = $this->data['active_till'];
}
$maintenanceForm->addVar('active_till', $activeTill);
$maintenanceFormList->addRow(_('Active since'), createDateSelector('active_since', $fromDate, 'active_till'));
$maintenanceFormList->addRow(_('Active till'), createDateSelector('active_till', $toDate, 'active_since'));
$maintenanceFormList->addRow(_('Description'), new CTextArea('description', $this->data['description']));
/*
 * Maintenance period tab
 */
$maintenancePeriodFormList = new CFormList('maintenancePeriodFormList');
$maintenancePeriodTable = new CTable(_('No maintenance periods defined.'), 'formElementTable');
$maintenancePeriodTable->setHeader(array(_('Period type'), _('Schedule'), _('Period'), _('Action')));
foreach ($this->data['timeperiods'] as $id => $timeperiod) {
    $maintenancePeriodTable->addRow(array(new CCol(timeperiod_type2str($timeperiod['timeperiod_type']), 'nowrap'), new CCol(shedule2str($timeperiod), 'wraptext'), new CCol(zbx_date2age(0, $timeperiod['period']), 'nowrap'), new CCol(array(new CSubmit('edit_timeperiodid[' . $id . ']', _('Edit'), null, 'link_menu'), SPACE . SPACE, new CSubmit('del_timeperiodid[' . $id . ']', _('Remove'), null, 'link_menu')), 'nowrap')));
    if (isset($timeperiod['timeperiodid'])) {
 public function setSTime($stime)
 {
     if ($stime > 19000000000000.0 && $stime < 21000000000000.0) {
         $this->stime = zbxDateToTime($stime);
     } else {
         $this->stime = $stime;
     }
 }
function navigation_bar_calc($idx = null, $idx2 = 0, $update = false)
{
    if (!empty($idx)) {
        if ($update) {
            if (!empty($_REQUEST['period']) && $_REQUEST['period'] >= ZBX_MIN_PERIOD) {
                CProfile::update($idx . '.period', $_REQUEST['period'], PROFILE_TYPE_INT, $idx2);
            }
            if (!empty($_REQUEST['stime'])) {
                CProfile::update($idx . '.stime', $_REQUEST['stime'], PROFILE_TYPE_STR, $idx2);
            }
        }
        $_REQUEST['period'] = get_request('period', CProfile::get($idx . '.period', ZBX_PERIOD_DEFAULT, $idx2));
        $_REQUEST['stime'] = get_request('stime', CProfile::get($idx . '.stime', null, $idx2));
    }
    $_REQUEST['period'] = get_request('period', ZBX_PERIOD_DEFAULT);
    $_REQUEST['stime'] = get_request('stime', null);
    if ($_REQUEST['period'] < ZBX_MIN_PERIOD) {
        show_message(_n('Warning. Minimum time period to display is %1$s hour.', 'Warning. Minimum time period to display is %1$s hours.', (int) ZBX_MIN_PERIOD / SEC_PER_HOUR));
        $_REQUEST['period'] = ZBX_MIN_PERIOD;
    } elseif ($_REQUEST['period'] > ZBX_MAX_PERIOD) {
        show_message(_n('Warning. Maximum time period to display is %1$s day.', 'Warning. Maximum time period to display is %1$s days.', (int) ZBX_MAX_PERIOD / SEC_PER_DAY));
        $_REQUEST['period'] = ZBX_MAX_PERIOD;
    }
    if (!empty($_REQUEST['stime'])) {
        $time = zbxDateToTime($_REQUEST['stime']);
        if ($time + $_REQUEST['period'] > time()) {
            $_REQUEST['stime'] = date('YmdHis', time() - $_REQUEST['period']);
        }
    } else {
        $_REQUEST['stime'] = date('YmdHis', time() - $_REQUEST['period']);
    }
    return $_REQUEST['period'];
}
Exemplo n.º 9
0
order_result($actions, 'clock', ZBX_SORT_DOWN);
$paging = getPagingLine($actions);
//---------
foreach ($actions as $num => $row) {
    if (empty($row['details'])) {
        $details = array();
        $sql = 'SELECT table_name,field_name,oldvalue,newvalue ' . ' FROM auditlog_details ' . ' WHERE auditid=' . $row['auditid'];
        $db_details = DBselect($sql);
        while ($db_detail = DBfetch($db_details)) {
            $details[] = array($db_detail['table_name'] . '.' . $db_detail['field_name'] . ': ' . $db_detail['oldvalue'] . ' => ' . $db_detail['newvalue'], BR());
        }
    } else {
        $details = $row['details'];
    }
    $table->addRow(array(zbx_date2str(S_AUDITLOGS_RECORD_DATE_FORMAT, $row['clock']), $row['alias'], $row['ip'], $row['resourcetype'], $row['action'], $row['resourceid'], $row['resourcename'], new CCol($details, 'wraptext')));
}
// PAGING FOOTER
$table = array($paging, $table, $paging);
//---------
$audit_wdgt->addItem($table);
$audit_wdgt->show();
// NAV BAR
$timeline = array('period' => $effectiveperiod, 'starttime' => date('YmdHis', $starttime), 'usertime' => null);
if (isset($_REQUEST['stime'])) {
    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
}
$dom_graph_id = 'events';
$objData = array('id' => 'timeline_1', 'domid' => $dom_graph_id, 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1);
zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
zbx_add_post_js('timeControl.processObjects();');
include_once 'include/page_footer.php';
Exemplo n.º 10
0
function get_screen($screenid, $editmode, $effectiveperiod = NULL)
{
    global $USER_DETAILS;
    if ($screenid == 0) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $r = CScreen::get(array('screenids' => $screenid, 'editable' => $editmode == 1 ? 1 : null, 'output' => API_OUTPUT_SHORTEN));
    if (empty($r)) {
        access_deny();
    }
    if (is_null($effectiveperiod)) {
        $effectiveperiod = ZBX_MIN_PERIOD;
    }
    $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid);
    $row = DBfetch($result);
    if (!$row) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid;
    $iresult = DBSelect($sql);
    $skip_field = array();
    $irows = array();
    while ($irow = DBfetch($iresult)) {
        $irows[] = $irow;
        for ($i = 0; $i < $irow['rowspan'] || $i == 0; $i++) {
            for ($j = 0; $j < $irow['colspan'] || $j == 0; $j++) {
                if ($i != 0 || $j != 0) {
                    if (!isset($skip_field[$irow['y'] + $i])) {
                        $skip_field[$irow['y'] + $i] = array();
                    }
                    $skip_field[$irow['y'] + $i][$irow['x'] + $j] = 1;
                }
            }
        }
    }
    $table = new CTable(new CLink(S_NO_ROWS_IN_SCREEN . SPACE . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit');
    $table->setAttribute('id', 'iframe');
    if ($editmode == 1) {
        $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        for ($c = 0; $c < $row['hsize'] + 1; $c++) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_col={$c}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        $table->addRow($new_cols);
    }
    $empty_screen_col = array();
    for ($r = 0; $r < $row['vsize']; $r++) {
        $new_cols = array();
        $empty_screen_row = true;
        if ($editmode == 1) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$r}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        for ($c = 0; $c < $row['hsize']; $c++) {
            $item = array();
            if (isset($skip_field[$r][$c])) {
                continue;
            }
            $item_form = false;
            $irow = false;
            foreach ($irows as $tmprow) {
                if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                    $irow = $tmprow;
                    break;
                }
            }
            if ($irow) {
                $screenitemid = $irow['screenitemid'];
                $resourcetype = $irow['resourcetype'];
                $resourceid = $irow['resourceid'];
                $width = $irow['width'];
                $height = $irow['height'];
                $colspan = $irow['colspan'];
                $rowspan = $irow['rowspan'];
                $elements = $irow['elements'];
                $valign = $irow['valign'];
                $halign = $irow['halign'];
                $style = $irow['style'];
                $url = $irow['url'];
                $dynamic = $irow['dynamic'];
            } else {
                $screenitemid = 0;
                $resourcetype = 0;
                $resourceid = 0;
                $width = 0;
                $height = 0;
                $colspan = 0;
                $rowspan = 0;
                $elements = 0;
                $valign = VALIGN_DEFAULT;
                $halign = HALIGN_DEFAULT;
                $style = 0;
                $url = '';
                $dynamic = 0;
            }
            if ($screenitemid > 0) {
                $empty_screen_row = false;
                $empty_screen_col[$c] = 1;
            }
            if ($editmode == 1 && $screenitemid != 0) {
                $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');";
                $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form';
            } else {
                if ($editmode == 1 && $screenitemid == 0) {
                    $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');";
                    $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form';
                } else {
                    $action = NULL;
                }
            }
            if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) {
                // click on empty field
                $item = get_screen_item_form();
                $item_form = true;
            } else {
                if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) {
                    // click on element
                    $item = get_screen_item_form();
                    $item_form = true;
                } else {
                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) {
                        if ($editmode == 0) {
                            $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime');
                        }
                        // GRAPH & ZOOM features
                        $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                        $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                        $graphDims = getGraphDims($resourceid);
                        $graphDims['graphHeight'] = $height;
                        $graphDims['width'] = $width;
                        $graph = get_graph_by_graphid($resourceid);
                        $graphid = $graph['graphid'];
                        $legend = $graph['show_legend'];
                        $graph3d = $graph['show_3d'];
                        //-------------
                        // Host feature
                        if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                            $options = array('hostids' => $_REQUEST['hostid'], 'output' => array('hostid', 'host'));
                            $hosts = CHost::get($options);
                            $host = reset($hosts);
                            $options = array('graphids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_REFER, 'select_graph_items' => API_OUTPUT_EXTEND);
                            $graph = CGraph::get($options);
                            $graph = reset($graph);
                            if (count($graph['hosts']) == 1) {
                                // if items from one host we change them, or set calculated if not exist on that host
                                if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymax_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymax_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                                if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymin_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymin_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                            }
                            $url = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php';
                            $url = new Curl($url);
                            foreach ($graph as $name => $value) {
                                if ($name == 'width' || $name == 'height') {
                                    continue;
                                }
                                $url->setArgument($name, $value);
                            }
                            $new_items = get_same_graphitems_for_host($graph['gitems'], $_REQUEST['hostid'], false);
                            foreach ($new_items as $gitem) {
                                unset($gitem['gitemid']);
                                unset($gitem['graphid']);
                                foreach ($gitem as $name => $value) {
                                    $url->setArgument('items[' . $gitem['itemid'] . '][' . $name . ']', $value);
                                }
                            }
                            $url->setArgument('name', $host['host'] . ': ' . $graph['name']);
                            $url = $url->getUrl();
                        }
                        //-------------
                        $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                        $default = false;
                        if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart6.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $timeline = array();
                            $timeline['period'] = $effectiveperiod;
                            $timeline['starttime'] = date('YmdHis', get_min_itemclock_by_graphid($resourceid));
                            if (isset($_REQUEST['stime'])) {
                                $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                            }
                            // $src = $url.'&width='.$width.'&height='.$height.'&legend='.$legend.'&graph3d='.$graph3d;
                            $src = $url . '&width=' . $width . '&height=' . $height . '&legend=' . $legend . '&graph3d=' . $graph3d . '&period=' . $effectiveperiod . url_param('stime');
                            $objData['src'] = $src;
                        } else {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart2.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $src = $url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime');
                            $timeline = array();
                            if (isset($graphid) && !is_null($graphid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                                //get_min_itemclock_by_graphid($graphid);
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $objData['src'] = $src;
                        }
                        if ($editmode || !$default) {
                            $item = new CDiv();
                        } else {
                            $item = new CLink(null, $action);
                        }
                        $item->setAttribute('id', $containerid);
                        $item = array($item);
                        if ($editmode == 1) {
                            $item[] = BR();
                            $item[] = new CLink(S_CHANGE, $action);
                        }
                        if ($editmode == 2) {
                            insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        } else {
                            zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        }
                    } else {
                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
                            $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                            $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                            $graphDims = getGraphDims();
                            $graphDims['graphHeight'] = $height;
                            $graphDims['width'] = $width;
                            $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                            // Host feature
                            if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                    $resourceid = $newitemid;
                                } else {
                                    $resourceid = '';
                                }
                            }
                            //-------------
                            if ($editmode == 0 && !empty($resourceid)) {
                                $action = 'history.php?action=showgraph&itemid=' . $resourceid . url_param('period') . url_param('stime');
                            }
                            $timeline = array();
                            $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                            if (!zbx_empty($resourceid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $src = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&';
                            $src .= $url . 'width=' . $width . '&height=' . $height;
                            $objData['src'] = $src;
                            if ($editmode) {
                                $item = new CDiv();
                            } else {
                                $item = new CLink(null, $action);
                            }
                            $item->setAttribute('id', $containerid);
                            $item = array($item);
                            if ($editmode == 1) {
                                $item[] = BR();
                                $item[] = new CLink(S_CHANGE, $action);
                            }
                            if ($editmode == 2) {
                                insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            } else {
                                zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            }
                        } else {
                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) {
                                $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}&curtime=" . time());
                                if ($editmode == 0) {
                                    $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_selements' => API_OUTPUT_EXTEND, 'nopermissions' => 1);
                                    $sysmaps = CMap::get($options);
                                    $sysmap = reset($sysmaps);
                                    $action_map = getActionMapBySysmap($sysmap);
                                    $image_map->setMap($action_map->getName());
                                    $item = array($action_map, $image_map);
                                } else {
                                    $item = $image_map;
                                    //						$item = new CLink($image_map, $action);
                                }
                            } else {
                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                                    // Host feature
                                    if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                        if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                            $resourceid = $newitemid;
                                        } else {
                                            $resourceid = 0;
                                        }
                                    }
                                    //-------------
                                    $item = array(get_screen_plaintext($resourceid, $elements, $style));
                                    if ($editmode == 1) {
                                        array_push($item, new CLink(S_CHANGE, $action));
                                    }
                                } else {
                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTGROUP_TRIGGERS) {
                                        $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                        $tr_form = S_ALL_S;
                                        if ($resourceid > 0) {
                                            $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                            $hostgroups = CHostgroup::get($options);
                                            $hostgroup = reset($hostgroups);
                                            $tr_form = new CSpan(S_GROUP . ': ' . $hostgroup['name'], 'white');
                                            $params['groupids'] = $hostgroup['groupid'];
                                        } else {
                                            $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                            $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                            CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                            CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            $groups = CHostGroup::get($options);
                                            order_result($groups, 'name');
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            if ($groupid > 0) {
                                                $options['groupids'] = $groupid;
                                            }
                                            $hosts = CHost::get($options);
                                            $hosts = zbx_toHash($hosts, 'hostid');
                                            order_result($hosts, 'host');
                                            if (!isset($hosts[$hostid])) {
                                                $hostid = 0;
                                            }
                                            $tr_form = new CForm();
                                            $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                            $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                            $cmbGroup->addItem(0, S_ALL_SMALL);
                                            $cmbHosts->addItem(0, S_ALL_SMALL);
                                            foreach ($groups as $gnum => $group) {
                                                $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                            }
                                            foreach ($hosts as $hnum => $host) {
                                                $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                            }
                                            $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                            $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                            if ($groupid > 0) {
                                                $params['groupids'] = $groupid;
                                            }
                                            if ($hostid > 0) {
                                                $params['hostids'] = $hostid;
                                            }
                                        }
                                        $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                        $item[] = make_latest_issues($params);
                                        if ($editmode == 1) {
                                            array_push($item, new CLink(S_CHANGE, $action));
                                        }
                                        ///-----------------------
                                    } else {
                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOST_TRIGGERS) {
                                            $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                            $tr_form = S_ALL_S;
                                            if ($resourceid > 0) {
                                                $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                                $hosts = CHost::get($options);
                                                $host = reset($hosts);
                                                $tr_form = new CSpan(S_HOST . ': ' . $host['host'], 'white');
                                                $params['hostids'] = $host['hostid'];
                                            } else {
                                                $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                                $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                                CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                                CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                $groups = CHostGroup::get($options);
                                                order_result($groups, 'name');
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                if ($groupid > 0) {
                                                    $options['groupids'] = $groupid;
                                                }
                                                $hosts = CHost::get($options);
                                                $hosts = zbx_toHash($hosts, 'hostid');
                                                order_result($hosts, 'host');
                                                if (!isset($hosts[$hostid])) {
                                                    $hostid = 0;
                                                }
                                                $tr_form = new CForm();
                                                $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                                $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                                $cmbGroup->addItem(0, S_ALL_SMALL);
                                                $cmbHosts->addItem(0, S_ALL_SMALL);
                                                foreach ($groups as $gnum => $group) {
                                                    $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                                }
                                                foreach ($hosts as $hnum => $host) {
                                                    $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                                }
                                                $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                                $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                                if ($groupid > 0) {
                                                    $params['groupids'] = $groupid;
                                                }
                                                if ($hostid > 0) {
                                                    $params['hostids'] = $hostid;
                                                }
                                            }
                                            ///-----------------------
                                            $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                            $item[] = make_latest_issues($params);
                                            if ($editmode == 1) {
                                                array_push($item, new CLink(S_CHANGE, $action));
                                            }
                                        } else {
                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) {
                                                $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0);
                                                $item = array(get_table_header(array(S_SYSTEM_STATUS, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT))));
                                                $item[] = make_system_status($params);
                                                if ($editmode == 1) {
                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                }
                                            } else {
                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) {
                                                    $item = array(new CHostsInfo($resourceid, $style));
                                                    if ($editmode == 1) {
                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                    }
                                                } else {
                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                                        $item = new CTriggersInfo($resourceid, null, $style);
                                                        $item = array($item);
                                                        if ($editmode == 1) {
                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                        }
                                                    } else {
                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) {
                                                            //					$item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx());
                                                            $item = array(new CServerInfo());
                                                            if ($editmode == 1) {
                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                            }
                                                        } else {
                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) {
                                                                $item = new CFlashClock($width, $height, $style, $action);
                                                            } else {
                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) {
                                                                    $item = array(get_screen($resourceid, 2, $effectiveperiod));
                                                                    if ($editmode == 1) {
                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                    }
                                                                } else {
                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) {
                                                                        $hostids = array();
                                                                        $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                        while ($tmp_host = DBfetch($res)) {
                                                                            $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                        }
                                                                        $item = array(get_triggers_overview($hostids, $style));
                                                                        if ($editmode == 1) {
                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                        }
                                                                    } else {
                                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) {
                                                                            $hostids = array();
                                                                            $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                            while ($tmp_host = DBfetch($res)) {
                                                                                $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                            }
                                                                            $item = array(get_items_data_overview($hostids, $style));
                                                                            if ($editmode == 1) {
                                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                                            }
                                                                        } else {
                                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_URL) {
                                                                                $item = array(new CIFrame($url, $width, $height, "auto"));
                                                                                if ($editmode == 1) {
                                                                                    array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                }
                                                                            } else {
                                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) {
                                                                                    $item = array(get_history_of_actions($elements));
                                                                                    if ($editmode == 1) {
                                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                                    }
                                                                                } else {
                                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) {
                                                                                        $options = array('monitored' => 1, 'value' => array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE), 'limit' => $elements);
                                                                                        $hide_unknown = CProfile::get('web.events.filter.hide_unknown', 0);
                                                                                        if ($hide_unknown) {
                                                                                            $options['value'] = array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE);
                                                                                        }
                                                                                        $item = new CTableInfo(S_NO_EVENTS_FOUND);
                                                                                        $item->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION, S_VALUE, S_SEVERITY));
                                                                                        $events = getLastEvents($options);
                                                                                        foreach ($events as $enum => $event) {
                                                                                            $trigger = $event['trigger'];
                                                                                            $host = $event['host'];
                                                                                            $value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value']));
                                                                                            //						$row = zbx_array_merge($triggers[$row['triggerid']],$row);
                                                                                            //						if((1 == $hide_unknown) && (!event_initial_time($row,$hide_unknown))) continue;
                                                                                            $item->addRow(array(zbx_date2str(S_EVENTS_TRIGGERS_EVENTS_HISTORY_LIST_DATE_FORMAT, $event['clock']), get_node_name_by_elid($event['objectid']), $host['host'], new CLink($trigger['description'], 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']), $value, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority']))));
                                                                                        }
                                                                                        $item = array($item);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    } else {
                                                                                        $item = array(SPACE);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $str_halign = 'def';
            if ($halign == HALIGN_CENTER) {
                $str_halign = 'cntr';
            }
            if ($halign == HALIGN_LEFT) {
                $str_halign = 'left';
            }
            if ($halign == HALIGN_RIGHT) {
                $str_halign = 'right';
            }
            $str_valign = 'def';
            if ($valign == VALIGN_MIDDLE) {
                $str_valign = 'mdl';
            }
            if ($valign == VALIGN_TOP) {
                $str_valign = 'top';
            }
            if ($valign == VALIGN_BOTTOM) {
                $str_valign = 'bttm';
            }
            if ($editmode == 1 && !$item_form) {
                $item = new CDiv($item, 'draggable');
                $item->setAttribute('id', 'position_' . $r . '_' . $c);
                if ($editmode == 1) {
                    $item->setAttribute('onclick', 'javascript: ' . $onclick_action);
                }
            }
            $new_col = new CCol($item, $str_halign . '_' . $str_valign);
            if ($colspan) {
                $new_col->SetColSpan($colspan);
            }
            if ($rowspan) {
                $new_col->SetRowSpan($rowspan);
            }
            array_push($new_cols, $new_col);
        }
        if ($editmode == 1) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if ($empty_screen_row) {
                $rmv_row_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';";
            } else {
                $rmv_row_link = "javascript: if(Confirm('" . S_THIS_SCREEN_ROW_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';}";
            }
            $rmv_icon->addAction('onclick', $rmv_row_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        $table->addRow(new CRow($new_cols));
    }
    if ($editmode == 1) {
        $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
        $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$row['vsize']}';");
        $new_cols = array(new Ccol($add_icon));
        for ($c = 0; $c < $row['hsize']; $c++) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if (isset($empty_screen_col[$c])) {
                $rmv_col_link = "javascript: if(Confirm('" . S_THIS_SCREEN_COLUMN_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';}";
            } else {
                $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';";
            }
            $rmv_icon->addAction('onclick', $rmv_col_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        $table->addRow($new_cols);
    }
    return $table;
}
Exemplo n.º 11
0
 $left_tab->setCellSpacing(3);
 // MAINTENANCE FORM {{{
 if (isset($_REQUEST['maintenanceid']) && !isset($_REQUEST['form_refresh'])) {
     $options = array('editable' => 1, 'maintenanceids' => $_REQUEST['maintenanceid'], 'output' => API_OUTPUT_EXTEND);
     $maintenance = CMaintenance::get($options);
     $maintenance = reset($maintenance);
     $mname = $maintenance['name'];
     $maintenance_type = $maintenance['maintenance_type'];
     $active_since = $maintenance['active_since'];
     $active_till = $maintenance['active_till'];
     $description = $maintenance['description'];
 } else {
     $mname = get_request('mname', '');
     $maintenance_type = get_request('maintenance_type', 0);
     $active_since = zbxDateToTime(get_request('active_since', date('YmdHis')));
     $active_till = zbxDateToTime(get_request('active_till', date('YmdHis', time() + 86400)));
     $description = get_request('description', '');
 }
 $tblMntc = new CTable(null, 'formElementTable');
 $tblMntc->addRow(array(S_NAME, new CTextBox('mname', $mname, 50)));
 $cmbType = new CComboBox('maintenance_type', $maintenance_type);
 $cmbType->addItem(MAINTENANCE_TYPE_NORMAL, S_WITH_DATA_COLLECTION);
 $cmbType->addItem(MAINTENANCE_TYPE_NODATA, S_NO_DATA_COLLECTION);
 $tblMntc->addRow(array(S_MAINTENANCE_TYPE, $cmbType));
 $tblMntc->addItem(new Cvar('active_since', date('YmdHis', $active_since)));
 $tblMntc->addItem(new Cvar('active_till', date('YmdHis', $active_till)));
 $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
 $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; CLNDR["mntc_active_since"].clndr.clndrshow(pos.top,pos.left);');
 zbx_add_post_js('create_calendar(null, ["mntc_since_day","mntc_since_month","mntc_since_year",' . '"mntc_since_hour","mntc_since_minute"],"mntc_active_since","active_since");');
 $tblMntc->addRow(array(S_ACTIVE_SINCE, array(new CNumericBox('mntc_since_day', $active_since > 0 ? date('d', $active_since) : '', 2), '/', new CNumericBox('mntc_since_month', $active_since > 0 ? date('m', $active_since) : '', 2), '/', new CNumericBox('mntc_since_year', $active_since > 0 ? date('Y', $active_since) : '', 4), SPACE, new CNumericBox('mntc_since_hour', $active_since > 0 ? date('H', $active_since) : '', 2), ':', new CNumericBox('mntc_since_minute', $active_since > 0 ? date('i', $active_since) : '', 2), $clndr_icon)));
 $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; CLNDR["mntc_active_till"].clndr.clndrshow(pos.top,pos.left);');
Exemplo n.º 12
0
    foreach (eventSourceObjects() as $eventSource) {
        $data['alerts'] = array_merge($data['alerts'], API::Alert()->get(array('output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'userids' => $userId, 'time_from' => $from, 'time_till' => $till, 'eventsource' => $eventSource['source'], 'eventobject' => $eventSource['object'], 'limit' => $config['search_limit'] + 1)));
    }
    CArrayHelper::sort($data['alerts'], array(array('field' => 'alertid', 'order' => ZBX_SORT_DOWN)));
    $data['alerts'] = array_slice($data['alerts'], 0, $config['search_limit'] + 1);
    // paging
    $data['paging'] = getPagingLine($data['alerts']);
    // get users
    if (!$data['alias']) {
        $data['users'] = API::User()->get(array('output' => array('userid', 'alias', 'name', 'surname'), 'userids' => zbx_objectValues($data['alerts'], 'userid'), 'preservekeys' => true));
    }
}
// get first alert clock
$firstAlert = null;
if ($userId) {
    $firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock' . ' FROM alerts a' . ' WHERE a.userid=' . zbx_dbstr($userId)));
} elseif ($data['alias'] === '') {
    $firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock FROM alerts a'));
}
$minStartTime = $firstAlert ? $firstAlert['clock'] : null;
// get actions names
if ($data['alerts']) {
    $data['actions'] = API::Action()->get(array('output' => array('actionid', 'name'), 'actionids' => array_unique(zbx_objectValues($data['alerts'], 'actionid')), 'preservekeys' => true));
}
// timeline
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date(TIMESTAMP_FORMAT, $minStartTime), 'usertime' => $data['stime'] ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditacts.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemplo n.º 13
0
function navigation_bar_calc($idx = null, $idx2 = 0, $update = false)
{
    //SDI($_REQUEST['stime']);
    if (!is_null($idx)) {
        if ($update) {
            if (isset($_REQUEST['period']) && $_REQUEST['period'] >= ZBX_MIN_PERIOD) {
                CProfile::update($idx . '.period', $_REQUEST['period'], PROFILE_TYPE_INT, $idx2);
            }
            if (isset($_REQUEST['stime'])) {
                CProfile::update($idx . '.stime', $_REQUEST['stime'], PROFILE_TYPE_STR, $idx2);
            }
        }
        $_REQUEST['period'] = get_request('period', CProfile::get($idx . '.period', ZBX_PERIOD_DEFAULT, $idx2));
        $_REQUEST['stime'] = get_request('stime', CProfile::get($idx . '.stime', null, $idx2));
    }
    $_REQUEST['period'] = get_request('period', ZBX_PERIOD_DEFAULT);
    $_REQUEST['stime'] = get_request('stime', null);
    if ($_REQUEST['period'] < ZBX_MIN_PERIOD) {
        show_message(S_WARNING . '. ' . S_TIME_PERIOD . SPACE . S_MIN_VALUE_SMALL . ': ' . ZBX_MIN_PERIOD . ' (' . (int) (ZBX_MIN_PERIOD / 3600) . S_HOUR_SHORT . ')');
        $_REQUEST['period'] = ZBX_MIN_PERIOD;
    } else {
        if ($_REQUEST['period'] > ZBX_MAX_PERIOD) {
            show_message(S_WARNING . '. ' . S_TIME_PERIOD . SPACE . S_MAX_VALUE_SMALL . ': ' . ZBX_MAX_PERIOD . ' (' . (int) (ZBX_MAX_PERIOD / 86400) . S_DAY_SHORT . ')');
            $_REQUEST['period'] = ZBX_MAX_PERIOD;
        }
    }
    if (isset($_REQUEST['stime'])) {
        $time = zbxDateToTime($_REQUEST['stime']);
        if ($time + $_REQUEST['period'] > time()) {
            $_REQUEST['stime'] = date('YmdHis', time() - $_REQUEST['period']);
        }
    } else {
        $_REQUEST['stime'] = date('YmdHis', time() - $_REQUEST['period']);
    }
    return $_REQUEST['period'];
}
            $to = zbx_date2str(_('d M Y H:i'), $serviceTime['ts_to']);
            break;
    }
    $row = new CRow(array(array($type, new CVar('times[' . $i . '][type]', $serviceTime['type']), new CVar('times[' . $i . '][ts_from]', $serviceTime['ts_from']), new CVar('times[' . $i . '][ts_to]', $serviceTime['ts_to']), new CVar('times[' . $i . '][note]', $serviceTime['note'])), $from . ' - ' . $to, htmlspecialchars($serviceTime['note']), new CButton('remove', _('Remove'), 'javascript: removeTime(\'' . $i . '\');', 'link_menu')));
    $row->setAttribute('id', 'times_' . $i);
    $servicesTimeTable->addRow($row);
    $i++;
}
$servicesTimeFormList->addRow(_('Service times'), new CDiv($servicesTimeTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// create service time table
$serviceTimeTable = new CTable(null, 'formElementTable');
if ($this->data['new_service_time']['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME) {
    $downtimeSince = date('YmdHis');
    $downtimeTill = date('YmdHis', time() + 86400);
    $downtimeSince = zbxDateToTime($downtimeSince);
    $downtimeTill = zbxDateToTime($downtimeTill);
    // create calendar table
    $timeCalendarTable = new CTable();
    $calendarIcon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $calendarIcon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top -= 203; pos.left += 16; CLNDR['downtime_since'].clndr.clndrshow(pos.top, pos.left); CLNDR['downtime_till'].clndr.clndrhide();");
    // downtime since
    if (isset($_REQUEST['new_service_time']['from'])) {
        $year = get_request('downtime_since_year');
        $month = get_request('downtime_since_month');
        $day = get_request('downtime_since_day');
        $hours = get_request('downtime_since_hour');
        $minutes = get_request('downtime_since_minute');
    } elseif ($downtimeSince > 0) {
        $year = date('Y', $downtimeSince);
        $month = date('m', $downtimeSince);
        $day = date('d', $downtimeSince);
Exemplo n.º 15
0
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
    CProfile::update('web.auditacts.filter.alias', $_REQUEST['alias'], PROFILE_TYPE_STR);
}
/*
 * Display
 */
$effectivePeriod = navigation_bar_calc('web.auditacts.timeline', 0, true);
$data = array('stime' => get_request('stime'), 'alias' => get_request('alias'), 'alerts' => array());
$from = zbxDateToTime($data['stime']);
$till = $from + $effectivePeriod;
// get alerts
$options = array('time_from' => $from, 'time_till' => $till, 'output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'sortfield' => 'alertid', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $config['search_limit'] + 1);
if (!empty($data['alias'])) {
    $users = API::User()->get(array('filter' => array('alias' => $data['alias'])));
    $options['userids'] = zbx_objectValues($users, 'userid');
}
$data['alerts'] = API::Alert()->get($options);
// get paging
$data['paging'] = getPagingLine($data['alerts']);
// get timeline
unset($options['userids'], $options['time_from'], $options['time_till'], $options['selectMediatypes']);
$options['limit'] = 1;
$options['sortorder'] = ZBX_SORT_UP;
$firstAlert = API::Alert()->get($options);
$firstAlert = reset($firstAlert);
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date('YmdHis', !empty($firstAlert) ? $firstAlert['clock'] : time() - SEC_PER_HOUR), 'usertime' => isset($data['stime']) ? date('YmdHis', zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditacts.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
require_once 'include/config.inc.php';
require_once 'include/js.inc.php';
$dstfrm = get_request('dstfrm', 0);
// destination form
$page['title'] = _('Period');
$page['file'] = 'popup_period.php';
$page['scripts'] = array('class.calendar.js');
define('ZBX_PAGE_NO_MENU', 1);
require_once 'include/page_header.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('dstfrm' => array(T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, null), 'config' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3'), NULL), 'period_id' => array(T_ZBX_INT, O_OPT, null, null, null), 'caption' => array(T_ZBX_STR, O_OPT, null, null, null), 'report_timesince' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'report_timetill' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'color' => array(T_ZBX_CLR, O_OPT, null, null, 'isset({save})'), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_STR, O_OPT, null, null, null));
check_fields($fields);
insert_js_function('add_period');
insert_js_function('update_period');
$_REQUEST['report_timesince'] = zbxDateToTime(get_request('report_timesince', date('YmdHis', time() - SEC_PER_DAY)));
$_REQUEST['report_timetill'] = zbxDateToTime(get_request('report_timetill', date('YmdHis')));
$_REQUEST['caption'] = get_request('caption', '');
if (zbx_empty($_REQUEST['caption']) && isset($_REQUEST['report_timesince']) && isset($_REQUEST['report_timetill'])) {
    $_REQUEST['caption'] = zbx_date2str(POPUP_PERIOD_CAPTION_DATE_FORMAT, $_REQUEST['report_timesince']) . ' - ' . zbx_date2str(POPUP_PERIOD_CAPTION_DATE_FORMAT, $_REQUEST['report_timetill']);
}
if (isset($_REQUEST['save'])) {
    if (isset($_REQUEST['period_id'])) {
        insert_js("update_period('" . $_REQUEST['period_id'] . "'," . zbx_jsvalue($_REQUEST['dstfrm']) . "," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['report_timesince'] . "','" . $_REQUEST['report_timetill'] . "','" . $_REQUEST['color'] . "');\n");
    } else {
        insert_js("add_period(" . zbx_jsvalue($_REQUEST['dstfrm']) . "," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['report_timesince'] . "','" . $_REQUEST['report_timetill'] . "','" . $_REQUEST['color'] . "');\n");
    }
} else {
    echo SBR;
    $frmPd = new CFormTable(_('Period'));
    $frmPd->setName('period');
    $frmPd->addVar('dstfrm', $_REQUEST['dstfrm']);
Exemplo n.º 17
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $output = [];
     $items = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'], 'selectHosts' => ['name'], 'itemids' => $this->itemids, 'webitems' => true, 'preservekeys' => true]);
     $items = CMacrosResolverHelper::resolveItemNames($items);
     $stime = zbxDateToTime($this->timeline['stime']);
     $firstItem = reset($items);
     $iv_string = [ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1];
     $iv_numeric = [ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1];
     if ($this->action == HISTORY_VALUES || $this->action == HISTORY_LATEST) {
         $options = ['history' => $firstItem['value_type'], 'itemids' => $this->itemids, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN];
         if ($this->action == HISTORY_LATEST) {
             $options['limit'] = 500;
         } elseif ($this->action == HISTORY_VALUES) {
             $config = select_config();
             // interval start value is non-inclusive, hence the + 1 second
             $options['time_from'] = $stime + 1;
             $options['time_till'] = $stime + $this->timeline['period'];
             $options['limit'] = $config['search_limit'];
         }
         // text log
         if (isset($iv_string[$firstItem['value_type']])) {
             $isManyItems = count($items) > 1;
             $useLogItem = $firstItem['value_type'] == ITEM_VALUE_TYPE_LOG;
             $useEventLogItem = strpos($firstItem['key_'], 'eventlog[') === 0;
             if (empty($this->plaintext)) {
                 $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), $isManyItems ? _('Item') : null, $useLogItem ? (new CColHeader(_('Local time')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Source')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Severity')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Event ID')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Value')]);
             }
             if ($this->filter !== '' && in_array($this->filterTask, [FILTER_TASK_SHOW, FILTER_TASK_HIDE])) {
                 $options['search'] = ['value' => $this->filter];
                 if ($this->filterTask == FILTER_TASK_HIDE) {
                     $options['excludeSearch'] = 1;
                 }
             }
             $options['sortfield'] = 'id';
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $data['value'] = rtrim($data['value'], " \t\r\n");
                 if (empty($this->plaintext)) {
                     $item = $items[$data['itemid']];
                     $host = reset($item['hosts']);
                     $color = null;
                     if ($this->filter !== '') {
                         $haystack = mb_strtolower($data['value']);
                         $needle = mb_strtolower($this->filter);
                         $pos = mb_strpos($haystack, $needle);
                         if ($pos !== false && $this->filterTask == FILTER_TASK_MARK) {
                             $color = $this->markColor;
                         } elseif ($pos === false && $this->filterTask == FILTER_TASK_INVERT_MARK) {
                             $color = $this->markColor;
                         }
                         switch ($color) {
                             case MARK_COLOR_RED:
                                 $color = ZBX_STYLE_RED;
                                 break;
                             case MARK_COLOR_GREEN:
                                 $color = ZBX_STYLE_GREEN;
                                 break;
                             case MARK_COLOR_BLUE:
                                 $color = ZBX_STYLE_BLUE;
                                 break;
                         }
                     }
                     $row = [];
                     $row[] = (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
                     if ($isManyItems) {
                         $row[] = (new CCol($host['name'] . NAME_DELIMITER . $item['name_expanded']))->addClass($color);
                     }
                     if ($useLogItem) {
                         $row[] = $data['timestamp'] != 0 ? (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['timestamp'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
                         // if this is a eventLog item, showing additional info
                         if ($useEventLogItem) {
                             $row[] = (new CCol($data['source']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
                             $row[] = $data['severity'] != 0 ? (new CCol(get_item_logtype_description($data['severity'])))->addClass(ZBX_STYLE_NOWRAP)->addClass(get_item_logtype_style($data['severity'])) : '';
                             $row[] = $data['logeventid'] != 0 ? (new CCol($data['logeventid']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
                         }
                     }
                     $row[] = (new CCol(new CPre(zbx_nl2br($data['value']))))->addClass($color);
                     $historyTable->addRow($row);
                 } else {
                     $output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($data['value']);
                 }
             }
             if (empty($this->plaintext)) {
                 $output[] = $historyTable;
             }
         } else {
             if (empty($this->plaintext)) {
                 $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), _('Value')]);
             }
             $options['sortfield'] = ['itemid', 'clock'];
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $item = $items[$data['itemid']];
                 $value = rtrim($data['value'], " \t\r\n");
                 // format the value as float
                 if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) {
                     sscanf($data['value'], '%f', $value);
                 }
                 // html table
                 if (empty($this->plaintext)) {
                     if ($item['valuemapid']) {
                         $value = applyValueMap($value, $item['valuemapid']);
                     }
                     $historyTable->addRow([(new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP), new CPre(zbx_nl2br($value))]);
                 } else {
                     $output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($value);
                 }
             }
             if (empty($this->plaintext)) {
                 $output[] = $historyTable;
             }
         }
     }
     // time control
     if (!$this->plaintext && str_in_array($this->action, [HISTORY_VALUES, HISTORY_GRAPH, HISTORY_BATCH_GRAPH])) {
         $graphDims = getGraphDims();
         $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($firstItem['itemid']));
         $this->dataId = 'historyGraph';
         $timeControlData = ['periodFixed' => CProfile::get('web.history.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD];
         if (($this->action == HISTORY_GRAPH || $this->action == HISTORY_BATCH_GRAPH) && !isset($iv_string[$firstItem['value_type']])) {
             $containerId = 'graph_cont1';
             $output[] = (new CDiv())->addClass('center')->setId($containerId);
             $timeControlData['id'] = $this->getDataId();
             $timeControlData['containerid'] = $containerId;
             $timeControlData['src'] = $this->getGraphUrl($this->itemids);
             $timeControlData['objDims'] = $graphDims;
             $timeControlData['loadSBox'] = 1;
             $timeControlData['loadImage'] = 1;
             $timeControlData['dynamic'] = 1;
         } else {
             $timeControlData['id'] = $this->getDataId();
             $timeControlData['mainObject'] = 1;
         }
         if ($this->mode == SCREEN_MODE_JS) {
             $timeControlData['dynamic'] = 0;
             return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');';
         } else {
             zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         }
     }
     if (!empty($this->plaintext)) {
         return $output;
     } else {
         if ($this->mode != SCREEN_MODE_JS) {
             $flickerfreeData = ['itemids' => $this->itemids, 'action' => $this->action == HISTORY_BATCH_GRAPH ? HISTORY_GRAPH : $this->action, 'filter' => $this->filter, 'filterTask' => $this->filterTask, 'markColor' => $this->markColor];
             return $this->getOutput($output, true, $flickerfreeData);
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Easy way to view time data.
  *
  * @static
  *
  * @param array		$options
  * @param int		$options['period']
  * @param string	$options['stime']
  * @param string	$options['stimeNow']
  * @param string	$options['starttime']
  * @param string	$options['usertime']
  * @param int		$options['isNow']
  */
 public static function debugTime(array $time = array())
 {
     return 'period=' . zbx_date2age(0, $time['period']) . ', (' . $time['period'] . ')<br/>' . 'starttime=' . date('F j, Y, g:i a', zbxDateToTime($time['starttime'])) . ', (' . $time['starttime'] . ')<br/>' . 'stime=' . date('F j, Y, g:i a', zbxDateToTime($time['stime'])) . ', (' . $time['stime'] . ')<br/>' . 'stimeNow=' . date('F j, Y, g:i a', zbxDateToTime($time['stimeNow'])) . ', (' . $time['stimeNow'] . ')<br/>' . 'usertime=' . date('F j, Y, g:i a', zbxDateToTime($time['usertime'])) . ', (' . $time['usertime'] . ')<br/>' . 'isnow=' . $time['isNow'] . '<br/>';
 }
Exemplo n.º 19
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $output = array();
     $stime = zbxDateToTime($this->timeline['stime']);
     $iv_string = array(ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1);
     $iv_numeric = array(ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1);
     if ($this->action == 'showvalues' || $this->action == 'showlatest') {
         $options = array('history' => $this->item['value_type'], 'itemids' => array_keys($this->items), 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN);
         if ($this->action == 'showlatest') {
             $options['limit'] = 500;
         } elseif ($this->action == 'showvalues') {
             $config = select_config();
             $options['time_from'] = $stime - 10;
             // some seconds to allow script to execute
             $options['time_till'] = $stime + $this->timeline['period'];
             $options['limit'] = $config['search_limit'];
         }
         // text log
         if (isset($iv_string[$this->item['value_type']])) {
             $isManyItems = count($this->items) > 1;
             $useLogItem = $this->item['value_type'] == ITEM_VALUE_TYPE_LOG;
             $useEventLogItem = strpos($this->item['key_'], 'eventlog[') === 0;
             if (empty($this->plaintext)) {
                 $historyTable = new CTableInfo(_('No values found.'));
                 $historyTable->setHeader(array(_('Timestamp'), $isManyItems ? _('Item') : null, $useLogItem ? _('Local time') : null, $useEventLogItem && $useLogItem ? _('Source') : null, $useEventLogItem && $useLogItem ? _('Severity') : null, $useEventLogItem && $useLogItem ? _('Event ID') : null, _('Value')), 'header');
             }
             if (!zbx_empty($this->filter) && in_array($this->filterTask, array(FILTER_TASK_SHOW, FILTER_TASK_HIDE))) {
                 $options['search'] = array('value' => $this->filter);
                 if ($this->filterTask == FILTER_TASK_HIDE) {
                     $options['excludeSearch'] = 1;
                 }
             }
             $options['sortfield'] = 'id';
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $data['value'] = encode_log(trim($data['value'], "\r\n"));
                 if (empty($this->plaintext)) {
                     $item = $this->items[$data['itemid']];
                     $host = reset($item['hosts']);
                     $color = null;
                     if (isset($this->filter) && !zbx_empty($this->filter)) {
                         $contain = zbx_stristr($data['value'], $this->filter);
                         if ($contain && $this->filterTask == FILTER_TASK_MARK) {
                             $color = $this->markColor;
                         }
                         if (!$contain && $this->filterTask == FILTER_TASK_INVERT_MARK) {
                             $color = $this->markColor;
                         }
                         switch ($color) {
                             case MARK_COLOR_RED:
                                 $color = 'red';
                                 break;
                             case MARK_COLOR_GREEN:
                                 $color = 'green';
                                 break;
                             case MARK_COLOR_BLUE:
                                 $color = 'blue';
                                 break;
                         }
                     }
                     $row = array(nbsp(zbx_date2str(_('Y.M.d H:i:s'), $data['clock'])));
                     if ($isManyItems) {
                         $row[] = $host['name'] . NAME_DELIMITER . $item['name_expanded'];
                     }
                     if ($useLogItem) {
                         $row[] = $data['timestamp'] == 0 ? '-' : zbx_date2str(HISTORY_LOG_LOCALTIME_DATE_FORMAT, $data['timestamp']);
                         // if this is a eventLog item, showing additional info
                         if ($useEventLogItem) {
                             $row[] = zbx_empty($data['source']) ? '-' : $data['source'];
                             $row[] = $data['severity'] == 0 ? '-' : new CCol(get_item_logtype_description($data['severity']), get_item_logtype_style($data['severity']));
                             $row[] = $data['logeventid'] == 0 ? '-' : $data['logeventid'];
                         }
                     }
                     $row[] = new CCol($data['value'], 'pre');
                     $newRow = new CRow($row);
                     if (!is_null($color)) {
                         $newRow->setAttribute('class', $color);
                     }
                     $historyTable->addRow($newRow);
                 } else {
                     $output[] = zbx_date2str(HISTORY_LOG_ITEM_PLAINTEXT, $data['clock']);
                     $output[] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n";
                 }
             }
             if (empty($this->plaintext)) {
                 $output[] = $historyTable;
             }
         } else {
             if (empty($this->plaintext)) {
                 $historyTable = new CTableInfo(_('No values found.'));
                 $historyTable->setHeader(array(_('Timestamp'), _('Value')));
             }
             $options['sortfield'] = array('itemid', 'clock');
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $item = $this->items[$data['itemid']];
                 $value = $data['value'];
                 // format the value as float
                 if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) {
                     sscanf($data['value'], '%f', $value);
                 }
                 // html table
                 if (empty($this->plaintext)) {
                     if ($item['valuemapid']) {
                         $value = applyValueMap($value, $item['valuemapid']);
                     }
                     $historyTable->addRow(array(zbx_date2str(HISTORY_ITEM_DATE_FORMAT, $data['clock']), zbx_nl2br($value)));
                 } else {
                     $output[] = zbx_date2str(HISTORY_PLAINTEXT_DATE_FORMAT, $data['clock']);
                     $output[] = "\t" . $data['clock'] . "\t" . htmlspecialchars($value) . "\n";
                 }
             }
             if (empty($this->plaintext)) {
                 $output[] = $historyTable;
             }
         }
     }
     if ($this->action == 'showgraph' && !isset($iv_string[$this->item['value_type']])) {
         $this->dataId = 'historyGraph';
         $containerId = 'graph_cont1';
         $src = 'chart.php?itemid=' . $this->item['itemid'] . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stime'] . $this->getProfileUrlParams();
         $output[] = new CDiv(null, 'center', $containerId);
     }
     // time control
     if (!$this->plaintext && str_in_array($this->action, array('showvalues', 'showgraph'))) {
         $graphDims = getGraphDims();
         $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($this->item['itemid']));
         $timeControlData = array('periodFixed' => CProfile::get('web.history.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
         if (!empty($this->dataId)) {
             $timeControlData['id'] = $this->getDataId();
             $timeControlData['containerid'] = $containerId;
             $timeControlData['src'] = $src;
             $timeControlData['objDims'] = $graphDims;
             $timeControlData['loadSBox'] = 1;
             $timeControlData['loadImage'] = 1;
             $timeControlData['dynamic'] = 1;
         } else {
             $this->dataId = 'historyGraph';
             $timeControlData['id'] = $this->getDataId();
             $timeControlData['mainObject'] = 1;
         }
         if ($this->mode == SCREEN_MODE_JS) {
             $timeControlData['dynamic'] = 0;
             return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');';
         } else {
             zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');
         }
     }
     if (!empty($this->plaintext)) {
         return $output;
     } else {
         if ($this->mode != SCREEN_MODE_JS) {
             $flickerfreeData = array('itemids' => $this->itemids, 'action' => $this->action, 'filter' => $this->filter, 'filterTask' => $this->filterTask, 'markColor' => $this->markColor);
             return $this->getOutput($output, true, $flickerfreeData);
         }
     }
 }
Exemplo n.º 20
0
        }
    } else {
        $stime = date(TIMESTAMP_FORMAT, time() - $period);
    }
} else {
    $sourceName = $source == EVENT_OBJECT_TRIGGER ? 'trigger' : 'discovery';
    if (hasRequest('period')) {
        $_REQUEST['period'] = getRequest('period', ZBX_PERIOD_DEFAULT);
        CProfile::update('web.events.' . $sourceName . '.period', getRequest('period'), PROFILE_TYPE_INT);
    } else {
        $_REQUEST['period'] = CProfile::get('web.events.' . $sourceName . '.period');
    }
    $period = navigation_bar_calc();
    $stime = getRequest('stime');
}
$from = zbxDateToTime($stime);
$till = $from + $period;
/*
 * Display
 */
if ($source == EVENT_SOURCE_TRIGGERS) {
    if ($triggerId != 0 && hasRequest('filter_set')) {
        $host = API::Host()->get(['output' => ['hostid'], 'selectGroups' => ['groupid'], 'triggerids' => [$triggerId], 'limit' => 1]);
        $host = reset($host);
        $hostid = $host['hostid'];
        $group = reset($host['groups']);
        $groupid = $group['groupid'];
    } else {
        $groupid = getRequest('groupid');
        $hostid = getRequest('hostid');
    }
Exemplo n.º 21
0
        unset($_REQUEST['periods'][$pid]);
    }
    unset($_REQUEST['delete_period'], $_REQUEST['group_pid']);
}
// item validation
$config = $_REQUEST['config'] = get_request('config', 1);
// items array validation
if ($config != 3) {
    $items = get_request('items');
    $validItems = validateBarReportItems($items);
    if ($config == 2) {
        $validPeriods = validateBarReportPeriods(get_request('periods'));
    }
}
$_REQUEST['report_timesince'] = zbxDateToTime(get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY)));
$_REQUEST['report_timetill'] = zbxDateToTime(get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME, time())));
$rep6_wdgt = new CWidget();
$r_form = new CForm();
$cnfCmb = new CComboBox('config', $config, 'submit();');
$cnfCmb->addItem(1, _('Distribution of values for multiple periods'));
$cnfCmb->addItem(2, _('Distribution of values for multiple items'));
$cnfCmb->addItem(3, _('Compare values for multiple periods'));
$r_form->addItem(array(_('Reports') . SPACE, $cnfCmb));
$rep6_wdgt->addPageHeader(_('Bar reports'));
$rep6_wdgt->addHeader(_('Report'), $r_form);
$rep6_wdgt->addItem(BR());
$rep_tab = new CTable();
$rep_tab->setCellPadding(3);
$rep_tab->setCellSpacing(3);
$rep_tab->setAttribute('border', 0);
switch ($config) {
        $fromDate = zbxDateToTime($downtimeSince);
        $serviceTimeFrom = $downtimeSince;
    }
    $servicesForm->addVar('new_service_time[from]', $serviceTimeFrom);
    // downtime till
    if (isset($_REQUEST['new_service_time']['to'])) {
        $toYear = getRequest('new_service_time_to_year');
        $toMonth = getRequest('new_service_time_to_month');
        $toDay = getRequest('new_service_time_to_day');
        $toHours = getRequest('new_service_time_to_hour');
        $toMinutes = getRequest('new_service_time_to_minute');
        $toDate = array('y' => $toYear, 'm' => $toMonth, 'd' => $toDay, 'h' => $toHours, 'i' => $toMinutes);
        $serviceTimeTo = $toYear . $toMonth . $toDay . $toHours . $toMinutes;
    } else {
        $downtimeTill = date(TIMESTAMP_FORMAT_ZERO_TIME, time() + SEC_PER_DAY);
        $toDate = zbxDateToTime($downtimeTill);
        $serviceTimeTo = $downtimeTill;
    }
    $servicesForm->addVar('new_service_time[to]', $serviceTimeTo);
    // create calendar table
    $timeCalendarTable = new CTable();
    $noteTextBox = new CTextBox('new_service_time[note]', '', ZBX_TEXTBOX_STANDARD_SIZE);
    $noteTextBox->setAttribute('placeholder', _('short description'));
    $timeCalendarTable->addRow(array(_('Note'), $noteTextBox));
    $timeCalendarTable->addRow(array(_('From'), createDateSelector('new_service_time_from', $fromDate, 'new_service_time_to')));
    $timeCalendarTable->addRow(array(_('Till'), createDateSelector('new_service_time_to', $toDate, 'new_service_time_from')));
    $serviceTimeTable->addRow($timeCalendarTable);
} else {
    $weekFromComboBox = new CComboBox('new_service_time[from_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['from_week'] : 0);
    $weekToComboBox = new CComboBox('new_service_time[to_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['to_week'] : 0);
    for ($dow = 0; $dow < 7; $dow++) {
Exemplo n.º 23
0
    $_REQUEST['filter_groupid'] = get_request('filter_groupid', 0);
    $_REQUEST['filter_hostid'] = get_request('filter_hostid', 0);
    $_REQUEST['filter_timesince'] = get_request('filter_timesince', CProfile::get('web.avail_report.filter.timesince', 0));
    $_REQUEST['filter_timetill'] = get_request('filter_timetill', CProfile::get('web.avail_report.filter.timetill', 0));
}
if ($_REQUEST['filter_timetill'] > 0 && $_REQUEST['filter_timesince'] > $_REQUEST['filter_timetill']) {
    $tmp = $_REQUEST['filter_timesince'];
    $_REQUEST['filter_timesince'] = $_REQUEST['filter_timetill'];
    $_REQUEST['filter_timetill'] = $tmp;
}
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
    CProfile::update('web.avail_report.filter.timesince', $_REQUEST['filter_timesince'], PROFILE_TYPE_STR);
    CProfile::update('web.avail_report.filter.timetill', $_REQUEST['filter_timetill'], PROFILE_TYPE_STR);
}
$_REQUEST['filter_timesince'] = zbxDateToTime($_REQUEST['filter_timesince']);
$_REQUEST['filter_timetill'] = zbxDateToTime($_REQUEST['filter_timetill']);
$_REQUEST['groupid'] = $_REQUEST['filter_groupid'];
$_REQUEST['hostid'] = $_REQUEST['filter_hostid'];
// --------------
$config = get_request('config', CProfile::get('web.avail_report.config', 0));
CProfile::update('web.avail_report.config', $config, PROFILE_TYPE_INT);
$params = array();
$options = array('allow_all_hosts', 'with_items');
if (0 == $config) {
    array_push($options, 'monitored_hosts');
} else {
    array_push($options, 'templated_hosts');
}
if (!$ZBX_WITH_ALL_NODES) {
    array_push($options, 'only_current_node');
}
Exemplo n.º 24
0
        $src = 'chart6.php?graphid=' . $_REQUEST['graphid'];
    } else {
        $loadSBox = 1;
        $scrollWidthByImage = 1;
        $containerid = 'graph_cont1';
        $src = 'chart2.php?graphid=' . $_REQUEST['graphid'];
    }
    $graph_cont = new CCol();
    $graph_cont->setAttribute('id', $containerid);
    $table->addRow($graph_cont);
    $icon = get_icon('favourite', array('fav' => 'web.favorite.graphids', 'elname' => 'graphid', 'elid' => $_REQUEST['graphid']));
    $fs_icon = get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']));
    $rst_icon = get_icon('reset', array('id' => $_REQUEST['graphid']));
    array_push($icons, $icon, $rst_icon, $fs_icon);
    // NAV BAR
    $utime = zbxDateToTime($_REQUEST['stime']);
    $starttime = get_min_itemclock_by_graphid($_REQUEST['graphid']);
    if ($utime < $starttime) {
        $starttime = $utime;
    }
    $timeline = array('starttime' => date('YmdHis', $starttime), 'period' => $effectiveperiod, 'usertime' => date('YmdHis', $utime + $effectiveperiod));
    $dom_graph_id = 'graph';
    $objData = array('id' => $_REQUEST['graphid'], 'domid' => $dom_graph_id, 'containerid' => $containerid, 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => $loadSBox, 'loadImage' => 1, 'loadScroll' => 1, 'scrollWidthByImage' => $scrollWidthByImage, 'dynamic' => 1);
    zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
    zbx_add_post_js('timeControl.processObjects();');
}
$charts_wdgt->addPageHeader(S_GRAPHS_BIG, $icons);
$charts_wdgt->addHeader($header, $r_form);
$charts_wdgt->addItem(BR());
$charts_wdgt->addItem($table);
$charts_wdgt->show();
Exemplo n.º 25
0
/**
 * Correcting adding one unix timestamp to another.
 *
 * @param int		$sec
 * @param mixed		$unixtime	Can accept values:
 *									1) int - unix timestamp,
 *									2) string - date in YmdHis or YmdHi formats,
 *									3) null - current unixtime stamp will be used
 *
 * @return int
 */
function zbxAddSecondsToUnixtime($sec, $unixtime)
{
    return strtotime('+' . $sec . ' seconds', zbxDateToTime($unixtime));
}
Exemplo n.º 26
0
if (!hasRequest('filter_rst')) {
    $_REQUEST['filter_groupid'] = getRequest('filter_groupid', CProfile::get('web.avail_report.' . $availabilityReportMode . '.groupid', 0));
    $_REQUEST['filter_hostid'] = getRequest('filter_hostid', CProfile::get('web.avail_report.' . $availabilityReportMode . '.hostid', 0));
    $_REQUEST['filter_timesince'] = getRequest('filter_timesince', CProfile::get('web.avail_report.' . $availabilityReportMode . '.timesince', 0));
    $_REQUEST['filter_timetill'] = getRequest('filter_timetill', CProfile::get('web.avail_report.' . $availabilityReportMode . '.timetill', 0));
}
CProfile::update('web.avail_report.' . $availabilityReportMode . '.groupid', getRequest('filter_groupid', 0), PROFILE_TYPE_ID);
CProfile::update('web.avail_report.' . $availabilityReportMode . '.timesince', getRequest('filter_timesince', 0), PROFILE_TYPE_STR);
CProfile::update('web.avail_report.' . $availabilityReportMode . '.timetill', getRequest('filter_timetill', 0), PROFILE_TYPE_STR);
CProfile::update('web.avail_report.' . $availabilityReportMode . '.hostid', getRequest('filter_hostid', 0), PROFILE_TYPE_ID);
$config = select_config();
if ($_REQUEST['filter_timetill'] > 0 && $_REQUEST['filter_timesince'] > $_REQUEST['filter_timetill']) {
    zbx_swap($_REQUEST['filter_timesince'], $_REQUEST['filter_timetill']);
}
$_REQUEST['filter_timesince'] = zbxDateToTime($_REQUEST['filter_timesince'] ? $_REQUEST['filter_timesince'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY));
$_REQUEST['filter_timetill'] = zbxDateToTime($_REQUEST['filter_timetill'] ? $_REQUEST['filter_timetill'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time()));
/*
 * Header
 */
$triggerData = isset($_REQUEST['triggerid']) ? API::Trigger()->get(array('triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND, 'expandDescription' => true)) : null;
$reportWidget = new CWidget();
$reportWidget->addPageHeader(_('AVAILABILITY REPORT'));
if ($triggerData) {
    $triggerData = reset($triggerData);
    $host = reset($triggerData['hosts']);
    $triggerData['hostid'] = $host['hostid'];
    $triggerData['hostname'] = $host['name'];
    $reportWidget->addHeader(array(new CLink($triggerData['hostname'], '?filter_groupid=' . $_REQUEST['filter_groupid']), NAME_DELIMITER, $triggerData['description']), SPACE);
    $table = new CTableInfo(null, 'graph');
    $table->addRow(new CImg('chart4.php?triggerid=' . $_REQUEST['triggerid']));
    $reportWidget->addItem(BR());
Exemplo n.º 27
0
$options = array('output' => API_OUTPUT_EXTEND, 'sortfield' => 'eventid', 'sortorder' => ZBX_SORT_UP, 'nopermissions' => 1, 'limit' => 1);
if ($source == EVENT_SOURCE_DISCOVERY) {
    $options['source'] = EVENT_SOURCE_DISCOVERY;
} else {
    if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) {
        $options['object'] = EVENT_OBJECT_TRIGGER;
        $options['triggerids'] = $_REQUEST['triggerid'];
    }
}
$firstEvent = CEvent::get($options);
// }}} CHECK IF EVENTS EXISTS
$_REQUEST['period'] = get_request('period', 604800);
// 1 week
$effectiveperiod = navigation_bar_calc();
$bstime = $_REQUEST['stime'];
$from = zbxDateToTime($_REQUEST['stime']);
$till = $from + $effectiveperiod;
if (empty($firstEvent)) {
    $starttime = null;
    $events = array();
    $paging = getPagingLine($events);
} else {
    $config = select_config();
    $firstEvent = reset($firstEvent);
    $starttime = $firstEvent['clock'];
    if ($source == EVENT_SOURCE_DISCOVERY) {
        $options = array('source' => EVENT_SOURCE_DISCOVERY, 'time_from' => $from, 'time_till' => $till, 'output' => API_OUTPUT_SHORTEN, 'sortfield' => 'eventid', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $config['search_limit'] + 1);
        $dsc_events = CEvent::get($options);
        $paging = getPagingLine($dsc_events);
        $options = array('source' => EVENT_SOURCE_DISCOVERY, 'eventids' => zbx_objectValues($dsc_events, 'eventid'), 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'select_triggers' => API_OUTPUT_EXTEND, 'select_items' => API_OUTPUT_EXTEND);
        $dsc_events = CEvent::get($options);
Exemplo n.º 28
0
$queryData = true;
$firstAlert = null;
if ($data['alias']) {
    $user = API::User()->get(array('output' => array('userid'), 'filter' => array('alias' => $data['alias'])));
    if ($user) {
        $user = reset($user);
    } else {
        $queryData = false;
    }
}
// fetch alerts for different objects and sources and combine them in a single stream
if ($queryData) {
    foreach (eventSourceObjects() as $eventSource) {
        $data['alerts'] = array_merge($data['alerts'], API::Alert()->get(array('output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'userids' => $data['alias'] ? $user['userid'] : null, 'time_from' => $from, 'time_till' => $till, 'eventsource' => $eventSource['source'], 'eventobject' => $eventSource['object'], 'limit' => $config['search_limit'] + 1)));
    }
    CArrayHelper::sort($data['alerts'], array(array('field' => 'alertid', 'order' => ZBX_SORT_DOWN)));
    $data['alerts'] = array_slice($data['alerts'], 0, $config['search_limit'] + 1);
    // get first alert
    if ($user) {
        $firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock' . ' FROM alerts a' . ' WHERE a.userid=' . zbx_dbstr($user['userid'])));
    }
}
// padding
$data['paging'] = getPagingLine($data['alerts']);
// timeline
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date(TIMESTAMP_FORMAT, $firstAlert ? $firstAlert['clock'] : ZBX_MAX_PERIOD), 'usertime' => isset($data['stime']) ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditacts.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemplo n.º 29
0
        case AUDIT_ACTION_ENABLE:
            $action = _('Enabled');
            break;
        case AUDIT_ACTION_DISABLE:
            $action = _('Disabled');
            break;
        default:
            $action = _('Unknown action');
    }
    $audit['action'] = $action;
    $audit['resourcetype'] = audit_resource2str($audit['resourcetype']);
    if (empty($audit['details'])) {
        $audit['details'] = DBfetchArray(DBselect('SELECT ad.table_name,ad.field_name,ad.oldvalue,ad.newvalue' . ' FROM auditlog_details ad' . ' WHERE ad.auditid=' . zbx_dbstr($audit['auditid'])));
    }
    $data['actions'][$audit['auditid']] = $audit;
}
if (!empty($data['actions'])) {
    order_result($data['actions'], 'clock', ZBX_SORT_DOWN);
}
// get paging
$data['paging'] = getPagingLine($data['actions'], ZBX_SORT_DOWN, new CUrl('auditlogs.php'));
// get timeline
unset($sqlWhere['from'], $sqlWhere['till']);
$sql = 'SELECT MIN(a.clock) AS clock' . ' FROM auditlog a,users u' . ' WHERE a.userid=u.userid' . implode('', $sqlWhere);
$firstAudit = DBfetch(DBselect($sql, $config['search_limit'] + 1));
$data['timeline'] = ['period' => $effectivePeriod, 'starttime' => date(TIMESTAMP_FORMAT, $firstAudit ? $firstAudit['clock'] : null), 'usertime' => isset($_REQUEST['stime']) ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null];
// render view
$auditView = new CView('administration.auditlogs.list', $data);
$auditView->render();
$auditView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemplo n.º 30
0
function get_timeperiod_form()
{
    $tblPeriod = new CTableInfo();
    /* init new_timeperiod variable */
    $new_timeperiod = get_request('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod) && isset($new_timeperiod['id'])) {
        $tblPeriod->addItem(new Cvar('new_timeperiod[id]', $new_timeperiod['id']));
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // START TIME
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / 3600);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * 3600) / 60);
    }
    //--
    // PERIOD
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / 86400);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * 86400) / 3600);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * 86400 - $new_timeperiod['period_hours'] * 3600) / 60);
    }
    //--
    // DAYSOFWEEK
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    //--
    // MONTHS
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    //--
    $bit_dayofweek = zbx_str_revert($dayofweek);
    $bit_month = zbx_str_revert($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, S_ONE_TIME_ONLY);
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $tblPeriod->addRow(array(S_PERIOD_TYPE, $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new Cvar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(S_EVERY_DAY_S, new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } else {
        if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
            $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
            $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
            $tblPeriod->addItem(new Cvar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
            $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
            $tblPeriod->addRow(array(S_EVERY_WEEK_S, new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
            $tabDays = new CTable();
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), S_MONDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), S_TUESDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), S_WEDNESDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), S_THURSDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), S_FRIDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), S_SATURDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), S_SUNDAY));
            $tblPeriod->addRow(array(S_DAY_OF_WEEK, $tabDays));
        } else {
            if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
                $tblPeriod->addItem(new Cvar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
                $tabMonths = new CTable();
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), S_JANUARY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), S_JULY));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), S_FEBRUARY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), S_AUGUST));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), S_MARCH, SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), S_SEPTEMBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), S_APRIL, SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), S_OCTOBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), S_MAY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), S_NOVEMBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), S_JUNE, SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), S_DECEMBER));
                $tblPeriod->addRow(array(S_MONTH, $tabMonths));
                $radioDaily = new CTag('input');
                $radioDaily->setAttribute('type', 'radio');
                $radioDaily->setAttribute('name', 'new_timeperiod[month_date_type]');
                $radioDaily->setAttribute('value', '0');
                $radioDaily->setAttribute('onclick', 'submit()');
                $radioDaily2 = new CTag('input');
                $radioDaily2->setAttribute('type', 'radio');
                $radioDaily2->setAttribute('name', 'new_timeperiod[month_date_type]');
                $radioDaily2->setAttribute('value', '1');
                $radioDaily2->setAttribute('onclick', 'submit()');
                if ($new_timeperiod['month_date_type']) {
                    $radioDaily2->setAttribute('checked', 'checked');
                } else {
                    $radioDaily->setAttribute('checked', 'checked');
                }
                $tblPeriod->addRow(array(S_DATE, array($radioDaily, S_DAY, SPACE, SPACE, $radioDaily2, S_DAY_OF_WEEK)));
                if ($new_timeperiod['month_date_type'] > 0) {
                    $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
                    $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
                    $cmbCount->addItem(1, S_FIRST);
                    $cmbCount->addItem(2, S_SECOND);
                    $cmbCount->addItem(3, S_THIRD);
                    $cmbCount->addItem(4, S_FOURTH);
                    $cmbCount->addItem(5, S_LAST);
                    $td = new CCol($cmbCount);
                    $td->setColSpan(2);
                    $tabDays = new CTable();
                    $tabDays->addRow($td);
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), S_MONDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), S_TUESDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), S_WEDNESDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), S_THURSDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), S_FRIDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), S_SATURDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), S_SUNDAY));
                    $tblPeriod->addRow(array(S_DAY_OF_WEEK, $tabDays));
                } else {
                    $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
                    $tblPeriod->addRow(array(S_DAY_OF_MONTH, new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
                }
            } else {
                $tblPeriod->addItem(new Cvar('new_timeperiod[every]', $new_timeperiod['every']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
                $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
                $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[hour]', $new_timeperiod['hour']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[minute]', $new_timeperiod['minute']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
                /***********************************************************/
                $tblPeriod->addItem(new Cvar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
                $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
                $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['new_timeperiod_date'].clndr.clndrshow(pos.top,pos.left);");
                $filtertimetab = new CTable(null, 'calendar');
                $filtertimetab->setAttribute('width', '10%');
                $filtertimetab->setCellPadding(0);
                $filtertimetab->setCellSpacing(0);
                $start_date = zbxDateToTime($new_timeperiod['start_date']);
                $filtertimetab->addRow(array(new CNumericBox('new_timeperiod_day', $start_date > 0 ? date('d', $start_date) : '', 2), '/', new CNumericBox('new_timeperiod_month', $start_date > 0 ? date('m', $start_date) : '', 2), '/', new CNumericBox('new_timeperiod_year', $start_date > 0 ? date('Y', $start_date) : '', 4), SPACE, new CNumericBox('new_timeperiod_hour', $start_date > 0 ? date('H', $start_date) : '', 2), ':', new CNumericBox('new_timeperiod_minute', $start_date > 0 ? date('i', $start_date) : '', 2), $clndr_icon));
                zbx_add_post_js('create_calendar(null,' . '["new_timeperiod_day","new_timeperiod_month","new_timeperiod_year","new_timeperiod_hour","new_timeperiod_minute"],' . '"new_timeperiod_date",' . '"new_timeperiod[start_date]");');
                $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['mntc_active_till'].clndr.clndrshow(pos.top,pos.left);");
                $tblPeriod->addRow(array(S_DATE, $filtertimetab));
                //-------
            }
        }
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tabTime = new CTable(null, 'calendar');
        $tabTime->addRow(array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)));
        $tblPeriod->addRow(array(S_AT . SPACE . '(' . S_HOUR . ':' . S_MINUTE . ')', $tabTime));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours']);
    for ($i = 0; $i < 25; $i++) {
        $perHours->addItem($i, $i . SPACE);
    }
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes']);
    for ($i = 0; $i < 60; $i++) {
        $perMinutes->addItem($i, $i . SPACE);
    }
    $tblPeriod->addRow(array(S_MAINTENANCE_PERIOD_LENGTH, array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), S_DAYS . SPACE . SPACE, $perHours, SPACE . S_HOURS, $perMinutes, SPACE . S_MINUTES)));
    //			$tabPeriod = new CTable();
    //			$tabPeriod->addRow(S_DAYS)
    //			$tblPeriod->addRow(array(S_AT.SPACE.'('.S_HOUR.':'.S_MINUTE.')', $tabTime));
    $td = new CCol(array(new CButton('add_timeperiod', $new ? S_SAVE : S_ADD), SPACE, new CButton('cancel_new_timeperiod', S_CANCEL)));
    $td->setAttribute('colspan', '3');
    $td->setAttribute('style', 'text-align: right;');
    $tblPeriod->setFooter($td);
    return $tblPeriod;
}