<?php header("Content-Type: text/html; charset=utf-8", true); /* * Arquivo de exportação de dados do zabbix-extras */ require_once 'include/config.inc.php'; require_once 'include/zbxe_visual_imp.php'; $campos = "lang, tx_original, tx_new"; $res = DBselect("SELECT {$campos} FROM zbxe_translation"); $i = 0; while ($row = DBfetch($res)) { echo "preparaQuery(\"INSERT INTO zbxe_translation ({$campos}) VALUES(" . quotestr($row['lang']) . ", " . quotestr($row['tx_original']) . ", " . quotestr($row['tx_new']) . ")\");<br>"; } $campos = "userid, tx_option, tx_value, st_ativo"; $res = DBselect("SELECT {$campos} FROM zbxe_preferences"); $i = 0; while ($row = DBfetch($res)) { echo "preparaQuery(\"INSERT INTO zbxe_preferences ({$campos}) VALUES(" . quotestr($row['userid']) . ", " . quotestr($row['tx_option']) . ", " . quotestr($row['tx_value']) . ", " . quotestr($row['st_ativo']) . ")\");<br>"; }
/** * array of values to csv-formatted string for one line, order defiled by $fields * @param array $row hash values for csv line * @param array $fields plain array - field names * @return string one csv line with properly quoted values and "\n" at the end */ public static function to_csv_row($row, $fields) { $result = ''; foreach ($fields as $key => $fld) { $str = $row[$fld]; if (preg_match('/[",]/', $str)) { $str = quotestr($str); } $result .= ($result ? "," : "") . $str; } return $result . "\n"; }
function zbxeShowTranslation() { //global $ZBXE_VAR; //$userid = ($id != "" ? 0 : CWebUser::$data['userid']); $userFormExtra = new CFormList('userFormExtraTra'); $userFormExtra->addRow(_zeT('English String'), _zeT('Translation for') . " " . CWebUser::$data['lang']); $res = DBselect('select tx_original, tx_new from zbxe_translation where lang=' . quotestr(CWebUser::$data['lang']) . ' order by tx_original'); $i = 0; while ($row = DBfetch($res)) { $tx_new = new CTextBox("translate[{$i}][new]", $row['tx_new'], ZBX_TEXTBOX_STANDARD_SIZE); $tx_original = new CInput('hidden', "translate[{$i}][original]", $row['tx_original']); $userFormExtra->addRow($row['tx_original'], array($tx_new, $tx_original)); $i++; } return $userFormExtra; }
} $table = new CTableInfo(); switch ($formato) { case 'csv': $table->setHeader(array(_zeT("Data"))); break; case 'html': $table->setHeader(array(_zeT('Instant'), _zeT('Value'), _zeT('Type'))); break; } $points = ""; $descUnidade = ""; for ($i = 0; $i < $cont; $i++) { switch ($formato) { case 'csv': $table->addRow(array(quotestr($report[$i]['momento']) . ";" . quotestr($report[$i]['valor']) . ";" . quotestr($report[$i]['tipo']) . ";")); break; case 'html': $momento = new CCol($report[$i]['momento'], 1); $valor = convert_units(array('value' => $report[$i]['valor'], 'units' => $unidade)); $valor = new CCol($valor, 1); $tipo = new CCol($report[$i]['tipo'], 1); $table->addRow(array($momento, $valor, $tipo)); break; } // Tratando o valor para o gráfico caso seja formatação de Byte if ($unidade == 'B') { $maximo = $maximo - 1; if ($maximo < 1024) { $fator = 1; $descUnidade = 'B';
if ($view == "G") { $table->setHeader(array(_("Host"), _zeT("History Costs"), _zeT("Trends Costs"), _zeT("Storage Costs"), _zeT("VPS"))); } else { $table->setHeader(array(_("Host"), _("Item"), _("Key"), _("Delay"), _("History"), _("Trends"), _("Status"), _zeT("History Costs"), _zeT("Trends Costs"), _zeT("Storage Costs"), _zeT("VPS"))); } break; } $linha = array(); $linhasDesc = " " . _zeT("rows"); $cont2 = count($report[0]) - 1; for ($i = 0; $i < $cont; $i++) { switch ($formato) { case 'csv': $linhaCSV = ""; for ($x = 0; $x < $cont2; $x++) { $linhaCSV .= quotestr($report[$i][$x] . ($x == 7 || $x == 8 ? $linhasDesc : " ")) . ";"; } $table->addRow(array($linhaCSV)); break; case 'html': for ($x = 0; $x < $cont2; $x++) { $linha[$x] = new CCol($report[$i][$x] . ($x == 7 || $x == 8 ? $linhasDesc : " "), 1); } $table->addRow($linha); break; } } $descricao = new CCol(''); $descricao->setAttribute('colspan', '6'); $descricao->setAttribute('align', 'right'); if ($formato !== 'csv') {
function zbxeSubMenus($menu) { $query = 'select tx_value from zbxe_preferences where tx_option = ' . quotestr($menu); $res = DBselect($query); $retorno = array(); $i = 0; while ($row = DBfetch($res)) { $tmp = explode("|", $row['tx_value']); $retorno[$i] = array('url' => $tmp[0], 'label' => _zeT($tmp[1])); $i += 1; } return $retorno; }