Commit 955d9875babcd7cd5868d52aedf5ab40b5c37184

Authored by anderson.peterle@previdencia.gov.br
1 parent a8ce751a
Exists in master and in 1 other branch 3.1

Adequacoes para futuro uso do modulo de Suporte Remoto Seguro(srCACIC). Opcoes p…

…ara geracao dos relatorios em PDF, ODS e CSV. Redimensionamento de colunas para informacoes patrimoniais. Melhorias em algumas funcoes genericas contidas no arquivo library.php

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/gerente@615 fecfc0c7-e812-0410-ae72-849f08638ee7
admin/consulta_especial.php
... ... @@ -82,6 +82,7 @@ if ($_POST['frmExtractFileTGZ'])
82 82 {
83 83 $arrExtractFileTGZ = explode('#',$i);
84 84 $strExtractFileTGZ = "tar -xvzf ".$_POST['frmPath'].str_replace('_ponto_','.',$arrExtractFileTGZ[1]);
  85 + echo 'Tentarei executar "'.$strExtractFileTGZ.'"<br>';
85 86 $cmdExtractFileTGZ = shell_exec($strExtractFileTGZ);
86 87 }
87 88 }
... ... @@ -94,6 +95,30 @@ if ($_POST[&#39;frmExtractFileTGZ&#39;])
94 95 }
95 96 }
96 97  
  98 +if ($_POST['frmCompactFileTGZ'])
  99 + {
  100 + if (PHP_OS == "Linux" || PHP_OS == "Unix")
  101 + {
  102 + foreach($HTTP_POST_VARS as $i => $v)
  103 + {
  104 + $intPos = stripos2($i,'compactFileTGZ#',false);
  105 + if ($intPos)
  106 + {
  107 + $arrCompactFileTGZ = explode('#',$i);
  108 + $strCompactFileTGZ = "tar -cvzf CompactFile.tgz ".$_POST['frmPath'].str_replace('_ponto_','.',$arrCompactFileTGZ[1]);
  109 + echo 'Tentarei executar "'.$strCompactFileTGZ.'"<br>';
  110 + $cmdExtractFileTGZ = shell_exec($strCompactFileTGZ);
  111 + }
  112 + }
  113 + }
  114 + else
  115 + {
  116 + ?>
  117 + <script language="javascript">alert('ATENÇÃO: Este recurso está disponível apenas para Servidor com LINUX!');</script>
  118 + <?
  119 + }
  120 + }
  121 +
97 122 if ($_SERVER['REMOTE_ADDR']=='10.71.0.58')
98 123 echo $_POST['frmCreateNewFolder'].'<br>';
99 124 if ($_POST['frmCreateNewFolder'])
... ... @@ -188,6 +213,9 @@ function deleteFile()
188 213  
189 214 if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
190 215 window.document.forms[0].elements[j].checked = false;
  216 +
  217 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  218 + window.document.forms[0].elements[j].checked = false;
191 219  
192 220 }
193 221  
... ... @@ -222,7 +250,9 @@ function timeStamp()
222 250  
223 251 if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
224 252 window.document.forms[0].elements[j].checked = false;
225   -
  253 +
  254 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  255 + window.document.forms[0].elements[j].checked = false;
226 256 }
227 257  
228 258 if (intFilesToTimeStamp > 0)
... ... @@ -281,7 +311,9 @@ function changePermissions()
281 311  
282 312 if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
283 313 window.document.forms[0].elements[j].checked = false;
284   -
  314 +
  315 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  316 + window.document.forms[0].elements[j].checked = false;
285 317 }
286 318  
287 319 if (intFilesToChangePermissions > 0)
... ... @@ -308,6 +340,89 @@ function changePermissions()
308 340 }
309 341 }
310 342  
  343 +function extractFileTGZ()
  344 + {
  345 + var intFilesToExtract = 0;
  346 + for (j=0;j<window.document.forms[0].elements.length;j++)
  347 + {
  348 + if (window.document.forms[0].elements[j].id.substring(0,11) == 'deleteFile#' && window.document.forms[0].elements[j].checked)
  349 + window.document.forms[0].elements[j].checked = false;
  350 +
  351 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'touchTimeStamp#' && window.document.forms[0].elements[j].checked)
  352 + window.document.forms[0].elements[j].checked = false;
  353 +
  354 + if (window.document.forms[0].elements[j].id.substring(0,18) == 'changePermissions#' && window.document.forms[0].elements[j].checked)
  355 + window.document.forms[0].elements[j].checked = false;
  356 +
  357 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
  358 + intFilesToExtract ++;
  359 +
  360 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  361 + window.document.forms[0].elements[j].checked = false;
  362 + }
  363 +
  364 + if (intFilesToExtract > 0)
  365 + {
  366 +
  367 + if (confirm('Confirma EXTRAÇÃO DO'+(intFilesToExtract == 1?'':'S') + ' ARQUIVO'+(intFilesToExtract == 1?'':'S') + ' SELECIONADO'+(intFilesToExtract == 1?'':'S') + '?'))
  368 + {
  369 + for (j=0;j<window.document.forms[0].elements.length;j++)
  370 + if (window.document.forms[0].elements[j].name == 'frmExtractFileTGZ')
  371 + window.document.forms[0].elements[j].value = 'A';
  372 +
  373 + window.document.forms[0].submit();
  374 + }
  375 + else
  376 + return false;
  377 + }
  378 + else
  379 + {
  380 + alert('ATENÇÃO: É necessário marcar algum ítem para extração!');
  381 + return false;
  382 + }
  383 + }
  384 +function compactFileTGZ()
  385 + {
  386 + var intFilesToCompact = 0;
  387 + for (j=0;j<window.document.forms[0].elements.length;j++)
  388 + {
  389 + if (window.document.forms[0].elements[j].id.substring(0,11) == 'deleteFile#' && window.document.forms[0].elements[j].checked)
  390 + window.document.forms[0].elements[j].checked = false;
  391 +
  392 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'touchTimeStamp#' && window.document.forms[0].elements[j].checked)
  393 + window.document.forms[0].elements[j].checked = false;
  394 +
  395 + if (window.document.forms[0].elements[j].id.substring(0,18) == 'changePermissions#' && window.document.forms[0].elements[j].checked)
  396 + window.document.forms[0].elements[j].checked = false;
  397 +
  398 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
  399 + window.document.forms[0].elements[j].checked = false;
  400 +
  401 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  402 + intFilesToCompact ++;
  403 + }
  404 +
  405 + if (intFilesToCompact > 0)
  406 + {
  407 +
  408 + if (confirm('Confirma COMPACTAÇÃO DO'+(intFilesToCompact == 1?'':'S') + ' ITE'+(intFilesToCompact == 1?'M':'NS') + ' SELECIONADO'+(intFilesToCompact == 1?'':'S') + '?'))
  409 + {
  410 + for (j=0;j<window.document.forms[0].elements.length;j++)
  411 + if (window.document.forms[0].elements[j].name == 'frmCompactFileTGZ')
  412 + window.document.forms[0].elements[j].value = 'A';
  413 +
  414 + window.document.forms[0].submit();
  415 + }
  416 + else
  417 + return false;
  418 + }
  419 + else
  420 + {
  421 + alert('ATENÇÃO: É necessário marcar algum ítem para compactação!');
  422 + return false;
  423 + }
  424 + }
  425 +
311 426 function createNewFolder()
312 427 {
313 428 for (j=0;j<window.document.forms[0].elements.length;j++)
... ... @@ -323,7 +438,9 @@ function createNewFolder()
323 438  
324 439 if (window.document.forms[0].elements[j].id.substring(0,15) == 'extractFileTGZ#' && window.document.forms[0].elements[j].checked)
325 440 window.document.forms[0].elements[j].checked = false;
326   -
  441 +
  442 + if (window.document.forms[0].elements[j].id.substring(0,15) == 'compactFileTGZ#' && window.document.forms[0].elements[j].checked)
  443 + window.document.forms[0].elements[j].checked = false;
327 444 }
328 445 var strCreateNewFolder = prompt('Informe Nome para Nova Pasta');
329 446 if (strCreateNewFolder && confirm('Confirma CRIAÇÃO DE PASTA?'))
... ... @@ -527,6 +644,7 @@ if ($_SESSION[&#39;cs_nivel_administracao&#39;]== 1)
527 644 <td align="center"><img src="../imgs/timestamp.gif" border="0" width="18" height="18" title="Alterar TimeStamp de Arquivos" onClick="return timeStamp()"></td>
528 645 <td align="center"><img src="../imgs/details.gif" width="18" height="18" title="Alterar Permissões de Arquivos" onClick="return changePermissions()"></td>
529 646 <td align="center"><img src="../imgs/extractfile.gif" width="18" height="18" title="Extrair Arquivo TGZ" onClick="return extractFileTGZ()"></td>
  647 + <td align="center"><img src="../imgs/compactfile.ico" width="18" height="18" title="Gerar Arquivo TGZ" onClick="return compactFileTGZ()"></td>
530 648 </tr>
531 649  
532 650 <?
... ... @@ -629,12 +747,18 @@ if ($_SESSION[&#39;cs_nivel_administracao&#39;]== 1)
629 747 <td align="center" valign="middle">
630 748 <? if ($isTGZ)
631 749 echo '<input type="checkbox" id="extractFileTGZ#'. str_replace('.','_ponto_',$strItem) . '" name="extractFileTGZ#'. str_replace('.','_ponto_',$strItem) .'" title="Marque para extrair o arquivo '. $strItem . '">';
632   - ?>
  750 + ?>
633 751 </td>
  752 + <?
  753 + echo '<td align="center" valign="middle">';
  754 + echo '<input type="checkbox" id="compactFileTGZ#'. str_replace('.','_ponto_',$strItem) . '" name="compactFileTGZ#'. str_replace('.','_ponto_',$strItem) .'" title="Marque para compactar o ítem '. $strItem . '">';
  755 + echo '</td>';
  756 + ?>
634 757 <input type="hidden" id="frmTouchTimeStamp" name="frmTouchTimeStamp" value="">
635 758 <input type="hidden" id="frmChangePermissions" name="frmChangePermissions" value="">
636 759 <input type="hidden" id="frmCreateNewFolder" name="frmCreateNewFolder" value="">
637 760 <input type="hidden" id="frmExtractFileTGZ" name="frmExtractFileTGZ" value="">
  761 + <input type="hidden" id="frmCompactFileTGZ" name="frmCompactFileTGZ" value="">
638 762 </tr>
639 763 <?
640 764 }
... ... @@ -655,7 +779,7 @@ if ($_SESSION[&#39;cs_nivel_administracao&#39;]== 1)
655 779 ?>
656 780 <tr>
657 781 <td colspan="6"><div align="right"><strong><? echo ($strTotal/2);?></strong></div></td>
658   - <TD colspan="5">&nbsp;</TD>
  782 + <TD colspan="6">&nbsp;</TD>
659 783 </tr>
660 784 </table>
661 785 </table>
... ...
admin/dominios/detalhes_dominio.php 0 → 100755
... ... @@ -0,0 +1,336 @@
  1 +<?
  2 + /*
  3 + Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
  4 +
  5 + Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
  6 +
  7 + O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
  8 + publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opnião) qualquer versão.
  9 +
  10 + Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
  11 + MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
  12 +
  13 + Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
  14 + Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15 + */
  16 +session_start();
  17 +require_once('../../include/library.php');
  18 +
  19 +AntiSpy('1,2'); // Permitido somente a estes cs_nivel_administracao...
  20 +
  21 +// 1 - Administração
  22 +// 2 - Gestão Central
  23 +
  24 +
  25 +conecta_bd_cacic();
  26 +
  27 +
  28 +if ($_POST['ExcluiDominio'] <> '' && $_SESSION['cs_nivel_administracao']==1)
  29 + {
  30 + $query = "UPDATE dominios
  31 + SET in_ativo = 'N'
  32 + WHERE id_dominio = ".$_POST['frm_id_dominio'];
  33 +
  34 + mysql_query($query) or die('Update falhou ou sua sessão expirou!');
  35 + GravaLog('UPD',$_SERVER['SCRIPT_NAME'],'dominios');
  36 + header ("Location: ../../include/operacao_ok.php?chamador=../admin/dominios/index.php&tempo=1");
  37 + }
  38 +else if ($_POST['GravaAlteracoes'] <> '' && $_SESSION['cs_nivel_administracao']==1)
  39 + {
  40 + $query = "UPDATE dominios
  41 + SET nm_dominio = '".$_POST['frm_nm_dominio'] ."',
  42 + te_ip_dominio = '".$_POST['frm_te_ip_dominio'] ."',
  43 + id_tipo_protocolo = '".$_POST['frm_id_tipo_protocolo'] ."',
  44 + nu_versao_protocolo = '".$_POST['frm_nu_versao_protocolo']."',
  45 + te_string_DN = '".$_POST['frm_te_string_DN'] ."',
  46 + te_observacao = '".$_POST['frm_te_observacao'] ."'
  47 + WHERE id_dominio = ".$_POST['frm_id_dominio'];
  48 +
  49 + mysql_query($query) or die('Update falhou ou sua sessão expirou!');
  50 + GravaLog('UPD',$_SERVER['SCRIPT_NAME'],'dominios');
  51 + header ("Location: ../../include/operacao_ok.php?chamador=../admin/dominios/index.php&tempo=1");
  52 + }
  53 +else
  54 + {
  55 + $query = "SELECT *
  56 + FROM dominios
  57 + WHERE id_dominio = ".$_GET['id_dominio'];
  58 + $result = mysql_query($query) or die ('Erro no acesso à tabela dominios ou sua sessão expirou!');
  59 +
  60 + $row = mysql_fetch_array($result);
  61 + ?>
  62 + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  63 + <html>
  64 + <head>
  65 + <link rel="stylesheet" type="text/css" href="../../include/cacic.css">
  66 + <title>Detalhes de Dom&iacute;nio</title>
  67 + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  68 + <SCRIPT LANGUAGE="JavaScript">
  69 +
  70 + function valida_form()
  71 + {
  72 +
  73 + if ( document.form.frm_nm_dominio.value == "" )
  74 + {
  75 + alert("O nome é obrigatório.");
  76 + document.form.frm_nm_dominio.focus();
  77 + return false;
  78 + }
  79 + else if ( document.form.frm_te_ip_dominio.value == "" )
  80 + {
  81 + alert("O IP é obrigatório.");
  82 + document.form.frm_te_ip_dominio.focus();
  83 + return false;
  84 + }
  85 + else if ( document.form.frm_id_tipo_protocolo.value == "" )
  86 + {
  87 + alert("Selecione o Tipo de Protocolo.");
  88 + document.form.frm_id_tipo_protocolo.focus();
  89 + return false;
  90 + }
  91 + return true;
  92 + }
  93 + </script>
  94 + <style type="text/css">
  95 +<!--
  96 +.style2 { font-size: 9px;
  97 + color: #000099;
  98 +}
  99 +-->
  100 + </style>
  101 + </head>
  102 +
  103 + <body background="../../imgs/linha_v.gif" onLoad="SetaCampo('frm_nm_dominio');">
  104 + <script language="JavaScript" type="text/javascript" src="../../include/cacic.js"></script>
  105 + <table width="90%" border="0" align="center">
  106 + <tr>
  107 + <td class="cabecalho">Detalhes do Dom&iacute;nio "<? echo $row['nm_dominio'];?>"</td>
  108 + </tr>
  109 + <tr>
  110 + <td class="descricao">As informa&ccedil;&otilde;es referem-se a um dom&iacute;nio usado na autentica&ccedil;&atilde;o de usu&aacute;rios do suporte remoto seguro.</td>
  111 + </tr>
  112 + </table>
  113 + <form action="detalhes_dominio.php" method="post" ENCTYPE="multipart/form-data" name="form">
  114 + <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
  115 + <tr>
  116 + <td class="label"><br>Nome do Dom&iacute;nio:</td>
  117 + <td nowrap class="label"><br>Endere&ccedil;o IP do Dom&iacute;nio:</td>
  118 + </tr>
  119 + <tr><td height="1" bgcolor="#333333" colspan="3"></td></tr>
  120 + <tr>
  121 + <td class="label_peq_sem_fundo"> <input name="frm_nm_dominio" type="text" size="60" maxlength="60" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" value="<? echo $row['nm_dominio'];?>">
  122 + <input name="frm_id_dominio" type="hidden" value="<? echo $_GET['id_dominio'];?>"></td>
  123 + <td class="label_peq_sem_fundo"><input name="frm_te_ip_dominio" type="text" size="30" maxlength="15" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_ip_dominio" value="<? echo $row['te_ip_dominio'];?>"></td>
  124 + </tr>
  125 + <tr>
  126 + <td class="label"><div align="left"><br>Protocolo:</div></td>
  127 + <td class="label"><div align="left"><br>Vers&atilde;o:</div></td>
  128 + </tr>
  129 + <tr>
  130 + <td height="1" bgcolor="#333333" colspan="3"></td>
  131 + </tr>
  132 + <tr>
  133 + <td nowrap><label>
  134 + <select name="frm_id_tipo_protocolo" class="opcao_tabela" id="frm_id_tipo_protocolo">
  135 + <option value="LDAP" <? if ($row['id_tipo_protocolo']=='LDAP') echo 'selected';?>>LDAP</option>
  136 + <option value="Open LDAP"<? if ($row['id_tipo_protocolo']=='Open LDAP') echo 'selected';?>>Open LDAP</option>
  137 + </select>
  138 + </label></td>
  139 + <td class="label"><div align="left"><span class="label_peq_sem_fundo">
  140 + <input name="frm_nu_versao_protocolo" type="text" size="30" maxlength="10" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_nu_versao_protocolo" value="<? echo $row['nu_versao_protocolo'];?>" >
  141 + </span></div></td>
  142 + </tr>
  143 + <tr>
  144 + <td class="label"><br>
  145 + String de Pesquisa: <span class="normal style2">(Ex.: o=dominio.com.br / DC=dominio, DC=com, DC=br)</span></td>
  146 + <td class="label"><div align="left"><br>
  147 + Observa&ccedil;&otilde;es:</div></td>
  148 + </tr>
  149 + <tr>
  150 + <td height="1" bgcolor="#333333" colspan="3"></td>
  151 + </tr>
  152 + <tr>
  153 + <td><span class="label_peq_sem_fundo">
  154 + <input name="frm_te_string_DN" type="text" size="60" maxlength="100" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_string_DN" value="<? echo $row['te_string_DN'];?>" >
  155 + </span></td>
  156 + <td><span class="label_peq_sem_fundo">
  157 + <input name="frm_te_observacao" type="text" size="60" maxlength="100" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_observacao" value="<? echo $row['te_observacao'];?>" >
  158 + </span></td>
  159 + </tr>
  160 +
  161 + <tr>
  162 + <td colspan="3">&nbsp;</td>
  163 + </tr>
  164 + </table>
  165 +
  166 + <br>
  167 + <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
  168 + <tr>
  169 + <td colspan="7" class="label">Redes Associadas ao Dom&iacute;nio:</td>
  170 + </tr>
  171 + <tr>
  172 + <td height="1" bgcolor="#333333" colspan="7"></td>
  173 + </tr>
  174 + <?
  175 + $query = "SELECT count(id_dominio) as Total
  176 + FROM redes
  177 + WHERE id_dominio = ".$_GET['id_dominio'];
  178 + $result = mysql_query($query) or die ('Erro no acesso à tabela redes ou sua sessão expirou!');
  179 + $rowRedesDominio = mysql_fetch_array($result);
  180 + if ($rowRedesDominio['Total'] > 0)
  181 + {
  182 + ?>
  183 + <tr>
  184 + <td class="cabecalho_tabela">&nbsp;</td>
  185 + <td class="cabecalho_tabela">&nbsp;</td>
  186 + <td align="left" nowrap class="cabecalho_tabela">Local</td>
  187 + <td class="cabecalho_tabela">&nbsp;</td>
  188 + <td align="left" nowrap class="cabecalho_tabela">IP</td>
  189 + <td align="left" class="cabecalho_tabela">&nbsp;</td>
  190 + <td align="left" class="cabecalho_tabela">Rede</td>
  191 + </tr>
  192 + <tr>
  193 + <td height="1" bgcolor="#333333" colspan="7"></td>
  194 + </tr>
  195 +
  196 + <?
  197 +
  198 + $query = "SELECT r.id_ip_rede,
  199 + r.nm_rede,
  200 + l.id_local,
  201 + l.sg_local,
  202 + l.nm_local
  203 + FROM redes r,
  204 + locais l
  205 + WHERE r.id_dominio = ".$_GET['id_dominio'] ." AND
  206 + l.id_local = r.id_local
  207 + ORDER BY l.sg_local,l.nm_local,r.nm_rede";
  208 + $result = mysql_query($query) or die ('Erro no acesso à tabela redes ou sua sessão expirou!');
  209 +
  210 + $seq = 1;
  211 + $Cor = 1;
  212 + while ($row = mysql_fetch_array($result))
  213 + {
  214 + ?>
  215 + <tr <? if ($Cor) echo 'bgcolor="#E1E1E1"'; ?>>
  216 + <td width="3%" align="center" nowrap class="opcao_tabela"><a href="../redes/detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&nm_chamador=dominios"><? echo $seq; ?></a></td>
  217 + <td width="1%" align="left" nowrap class="opcao_tabela">&nbsp;&nbsp;</td>
  218 + <td width="1%" align="left" nowrap class="opcao_tabela"><a href="../locais/detalhes_local.php?id_local=<? echo $row['id_local'];?>&nm_chamador=dominios"><? echo $row['sg_local'].'/'.$row['nm_local']; ?></a></td>
  219 + <td width="1%" align="left" nowrap class="opcao_tabela">&nbsp;</td>
  220 + <td width="3%" align="left" nowrap class="opcao_tabela"><a href="../redes/detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&nm_chamador=dominios"><? echo $row['id_ip_rede']; ?></a></td>
  221 + <td width="1%" align="left" class="opcao_tabela">&nbsp;&nbsp;</td>
  222 + <td width="92%" align="left" class="opcao_tabela"><a href="../redes/detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&nm_chamador=dominios"><? echo $row['nm_rede']; ?></a></td>
  223 + </tr>
  224 + <?
  225 + $seq++;
  226 + $Cor=!$Cor;
  227 + }
  228 +
  229 + }
  230 + else
  231 + echo '<tr><td colspan="5" class="label_vermelho">Ainda não existem redes associadas ao domínio!</td></tr>';
  232 + ?>
  233 + <tr>
  234 + <td height="1" bgcolor="#333333" colspan="7"></td>
  235 + </tr>
  236 + </table>
  237 + <br>
  238 + <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
  239 + <tr>
  240 + <td colspan="10" class="label">Usu&aacute;rios Associados ao Dom&iacute;nio:</td>
  241 + </tr>
  242 + <tr>
  243 + <td height="1" bgcolor="#333333" colspan="10"></td>
  244 + </tr>
  245 + <?
  246 + $query = "SELECT count(id_dominio) as Total
  247 + FROM usuarios
  248 + WHERE id_dominio = ".$_GET['id_dominio'];
  249 + $result = mysql_query($query) or die ('Erro no acesso à tabela usuários ou sua sessão expirou!');
  250 + $rowUsuariosDominio = mysql_fetch_array($result);
  251 + if ($rowUsuariosDominio['Total'] > 0)
  252 + {
  253 + ?>
  254 + <tr>
  255 + <td class="cabecalho_tabela">&nbsp;</td>
  256 + <td class="cabecalho_tabela">&nbsp;</td>
  257 + <td align="left" class="cabecalho_tabela">Local</td>
  258 + <td class="cabecalho_tabela">&nbsp;</td>
  259 + <td align="left" nowrap class="cabecalho_tabela">Nome de Acesso</td>
  260 + <td align="left" class="cabecalho_tabela">&nbsp;</td>
  261 + <td align="left" class="cabecalho_tabela">Nome Completo</td>
  262 + <td align="left" class="cabecalho_tabela">Email</td>
  263 + <td align="left" class="cabecalho_tabela">Telefone/Ramal</td>
  264 + <td align="left" class="cabecalho_tabela">&nbsp;</td>
  265 + </tr>
  266 + <tr>
  267 + <td height="1" bgcolor="#333333" colspan="10"></td>
  268 + </tr>
  269 +
  270 + <?
  271 + $query = "SELECT u.id_usuario,
  272 + u.nm_usuario_acesso,
  273 + u.nm_usuario_completo,
  274 + u.te_emails_contato,
  275 + u.te_telefones_contato,
  276 + l.sg_local,
  277 + l.nm_local,
  278 + l.id_local
  279 + FROM usuarios u,
  280 + locais l
  281 + WHERE u.id_dominio = ".$_GET['id_dominio']." AND
  282 + u.id_local = l.id_local
  283 + ORDER BY l.nm_local,u.nm_usuario_acesso";
  284 + $result = mysql_query($query) or die ('Erro no acesso à tabela redes ou sua sessão expirou!');
  285 + $seq = 1;
  286 + $Cor = 1;
  287 + while ($row = mysql_fetch_array($result))
  288 + {
  289 + ?>
  290 + <tr <? if ($Cor) echo 'bgcolor="#E1E1E1"'; ?>>
  291 + <td width="3%" align="center" nowrap class="opcao_tabela"><a href="../usuarios/detalhes_usuario.php?id_usuario=<? echo $row['id_usuario'];?>&nm_chamador=dominios"><? echo $seq; ?></a></td>
  292 + <td width="1%" align="left" nowrap class="opcao_tabela">&nbsp;&nbsp;</td>
  293 + <td width="1%" align="left" nowrap class="opcao_tabela"><a href="../locais/detalhes_local.php?id_local=<? echo $row['id_local'];?>&nm_chamador=dominios"><? echo $row['sg_local'].'/'.$row['nm_local']; ?></a></td>
  294 + <td width="1%" align="left" nowrap class="opcao_tabela">&nbsp;</td>
  295 + <td width="3%" align="left" nowrap class="opcao_tabela"><a href="../usuarios/detalhes_usuario.php?id_usuario=<? echo $row['id_usuario'];?>&nm_chamador=dominios"><? echo $row['nm_usuario_acesso']; ?></a></td>
  296 + <td width="1%" align="left" class="opcao_tabela">&nbsp;&nbsp;</td>
  297 + <td width="92%" align="left" class="opcao_tabela"><a href="../usuarios/detalhes_usuario.php?id_usuario=<? echo $row['id_usuario'];?>&nm_chamador=dominios"><? echo $row['nm_usuario_completo']; ?></a></td>
  298 + <td width="92%" align="left" class="opcao_tabela"><a href="../usuarios/detalhes_usuario.php?id_usuario=<? echo $row['id_usuario'];?>&nm_chamador=dominios"><? echo $row['te_emails_contato']; ?></a></td>
  299 + <td width="92%" align="left" class="opcao_tabela"><a href="../usuarios/detalhes_usuario.php?id_usuario=<? echo $row['id_usuario'];?>&nm_chamador=dominios"><? echo $row['te_telefones_contato']; ?></a></td>
  300 + <td width="92%" align="left" class="opcao_tabela">&nbsp;</td>
  301 + </tr>
  302 + <?
  303 + $seq++;
  304 + $Cor=!$Cor;
  305 + }
  306 + }
  307 + else
  308 + echo '<tr><td colspan="5" class="label_vermelho">Ainda não existem usuários associados ao domínio!</td></tr>';
  309 + ?>
  310 + <tr>
  311 + <td height="1" bgcolor="#333333" colspan="10"></td>
  312 + </tr>
  313 + </table>
  314 +
  315 + <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
  316 + <tr><td colspan="5" align="center"><?
  317 + if ($_SESSION['cs_nivel_administracao']==1)
  318 + {
  319 + ?>
  320 + <br>
  321 + <p>
  322 + <input name="GravaAlteracoes" type="submit" id="GravaAlteracoes" value=" Gravar Altera&ccedil;&otilde;es " onClick="return Confirma('Confirma Informações para o Domínio?');return valida_form();">
  323 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  324 + <input name="ExcluiDominio" type="submit" id="ExcluiDominio" onClick="return Confirma('Confirma Exclusão(Desativação) do Domínio?');" value=" Excluir/Desativar Dom&iacute;nio">
  325 + </p>
  326 + <?
  327 + }
  328 + ?>
  329 + </td></tr>
  330 + </table>
  331 + </form>
  332 + </body>
  333 +</html>
  334 + <?
  335 + }
  336 +?>
... ...
admin/dominios/incluir_dominio.php 0 → 100755
... ... @@ -0,0 +1,193 @@
  1 +<?
  2 + /*
  3 + Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
  4 +
  5 + Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
  6 +
  7 + O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
  8 + publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opnião) qualquer versão.
  9 +
  10 + Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
  11 + MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
  12 +
  13 + Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
  14 + Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15 + */
  16 + session_start();
  17 +include_once "../../include/library.php";
  18 +AntiSpy('1,2'); // Permitido somente a estes cs_nivel_administracao...
  19 +// 1 - Administração
  20 +// 2 - Gestão Central
  21 +
  22 +
  23 +if($_POST['submit']<>'' && $_SESSION['cs_nivel_administracao']==1)
  24 + {
  25 + Conecta_bd_cacic();
  26 +
  27 + $query = "SELECT *
  28 + FROM dominios
  29 + WHERE nm_dominio = '".$_POST['frm_nm_dominio']."'";
  30 + $result = mysql_query($query) or die ('1-Select falhou ou sua sessão expirou!');
  31 +
  32 + if (mysql_num_rows($result) > 0)
  33 + {
  34 + header ("Location: ../../include/registro_ja_existente.php?chamador=../admin/dominios/index.php&tempo=1");
  35 + }
  36 + else
  37 + {
  38 + $query = "INSERT
  39 + INTO dominios
  40 + (nm_dominio,
  41 + te_ip_dominio,
  42 + id_tipo_protocolo,
  43 + nu_versao_protocolo,
  44 + te_string_DN,
  45 + te_observacao)
  46 + VALUES ('".$_POST['frm_nm_dominio']."',
  47 + '".$_POST['frm_te_ip_dominio']."',
  48 + '".$_POST['frm_id_tipo_protocolo']."',
  49 + '".$_POST['frm_nu_versao_protocolo']."',
  50 + '".$_POST['frm_te_string_DN']."',
  51 + '".$_POST['frm_te_observacao']."')";
  52 + $result = mysql_query($query) or die ('2-Falha na Inserção em Dominios ou sua sessão expirou!');
  53 + GravaLog('INS',$_SERVER['SCRIPT_NAME'],'dominios');
  54 +
  55 + header ("Location: index.php");
  56 + }
  57 + }
  58 +else
  59 + {
  60 + ?>
  61 + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  62 + <html>
  63 + <head>
  64 + <link rel="stylesheet" type="text/css" href="../../include/cacic.css">
  65 + <title>Inclus&atilde;o de Dom&iacute;nio</title>
  66 + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  67 + <SCRIPT LANGUAGE="JavaScript">
  68 +
  69 + function valida_form()
  70 + {
  71 +
  72 + if ( document.form.frm_nm_dominio.value == "" )
  73 + {
  74 + alert("O nome é obrigatório.");
  75 + document.form.frm_nm_dominio.focus();
  76 + return false;
  77 + }
  78 + else if ( document.form.frm_te_ip_dominio.value == "" )
  79 + {
  80 + alert("O IP é obrigatório.");
  81 + document.form.frm_te_ip_dominio.focus();
  82 + return false;
  83 + }
  84 + else if ( document.form.frm_id_tipo_protocolo.value == "" )
  85 + {
  86 + alert("Selecione o Tipo de Protocolo.");
  87 + document.form.frm_id_tipo_protocolo.focus();
  88 + return false;
  89 + }
  90 +
  91 + return true;
  92 + }
  93 + </script>
  94 + <script language="JavaScript" type="text/JavaScript">
  95 + <!--
  96 + function MM_reloadPage(init) { //reloads the window if Nav4 resized
  97 + if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  98 + document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  99 + else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  100 + }
  101 + MM_reloadPage(true);
  102 + //-->
  103 + </script>
  104 + <style type="text/css">
  105 +<!--
  106 +.style2 {
  107 + font-size: 9px;
  108 + color: #000099;
  109 +}
  110 +-->
  111 + </style>
  112 + </head>
  113 +
  114 + <body background="../../imgs/linha_v.gif" onLoad="SetaCampo('frm_nm_dominio');">
  115 + <script language="JavaScript" type="text/javascript" src="../../include/cacic.js"></script>
  116 + <table width="90%" border="0" align="center">
  117 + <tr>
  118 + <td class="cabecalho">Inclus&atilde;o
  119 + de Dom&iacute;nio</td>
  120 + </tr>
  121 + <tr>
  122 + <td class="descricao">As informa&ccedil;&otilde;es que dever&atilde;o ser
  123 + cadastradas abaixo referem-se a um dom&iacute;nio a ser utilizado na autentica&ccedil;&atilde;o de usu&aacute;rios do suporte remoto seguro. </td>
  124 + </tr>
  125 + </table>
  126 + <form action="incluir_dominio.php" method="post" ENCTYPE="multipart/form-data" name="form" onSubmit="return valida_form()">
  127 + <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  128 + <tr>
  129 + <td class="label"><br>
  130 + Nome do Dom&iacute;nio:</td>
  131 + <td nowrap class="label"><br>
  132 + Endere&ccedil;o IP do Dom&iacute;nio:</td>
  133 + </tr>
  134 + <tr>
  135 + <td height="1" bgcolor="#333333" colspan="3"></td>
  136 + </tr>
  137 + <tr>
  138 + <td class="label_peq_sem_fundo"> <input name="frm_nm_dominio" type="text" size="60" maxlength="60" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
  139 + &nbsp;&nbsp;</td>
  140 + <td class="label_peq_sem_fundo"><input name="frm_te_ip_dominio" type="text" size="30" maxlength="15" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_ip_dominio" ></td>
  141 + </tr>
  142 + <tr>
  143 + <td class="label"><div align="left"><br>
  144 + Protocolo:</div></td>
  145 + <td class="label"><div align="left"><br>
  146 + Vers&atilde;o:</div></td>
  147 + </tr>
  148 + <tr>
  149 + <td height="1" bgcolor="#333333" colspan="3"></td>
  150 + </tr>
  151 + <tr>
  152 + <td nowrap><label>
  153 + <select name="frm_id_tipo_protocolo" class="opcao_tabela" id="frm_id_tipo_protocolo">
  154 + <option value="LDAP" selected>LDAP</option>
  155 + <option value="Open LDAP">Open LDAP</option>
  156 + </select>
  157 + </label></td>
  158 + <td class="label"><div align="left"><span class="label_peq_sem_fundo">
  159 + <input name="frm_nu_versao_protocolo" type="text" size="30" maxlength="10" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_nu_versao_protocolo" >
  160 + </span></div></td>
  161 + </tr>
  162 + <tr>
  163 + <td class="label"><br>
  164 + String de Pesquisa: <span class="normal style2">(Ex.: o=dominio.com.br / DC=dominio, DC=com, DC=br)</span></td>
  165 + <td class="label"><div align="left"><br>
  166 + Observa&ccedil;&otilde;es:</div></td>
  167 + </tr>
  168 + <tr>
  169 + <td height="1" bgcolor="#333333" colspan="3"></td>
  170 + </tr>
  171 + <tr>
  172 + <td><span class="label_peq_sem_fundo">
  173 + <input name="frm_te_string_DN" type="text" size="60" maxlength="100" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_string_DN" >
  174 + </span></td>
  175 + <td><span class="label_peq_sem_fundo">
  176 + <input name="frm_te_observacao" type="text" size="60" maxlength="100" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" id="frm_te_observacao" >
  177 + </span></td>
  178 + </tr>
  179 + <tr>
  180 + <td colspan="3">&nbsp;</td>
  181 + </tr>
  182 + </table>
  183 + <p align="center">
  184 + <input name="submit" type="submit" value=" Gravar Informa&ccedil;&otilde;es " onClick="return Confirma('Confirma Inclusão de Domínio?');">
  185 + </p>
  186 + </form>
  187 + <p>
  188 + <?
  189 + }
  190 +?>
  191 +</p>
  192 +</body>
  193 +</html>
... ...
admin/dominios/index.php 0 → 100755
... ... @@ -0,0 +1,216 @@
  1 +<?
  2 + /*
  3 + Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
  4 +
  5 + Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
  6 +
  7 + O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
  8 + publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opnião) qualquer versão.
  9 +
  10 + Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
  11 + MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
  12 +
  13 + Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
  14 + Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15 + */
  16 +session_start();
  17 +if ($_POST['submit'] && $_SESSION['cs_nivel_administracao']==1)
  18 + header ("Location: incluir_dominio.php");
  19 +
  20 +include_once "../../include/library.php";
  21 +AntiSpy();
  22 +
  23 +Conecta_bd_cacic();
  24 +$query = 'SELECT *
  25 + FROM dominios
  26 + ORDER BY ';
  27 +
  28 +$query .= ($_GET['cs_ordem']<>''?$_GET['cs_ordem']:'nm_dominio');
  29 +$result = mysql_query($query);
  30 +$msg = '<div align="center">
  31 + <font color="#c0c0c0" size="1" face="Verdana, Arial, Helvetica, sans-serif">
  32 + Clique nas Colunas para Ordenar</font><br><br></div>';
  33 +?>
  34 +
  35 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  36 +<html>
  37 +<head>
  38 +<link rel="stylesheet" type="text/css" href="../../include/cacic.css">
  39 +<title>Cadastro de Dom&iacute;nio</title>
  40 +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  41 +</head>
  42 +
  43 +<body background="../../imgs/linha_v.gif">
  44 +<script language="JavaScript" type="text/javascript" src="../../include/cacic.js"></script>
  45 +<form name="form1" method="post" action="">
  46 +<table width="90%" border="0" align="center">
  47 + <tr>
  48 + <td class="cabecalho">Cadastro de Dom&iacute;nio</td>
  49 + </tr>
  50 + <tr>
  51 + <td class="descricao">Neste m&oacute;dulo dever&atilde;o ser cadastrados
  52 + todos os dom&iacute;nios utilizados para autentica&ccedil;&atilde;o de contas para abertura de sess&otilde;es de suporte remoto seguro.</td>
  53 + </tr>
  54 +</table>
  55 +<br><table border="0" align="center" cellpadding="0" cellspacing="1">
  56 + <tr>
  57 + <td><div align="center">
  58 + <?
  59 + if ($_SESSION['cs_nivel_administracao']==1)
  60 + {
  61 + ?>
  62 + <input name="submit" type="submit" id="submit" value="Incluir Informa&ccedil;&otilde;es de Novo Dom&iacute;nio">
  63 + <?
  64 + }
  65 + ?>
  66 + </div></td>
  67 + </tr>
  68 + <tr>
  69 + <td height="10">&nbsp;</td>
  70 + </tr>
  71 + <tr>
  72 + <td height="10"><? echo $msg;?></td>
  73 + </tr>
  74 +
  75 + <tr>
  76 + <td height="1" bgcolor="#333333"></td>
  77 + </tr>
  78 + <tr>
  79 + <td> <table border="0" cellpadding="2" cellspacing="0" bordercolor="#333333" align="center">
  80 + <tr bgcolor="#E1E1E1" nowrap>
  81 + <td align="center" nowrap>&nbsp;</td>
  82 + <td align="center" nowrap><div align="left"></div></td>
  83 + <td align="center" nowrap>&nbsp;</td>
  84 + <td align="center" nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=nm_dominio">Nome</a></div></td>
  85 + <td nowrap >&nbsp;</td>
  86 + <td nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=te_ip_dominio">Endere&ccedil;o IP</a></div></td>
  87 + <td nowrap >&nbsp;</td>
  88 + <td nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=nu_versao_protocolo">Protocolo/Vers&atilde;o</div></td>
  89 + <td nowrap class="cabecalho_tabela">&nbsp;</td>
  90 + <td class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=in_ativo">Ativo?</div></td>
  91 + <td nowrap class="cabecalho_tabela">&nbsp;</td>
  92 + </tr>
  93 + <tr>
  94 + <td height="1" bgcolor="#333333" colspan="11"></td>
  95 + </tr>
  96 +
  97 +<?
  98 +if(mysql_num_rows($result)==0)
  99 + {
  100 + $msg = '<div align="center">
  101 + <font color="red" size="1" face="Verdana, Arial, Helvetica, sans-serif">
  102 + Nenhum domínio cadastrado ou sua sessão expirou!</font><br><br></div>';
  103 + }
  104 +else
  105 + {
  106 + $Cor = 0;
  107 + $NumRegistro = 1;
  108 +
  109 + while($row = mysql_fetch_array($result))
  110 + {
  111 + ?>
  112 + <tr
  113 + <? if ($Cor)
  114 + echo 'bgcolor="#E1E1E1"';
  115 + ?>>
  116 + <td nowrap>&nbsp;</td>
  117 + <td nowrap class="opcao_tabela"><div align="left"><? echo $NumRegistro; ?></div></td>
  118 + <td nowrap>&nbsp;</td>
  119 + <td nowrap class="opcao_tabela"><div align="left">
  120 + <?
  121 + if ($_SESSION['cs_nivel_administracao']==1)
  122 + {
  123 + ?>
  124 + <a href="detalhes_dominio.php?id_dominio=<? echo $row['id_dominio'];?>">
  125 + <?
  126 + }
  127 +
  128 + echo $row['nm_dominio'];
  129 + if ($_SESSION['cs_nivel_administracao']==1)
  130 + {
  131 + ?>
  132 + </a>
  133 + <?
  134 + }
  135 + ?>
  136 +
  137 + </div></td>
  138 + <td nowrap>&nbsp;</td>
  139 + <td nowrap class="opcao_tabela"><div align="left">
  140 +
  141 + <?
  142 + if ($_SESSION['cs_nivel_administracao']==1)
  143 + {
  144 + ?>
  145 + <a href="detalhes_dominio.php?id_dominio=<? echo $row['id_dominio'];?>">
  146 + <?
  147 + }
  148 + echo $row['te_ip_dominio'];
  149 + if ($_SESSION['cs_nivel_administracao']==1)
  150 + {
  151 + ?>
  152 + </a>
  153 + <?
  154 + }
  155 + ?>
  156 + </div></td>
  157 + <td nowrap>&nbsp;</td>
  158 + <td nowrap class="opcao_tabela">
  159 +
  160 + <div align="center">
  161 + <?
  162 + if ($_SESSION['cs_nivel_administracao']==1)
  163 + {
  164 + ?>
  165 + <a href="detalhes_dominio.php?id_dominio=<? echo $row['id_dominio'];?>">
  166 + <?
  167 + }
  168 + echo $row['id_tipo_protocolo'] . '/'.$row['nu_versao_protocolo'];
  169 + if ($_SESSION['cs_nivel_administracao']==1)
  170 + {
  171 + ?>
  172 + </a>
  173 + <?
  174 + }
  175 + ?>
  176 + </div></td>
  177 + <td nowrap class="opcao_tabela">&nbsp;</td>
  178 + <td nowrap class="opcao_tabela"><div align="center"><a href="detalhes_dominio.php?id_dominio=<? echo $row['id_dominio'];?>">
  179 + <?
  180 + echo $row['in_ativo'];
  181 + if ($_SESSION['cs_nivel_administracao']==1)
  182 + {
  183 + ?>
  184 + </a>
  185 + <?
  186 + }
  187 + ?>
  188 + </div></td>
  189 + <td nowrap class="opcao_tabela">&nbsp;</td>
  190 + <?
  191 + $Cor=!$Cor;
  192 + $NumRegistro++;
  193 + }
  194 + }
  195 + ?>
  196 + </table></td>
  197 + </tr>
  198 + <tr>
  199 + <td height="1" bgcolor="#333333"></td>
  200 + </tr>
  201 + <tr>
  202 + <td height="10">&nbsp;</td>
  203 + </tr>
  204 + <tr>
  205 + <td height="10"><? echo $msg;?></td>
  206 + </tr>
  207 + <tr>
  208 + <td><div align="center">
  209 + <input name="submit" type="submit" id="submit" value="Incluir Informa&ccedil;&otilde;es de Novo Dom&iacute;nio" <? echo ($_SESSION['cs_nivel_administracao']<>1?'disabled':'')?>>
  210 + </div></td>
  211 + </tr>
  212 + </table>
  213 + </form>
  214 + <p>&nbsp;</p>
  215 + </body>
  216 + </html>
... ...
admin/exclui_informacoes_computadores.php
... ... @@ -83,9 +83,51 @@ if ($_POST[&#39;submit_cond&#39;])
83 83 c.id_local = d.id_local '.
84 84 $where . '
85 85 ORDER by a.te_nome_computador';
  86 +
  87 + $Query_Pesquisa = 'SELECT computadores.id_so,
  88 + computadores.te_node_address,
  89 + computadores.te_nome_computador,
  90 + computadores.te_ip,
  91 + computadores.te_versao_cacic,
  92 + computadores.te_versao_gercols,
  93 + computadores.dt_hr_ult_acesso,
  94 + computadores.dt_hr_inclusao,
  95 + so.sg_so,
  96 + redes.id_local
  97 + FROM computadores
  98 + LEFT JOIN so ON (computadores.id_so = so.id_so)
  99 + LEFT JOIN redes ON (computadores.id_ip_rede = redes.id_ip_rede)
  100 + WHERE '.stripslashes($query_sele_exclui).
  101 + $where . '
  102 + ORDER by computadores.te_nome_computador';
  103 +
86 104 conecta_bd_cacic();
87   - $result = mysql_query($Query_Pesquisa) or die($oTranslator->_('kciq_msg select on table fail', array('computadores/so/redes/locais'))."! ".$oTranslator->_('kciq_msg session fail',false,true)."!");
88   -
  105 + $result = mysql_query($Query_Pesquisa) or die('Erro no select (1) ou sua sessão expirou!');
  106 +
  107 + $strIdLocal = '';
  108 + $arrSgLocal = array();
  109 + while($row = mysql_fetch_array($result))
  110 + {
  111 + if ($row['id_local']<>'' && $arrSgLocal[$row['id_local']]=='')
  112 + {
  113 + $arrSgLocal[$row['id_local']] = '*';
  114 + $strIdLocal .= ($strIdLocal==''?'':',');
  115 + $strIdLocal .= $row['id_local'];
  116 + }
  117 + }
  118 + if ($strIdLocal <> '')
  119 + {
  120 + $Query_Locais = 'SELECT locais.id_local,
  121 + locais.sg_local
  122 + FROM locais
  123 + WHERE locais.id_local in ('.$strIdLocal.')';
  124 + if ($_SERVER['REMOTE_ADDR']=='10.71.0.58')
  125 + echo 'Query_Locais: '.$Query_Locais.'<br>';
  126 + $resultLocais = mysql_query($Query_Locais) or die('Erro no select (2) ou sua sessão expirou!');
  127 + while($row = mysql_fetch_array($resultLocais))
  128 + $arrSgLocal[$row['id_local']] = $row['sg_local'];
  129 + }
  130 +
89 131 ?>
90 132 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
91 133 <html>
... ... @@ -250,24 +292,66 @@ else
250 292 {
251 293 $v_cs_exclui = '';
252 294 conecta_bd_cacic();
  295 +
  296 +
  297 + // Faço testes para identificar as tabelas válidas para as consultas...
  298 + $result_tables = mysql_list_tables($nome_bd); //Retorna a lista de tabelas do CACIC
  299 +
  300 + /*
  301 + while ($row_consulta = mysql_fetch_row($result_tables)) //Percorre as tabelas comandando a exclusão, conforme TE_NODE_ADDRESS e ID_SO
  302 + {
  303 + $v_query_consulta = 'SELECT count(id_so) FROM '.$row_consulta[0] .' WHERE concat(te_node_address,id_so) <> ""';
  304 + if ($_SERVER['REMOTE_ADDR']=='10.71.0.58')
  305 + echo 'v_query_consulta: '.$v_query_consulta.'<br>';
  306 +
  307 + $consulta = @mysql_query($v_query_consulta); //Neste caso, o "@" inibe qualquer mensagem de erro retornada pela função MYSQL_QUERY()
  308 + if ($consulta)
  309 + $strTripaTabelasValidas .= '#'.$row_consulta[0].'#';
  310 + }
  311 + */
  312 + $strTripaTabelasValidas = '#acoes_excecoes#aplicativos_monitorados#compartilhamentos#componentes_estacoes#componentes_estacoes_historico#historico_hardware#historico_tcp_ip#historicos_hardware#historicos_outros_softwares#historicos_software#historicos_software_completo#officescan#patrimonio#softwares_inventariados_estacoes#unidades_disco#variaveis_ambiente_estacoes#versoes_softwares#';
  313 +
  314 + //
  315 + $v_cs_exclui = '';
  316 + //
  317 + $strTripaCampos = '';
  318 + $intContaMaquinas = 0;
253 319 while(list($key, $value) = each($HTTP_POST_VARS))
254 320 {
255 321 if (strpos($key,'chk_')>-1)
256   - {
257   - if (!$result_tables) $result_tables = mysql_list_tables($nome_bd); //Retorna a lista de tabelas do CACIC
  322 + {
  323 + $strTripaCampos .= ($strTripaCampos == ''?'':',');
  324 + $strTripaCampos .= '"#'.str_replace('chk_','',$key).'#"';
  325 + $intContaMaquinas ++;
  326 + }
  327 + }
  328 +
  329 +
  330 +// for ($intContaMaquinasAux = 0; $intContaMaquinasAux <= $intContaMaquinas; $intContaMaquinasAux ++)
  331 +// {
  332 + //if (!$result_tables) $result_tables = mysql_list_tables($nome_bd); //Retorna a lista de tabelas do CACIC
258 333  
259   - mysql_data_seek($result_tables,0);
260   - $v_arr_exclui = explode('#',$key);
261   - while ($row_exclui = mysql_fetch_row($result_tables)) //Percorre as tabelas comandando a exclusão, conforme TE_NODE_ADDRESS e ID_SO
  334 + mysql_data_seek($result_tables,0);
  335 + //$v_arr_exclui = explode('#',$key);
  336 + $boolOK = false;
  337 + while ($row_exclui = mysql_fetch_row($result_tables)) //Percorre as tabelas comandando a exclusão, conforme TE_NODE_ADDRESS e ID_SO
  338 + {
  339 + $boolOK = stripos2($strTripaTabelasValidas, '#'.$row_exclui[0].'#',false);
  340 + if ($boolOK)
262 341 {
263   - $v_query_exclui = 'DELETE FROM '.$row_exclui[0] .' WHERE te_node_address = "'. str_replace('chk_','',$v_arr_exclui[0]) . '" and id_so="'.str_replace('chk_','',$v_arr_exclui[1]).'"';
264   - $exclui = @mysql_query($v_query_exclui); //Neste caso, o "@" inibe qualquer mensagem de erro retornada pela função MYSQL_QUERY()
  342 + $v_query_exclui = 'DELETE FROM '.$row_exclui[0] .' WHERE concat("#",te_node_address,"#",id_so,"#") in ('.$strTripaCampos.')';
  343 + $exclui = @mysql_query($v_query_exclui); //Neste caso, o "@" inibe qualquer mensagem de erro retornada pela função MYSQL_QUERY()
  344 + GravaTESTES('Deleção de registros de "'.$row_exclui[0].'" => '.$exclui);
265 345 $v_cs_exclui = '1';
266   - }
267   - }
  346 + }
  347 + }
  348 + $v_query_exclui = 'DELETE FROM computadores WHERE concat("#",te_node_address,"#",id_so,"#") in ('.$strTripaCampos.')';
  349 + $exclui = @mysql_query($v_query_exclui); //Neste caso, o "@" inibe qualquer mensagem de erro retornada pela função MYSQL_QUERY()
  350 +
268 351 if ($v_cs_exclui)
269 352 GravaLog('DEL',$_SERVER['SCRIPT_NAME'],'computadores');
270   - }
  353 +
  354 +// }
271 355 }
272 356 ?>
273 357 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
... ...
admin/patrimonio/nivel2/detalhes_nivel2.php
... ... @@ -52,12 +52,22 @@ if ($exclui_uon2)
52 52 else if($_POST['gravainformacaoUON2'])
53 53 {
54 54  
55   - $query = " DELETE
56   - FROM unid_organizacional_nivel2
57   - WHERE id_unid_organizacional_nivel2 = ".$_POST['frm_id_unid_organizacional_nivel2']." and
58   - id_unid_organizacional_nivel1 = ".$_POST['frm_id_unid_organizacional_nivel1']. $where;
59   - mysql_query($query) or die($oTranslator->_('Falha em exclusao na tabela (%1) ou sua sessao expirou!',array('unid_organizacional_nivel2')));
60   - GravaLog('DEL',$_SERVER['SCRIPT_NAME'],'unid_organizacional_nivel2');
  55 + $query = " UPDATE unid_organizacional_nivel2
  56 + SET nm_unid_organizacional_nivel2 = '".$_POST['frm_nm_unid_organizacional_nivel2']."',
  57 + te_endereco_uon2 = '".$_POST['frm_te_endereco_uon2']."',
  58 + te_bairro_uon2 = '".$_POST['frm_te_bairro_uon2']."',
  59 + te_cidade_uon2 = '".$_POST['frm_te_cidade_uon2']."',
  60 + te_uf_uon2 = '".$_POST['frm_te_uf_uon2']."',
  61 + nm_responsavel_uon2 = '".$_POST['frm_nm_responsavel_uon2']."',
  62 + te_email_responsavel_uon2 = '".$_POST['frm_te_email_responsavel_uon2']."',
  63 + nu_tel1_responsavel_uon2 = '".$_POST['frm_nu_tel1_responsavel_uon2']."',
  64 + nu_tel2_responsavel_uon2 = '".$_POST['frm_nu_tel2_responsavel_uon2']."',
  65 + id_unid_organizacional_nivel1a = '".$_POST['frm_id_unid_organizacional_nivel1a']."',
  66 + id_local = '".$_POST['frm_id_local']."'
  67 + WHERE id_unid_organizacional_nivel2 = ".$_POST['frm_id_unid_organizacional_nivel2_anterior'];
  68 +
  69 + $result = mysql_query($query) or die ('1-Insert falhou ou sua sessão expirou!');
  70 + GravaLog('UPD',$_SERVER['SCRIPT_NAME'],'unid_organizacional_nivel2');
61 71 if (!atualiza_configuracoes_uonx('2'))
62 72 {
63 73 echo mensagem($oTranslator->_('Falha na exclusao de configuracoes'));
... ...
admin/redes/detalhes_rede.php
... ... @@ -96,6 +96,7 @@ elseif ($_POST[&#39;GravaAlteracoes&#39;])
96 96 nm_usuario_login_serv_updates = '".$_POST['frm_nm_usuario_login_serv_updates']."',
97 97 nu_porta_serv_updates = '".$_POST['frm_nu_porta_serv_updates']."',
98 98 nm_usuario_login_serv_updates_gerente = '".$_POST['frm_nm_usuario_login_serv_updates_gerente']."',
  99 + id_dominio = '".$_POST['frm_id_dominio']."',
99 100 id_local = ".$_POST['frm_id_local'].
100 101 $senhas . "
101 102 WHERE trim(id_ip_rede) = '".trim($_REQUEST['id_ip_rede'])."' AND
... ... @@ -310,7 +311,8 @@ $pos = substr_count($_SERVER[&#39;HTTP_REFERER&#39;],&#39;navegacao&#39;);
310 311 <tr>
311 312 <td>&nbsp;</td>
312 313 <td class="label"><br>Local:</td>
313   - <td class="label" colspan="2">&nbsp;</td>
  314 + <td class="label" colspan="2"><br>
  315 + Dom&iacute;nio:</td>
314 316 </tr>
315 317 <tr>
316 318 <td colspan="4" height="1" bgcolor="#333333"></td>
... ... @@ -357,7 +359,22 @@ $pos = substr_count($_SERVER[&#39;HTTP_REFERER&#39;],&#39;navegacao&#39;);
357 359 ?>
358 360 <input name="id_local_anterior" type="hidden" id="id_local_anterior" value="<? echo $id_local_anterior; ?>">
359 361 <input name="id_local" type="hidden" id="id_local" value="<? echo $_GET['id_local']; ?>"> </td>
360   - <td>&nbsp; </td>
  362 + <td nowrap><select name="frm_id_dominio" id="frm_id_dominio" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
  363 + <option value="" selected></option>
  364 + <?
  365 +
  366 + $qry_dominio = "SELECT id_dominio,
  367 + nm_dominio
  368 + FROM dominios
  369 + ORDER BY nm_dominio";
  370 +
  371 + $result_dominio = mysql_query($qry_dominio) or die ('Falha na consulta &agrave; tabela Dominios ou sua sess&atilde;o expirou!');
  372 +
  373 + while($row = mysql_fetch_array($result_dominio))
  374 + echo '<option value="'.$row['id_dominio'].'" '.(mysql_result($result, 0, 'id_dominio')==$row['id_dominio']?'selected':'').'>'.$row['nm_dominio'].'</option>';
  375 +
  376 + ?>
  377 + </select></td>
361 378 <td>&nbsp;</td>
362 379 </tr>
363 380 <tr>
... ...
admin/redes/incluir_rede.php
... ... @@ -69,7 +69,8 @@ if($_REQUEST[&#39;submit&#39;])
69 69 nm_usuario_login_serv_updates_gerente,
70 70 te_senha_login_serv_updates_gerente,
71 71 nu_porta_serv_updates,
72   - id_local)
  72 + id_dominio,
  73 + id_local)
73 74 VALUES ('$frm_id_ip_rede',
74 75 '$frm_te_mascara_rede',
75 76 '$frm_nm_rede',
... ... @@ -89,7 +90,8 @@ if($_REQUEST[&#39;submit&#39;])
89 90 '$frm_nm_usuario_login_serv_updates_gerente',
90 91 '$frm_te_senha_login_serv_updates_gerente',
91 92 '$frm_nu_porta_serv_updates',
92   - '$frm_id_local')";
  93 + '$frm_id_dominio',
  94 + '$frm_id_local')";
93 95  
94 96 $result = mysql_query($query) or die ('Insert falhou ou sua sessão expirou!');
95 97 GravaLog('INS',$_SERVER['SCRIPT_NAME'],'redes');
... ... @@ -324,7 +326,7 @@ MM_reloadPage(true);
324 326 <tr>
325 327 <td>&nbsp;</td>
326 328 <td class="label"><br>Local:</td>
327   - <td class="label" colspan="2">&nbsp;</td>
  329 + <td class="label" colspan="2"><br>Dom&iacute;nio:</td>
328 330 </tr>
329 331 <tr>
330 332 <td colspan="4" height="1" bgcolor="#333333"></td>
... ... @@ -363,7 +365,22 @@ MM_reloadPage(true);
363 365 //if ($_SESSION['cs_nivel_administracao']<>1)
364 366 // echo '<input name="frm_id_local" id="frm_id_local" type="hidden" value="'.$_SESSION['id_local'].'">';
365 367 ?> </td>
366   - <td>&nbsp; </td>
  368 + <td nowrap><select name="frm_id_dominio" id="frm_id_dominio" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
  369 + <option value="" selected></option>
  370 + <?
  371 +
  372 + $qry_dominio = "SELECT id_dominio,
  373 + nm_dominio
  374 + FROM dominios
  375 + ORDER BY nm_dominio";
  376 +
  377 + $result_dominio = mysql_query($qry_dominio) or die ('Falha na consulta &agrave; tabela Dominios ou sua sess&atilde;o expirou!');
  378 +
  379 + while($row = mysql_fetch_array($result_dominio))
  380 + echo '<option value="'.$row['id_dominio'].'" '.($row_usuario['id_dominio']==$row['id_dominio']?'selected':'').'>'.$row['nm_dominio'].'</option>';
  381 +
  382 + ?>
  383 + </select></td>
367 384 <td>&nbsp;</td>
368 385 </tr>
369 386 <tr>
... ...
admin/redes/index.php
... ... @@ -49,7 +49,7 @@ if ($_SESSION[&#39;te_locais_secundarios&#39;]&lt;&gt;&#39;&#39; &amp;&amp; $where &lt;&gt; &#39;&#39;)
49 49 $ordem = ($_GET['cs_ordem']<>''?$_GET['cs_ordem']:'sg_local,nm_rede');
50 50  
51 51 $query = 'SELECT *
52   - FROM redes '.
  52 + FROM redes LEFT JOIN dominios ON redes.id_dominio = dominios.id_dominio '.
53 53 $where .'
54 54 ORDER BY '.$ordem;
55 55  
... ... @@ -103,15 +103,17 @@ $msg = &#39;&lt;div align=&quot;center&quot;&gt;
103 103 <td align="center" nowrap>&nbsp;</td>
104 104 <td align="center" nowrap>&nbsp;</td>
105 105 <td align="center" nowrap>&nbsp;</td>
106   - <td align="center" nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=id_ip_rede"><?=$oTranslator->_('Endereco/Mascara');?></a></div></td>
  106 + <td align="center" nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=id_ip_rede">Endere&ccedil;o/M&aacute;scara</a></div></td>
107 107 <td nowrap >&nbsp;</td>
108   - <td nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=nm_rede"><?=$oTranslator->_('Subrede');?></a></div></td>
  108 + <td nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=nm_rede"><?=$oTranslator->_('Subrede');?></a></div></td>
  109 + <td nowrap >&nbsp;</td>
  110 + <td nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=nm_dominio">Domínio</a></div></td>
109 111 <td nowrap >&nbsp;</td>
110 112 <td align="center" nowrap class="cabecalho_tabela"><div align="left"><a href="index.php?cs_ordem=sg_local,nm_rede"><?=$oTranslator->_('Local');?></a></div></td>
111 113 <td nowrap >&nbsp;</td>
112 114 </tr>
113 115 <tr>
114   - <td height="1" bgcolor="#333333" colspan="9"></td>
  116 + <td height="1" bgcolor="#333333" colspan="11"></td>
115 117 </tr>
116 118  
117 119 <?
... ... @@ -137,6 +139,8 @@ else
137 139 <td nowrap>&nbsp;</td>
138 140 <td nowrap class="opcao_tabela"><div align="left"><a href="detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&id_local=<? echo $row['id_local'];?>"><? echo $row['nm_rede']; ?></a></div></td>
139 141 <td nowrap>&nbsp;</td>
  142 + <td nowrap><a href="detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&id_local=<? echo $row['id_local'];?>"><? echo $row['nm_dominio']; ?></a></td>
  143 + <td nowrap>&nbsp;</td>
140 144 <td nowrap class="opcao_tabela"><div align="left"><a href="detalhes_rede.php?id_ip_rede=<? echo $row['id_ip_rede'];?>&id_local=<? echo $row['id_local'];?>"><? echo $row['sg_local']; ?></a></div></td>
141 145 <td nowrap>&nbsp;</td>
142 146 <?
... ...
admin/sistemas_operacionais/detalhes_sistema_operacional.php
... ... @@ -26,7 +26,7 @@ require_once(&#39;../../include/library.php&#39;);
26 26 AntiSpy();
27 27 Conecta_bd_cacic();
28 28  
29   -if ($_REQUEST['ExcluiSO'])
  29 +if ($_REQUEST['ExcluiSO'] && $_SESSION['cs_nivel_administracao']==1)
30 30 {
31 31 $query = "DELETE
32 32 FROM so
... ... @@ -35,13 +35,15 @@ if ($_REQUEST[&#39;ExcluiSO&#39;])
35 35 GravaLog('DEL',$_SERVER['SCRIPT_NAME'],'so');
36 36 header ("Location: ../../include/operacao_ok.php?chamador=../admin/sistemas_operacionais/index.php&tempo=1");
37 37 }
38   -elseif ($_POST['GravaAlteracoes'])
  38 +elseif ($_POST['GravaAlteracoes'] && $_SESSION['cs_nivel_administracao']==1)
39 39 {
  40 + $strMsWindows = ($_POST['frm_in_mswindows']=='S'?'S':'N');
40 41 $query = "UPDATE so SET
41   - te_desc_so = '".$_POST['frm_te_desc_so']."',
42   - sg_so = '".$_POST['frm_sg_so']."',
43   - te_so = '".$_POST['frm_te_so']."'
44   - WHERE id_so = ".$_REQUEST['frm_id_so'];
  42 + te_desc_so = '".$_POST['frm_te_desc_so']."',
  43 + sg_so = '".$_POST['frm_sg_so']."',
  44 + te_so = '".$_POST['frm_te_so']."',
  45 + in_mswindows = '".$strMsWindows."'
  46 + WHERE id_so = ".$_REQUEST['frm_id_so'];
45 47 mysql_query($query) or die('Falha na atualização da tabela SO ou sua sessão expirou!');
46 48 GravaLog('UPD',$_SERVER['SCRIPT_NAME'],'SO');
47 49  
... ... @@ -139,12 +141,33 @@ function valida_form()
139 141 <td nowrap><input name="frm_te_so" type="text" class="normal" id="frm_te_so" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" value="<? echo $row['te_so'];?>" size="50" maxlength="50" <? if (trim($row['te_so']) <> '') echo 'disabled readonly="true"';?>></td>
140 142 <td nowrap><input name="frm_id_so" type="text" disabled class="normal" id="frm_id_so" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" value="<? echo $row['id_so'];?>" size="50" maxlength="11" readonly="true"></td>
141 143 </tr>
  144 + <tr>
  145 + <td nowrap>&nbsp;</td>
  146 + <td nowrap>&nbsp;</td>
  147 + </tr>
  148 + <tr>
  149 + <td height="1" bgcolor="#333333"></td>
  150 + <td bgcolor="#333333"></td>
  151 + </tr>
  152 +
  153 + <tr>
  154 + <td nowrap class="label"><div align="left"><input type="checkbox" name="frm_in_mswindows" id="frm_in_mswindows" value="S" <? if ($row['in_mswindows']=='S') echo 'checked';?>>
  155 + Sistema Operacional MS-Windows</div></td>
  156 + <td nowrap>&nbsp;</td>
  157 + </tr>
142 158 </table>
143 159 <p align="center"> <br>
144 160 <br>
145   - <input name="GravaAlteracoes" type="submit" id="GravaAlteracoes" value=" Gravar Altera&ccedil;&otilde;es " onClick="return valida_form();return Confirma('Confirma Informações para Local?');" <? echo ($_SESSION['cs_nivel_administracao']<>1?'disabled':'')?>>
146   - &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
147   - <input name="ExcluiSO" type="submit" id="ExcluiSO" onClick="return Confirma('Confirma Exclusão de Sistema Operacional?');" value=" Excluir Sistema Operacional" <? echo ($_SESSION['cs_nivel_administracao']<>1?'disabled':'')?>>
  161 + <?
  162 + if ($_SESSION['cs_nivel_administracao']==1)
  163 + {
  164 + ?>
  165 + <input name="GravaAlteracoes" type="submit" id="GravaAlteracoes" value=" Gravar Alterações " onClick="return valida_form();return Confirma('Confirma Informações para Local?');" <? echo ($_SESSION['cs_nivel_administracao']<>1?'disabled':'')?>>
  166 +
  167 + <input name="ExcluiSO" type="submit" id="ExcluiSO" onClick="return Confirma('Confirma Exclusão de Sistema Operacional?');" value=" Excluir Sistema Operacional" <? echo ($_SESSION['cs_nivel_administracao']<>1?'disabled':'')?>>
  168 + <?
  169 + }
  170 + ?>
148 171 </p>
149 172 <input type="hidden" id="frm_id_so" name="frm_id_so" value="<? echo $_GET['id_so'];?>">
150 173 </form>
... ...
admin/usuarios/detalhes_usuario.php
... ... @@ -51,6 +51,7 @@ elseif ($_POST[&#39;GravaAlteracoes&#39;])
51 51 nm_usuario_completo = '".$_POST['frm_nm_usuario_completo'] ."',
52 52 id_grupo_usuarios = '".$_POST['frm_id_grupo_usuarios'] ."',
53 53 id_local = ".$_POST['frm_id_local'] .",
  54 + id_dominio = ".$_POST['frm_id_dominio'] .",
54 55 te_emails_contato = '".$_POST['frm_te_emails_contato'] ."',
55 56 te_telefones_contato = '".$_POST['frm_te_telefones_contato'] ."',
56 57 te_locais_secundarios = '".$v_te_locais_secundarios ."'
... ... @@ -79,6 +80,7 @@ else
79 80 a.nm_usuario_completo,
80 81 a.id_grupo_usuarios,
81 82 a.id_local,
  83 + a.id_dominio,
82 84 a.te_emails_contato,
83 85 a.te_telefones_contato,
84 86 loc.sg_local,
... ... @@ -298,6 +300,30 @@ else
298 300 <td class="label">&nbsp;</td>
299 301 <td>&nbsp;</td>
300 302 </tr>
  303 + <tr nowrap>
  304 + <td nowrap class="label">Dom&iacute;nio:</td>
  305 + <td nowrap><select name="frm_id_dominio" id="frm_id_dominio" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
  306 + <option value="" selected></option>
  307 + <?
  308 +
  309 + $qry_dominio = "SELECT id_dominio,
  310 + nm_dominio
  311 + FROM dominios
  312 + ORDER BY nm_dominio";
  313 +
  314 + $result_dominio = mysql_query($qry_dominio) or die ('Falha na consulta &agrave; tabela Dominios ou sua sess&atilde;o expirou!');
  315 +
  316 + while($row = mysql_fetch_array($result_dominio))
  317 + echo '<option value="'.$row['id_dominio'].'" '.($row_usuario['id_dominio']==$row['id_dominio']?'selected':'').'>'.$row['nm_dominio'].'</option>';
  318 +
  319 + ?>
  320 + </select>
  321 + <strong>Obs.: </strong>Usado para autentica&ccedil;&atilde;o de Suporte Remoto.</td>
  322 + </tr>
  323 + <tr>
  324 + <td class="label">&nbsp;</td>
  325 + <td>&nbsp;</td>
  326 + </tr>
301 327 <tr>
302 328 <td class="label"><?=$oTranslator->_('Identificacao');?>:</td>
303 329 <td><input name="frm_nm_usuario_acesso" readonly="" type="text" id="frm_nm_usuario_acesso" value="<? echo mysql_result($result, 0, 'nm_usuario_acesso'); ?>" size="50" maxlength="100" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" ></td>
... ...
admin/usuarios/incluir_usuario.php
... ... @@ -48,6 +48,7 @@ if($_POST[&#39;submit&#39;])
48 48 dt_log_in,
49 49 id_grupo_usuarios,
50 50 id_local,
  51 + id_dominio,
51 52 te_emails_contato,
52 53 te_telefones_contato,
53 54 te_locais_secundarios)
... ... @@ -57,6 +58,7 @@ if($_POST[&#39;submit&#39;])
57 58 now(),
58 59 '".$_POST['frm_id_grupo_usuarios']."',
59 60 '".$_POST['frm_id_local']."',
  61 + '".$_POST['frm_id_dominio']."',
60 62 '".$_POST['frm_te_emails_contato']."',
61 63 '".$_POST['frm_te_telefones_contato']."',
62 64 '".$_POST['frm_te_locais_secundarios']."')";
... ... @@ -264,6 +266,29 @@ else
264 266 <td class="label">&nbsp;</td>
265 267 <td>&nbsp;</td>
266 268 </tr>
  269 + <tr nowrap>
  270 + <td nowrap class="label">Dom&iacute;nio:</td>
  271 + <td nowrap><select name="frm_id_dominio" id="frm_id_dominio" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
  272 + <?
  273 +
  274 + $qry_dominio = "SELECT id_dominio,
  275 + nm_dominio
  276 + FROM dominios
  277 + ORDER BY nm_dominio";
  278 +
  279 + $result_dominio = mysql_query($qry_dominio) or die ('Falha na consulta à tabela Dominios ou sua sessão expirou!');
  280 +
  281 + while($row = mysql_fetch_array($result_dominio))
  282 + echo '<option value="'.$row['id_dominio'].'">'.$row['nm_dominio'].'</option>';
  283 +
  284 + ?>
  285 + </select>
  286 + <strong>Obs.: </strong>Usado para autentica&ccedil;&atilde;o de Suporte Remoto.</td>
  287 + </tr>
  288 + <tr>
  289 + <td class="label">&nbsp;</td>
  290 + <td>&nbsp;</td>
  291 + </tr>
267 292 <tr>
268 293 <td class="label"><?=$oTranslator->_('Identificacao');?>:</td>
269 294 <td> <input name="frm_nm_usuario_acesso" type="text" id="frm_nm_usuario_acesso" size="15" maxlength="15" class="normal" onFocus="SetaClassDigitacao(this);" onBlur="SetaClassNormal(this);" >
... ...
alteracoes_estrutura_BD_CACIC_240x.sql 0 → 100755
... ... @@ -0,0 +1,74 @@
  1 +-- ---------------------------------------------------------------------------------------------
  2 +-- Estrutura da tabela `srcacic_sessoes`
  3 +-- Armazenamento de sessoes de Suporte Remoto Seguro
  4 +-- Contera os dados dos usuarios visitante e visitado e suas sessoes para fins de suporte remoto
  5 +-- ---------------------------------------------------------------------------------------------
  6 +CREATE TABLE `srcacic_sessoes`
  7 + (
  8 + `id_sessao` int(11) NOT NULL auto_increment,
  9 + `dt_hr_inicio_sessao` datetime NOT NULL,
  10 + `dt_hr_fim_sessao` datetime default NULL,
  11 + `id_usuario_visitante` int(11) NOT NULL default '0',
  12 + `nm_nome_acesso_visitado` varchar(30) character set utf8 NOT NULL,
  13 + `nm_nome_completo_visitado` varchar(100) NOT NULL default 'NoNoNo',
  14 + `te_node_address_visitado` varchar(17) character set utf8 NOT NULL,
  15 + `id_so_visitado` int(11) NOT NULL,
  16 + `te_node_address_visitante` varchar(17) character set utf8 NOT NULL default 'NoNoNo',
  17 + `dt_hr_ult_contato` datetime default NULL,
  18 + PRIMARY KEY (`id_sessao`),
  19 + KEY `idx_idUsuario` (`id_usuario_visitante`),
  20 + KEY `idx_dtHrInicioSessao` (`dt_hr_inicio_sessao`)
  21 + )
  22 +ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Log de Atividades no Sistema CACIC' AUTO_INCREMENT=1 ;
  23 +
  24 +-- -----------------------------------------------------------------------------------------------------------
  25 +-- Estrutura da tabela `dominios`
  26 +-- Armazenamento de dados de servidores de dominios
  27 +-- Esses dados serao utilizados nas autenticacoes de usuarios e criacao de sessoes para fins de suporte remoto
  28 +-- -----------------------------------------------------------------------------------------------------------
  29 +CREATE TABLE `dominios`
  30 + (
  31 + `id_dominio` int(11) NOT NULL auto_increment,
  32 + `nm_dominio` varchar(60) NOT NULL,
  33 + `te_ip_dominio` varchar(15) NOT NULL,
  34 + `id_tipo_protocolo` varchar(20) NOT NULL,
  35 + `nu_versao_protocolo` varchar(10) NOT NULL,
  36 + `te_string_DN` varchar(100) NOT NULL,
  37 + `te_observacao` text NOT NULL,
  38 + `in_ativo` char(1) NOT NULL default 'S',
  39 + PRIMARY KEY (`id_dominio`)
  40 + )
  41 +ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Servidores de Dominio para Autenticacao do srCACIC' AUTO_INCREMENT=2 ;
  42 +
  43 +-- -----------------------------------------------------------------------------------------------------------
  44 +-- Insercao da coluna `id_dominio`
  45 +-- Relacionamento de redes com servidores de dominios
  46 +-- -----------------------------------------------------------------------------------------------------------
  47 +ALTER TABLE `redes` ADD `id_dominio` INT( 11 ) NULL AFTER `id_local` ;
  48 +
  49 +-- -----------------------------------------------------------------------------------------------------------
  50 +-- Insercao da coluna `id_dominio`
  51 +-- Relacionamento de usuarios com servidores de dominios
  52 +-- -----------------------------------------------------------------------------------------------------------
  53 +ALTER TABLE `usuarios` ADD `id_dominio` INT( 11 ) NULL AFTER `id_local`
  54 +
  55 +-- -----------------------------------------------------------------------------------------------------------
  56 +-- Redimensionamento de coluna `nm_modulo` para armazenamento de nomes maiores
  57 +-- -----------------------------------------------------------------------------------------------------------
  58 +ALTER TABLE `redes_versoes_modulos` CHANGE `nm_modulo` `nm_modulo` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
  59 +
  60 +-- -------------------------------------------------------------------------------------------------------------
  61 +-- Insercao de coluna `in_mswindows` para classificacao do Sistema Operacional pelo tipo
  62 +-- Essa informacao sera usada principalmente na resposta do Gerente WEB aos Agentes quando estes fizerem contato
  63 +-- -------------------------------------------------------------------------------------------------------------
  64 +ALTER TABLE `so` ADD `in_mswindows` CHAR( 1 ) NOT NULL DEFAULT 'S';
  65 +
  66 +-- ----------------------------------------------------------------------------------------------------------------------------------
  67 +-- Redimensionamento de coluna `nm_unid_organizacional_nivel1a` para armazenamento de nomes maiores de linhas de negocio ou similares
  68 +-- ----------------------------------------------------------------------------------------------------------------------------------
  69 +ALTER TABLE `unid_organizacional_nivel1a` CHANGE `nm_unid_organizacional_nivel1a` `nm_unid_organizacional_nivel1a` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL
  70 +
  71 +-- ----------------------------------------------------------------------------------------------------------------------
  72 +-- Redimensionamento de coluna `nm_unid_organizacional_nivel2` para armazenamento de nomes maiores de orgaos ou similares
  73 +-- ----------------------------------------------------------------------------------------------------------------------
  74 +ALTER TABLE `unid_organizacional_nivel2` CHANGE `nm_unid_organizacional_nivel2` `nm_unid_organizacional_nivel2` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
0 75 \ No newline at end of file
... ...
graficos/pie_acessos.php
... ... @@ -51,7 +51,7 @@ $width = 700;
51 51 $height = 500;//250;
52 52 $DisplaySequence= 0; // Quantidade de posições para o sequencial
53 53 $ImgType = 'PNG';
54   -$myLineSize = 275;
  54 +$myLineSize = 263;
55 55 $CenterX = 450;
56 56 $DiameterX = 480;
57 57  
... ...
imgs/compactfile.ico 0 → 100755
No preview for this file type
imgs/download.png 0 → 100755

1.54 KB

imgs/extractfile.gif 0 → 100755

2.01 KB

include/Relatorio.php 0 → 100755
... ... @@ -0,0 +1,45 @@
  1 +<?php
  2 +abstract class Relatorio
  3 +{
  4 + private $m_titulo;
  5 + private $m_header;
  6 + private $m_body = array();
  7 +
  8 + public function setTitulo($titulo)
  9 + {
  10 + $this->m_titulo = $titulo;
  11 + }
  12 +
  13 + public function getTitulo()
  14 + {
  15 + return $this->m_titulo;
  16 + }
  17 +
  18 + public function setTableHeader(array $header)
  19 + {
  20 + $this->m_header = $header;
  21 + }
  22 +
  23 + public function addRow(array $row)
  24 + {
  25 + $this->m_body[] = $row;
  26 + }
  27 +
  28 + public function getHeader()
  29 + {
  30 + return $this->m_header;
  31 + }
  32 +
  33 + public function getBody()
  34 + {
  35 + return $this->m_body;
  36 + }
  37 +
  38 + public function relstrip($html)
  39 + {
  40 + return strip_tags(str_ireplace('<br>', "\n", $html));
  41 + }
  42 +
  43 + public abstract function output();
  44 +}
  45 +?>
... ...
include/RelatorioCSV.php 0 → 100755
... ... @@ -0,0 +1,42 @@
  1 +<?php
  2 +require_once('Relatorio.php');
  3 +
  4 +class RelatorioCSV extends Relatorio
  5 +{
  6 +
  7 + public function output()
  8 + {
  9 + $buffer = "";
  10 + //Data
  11 + foreach ($this->getBody() as $row)
  12 + {
  13 + $line = array();
  14 + foreach ($row as $cell)
  15 + {
  16 + $line[] = '"'.str_replace('"', '""', iconv('utf-8' ,'iso-8859-1', $this->relstrip($cell))).'"';
  17 + }
  18 + $buffer .= implode(",", $line) . "\r\n";
  19 + }
  20 +
  21 + if (ob_get_contents())
  22 + {
  23 + die('Saída já iniciada, impossível emitir CSV: ['.ob_get_contents().']');
  24 + }
  25 + if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
  26 + {
  27 + header('Content-Type: application/force-download');
  28 + }
  29 + else
  30 + {
  31 + header('Content-Type: application/octet-stream');
  32 + }
  33 + if (headers_sent())
  34 + {
  35 + die('Saída já iniciada, impossível emitir CSV.');
  36 + }
  37 + header('Content-Length: '.strlen($buffer));
  38 + header('Content-disposition: attachment; filename="relatorio.csv"');
  39 + echo $buffer;
  40 + }
  41 +}
  42 +?>
... ...
include/RelatorioHTML.php 0 → 100755
... ... @@ -0,0 +1,96 @@
  1 +<?php
  2 +require_once('Relatorio.php');
  3 +
  4 +class RelatorioHTML extends Relatorio
  5 +{
  6 + public function output()
  7 + {
  8 + $cor = FALSE;
  9 + $titulo = $this->getTitulo();
  10 + ?>
  11 + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  12 + <html>
  13 + <head>
  14 + <?php
  15 + echo "<title>$titulo</title>";
  16 + ?>
  17 + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  18 + <script language="JavaScript" type="text/JavaScript">
  19 + <!--
  20 + function MM_openBrWindow(theURL,winName,features) { //v2.0
  21 + window.open(theURL,winName,features);
  22 + }
  23 + //-->
  24 + </script>
  25 + </head>
  26 +
  27 + <body bgcolor="#FFFFFF" topmargin="5">
  28 + <table border="0" align="left" cellpadding="0" cellspacing="0" bordercolor="#999999">
  29 + <tr bgcolor="#E1E1E1">
  30 + <td rowspan="5" bgcolor="#FFFFFF"><img src="../../imgs/cacic_logo.png" width="50" height="50"></td>
  31 + <td rowspan="5" bgcolor="#FFFFFF"></td>
  32 + <td bgcolor="#FFFFFF"> </td>
  33 + </tr>
  34 + <tr width="100%" bgcolor="#E1E1E1">
  35 + <td nowrap bgcolor="#FFFFFF"><font color="#333333" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong><?=$titulo;?></strong></font></td>
  36 +
  37 + </tr>
  38 + <tr>
  39 + <td height="1" bgcolor="#333333"></td>
  40 + <tr>
  41 + <td><p align="left"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Gerado
  42 + em <? echo date("d/m/Y à\s H:i"); ?></font></p></td>
  43 + </tr>
  44 + <tr cellpadding="10" >
  45 + <td></td>
  46 + </tr>
  47 + </table>
  48 + <br>
  49 + <br>
  50 + <br>
  51 + <font size="1" face="Verdana, Arial, Helvetica, sans-serif"></tr>Exportar: <a href="?formato=pdf">PDF</a> | <a href="?formato=ods">ODS</a> | <a href="?formato=csv">CSV</a></font>
  52 + <br>
  53 + <br>
  54 + <?php
  55 + echo '<table cellpadding="2" cellspacing="0" border="1" bordercolor="#999999" bordercolordark="#E1E1E1">';
  56 + echo '<tr bgcolor="#E1E1E1" >';
  57 + foreach ($this->getHeader() as $cell)
  58 + {
  59 + echo '<td nowrap align="left">';
  60 + echo $cell;
  61 + echo '</td>';
  62 + }
  63 + echo '</tr>';
  64 +
  65 + //Data
  66 + foreach ($this->getBody() as $row)
  67 + {
  68 + echo '<tr ';
  69 + if ($cor)
  70 + {
  71 + echo 'bgcolor="#E1E1E1"';
  72 + }
  73 + echo '>';
  74 +
  75 + foreach ($row as $cell)
  76 + {
  77 + echo '<td nowrap align="left">';
  78 + echo $cell;
  79 + echo '&nbsp;</td>';
  80 + }
  81 + echo '</tr>';
  82 + $cor = !$cor;
  83 + }
  84 + ?>
  85 + </table>
  86 + <br><br>
  87 + <p align="left"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Relatório
  88 + gerado pelo <strong>CACIC</strong> - Configurador Automático e Coletor
  89 + de Informações Computacionais</font><br>
  90 + <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Software desenvolvido pela Dataprev - Unidade Regional Espírito Santo</font></p>
  91 + </body>
  92 + </html>
  93 + <?php
  94 + }
  95 +}
  96 +?>
... ...
include/RelatorioODS.php 0 → 100755
... ... @@ -0,0 +1,24 @@
  1 +<?php
  2 +require_once('Relatorio.php');
  3 +require_once("ods.php");
  4 +
  5 +class RelatorioODS extends Relatorio
  6 +{
  7 + public function output()
  8 + {
  9 + $ods = newOds();
  10 +
  11 + $i = 0;
  12 + foreach ($this->getBody() as $row)
  13 + {
  14 + $j = 0;
  15 + foreach ($row as $cell)
  16 + {
  17 + $ods->addCell(0, $i, $j++, iconv('iso-8859-1' ,'utf-8', str_ireplace('\n', '', $this->relstrip($cell))), 'string');
  18 + }
  19 + $i++;
  20 + }
  21 + $ods->output();
  22 + }
  23 +}
  24 +?>
... ...
include/RelatorioPDF.php 0 → 100755
... ... @@ -0,0 +1,263 @@
  1 +<?php
  2 +require_once('Relatorio.php');
  3 +require_once('fpdf.php');
  4 +
  5 +class PDFMTable extends FPDF
  6 +{
  7 + private $widths;
  8 + private $aligns;
  9 + private $fill;
  10 +
  11 + public function PDFMTable()
  12 + {
  13 + parent::__construct('L', 'mm', 'a3');
  14 + }
  15 +
  16 + function SetWidths($w)
  17 + {
  18 + //Set the array of column widths
  19 + $this->widths=$w;
  20 + $fullwidth = 0;
  21 + foreach ($w as $wh)
  22 + {
  23 + $fullwidth += $wh;
  24 + }
  25 + #$this->hPt=$this->fwPt;
  26 + #$this->w = $fullwidth;
  27 + $this->fhPt = ($fullwidth + $this->lMargin + $this->rMargin) * $this->k;
  28 + }
  29 +
  30 + function SetAligns($a)
  31 + {
  32 + //Set the array of column alignments
  33 + $this->aligns=$a;
  34 + }
  35 +
  36 + function Row($data)
  37 + {
  38 + //Calculate the height of the row
  39 + $nb=0;
  40 + #for($i=0;$i<count($data);$i++)
  41 + # $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
  42 + $i = 0;
  43 + foreach ($data as $value)
  44 + {
  45 + $nb=max($nb,$this->NbLines($this->widths[$i],$value));
  46 + $i++;
  47 + }
  48 + $h=5*$nb;
  49 + //Issue a page break first if needed
  50 + $this->CheckPageBreak($h);
  51 + //Draw the cells of the row
  52 + #for($i=0;$i<count($data);$i++)
  53 + #{
  54 + $i = 0;
  55 + foreach ($data as $value)
  56 + {
  57 + $w=$this->widths[$i];
  58 + $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
  59 + //Save the current position
  60 + $x=$this->GetX();
  61 + $y=$this->GetY();
  62 + if ($this->fill)
  63 + {
  64 + $style = 'DF';
  65 + }
  66 + else
  67 + {
  68 + $style = 'D';
  69 + }
  70 + //Draw the border
  71 + $this->Rect($x,$y,$w,$h, $style);
  72 + //Print the text
  73 + $this->MultiCell($w,5,$value,0,$a/*, $this->fill*/);
  74 + //Put the position to the right of the cell
  75 + $this->SetXY($x+$w,$y);
  76 + $i++;
  77 + }
  78 + $this->fill = !$this->fill;
  79 + //Go to the next line
  80 + $this->Ln($h);
  81 + }
  82 +
  83 + function CheckPageBreak($h)
  84 + {
  85 + //If the height h would cause an overflow, add a new page immediately
  86 + if($this->GetY()+$h>$this->PageBreakTrigger)
  87 + $this->AddPage($this->CurOrientation);
  88 + }
  89 +
  90 + function NbLines($w,$txt)
  91 + {
  92 + //Computes the number of lines a MultiCell of width w will take
  93 + $cw=&$this->CurrentFont['cw'];
  94 + if($w==0)
  95 + $w=$this->w-$this->rMargin-$this->x;
  96 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  97 + $s=str_replace("\r",'',$txt);
  98 + $nb=strlen($s);
  99 + if($nb>0 and $s[$nb-1]=="\n")
  100 + $nb--;
  101 + $sep=-1;
  102 + $i=0;
  103 + $j=0;
  104 + $l=0;
  105 + $nl=1;
  106 + while($i<$nb)
  107 + {
  108 + $c=$s[$i];
  109 + if($c=="\n")
  110 + {
  111 + $i++;
  112 + $sep=-1;
  113 + $j=$i;
  114 + $l=0;
  115 + $nl++;
  116 + continue;
  117 + }
  118 + if($c==' ')
  119 + $sep=$i;
  120 + $l+=$cw[$c];
  121 + if($l>$wmax)
  122 + {
  123 + if($sep==-1)
  124 + {
  125 + if($i==$j)
  126 + $i++;
  127 + }
  128 + else
  129 + $i=$sep+1;
  130 + $sep=-1;
  131 + $j=$i;
  132 + $l=0;
  133 + $nl++;
  134 + }
  135 + else
  136 + $i++;
  137 + }
  138 + return $nl;
  139 + }
  140 +}
  141 +
  142 +class RelatorioPDF extends Relatorio
  143 +{
  144 +
  145 + private function getMaxTextWidth($fpdf)
  146 + {
  147 + $maxWidths = array();
  148 + $mstr = array();
  149 + $arrays = array(array($this->getHeader()), $this->getBody());
  150 + foreach ($arrays as $array)
  151 + {
  152 + foreach ($array as $row)
  153 + {
  154 + $i = 0;
  155 + foreach ($row as $cell)
  156 + {
  157 + $w = 0;
  158 + $cell = $this->relstrip($cell);
  159 + if (strpos($cell, "\n") !== FALSE)
  160 + {
  161 + $lines = explode("\n", $cell);
  162 + foreach ($lines as $ln)
  163 + {
  164 + $tmp = $fpdf->GetStringWidth($ln);
  165 + if ($tmp > $w)
  166 + {
  167 + $w = $tmp;
  168 + $lol = $ln;
  169 + }
  170 + }
  171 + }
  172 + else
  173 + {
  174 + $w = $fpdf->GetStringWidth((string) $cell);
  175 + }
  176 +
  177 + if (!isset($maxWidths[$i]))
  178 + {
  179 + $maxWidths[$i] = $w + 10;
  180 + $mstr[$i] = $cell;
  181 + }
  182 + else if ($w > $maxWidths[$i])
  183 + {
  184 + $maxWidths[$i] = $w + 10;
  185 + $mstr[$i] = $cell;
  186 + }
  187 + $i++;
  188 + }
  189 + }
  190 + }
  191 + return $maxWidths;
  192 + }
  193 +
  194 + public function output()
  195 + {
  196 + $pdf = new PDFMTable();
  197 +
  198 +
  199 + //Colors, line width and bold font
  200 + $pdf->SetFillColor(90, 90, 200);
  201 + $pdf->SetTextColor(255);
  202 + $pdf->SetDrawColor(128, 0, 0);
  203 + $pdf->SetLineWidth(.3);
  204 + $pdf->SetFont('Arial');
  205 + //Header
  206 + $w = $this->getMaxTextWidth($pdf);
  207 + $fullwidth = array_sum($w);
  208 + $pdf->AddPage('L');
  209 + $pdf->SetWidths($w);
  210 +
  211 + $header = $this->getHeader();
  212 + $size = count($header);
  213 + $i = 0;
  214 + foreach ($header as $cell)
  215 + {
  216 + $x = $pdf->GetX();
  217 + $y = $pdf->GetY();
  218 + $pdf->MultiCell($w[$i], 7, $this->relstrip($cell), 1, 'C', 1);
  219 + $pdf->SetXY($x + $w[$i], $y);
  220 + $i++;
  221 + }
  222 + $pdf->Ln();
  223 + //Color and font restoration
  224 + $pdf->SetFillColor(224, 235, 255);
  225 + $pdf->SetTextColor(0);
  226 + $pdf->SetFont('Arial');
  227 + //Data
  228 + $fill = 0;
  229 + #foreach ($this->getBody() as $row)
  230 + $body = &$this->getBody();
  231 + $size = count($body);
  232 + for ($i = 0; $i < $size; $i++)
  233 + {
  234 + #echo 'ROW: '.$i.'<BR>';
  235 + $row = &$body[$i];
  236 + //unset($body[$i]);
  237 + //$px = $pdf->GetX();
  238 + //$py = $pdf->GetY();
  239 + //for ($i = 0; $i < count($row); $i++)
  240 + //{
  241 + // $pn = $pdf->PageNo();
  242 + // $pdf->MultiCell($w[$i], 6, iconv('utf-8' ,'iso-8859-1', /*'X: '.$px.*/'Y: '.$py/*$row[$i]*/), 1, 'L', $fill);
  243 + // $px += $w[$i];
  244 + // if ($pdf->PageNo() > $pn)
  245 + // {
  246 + // $py = 0;
  247 + // }
  248 + // $pdf->SetXY($px, $py);
  249 + //}
  250 + $count = count($row);
  251 + foreach ($row as $key => $value)
  252 + {
  253 + $row[$key] = $this->relstrip($value);// iconv('utf-8' ,'iso-8859-1', 'AAA'/*strip_tags($row[$j])*/);
  254 + }
  255 + $pdf->Row($row);
  256 + $fill = !$fill;
  257 + }
  258 + //$pdf->Cell(array_sum($w), 0, '', 'T');
  259 +
  260 + $pdf->Output('relatorio.pdf', 'D');
  261 + }
  262 +}
  263 +?>
... ...
include/fpdf.php 0 → 100755
... ... @@ -0,0 +1,1647 @@
  1 +<?php
  2 +/*******************************************************************************
  3 +* Software: FPDF *
  4 +* Version: 1.53 *
  5 +* Date: 2004-12-31 *
  6 +* Author: Olivier PLATHEY *
  7 +* License: Freeware *
  8 +* *
  9 +* You may use, modify and redistribute this software as you wish. *
  10 +*******************************************************************************/
  11 +
  12 +if(!class_exists('FPDF'))
  13 +{
  14 +define('FPDF_VERSION','1.53');
  15 +
  16 +class FPDF
  17 +{
  18 +//Private properties
  19 +var $page; //current page number
  20 +var $n; //current object number
  21 +var $offsets; //array of object offsets
  22 +var $buffer; //buffer holding in-memory PDF
  23 +var $pages; //array containing pages
  24 +var $state; //current document state
  25 +var $compress; //compression flag
  26 +var $DefOrientation; //default orientation
  27 +var $CurOrientation; //current orientation
  28 +var $OrientationChanges; //array indicating orientation changes
  29 +var $k; //scale factor (number of points in user unit)
  30 +var $fwPt,$fhPt; //dimensions of page format in points
  31 +var $fw,$fh; //dimensions of page format in user unit
  32 +var $wPt,$hPt; //current dimensions of page in points
  33 +var $w,$h; //current dimensions of page in user unit
  34 +var $lMargin; //left margin
  35 +var $tMargin; //top margin
  36 +var $rMargin; //right margin
  37 +var $bMargin; //page break margin
  38 +var $cMargin; //cell margin
  39 +var $x,$y; //current position in user unit for cell positioning
  40 +var $lasth; //height of last cell printed
  41 +var $LineWidth; //line width in user unit
  42 +var $CoreFonts; //array of standard font names
  43 +var $fonts; //array of used fonts
  44 +var $FontFiles; //array of font files
  45 +var $diffs; //array of encoding differences
  46 +var $images; //array of used images
  47 +var $PageLinks; //array of links in pages
  48 +var $links; //array of internal links
  49 +var $FontFamily; //current font family
  50 +var $FontStyle; //current font style
  51 +var $underline; //underlining flag
  52 +var $CurrentFont; //current font info
  53 +var $FontSizePt; //current font size in points
  54 +var $FontSize; //current font size in user unit
  55 +var $DrawColor; //commands for drawing color
  56 +var $FillColor; //commands for filling color
  57 +var $TextColor; //commands for text color
  58 +var $ColorFlag; //indicates whether fill and text colors are different
  59 +var $ws; //word spacing
  60 +var $AutoPageBreak; //automatic page breaking
  61 +var $PageBreakTrigger; //threshold used to trigger page breaks
  62 +var $InFooter; //flag set when processing footer
  63 +var $ZoomMode; //zoom display mode
  64 +var $LayoutMode; //layout display mode
  65 +var $title; //title
  66 +var $subject; //subject
  67 +var $author; //author
  68 +var $keywords; //keywords
  69 +var $creator; //creator
  70 +var $AliasNbPages; //alias for total number of pages
  71 +var $PDFVersion; //PDF version number
  72 +
  73 +/*******************************************************************************
  74 +* *
  75 +* Public methods *
  76 +* *
  77 +*******************************************************************************/
  78 +function FPDF($orientation='P',$unit='mm',$format='A4')
  79 +{
  80 + //Some checks
  81 + $this->_dochecks();
  82 + //Initialization of properties
  83 + $this->page=0;
  84 + $this->n=2;
  85 + $this->buffer='';
  86 + $this->pages=array();
  87 + $this->OrientationChanges=array();
  88 + $this->state=0;
  89 + $this->fonts=array();
  90 + $this->FontFiles=array();
  91 + $this->diffs=array();
  92 + $this->images=array();
  93 + $this->links=array();
  94 + $this->InFooter=false;
  95 + $this->lasth=0;
  96 + $this->FontFamily='';
  97 + $this->FontStyle='';
  98 + $this->FontSizePt=12;
  99 + $this->underline=false;
  100 + $this->DrawColor='0 G';
  101 + $this->FillColor='0 g';
  102 + $this->TextColor='0 g';
  103 + $this->ColorFlag=false;
  104 + $this->ws=0;
  105 + //Standard fonts
  106 + $this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
  107 + 'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
  108 + 'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
  109 + 'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
  110 + //Scale factor
  111 + if($unit=='pt')
  112 + $this->k=1;
  113 + elseif($unit=='mm')
  114 + $this->k=72/25.4;
  115 + elseif($unit=='cm')
  116 + $this->k=72/2.54;
  117 + elseif($unit=='in')
  118 + $this->k=72;
  119 + else
  120 + $this->Error('Incorrect unit: '.$unit);
  121 + //Page format
  122 + if(is_string($format))
  123 + {
  124 + $format=strtolower($format);
  125 + if($format=='a3')
  126 + $format=array(841.89,1190.55);
  127 + elseif($format=='a4')
  128 + $format=array(595.28,841.89);
  129 + elseif($format=='a5')
  130 + $format=array(420.94,595.28);
  131 + elseif($format=='letter')
  132 + $format=array(612,792);
  133 + elseif($format=='legal')
  134 + $format=array(612,1008);
  135 + else
  136 + $this->Error('Unknown page format: '.$format);
  137 + $this->fwPt=$format[0];
  138 + $this->fhPt=$format[1];
  139 + }
  140 + else
  141 + {
  142 + $this->fwPt=$format[0]*$this->k;
  143 + $this->fhPt=$format[1]*$this->k;
  144 + }
  145 + $this->fw=$this->fwPt/$this->k;
  146 + $this->fh=$this->fhPt/$this->k;
  147 + //Page orientation
  148 + $orientation=strtolower($orientation);
  149 + if($orientation=='p' || $orientation=='portrait')
  150 + {
  151 + $this->DefOrientation='P';
  152 + $this->wPt=$this->fwPt;
  153 + $this->hPt=$this->fhPt;
  154 + }
  155 + elseif($orientation=='l' || $orientation=='landscape')
  156 + {
  157 + $this->DefOrientation='L';
  158 + $this->wPt=$this->fhPt;
  159 + $this->hPt=$this->fwPt;
  160 + }
  161 + else
  162 + $this->Error('Incorrect orientation: '.$orientation);
  163 + $this->CurOrientation=$this->DefOrientation;
  164 + $this->w=$this->wPt/$this->k;
  165 + $this->h=$this->hPt/$this->k;
  166 + //Page margins (1 cm)
  167 + $margin=28.35/$this->k;
  168 + $this->SetMargins($margin,$margin);
  169 + //Interior cell margin (1 mm)
  170 + $this->cMargin=$margin/10;
  171 + //Line width (0.2 mm)
  172 + $this->LineWidth=.567/$this->k;
  173 + //Automatic page break
  174 + $this->SetAutoPageBreak(true,2*$margin);
  175 + //Full width display mode
  176 + $this->SetDisplayMode('fullwidth');
  177 + //Enable compression
  178 + $this->SetCompression(true);
  179 + //Set default PDF version number
  180 + $this->PDFVersion='1.3';
  181 +}
  182 +
  183 +function SetMargins($left,$top,$right=-1)
  184 +{
  185 + //Set left, top and right margins
  186 + $this->lMargin=$left;
  187 + $this->tMargin=$top;
  188 + if($right==-1)
  189 + $right=$left;
  190 + $this->rMargin=$right;
  191 +}
  192 +
  193 +function SetLeftMargin($margin)
  194 +{
  195 + //Set left margin
  196 + $this->lMargin=$margin;
  197 + if($this->page>0 && $this->x<$margin)
  198 + $this->x=$margin;
  199 +}
  200 +
  201 +function SetTopMargin($margin)
  202 +{
  203 + //Set top margin
  204 + $this->tMargin=$margin;
  205 +}
  206 +
  207 +function SetRightMargin($margin)
  208 +{
  209 + //Set right margin
  210 + $this->rMargin=$margin;
  211 +}
  212 +
  213 +function SetAutoPageBreak($auto,$margin=0)
  214 +{
  215 + //Set auto page break mode and triggering margin
  216 + $this->AutoPageBreak=$auto;
  217 + $this->bMargin=$margin;
  218 + $this->PageBreakTrigger=$this->h-$margin;
  219 +}
  220 +
  221 +function SetDisplayMode($zoom,$layout='continuous')
  222 +{
  223 + //Set display mode in viewer
  224 + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
  225 + $this->ZoomMode=$zoom;
  226 + else
  227 + $this->Error('Incorrect zoom display mode: '.$zoom);
  228 + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
  229 + $this->LayoutMode=$layout;
  230 + else
  231 + $this->Error('Incorrect layout display mode: '.$layout);
  232 +}
  233 +
  234 +function SetCompression($compress)
  235 +{
  236 + //Set page compression
  237 + if(function_exists('gzcompress'))
  238 + $this->compress=$compress;
  239 + else
  240 + $this->compress=false;
  241 +}
  242 +
  243 +function SetTitle($title)
  244 +{
  245 + //Title of document
  246 + $this->title=$title;
  247 +}
  248 +
  249 +function SetSubject($subject)
  250 +{
  251 + //Subject of document
  252 + $this->subject=$subject;
  253 +}
  254 +
  255 +function SetAuthor($author)
  256 +{
  257 + //Author of document
  258 + $this->author=$author;
  259 +}
  260 +
  261 +function SetKeywords($keywords)
  262 +{
  263 + //Keywords of document
  264 + $this->keywords=$keywords;
  265 +}
  266 +
  267 +function SetCreator($creator)
  268 +{
  269 + //Creator of document
  270 + $this->creator=$creator;
  271 +}
  272 +
  273 +function AliasNbPages($alias='{nb}')
  274 +{
  275 + //Define an alias for total number of pages
  276 + $this->AliasNbPages=$alias;
  277 +}
  278 +
  279 +function Error($msg)
  280 +{
  281 + //Fatal error
  282 + die('<B>FPDF error: </B>'.$msg);
  283 +}
  284 +
  285 +function Open()
  286 +{
  287 + //Begin document
  288 + $this->state=1;
  289 +}
  290 +
  291 +function Close()
  292 +{
  293 + //Terminate document
  294 + if($this->state==3)
  295 + return;
  296 + if($this->page==0)
  297 + $this->AddPage();
  298 + //Page footer
  299 + $this->InFooter=true;
  300 + $this->Footer();
  301 + $this->InFooter=false;
  302 + //Close page
  303 + $this->_endpage();
  304 + //Close document
  305 + $this->_enddoc();
  306 +}
  307 +
  308 +function AddPage($orientation='')
  309 +{
  310 + //Start a new page
  311 + if($this->state==0)
  312 + $this->Open();
  313 + $family=$this->FontFamily;
  314 + $style=$this->FontStyle.($this->underline ? 'U' : '');
  315 + $size=$this->FontSizePt;
  316 + $lw=$this->LineWidth;
  317 + $dc=$this->DrawColor;
  318 + $fc=$this->FillColor;
  319 + $tc=$this->TextColor;
  320 + $cf=$this->ColorFlag;
  321 + if($this->page>0)
  322 + {
  323 + //Page footer
  324 + $this->InFooter=true;
  325 + $this->Footer();
  326 + $this->InFooter=false;
  327 + //Close page
  328 + $this->_endpage();
  329 + }
  330 + //Start new page
  331 + $this->_beginpage($orientation);
  332 + //Set line cap style to square
  333 + $this->_out('2 J');
  334 + //Set line width
  335 + $this->LineWidth=$lw;
  336 + $this->_out(sprintf('%.2f w',$lw*$this->k));
  337 + //Set font
  338 + if($family)
  339 + $this->SetFont($family,$style,$size);
  340 + //Set colors
  341 + $this->DrawColor=$dc;
  342 + if($dc!='0 G')
  343 + $this->_out($dc);
  344 + $this->FillColor=$fc;
  345 + if($fc!='0 g')
  346 + $this->_out($fc);
  347 + $this->TextColor=$tc;
  348 + $this->ColorFlag=$cf;
  349 + //Page header
  350 + $this->Header();
  351 + //Restore line width
  352 + if($this->LineWidth!=$lw)
  353 + {
  354 + $this->LineWidth=$lw;
  355 + $this->_out(sprintf('%.2f w',$lw*$this->k));
  356 + }
  357 + //Restore font
  358 + if($family)
  359 + $this->SetFont($family,$style,$size);
  360 + //Restore colors
  361 + if($this->DrawColor!=$dc)
  362 + {
  363 + $this->DrawColor=$dc;
  364 + $this->_out($dc);
  365 + }
  366 + if($this->FillColor!=$fc)
  367 + {
  368 + $this->FillColor=$fc;
  369 + $this->_out($fc);
  370 + }
  371 + $this->TextColor=$tc;
  372 + $this->ColorFlag=$cf;
  373 +}
  374 +
  375 +function Header()
  376 +{
  377 + //To be implemented in your own inherited class
  378 +}
  379 +
  380 +function Footer()
  381 +{
  382 + //To be implemented in your own inherited class
  383 +}
  384 +
  385 +function PageNo()
  386 +{
  387 + //Get current page number
  388 + return $this->page;
  389 +}
  390 +
  391 +function SetDrawColor($r,$g=-1,$b=-1)
  392 +{
  393 + //Set color for all stroking operations
  394 + if(($r==0 && $g==0 && $b==0) || $g==-1)
  395 + $this->DrawColor=sprintf('%.3f G',$r/255);
  396 + else
  397 + $this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
  398 + if($this->page>0)
  399 + $this->_out($this->DrawColor);
  400 +}
  401 +
  402 +function SetFillColor($r,$g=-1,$b=-1)
  403 +{
  404 + //Set color for all filling operations
  405 + if(($r==0 && $g==0 && $b==0) || $g==-1)
  406 + $this->FillColor=sprintf('%.3f g',$r/255);
  407 + else
  408 + $this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
  409 + $this->ColorFlag=($this->FillColor!=$this->TextColor);
  410 + if($this->page>0)
  411 + $this->_out($this->FillColor);
  412 +}
  413 +
  414 +function SetTextColor($r,$g=-1,$b=-1)
  415 +{
  416 + //Set color for text
  417 + if(($r==0 && $g==0 && $b==0) || $g==-1)
  418 + $this->TextColor=sprintf('%.3f g',$r/255);
  419 + else
  420 + $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
  421 + $this->ColorFlag=($this->FillColor!=$this->TextColor);
  422 +}
  423 +
  424 +function GetStringWidth($s)
  425 +{
  426 + //Get width of a string in the current font
  427 + $s=(string)$s;
  428 + $cw=&$this->CurrentFont['cw'];
  429 + $w=0;
  430 + $l=strlen($s);
  431 + for($i=0;$i<$l;$i++)
  432 + $w+=$cw[$s{$i}];
  433 + return $w*$this->FontSize/1000;
  434 +}
  435 +
  436 +function SetLineWidth($width)
  437 +{
  438 + //Set line width
  439 + $this->LineWidth=$width;
  440 + if($this->page>0)
  441 + $this->_out(sprintf('%.2f w',$width*$this->k));
  442 +}
  443 +
  444 +function Line($x1,$y1,$x2,$y2)
  445 +{
  446 + //Draw a line
  447 + $this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
  448 +}
  449 +
  450 +function Rect($x,$y,$w,$h,$style='')
  451 +{
  452 + //Draw a rectangle
  453 + if($style=='F')
  454 + $op='f';
  455 + elseif($style=='FD' || $style=='DF')
  456 + $op='B';
  457 + else
  458 + $op='S';
  459 + $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
  460 +}
  461 +
  462 +function AddFont($family,$style='',$file='')
  463 +{
  464 + //Add a TrueType or Type1 font
  465 + $family=strtolower($family);
  466 + if($file=='')
  467 + $file=str_replace(' ','',$family).strtolower($style).'.php';
  468 + if($family=='arial')
  469 + $family='helvetica';
  470 + $style=strtoupper($style);
  471 + if($style=='IB')
  472 + $style='BI';
  473 + $fontkey=$family.$style;
  474 + if(isset($this->fonts[$fontkey]))
  475 + $this->Error('Font already added: '.$family.' '.$style);
  476 + include($this->_getfontpath().$file);
  477 + if(!isset($name))
  478 + $this->Error('Could not include font definition file');
  479 + $i=count($this->fonts)+1;
  480 + $this->fonts[$fontkey]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file);
  481 + if($diff)
  482 + {
  483 + //Search existing encodings
  484 + $d=0;
  485 + $nb=count($this->diffs);
  486 + for($i=1;$i<=$nb;$i++)
  487 + {
  488 + if($this->diffs[$i]==$diff)
  489 + {
  490 + $d=$i;
  491 + break;
  492 + }
  493 + }
  494 + if($d==0)
  495 + {
  496 + $d=$nb+1;
  497 + $this->diffs[$d]=$diff;
  498 + }
  499 + $this->fonts[$fontkey]['diff']=$d;
  500 + }
  501 + if($file)
  502 + {
  503 + if($type=='TrueType')
  504 + $this->FontFiles[$file]=array('length1'=>$originalsize);
  505 + else
  506 + $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
  507 + }
  508 +}
  509 +
  510 +function SetFont($family,$style='',$size=0)
  511 +{
  512 + //Select a font; size given in points
  513 + global $fpdf_charwidths;
  514 +
  515 + $family=strtolower($family);
  516 + if($family=='')
  517 + $family=$this->FontFamily;
  518 + if($family=='arial')
  519 + $family='helvetica';
  520 + elseif($family=='symbol' || $family=='zapfdingbats')
  521 + $style='';
  522 + $style=strtoupper($style);
  523 + if(strpos($style,'U')!==false)
  524 + {
  525 + $this->underline=true;
  526 + $style=str_replace('U','',$style);
  527 + }
  528 + else
  529 + $this->underline=false;
  530 + if($style=='IB')
  531 + $style='BI';
  532 + if($size==0)
  533 + $size=$this->FontSizePt;
  534 + //Test if font is already selected
  535 + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
  536 + return;
  537 + //Test if used for the first time
  538 + $fontkey=$family.$style;
  539 + if(!isset($this->fonts[$fontkey]))
  540 + {
  541 + //Check if one of the standard fonts
  542 + if(isset($this->CoreFonts[$fontkey]))
  543 + {
  544 + if(!isset($fpdf_charwidths[$fontkey]))
  545 + {
  546 + //Load metric file
  547 + $file=$family;
  548 + if($family=='times' || $family=='helvetica')
  549 + $file.=strtolower($style);
  550 + include($this->_getfontpath().$file.'.php');
  551 + if(!isset($fpdf_charwidths[$fontkey]))
  552 + $this->Error('Could not include font metric file');
  553 + }
  554 + $i=count($this->fonts)+1;
  555 + $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
  556 + }
  557 + else
  558 + $this->Error('Undefined font: '.$family.' '.$style);
  559 + }
  560 + //Select it
  561 + $this->FontFamily=$family;
  562 + $this->FontStyle=$style;
  563 + $this->FontSizePt=$size;
  564 + $this->FontSize=$size/$this->k;
  565 + $this->CurrentFont=&$this->fonts[$fontkey];
  566 + if($this->page>0)
  567 + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
  568 +}
  569 +
  570 +function SetFontSize($size)
  571 +{
  572 + //Set font size in points
  573 + if($this->FontSizePt==$size)
  574 + return;
  575 + $this->FontSizePt=$size;
  576 + $this->FontSize=$size/$this->k;
  577 + if($this->page>0)
  578 + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
  579 +}
  580 +
  581 +function AddLink()
  582 +{
  583 + //Create a new internal link
  584 + $n=count($this->links)+1;
  585 + $this->links[$n]=array(0,0);
  586 + return $n;
  587 +}
  588 +
  589 +function SetLink($link,$y=0,$page=-1)
  590 +{
  591 + //Set destination of internal link
  592 + if($y==-1)
  593 + $y=$this->y;
  594 + if($page==-1)
  595 + $page=$this->page;
  596 + $this->links[$link]=array($page,$y);
  597 +}
  598 +
  599 +function Link($x,$y,$w,$h,$link)
  600 +{
  601 + //Put a link on the page
  602 + $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link);
  603 +}
  604 +
  605 +function Text($x,$y,$txt)
  606 +{
  607 + //Output a string
  608 + $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
  609 + if($this->underline && $txt!='')
  610 + $s.=' '.$this->_dounderline($x,$y,$txt);
  611 + if($this->ColorFlag)
  612 + $s='q '.$this->TextColor.' '.$s.' Q';
  613 + $this->_out($s);
  614 +}
  615 +
  616 +function AcceptPageBreak()
  617 +{
  618 + //Accept automatic page break or not
  619 + return $this->AutoPageBreak;
  620 +}
  621 +
  622 +function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
  623 +{
  624 + //Output a cell
  625 + $k=$this->k;
  626 + if($this->y+$h>$this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak())
  627 + {
  628 + //Automatic page break
  629 + $x=$this->x;
  630 + $ws=$this->ws;
  631 + if($ws>0)
  632 + {
  633 + $this->ws=0;
  634 + $this->_out('0 Tw');
  635 + }
  636 + $this->AddPage($this->CurOrientation);
  637 + $this->x=$x;
  638 + if($ws>0)
  639 + {
  640 + $this->ws=$ws;
  641 + $this->_out(sprintf('%.3f Tw',$ws*$k));
  642 + }
  643 + }
  644 + if($w==0)
  645 + $w=$this->w-$this->rMargin-$this->x;
  646 + $s='';
  647 + if($fill==1 || $border==1)
  648 + {
  649 + if($fill==1)
  650 + $op=($border==1) ? 'B' : 'f';
  651 + else
  652 + $op='S';
  653 + $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
  654 + }
  655 + if(is_string($border))
  656 + {
  657 + $x=$this->x;
  658 + $y=$this->y;
  659 + if(strpos($border,'L')!==false)
  660 + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
  661 + if(strpos($border,'T')!==false)
  662 + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
  663 + if(strpos($border,'R')!==false)
  664 + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
  665 + if(strpos($border,'B')!==false)
  666 + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
  667 + }
  668 + if($txt!=='')
  669 + {
  670 + if($align=='R')
  671 + $dx=$w-$this->cMargin-$this->GetStringWidth($txt);
  672 + elseif($align=='C')
  673 + $dx=($w-$this->GetStringWidth($txt))/2;
  674 + else
  675 + $dx=$this->cMargin;
  676 + if($this->ColorFlag)
  677 + $s.='q '.$this->TextColor.' ';
  678 + $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
  679 + $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
  680 + if($this->underline)
  681 + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
  682 + if($this->ColorFlag)
  683 + $s.=' Q';
  684 + if($link)
  685 + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
  686 + }
  687 + if($s)
  688 + $this->_out($s);
  689 + $this->lasth=$h;
  690 + if($ln>0)
  691 + {
  692 + //Go to next line
  693 + $this->y+=$h;
  694 + if($ln==1)
  695 + $this->x=$this->lMargin;
  696 + }
  697 + else
  698 + $this->x+=$w;
  699 +}
  700 +
  701 +function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
  702 +{
  703 + //Output text with automatic or explicit line breaks
  704 + $cw=&$this->CurrentFont['cw'];
  705 + if($w==0)
  706 + $w=$this->w-$this->rMargin-$this->x;
  707 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  708 + $s=str_replace("\r",'',$txt);
  709 + $nb=strlen($s);
  710 + if($nb>0 && $s[$nb-1]=="\n")
  711 + $nb--;
  712 + $b=0;
  713 + if($border)
  714 + {
  715 + if($border==1)
  716 + {
  717 + $border='LTRB';
  718 + $b='LRT';
  719 + $b2='LR';
  720 + }
  721 + else
  722 + {
  723 + $b2='';
  724 + if(strpos($border,'L')!==false)
  725 + $b2.='L';
  726 + if(strpos($border,'R')!==false)
  727 + $b2.='R';
  728 + $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
  729 + }
  730 + }
  731 + $sep=-1;
  732 + $i=0;
  733 + $j=0;
  734 + $l=0;
  735 + $ns=0;
  736 + $nl=1;
  737 + while($i<$nb)
  738 + {
  739 + //Get next character
  740 + $c=$s{$i};
  741 + if($c=="\n")
  742 + {
  743 + //Explicit line break
  744 + if($this->ws>0)
  745 + {
  746 + $this->ws=0;
  747 + $this->_out('0 Tw');
  748 + }
  749 + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
  750 + $i++;
  751 + $sep=-1;
  752 + $j=$i;
  753 + $l=0;
  754 + $ns=0;
  755 + $nl++;
  756 + if($border && $nl==2)
  757 + $b=$b2;
  758 + continue;
  759 + }
  760 + if($c==' ')
  761 + {
  762 + $sep=$i;
  763 + $ls=$l;
  764 + $ns++;
  765 + }
  766 + $l+=$cw[$c];
  767 + if($l>$wmax)
  768 + {
  769 + //Automatic line break
  770 + if($sep==-1)
  771 + {
  772 + if($i==$j)
  773 + $i++;
  774 + if($this->ws>0)
  775 + {
  776 + $this->ws=0;
  777 + $this->_out('0 Tw');
  778 + }
  779 + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
  780 + }
  781 + else
  782 + {
  783 + if($align=='J')
  784 + {
  785 + $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
  786 + $this->_out(sprintf('%.3f Tw',$this->ws*$this->k));
  787 + }
  788 + $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
  789 + $i=$sep+1;
  790 + }
  791 + $sep=-1;
  792 + $j=$i;
  793 + $l=0;
  794 + $ns=0;
  795 + $nl++;
  796 + if($border && $nl==2)
  797 + $b=$b2;
  798 + }
  799 + else
  800 + $i++;
  801 + }
  802 + //Last chunk
  803 + if($this->ws>0)
  804 + {
  805 + $this->ws=0;
  806 + $this->_out('0 Tw');
  807 + }
  808 + if($border && strpos($border,'B')!==false)
  809 + $b.='B';
  810 + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
  811 + $this->x=$this->lMargin;
  812 +}
  813 +
  814 +function Write($h,$txt,$link='')
  815 +{
  816 + //Output text in flowing mode
  817 + $cw=&$this->CurrentFont['cw'];
  818 + $w=$this->w-$this->rMargin-$this->x;
  819 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  820 + $s=str_replace("\r",'',$txt);
  821 + $nb=strlen($s);
  822 + $sep=-1;
  823 + $i=0;
  824 + $j=0;
  825 + $l=0;
  826 + $nl=1;
  827 + while($i<$nb)
  828 + {
  829 + //Get next character
  830 + $c=$s{$i};
  831 + if($c=="\n")
  832 + {
  833 + //Explicit line break
  834 + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
  835 + $i++;
  836 + $sep=-1;
  837 + $j=$i;
  838 + $l=0;
  839 + if($nl==1)
  840 + {
  841 + $this->x=$this->lMargin;
  842 + $w=$this->w-$this->rMargin-$this->x;
  843 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  844 + }
  845 + $nl++;
  846 + continue;
  847 + }
  848 + if($c==' ')
  849 + $sep=$i;
  850 + $l+=$cw[$c];
  851 + if($l>$wmax)
  852 + {
  853 + //Automatic line break
  854 + if($sep==-1)
  855 + {
  856 + if($this->x>$this->lMargin)
  857 + {
  858 + //Move to next line
  859 + $this->x=$this->lMargin;
  860 + $this->y+=$h;
  861 + $w=$this->w-$this->rMargin-$this->x;
  862 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  863 + $i++;
  864 + $nl++;
  865 + continue;
  866 + }
  867 + if($i==$j)
  868 + $i++;
  869 + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
  870 + }
  871 + else
  872 + {
  873 + $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
  874 + $i=$sep+1;
  875 + }
  876 + $sep=-1;
  877 + $j=$i;
  878 + $l=0;
  879 + if($nl==1)
  880 + {
  881 + $this->x=$this->lMargin;
  882 + $w=$this->w-$this->rMargin-$this->x;
  883 + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  884 + }
  885 + $nl++;
  886 + }
  887 + else
  888 + $i++;
  889 + }
  890 + //Last chunk
  891 + if($i!=$j)
  892 + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
  893 +}
  894 +
  895 +function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
  896 +{
  897 + //Put an image on the page
  898 + if(!isset($this->images[$file]))
  899 + {
  900 + //First use of image, get info
  901 + if($type=='')
  902 + {
  903 + $pos=strrpos($file,'.');
  904 + if(!$pos)
  905 + $this->Error('Image file has no extension and no type was specified: '.$file);
  906 + $type=substr($file,$pos+1);
  907 + }
  908 + $type=strtolower($type);
  909 + $mqr=get_magic_quotes_runtime();
  910 + set_magic_quotes_runtime(0);
  911 + if($type=='jpg' || $type=='jpeg')
  912 + $info=$this->_parsejpg($file);
  913 + elseif($type=='png')
  914 + $info=$this->_parsepng($file);
  915 + else
  916 + {
  917 + //Allow for additional formats
  918 + $mtd='_parse'.$type;
  919 + if(!method_exists($this,$mtd))
  920 + $this->Error('Unsupported image type: '.$type);
  921 + $info=$this->$mtd($file);
  922 + }
  923 + set_magic_quotes_runtime($mqr);
  924 + $info['i']=count($this->images)+1;
  925 + $this->images[$file]=$info;
  926 + }
  927 + else
  928 + $info=$this->images[$file];
  929 + //Automatic width and height calculation if needed
  930 + if($w==0 && $h==0)
  931 + {
  932 + //Put image at 72 dpi
  933 + $w=$info['w']/$this->k;
  934 + $h=$info['h']/$this->k;
  935 + }
  936 + if($w==0)
  937 + $w=$h*$info['w']/$info['h'];
  938 + if($h==0)
  939 + $h=$w*$info['h']/$info['w'];
  940 + $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
  941 + if($link)
  942 + $this->Link($x,$y,$w,$h,$link);
  943 +}
  944 +
  945 +function Ln($h='')
  946 +{
  947 + //Line feed; default value is last cell height
  948 + $this->x=$this->lMargin;
  949 + if(is_string($h))
  950 + $this->y+=$this->lasth;
  951 + else
  952 + $this->y+=$h;
  953 +}
  954 +
  955 +function GetX()
  956 +{
  957 + //Get x position
  958 + return $this->x;
  959 +}
  960 +
  961 +function SetX($x)
  962 +{
  963 + //Set x position
  964 + if($x>=0)
  965 + $this->x=$x;
  966 + else
  967 + $this->x=$this->w+$x;
  968 +}
  969 +
  970 +function GetY()
  971 +{
  972 + //Get y position
  973 + return $this->y;
  974 +}
  975 +
  976 +function SetY($y)
  977 +{
  978 + //Set y position and reset x
  979 + $this->x=$this->lMargin;
  980 + if($y>=0)
  981 + $this->y=$y;
  982 + else
  983 + $this->y=$this->h+$y;
  984 +}
  985 +
  986 +function SetXY($x,$y)
  987 +{
  988 + //Set x and y positions
  989 + $this->SetY($y);
  990 + $this->SetX($x);
  991 +}
  992 +
  993 +function Output($name='',$dest='')
  994 +{
  995 + //Output PDF to some destination
  996 + //Finish document if necessary
  997 + if($this->state<3)
  998 + $this->Close();
  999 + //Normalize parameters
  1000 + if(is_bool($dest))
  1001 + $dest=$dest ? 'D' : 'F';
  1002 + $dest=strtoupper($dest);
  1003 + if($dest=='')
  1004 + {
  1005 + if($name=='')
  1006 + {
  1007 + $name='doc.pdf';
  1008 + $dest='I';
  1009 + }
  1010 + else
  1011 + $dest='F';
  1012 + }
  1013 + switch($dest)
  1014 + {
  1015 + case 'I':
  1016 + //Send to standard output
  1017 + if(ob_get_contents())
  1018 + $this->Error('Some data has already been output, can\'t send PDF file');
  1019 + if(php_sapi_name()!='cli')
  1020 + {
  1021 + //We send to a browser
  1022 + header('Content-Type: application/pdf');
  1023 + if(headers_sent())
  1024 + $this->Error('Some data has already been output to browser, can\'t send PDF file');
  1025 + header('Content-Length: '.strlen($this->buffer));
  1026 + header('Content-disposition: inline; filename="'.$name.'"');
  1027 + }
  1028 + echo $this->buffer;
  1029 + break;
  1030 + case 'D':
  1031 + //Download file
  1032 + if(ob_get_contents())
  1033 + $this->Error('Some data has already been output, can\'t send PDF file: ['.ob_get_contents().']');
  1034 + if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
  1035 + header('Content-Type: application/force-download');
  1036 + else
  1037 + header('Content-Type: application/octet-stream');
  1038 + if(headers_sent())
  1039 + $this->Error('Saome data has already been output to browser, can\'t send PDF file');
  1040 + header('Content-Length: '.strlen($this->buffer));
  1041 + header('Content-disposition: attachment; filename="'.$name.'"');
  1042 + echo $this->buffer;
  1043 + break;
  1044 + case 'F':
  1045 + //Save to local file
  1046 + $f=fopen($name,'wb');
  1047 + if(!$f)
  1048 + $this->Error('Unable to create output file: '.$name);
  1049 + fwrite($f,$this->buffer,strlen($this->buffer));
  1050 + fclose($f);
  1051 + break;
  1052 + case 'S':
  1053 + //Return as a string
  1054 + return $this->buffer;
  1055 + default:
  1056 + $this->Error('Incorrect output destination: '.$dest);
  1057 + }
  1058 + return '';
  1059 +}
  1060 +
  1061 +/*******************************************************************************
  1062 +* *
  1063 +* Protected methods *
  1064 +* *
  1065 +*******************************************************************************/
  1066 +function _dochecks()
  1067 +{
  1068 + //Check for locale-related bug
  1069 + if(1.1==1)
  1070 + $this->Error('Don\'t alter the locale before including class file');
  1071 + //Check for decimal separator
  1072 + if(sprintf('%.1f',1.0)!='1.0')
  1073 + setlocale(LC_NUMERIC,'C');
  1074 +}
  1075 +
  1076 +function _getfontpath()
  1077 +{
  1078 + if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
  1079 + define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
  1080 + return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
  1081 +}
  1082 +
  1083 +function _putpages()
  1084 +{
  1085 + $nb=$this->page;
  1086 + if(!empty($this->AliasNbPages))
  1087 + {
  1088 + //Replace number of pages
  1089 + for($n=1;$n<=$nb;$n++)
  1090 + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
  1091 + }
  1092 + if($this->DefOrientation=='P')
  1093 + {
  1094 + $wPt=$this->fwPt;
  1095 + $hPt=$this->fhPt;
  1096 + }
  1097 + else
  1098 + {
  1099 + $wPt=$this->fhPt;
  1100 + $hPt=$this->fwPt;
  1101 + }
  1102 + $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
  1103 + for($n=1;$n<=$nb;$n++)
  1104 + {
  1105 + //Page
  1106 + $this->_newobj();
  1107 + $this->_out('<</Type /Page');
  1108 + $this->_out('/Parent 1 0 R');
  1109 + if(isset($this->OrientationChanges[$n]))
  1110 + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
  1111 + $this->_out('/Resources 2 0 R');
  1112 + if(isset($this->PageLinks[$n]))
  1113 + {
  1114 + //Links
  1115 + $annots='/Annots [';
  1116 + foreach($this->PageLinks[$n] as $pl)
  1117 + {
  1118 + $rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
  1119 + $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
  1120 + if(is_string($pl[4]))
  1121 + $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
  1122 + else
  1123 + {
  1124 + $l=$this->links[$pl[4]];
  1125 + $h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
  1126 + $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
  1127 + }
  1128 + }
  1129 + $this->_out($annots.']');
  1130 + }
  1131 + $this->_out('/Contents '.($this->n+1).' 0 R>>');
  1132 + $this->_out('endobj');
  1133 + //Page content
  1134 + $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
  1135 + $this->_newobj();
  1136 + $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
  1137 + $this->_putstream($p);
  1138 + $this->_out('endobj');
  1139 + }
  1140 + //Pages root
  1141 + $this->offsets[1]=strlen($this->buffer);
  1142 + $this->_out('1 0 obj');
  1143 + $this->_out('<</Type /Pages');
  1144 + $kids='/Kids [';
  1145 + for($i=0;$i<$nb;$i++)
  1146 + $kids.=(3+2*$i).' 0 R ';
  1147 + $this->_out($kids.']');
  1148 + $this->_out('/Count '.$nb);
  1149 + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
  1150 + $this->_out('>>');
  1151 + $this->_out('endobj');
  1152 +}
  1153 +
  1154 +function _putfonts()
  1155 +{
  1156 + $nf=$this->n;
  1157 + foreach($this->diffs as $diff)
  1158 + {
  1159 + //Encodings
  1160 + $this->_newobj();
  1161 + $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
  1162 + $this->_out('endobj');
  1163 + }
  1164 + $mqr=get_magic_quotes_runtime();
  1165 + set_magic_quotes_runtime(0);
  1166 + foreach($this->FontFiles as $file=>$info)
  1167 + {
  1168 + //Font file embedding
  1169 + $this->_newobj();
  1170 + $this->FontFiles[$file]['n']=$this->n;
  1171 + $font='';
  1172 + $f=fopen($this->_getfontpath().$file,'rb',1);
  1173 + if(!$f)
  1174 + $this->Error('Font file not found');
  1175 + while(!feof($f))
  1176 + $font.=fread($f,8192);
  1177 + fclose($f);
  1178 + $compressed=(substr($file,-2)=='.z');
  1179 + if(!$compressed && isset($info['length2']))
  1180 + {
  1181 + $header=(ord($font{0})==128);
  1182 + if($header)
  1183 + {
  1184 + //Strip first binary header
  1185 + $font=substr($font,6);
  1186 + }
  1187 + if($header && ord($font{$info['length1']})==128)
  1188 + {
  1189 + //Strip second binary header
  1190 + $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
  1191 + }
  1192 + }
  1193 + $this->_out('<</Length '.strlen($font));
  1194 + if($compressed)
  1195 + $this->_out('/Filter /FlateDecode');
  1196 + $this->_out('/Length1 '.$info['length1']);
  1197 + if(isset($info['length2']))
  1198 + $this->_out('/Length2 '.$info['length2'].' /Length3 0');
  1199 + $this->_out('>>');
  1200 + $this->_putstream($font);
  1201 + $this->_out('endobj');
  1202 + }
  1203 + set_magic_quotes_runtime($mqr);
  1204 + foreach($this->fonts as $k=>$font)
  1205 + {
  1206 + //Font objects
  1207 + $this->fonts[$k]['n']=$this->n+1;
  1208 + $type=$font['type'];
  1209 + $name=$font['name'];
  1210 + if($type=='core')
  1211 + {
  1212 + //Standard font
  1213 + $this->_newobj();
  1214 + $this->_out('<</Type /Font');
  1215 + $this->_out('/BaseFont /'.$name);
  1216 + $this->_out('/Subtype /Type1');
  1217 + if($name!='Symbol' && $name!='ZapfDingbats')
  1218 + $this->_out('/Encoding /WinAnsiEncoding');
  1219 + $this->_out('>>');
  1220 + $this->_out('endobj');
  1221 + }
  1222 + elseif($type=='Type1' || $type=='TrueType')
  1223 + {
  1224 + //Additional Type1 or TrueType font
  1225 + $this->_newobj();
  1226 + $this->_out('<</Type /Font');
  1227 + $this->_out('/BaseFont /'.$name);
  1228 + $this->_out('/Subtype /'.$type);
  1229 + $this->_out('/FirstChar 32 /LastChar 255');
  1230 + $this->_out('/Widths '.($this->n+1).' 0 R');
  1231 + $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
  1232 + if($font['enc'])
  1233 + {
  1234 + if(isset($font['diff']))
  1235 + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
  1236 + else
  1237 + $this->_out('/Encoding /WinAnsiEncoding');
  1238 + }
  1239 + $this->_out('>>');
  1240 + $this->_out('endobj');
  1241 + //Widths
  1242 + $this->_newobj();
  1243 + $cw=&$font['cw'];
  1244 + $s='[';
  1245 + for($i=32;$i<=255;$i++)
  1246 + $s.=$cw[chr($i)].' ';
  1247 + $this->_out($s.']');
  1248 + $this->_out('endobj');
  1249 + //Descriptor
  1250 + $this->_newobj();
  1251 + $s='<</Type /FontDescriptor /FontName /'.$name;
  1252 + foreach($font['desc'] as $k=>$v)
  1253 + $s.=' /'.$k.' '.$v;
  1254 + $file=$font['file'];
  1255 + if($file)
  1256 + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
  1257 + $this->_out($s.'>>');
  1258 + $this->_out('endobj');
  1259 + }
  1260 + else
  1261 + {
  1262 + //Allow for additional types
  1263 + $mtd='_put'.strtolower($type);
  1264 + if(!method_exists($this,$mtd))
  1265 + $this->Error('Unsupported font type: '.$type);
  1266 + $this->$mtd($font);
  1267 + }
  1268 + }
  1269 +}
  1270 +
  1271 +function _putimages()
  1272 +{
  1273 + $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
  1274 + reset($this->images);
  1275 + while(list($file,$info)=each($this->images))
  1276 + {
  1277 + $this->_newobj();
  1278 + $this->images[$file]['n']=$this->n;
  1279 + $this->_out('<</Type /XObject');
  1280 + $this->_out('/Subtype /Image');
  1281 + $this->_out('/Width '.$info['w']);
  1282 + $this->_out('/Height '.$info['h']);
  1283 + if($info['cs']=='Indexed')
  1284 + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
  1285 + else
  1286 + {
  1287 + $this->_out('/ColorSpace /'.$info['cs']);
  1288 + if($info['cs']=='DeviceCMYK')
  1289 + $this->_out('/Decode [1 0 1 0 1 0 1 0]');
  1290 + }
  1291 + $this->_out('/BitsPerComponent '.$info['bpc']);
  1292 + if(isset($info['f']))
  1293 + $this->_out('/Filter /'.$info['f']);
  1294 + if(isset($info['parms']))
  1295 + $this->_out($info['parms']);
  1296 + if(isset($info['trns']) && is_array($info['trns']))
  1297 + {
  1298 + $trns='';
  1299 + for($i=0;$i<count($info['trns']);$i++)
  1300 + $trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
  1301 + $this->_out('/Mask ['.$trns.']');
  1302 + }
  1303 + $this->_out('/Length '.strlen($info['data']).'>>');
  1304 + $this->_putstream($info['data']);
  1305 + unset($this->images[$file]['data']);
  1306 + $this->_out('endobj');
  1307 + //Palette
  1308 + if($info['cs']=='Indexed')
  1309 + {
  1310 + $this->_newobj();
  1311 + $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
  1312 + $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
  1313 + $this->_putstream($pal);
  1314 + $this->_out('endobj');
  1315 + }
  1316 + }
  1317 +}
  1318 +
  1319 +function _putxobjectdict()
  1320 +{
  1321 + foreach($this->images as $image)
  1322 + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
  1323 +}
  1324 +
  1325 +function _putresourcedict()
  1326 +{
  1327 + $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
  1328 + $this->_out('/Font <<');
  1329 + foreach($this->fonts as $font)
  1330 + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
  1331 + $this->_out('>>');
  1332 + $this->_out('/XObject <<');
  1333 + $this->_putxobjectdict();
  1334 + $this->_out('>>');
  1335 +}
  1336 +
  1337 +function _putresources()
  1338 +{
  1339 + $this->_putfonts();
  1340 + $this->_putimages();
  1341 + //Resource dictionary
  1342 + $this->offsets[2]=strlen($this->buffer);
  1343 + $this->_out('2 0 obj');
  1344 + $this->_out('<<');
  1345 + $this->_putresourcedict();
  1346 + $this->_out('>>');
  1347 + $this->_out('endobj');
  1348 +}
  1349 +
  1350 +function _putinfo()
  1351 +{
  1352 + $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
  1353 + if(!empty($this->title))
  1354 + $this->_out('/Title '.$this->_textstring($this->title));
  1355 + if(!empty($this->subject))
  1356 + $this->_out('/Subject '.$this->_textstring($this->subject));
  1357 + if(!empty($this->author))
  1358 + $this->_out('/Author '.$this->_textstring($this->author));
  1359 + if(!empty($this->keywords))
  1360 + $this->_out('/Keywords '.$this->_textstring($this->keywords));
  1361 + if(!empty($this->creator))
  1362 + $this->_out('/Creator '.$this->_textstring($this->creator));
  1363 + $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
  1364 +}
  1365 +
  1366 +function _putcatalog()
  1367 +{
  1368 + $this->_out('/Type /Catalog');
  1369 + $this->_out('/Pages 1 0 R');
  1370 + if($this->ZoomMode=='fullpage')
  1371 + $this->_out('/OpenAction [3 0 R /Fit]');
  1372 + elseif($this->ZoomMode=='fullwidth')
  1373 + $this->_out('/OpenAction [3 0 R /FitH null]');
  1374 + elseif($this->ZoomMode=='real')
  1375 + $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
  1376 + elseif(!is_string($this->ZoomMode))
  1377 + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
  1378 + if($this->LayoutMode=='single')
  1379 + $this->_out('/PageLayout /SinglePage');
  1380 + elseif($this->LayoutMode=='continuous')
  1381 + $this->_out('/PageLayout /OneColumn');
  1382 + elseif($this->LayoutMode=='two')
  1383 + $this->_out('/PageLayout /TwoColumnLeft');
  1384 +}
  1385 +
  1386 +function _putheader()
  1387 +{
  1388 + $this->_out('%PDF-'.$this->PDFVersion);
  1389 +}
  1390 +
  1391 +function _puttrailer()
  1392 +{
  1393 + $this->_out('/Size '.($this->n+1));
  1394 + $this->_out('/Root '.$this->n.' 0 R');
  1395 + $this->_out('/Info '.($this->n-1).' 0 R');
  1396 +}
  1397 +
  1398 +function _enddoc()
  1399 +{
  1400 + $this->_putheader();
  1401 + $this->_putpages();
  1402 + $this->_putresources();
  1403 + //Info
  1404 + $this->_newobj();
  1405 + $this->_out('<<');
  1406 + $this->_putinfo();
  1407 + $this->_out('>>');
  1408 + $this->_out('endobj');
  1409 + //Catalog
  1410 + $this->_newobj();
  1411 + $this->_out('<<');
  1412 + $this->_putcatalog();
  1413 + $this->_out('>>');
  1414 + $this->_out('endobj');
  1415 + //Cross-ref
  1416 + $o=strlen($this->buffer);
  1417 + $this->_out('xref');
  1418 + $this->_out('0 '.($this->n+1));
  1419 + $this->_out('0000000000 65535 f ');
  1420 + for($i=1;$i<=$this->n;$i++)
  1421 + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
  1422 + //Trailer
  1423 + $this->_out('trailer');
  1424 + $this->_out('<<');
  1425 + $this->_puttrailer();
  1426 + $this->_out('>>');
  1427 + $this->_out('startxref');
  1428 + $this->_out($o);
  1429 + $this->_out('%%EOF');
  1430 + $this->state=3;
  1431 +}
  1432 +
  1433 +function _beginpage($orientation)
  1434 +{
  1435 + $this->page++;
  1436 + $this->pages[$this->page]='';
  1437 + $this->state=2;
  1438 + $this->x=$this->lMargin;
  1439 + $this->y=$this->tMargin;
  1440 + $this->FontFamily='';
  1441 + //Page orientation
  1442 + if(!$orientation)
  1443 + $orientation=$this->DefOrientation;
  1444 + else
  1445 + {
  1446 + $orientation=strtoupper($orientation{0});
  1447 + if($orientation!=$this->DefOrientation)
  1448 + $this->OrientationChanges[$this->page]=true;
  1449 + }
  1450 + if($orientation!=$this->CurOrientation)
  1451 + {
  1452 + //Change orientation
  1453 + if($orientation=='P')
  1454 + {
  1455 + $this->wPt=$this->fwPt;
  1456 + $this->hPt=$this->fhPt;
  1457 + $this->w=$this->fw;
  1458 + $this->h=$this->fh;
  1459 + }
  1460 + else
  1461 + {
  1462 + $this->wPt=$this->fhPt;
  1463 + $this->hPt=$this->fwPt;
  1464 + $this->w=$this->fh;
  1465 + $this->h=$this->fw;
  1466 + }
  1467 + $this->PageBreakTrigger=$this->h-$this->bMargin;
  1468 + $this->CurOrientation=$orientation;
  1469 + }
  1470 +}
  1471 +
  1472 +function _endpage()
  1473 +{
  1474 + //End of page contents
  1475 + $this->state=1;
  1476 +}
  1477 +
  1478 +function _newobj()
  1479 +{
  1480 + //Begin a new object
  1481 + $this->n++;
  1482 + $this->offsets[$this->n]=strlen($this->buffer);
  1483 + $this->_out($this->n.' 0 obj');
  1484 +}
  1485 +
  1486 +function _dounderline($x,$y,$txt)
  1487 +{
  1488 + //Underline text
  1489 + $up=$this->CurrentFont['up'];
  1490 + $ut=$this->CurrentFont['ut'];
  1491 + $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
  1492 + return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
  1493 +}
  1494 +
  1495 +function _parsejpg($file)
  1496 +{
  1497 + //Extract info from a JPEG file
  1498 + $a=GetImageSize($file);
  1499 + if(!$a)
  1500 + $this->Error('Missing or incorrect image file: '.$file);
  1501 + if($a[2]!=2)
  1502 + $this->Error('Not a JPEG file: '.$file);
  1503 + if(!isset($a['channels']) || $a['channels']==3)
  1504 + $colspace='DeviceRGB';
  1505 + elseif($a['channels']==4)
  1506 + $colspace='DeviceCMYK';
  1507 + else
  1508 + $colspace='DeviceGray';
  1509 + $bpc=isset($a['bits']) ? $a['bits'] : 8;
  1510 + //Read whole file
  1511 + $f=fopen($file,'rb');
  1512 + $data='';
  1513 + while(!feof($f))
  1514 + $data.=fread($f,4096);
  1515 + fclose($f);
  1516 + return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);
  1517 +}
  1518 +
  1519 +function _parsepng($file)
  1520 +{
  1521 + //Extract info from a PNG file
  1522 + $f=fopen($file,'rb');
  1523 + if(!$f)
  1524 + $this->Error('Can\'t open image file: '.$file);
  1525 + //Check signature
  1526 + if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
  1527 + $this->Error('Not a PNG file: '.$file);
  1528 + //Read header chunk
  1529 + fread($f,4);
  1530 + if(fread($f,4)!='IHDR')
  1531 + $this->Error('Incorrect PNG file: '.$file);
  1532 + $w=$this->_freadint($f);
  1533 + $h=$this->_freadint($f);
  1534 + $bpc=ord(fread($f,1));
  1535 + if($bpc>8)
  1536 + $this->Error('16-bit depth not supported: '.$file);
  1537 + $ct=ord(fread($f,1));
  1538 + if($ct==0)
  1539 + $colspace='DeviceGray';
  1540 + elseif($ct==2)
  1541 + $colspace='DeviceRGB';
  1542 + elseif($ct==3)
  1543 + $colspace='Indexed';
  1544 + else
  1545 + $this->Error('Alpha channel not supported: '.$file);
  1546 + if(ord(fread($f,1))!=0)
  1547 + $this->Error('Unknown compression method: '.$file);
  1548 + if(ord(fread($f,1))!=0)
  1549 + $this->Error('Unknown filter method: '.$file);
  1550 + if(ord(fread($f,1))!=0)
  1551 + $this->Error('Interlacing not supported: '.$file);
  1552 + fread($f,4);
  1553 + $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
  1554 + //Scan chunks looking for palette, transparency and image data
  1555 + $pal='';
  1556 + $trns='';
  1557 + $data='';
  1558 + do
  1559 + {
  1560 + $n=$this->_freadint($f);
  1561 + $type=fread($f,4);
  1562 + if($type=='PLTE')
  1563 + {
  1564 + //Read palette
  1565 + $pal=fread($f,$n);
  1566 + fread($f,4);
  1567 + }
  1568 + elseif($type=='tRNS')
  1569 + {
  1570 + //Read transparency info
  1571 + $t=fread($f,$n);
  1572 + if($ct==0)
  1573 + $trns=array(ord(substr($t,1,1)));
  1574 + elseif($ct==2)
  1575 + $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
  1576 + else
  1577 + {
  1578 + $pos=strpos($t,chr(0));
  1579 + if($pos!==false)
  1580 + $trns=array($pos);
  1581 + }
  1582 + fread($f,4);
  1583 + }
  1584 + elseif($type=='IDAT')
  1585 + {
  1586 + //Read image data block
  1587 + $data.=fread($f,$n);
  1588 + fread($f,4);
  1589 + }
  1590 + elseif($type=='IEND')
  1591 + break;
  1592 + else
  1593 + fread($f,$n+4);
  1594 + }
  1595 + while($n);
  1596 + if($colspace=='Indexed' && empty($pal))
  1597 + $this->Error('Missing palette in '.$file);
  1598 + fclose($f);
  1599 + return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);
  1600 +}
  1601 +
  1602 +function _freadint($f)
  1603 +{
  1604 + //Read a 4-byte integer from file
  1605 + $a=unpack('Ni',fread($f,4));
  1606 + return $a['i'];
  1607 +}
  1608 +
  1609 +function _textstring($s)
  1610 +{
  1611 + //Format a text string
  1612 + return '('.$this->_escape($s).')';
  1613 +}
  1614 +
  1615 +function _escape($s)
  1616 +{
  1617 + //Add \ before \, ( and )
  1618 + return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s)));
  1619 +}
  1620 +
  1621 +function _putstream($s)
  1622 +{
  1623 + $this->_out('stream');
  1624 + $this->_out($s);
  1625 + $this->_out('endstream');
  1626 +}
  1627 +
  1628 +function _out($s)
  1629 +{
  1630 + //Add a line to the document
  1631 + if($this->state==2)
  1632 + $this->pages[$this->page].=$s."\n";
  1633 + else
  1634 + $this->buffer.=$s."\n";
  1635 +}
  1636 +//End of class
  1637 +}
  1638 +
  1639 +//Handle special IE contype request
  1640 +if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
  1641 +{
  1642 + header('Content-Type: application/pdf');
  1643 + exit;
  1644 +}
  1645 +
  1646 +}
  1647 +?>
... ...
include/library.php
... ... @@ -460,6 +460,24 @@ function GravaTESTES($p_Valor)
460 460 }
461 461  
462 462 //________________________________________________________________________________________________
  463 +// Grava na tabela SRCACIC_LOGS as informações de atividades na estação visitada
  464 +//________________________________________________________________________________________________
  465 +function GravaLogSrCacic($p_id_sessao, $p_te_acao)
  466 + {
  467 + conecta_bd_cacic();
  468 + $queryINS = "INSERT
  469 + INTO srcacic_logs
  470 + (id_sessao,
  471 + dt_hr_acao,
  472 + te_acao)
  473 + VALUES (".$p_id_sessao.",
  474 + NOW(),
  475 + '".$p_te_acao."')";
  476 + $resultINS = mysql_query($queryINS);
  477 + }
  478 +
  479 +
  480 +//________________________________________________________________________________________________
463 481 // Grava na tabela LOG informações de atividades
464 482 //________________________________________________________________________________________________
465 483 function GravaLog($p_cs_acao, $p_nm_script, $p_nm_tabela)
... ... @@ -747,6 +765,79 @@ function computador_existe($te_node_address, $id_so)
747 765 }
748 766 }
749 767  
  768 +// --------------------------------------------------------------------------------------
  769 +// --------------------------------------------------------------------------------------
  770 +function ChecaSO($te_node_address,$id_so)
  771 + {
  772 + $boolRetorno = '0';
  773 + conecta_bd_cacic();
  774 + $query = 'SELECT id_so FROM so WHERE id_so <> '.$id_so.' AND in_mswindows = "S"';
  775 + $result = mysql_query($query);
  776 +
  777 + while ($row = mysql_fetch_array($result))
  778 + {
  779 + $arrComputadores = getValores('computadores', 'count(te_node_address) as TotalSO', 'te_node_address = "'.$te_node_address.'" and id_so = '.$row['id_so']);
  780 + $intTotalSO = $arrComputadores['TotalSO'];
  781 + if ($intTotalSO > 0)
  782 + {
  783 + $boolRetorno = '1';
  784 + //GravaTESTES('***** Processo DePara de Versão do MS-Windows *****');
  785 + //GravaTESTES('te_node_address='.$te_node_address.'#id_so_atual='.$id_so.'#id_so_antigo='.$row['id_so']);
  786 +
  787 + $arrPatrimonio = getValores('patrimonio', 'count(te_node_address) as TotalPAT', 'te_node_address = "'.$te_node_address.'" and id_so = '.$row['id_so']);
  788 + $intTotalPAT = $arrPatrimonio['TotalPAT'];
  789 + if ($intTotalPAT > 0)
  790 + {
  791 + //GravaTESTES('***** Gravando novo ID_SO na tabela PATRIMONIO *****');
  792 +
  793 + $query = 'UPDATE patrimonio SET id_so = '.$id_so.' WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  794 + $result = mysql_query($query);
  795 + }
  796 +
  797 + $arrOfficescan = getValores('officescan', 'count(te_node_address) as TotalOFF', 'te_node_address = "'.$te_node_address.'" and id_so = '.$row['id_so']);
  798 + $intTotalOFF = $arrOfficescan['TotalOFF'];
  799 + if ($intTotalOFF > 0)
  800 + {
  801 + //GravaTESTES('***** Gravando novo ID_SO na tabela OFFICESCAN *****');
  802 + $query = 'UPDATE officescan SET id_so = '.$id_so.' WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  803 + $result = mysql_query($query);
  804 + }
  805 +
  806 + $query = 'UPDATE historico_hardware SET id_so = '.$id_so.' WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  807 + $result = mysql_query($query);
  808 +
  809 + $query = 'UPDATE historico_tcpip SET id_so = '.$id_so.' WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  810 + $result = mysql_query($query);
  811 +
  812 +
  813 + //GravaTESTES('* Deletando ID antigo de comput., apl_mon, compart, compon_est_hist, soft_inv_est, unid_disco, var_amb_est *');
  814 +
  815 + $query = 'DELETE from computadores WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  816 + $result = mysql_query($query);
  817 +
  818 + $query = 'DELETE from aplicativos_monitorados WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  819 + $result = mysql_query($query);
  820 +
  821 + $query = 'DELETE from compartilhamentos WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  822 + $result = mysql_query($query);
  823 +
  824 + $query = 'DELETE from componentes_estacoes_historico WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  825 + $result = mysql_query($query);
  826 +
  827 + $query = 'DELETE from softwares_inventariados_estacoes WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  828 + $result = mysql_query($query);
  829 +
  830 + $query = 'DELETE from unidades_disco WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  831 + $result = mysql_query($query);
  832 +
  833 + $query = 'DELETE from variaveis_ambiente_estacoes WHERE te_node_address = "'.$te_node_address.'" AND id_so='.$row['id_so'];
  834 + $result = mysql_query($query);
  835 +
  836 + //GravaTESTES('======================================================================');
  837 + }
  838 + }
  839 + return $boolRetorno;
  840 + }
750 841  
751 842 // --------------------------------------------------------------------------------------
752 843 // Função que insere se um dado computador no BD, caso ele não esteja inserido.
... ... @@ -768,22 +859,22 @@ function inclui_computador_caso_nao_exista( $te_node_address,
768 859 /*
769 860 GravaTESTES('Script Chamador: '.$_SERVER['REQUEST_URI']);
770 861 GravaTESTES('v_te_ip: '.$v_te_ip);
771   -
772   -
773   -
774   - GravaTESTES('te_node_address: '.$te_node_address);
775   - GravaTESTES('id_so_new: '.$id_so_new);
776   - GravaTESTES('te_so_new: '.$te_so_new);
777   - GravaTESTES('te_so_new_new: '.$te_so_new_new);
778   - GravaTESTES('id_ip_rede: '.$id_ip_rede);
779   - GravaTESTES('te_ip: '.$te_ip);
780   - GravaTESTES('v_te_ip: '.$v_te_ip);
781   - GravaTESTES('te_nome_computador: '.$te_nome_computador);
782   - GravaTESTES('te_workgroup: '.$te_workgroup);
  862 + GravaTESTES('te_node_address: '.$te_node_address);
  863 + GravaTESTES('id_so_new: '.$id_so_new);
  864 + GravaTESTES('te_so_new: '.$te_so_new);
  865 + GravaTESTES('te_so_new_new: '.$te_so_new_new);
  866 + GravaTESTES('id_ip_rede: '.$id_ip_rede);
  867 + GravaTESTES('te_ip: '.$te_ip);
  868 + GravaTESTES('v_te_ip: '.$v_te_ip);
  869 + GravaTESTES('te_nome_computador: '.$te_nome_computador);
  870 + GravaTESTES('te_workgroup: '.$te_workgroup);
783 871 */
784 872  
785   - $id_so = get_valor_campo('so', 'id_so', 'id_so = '.$id_so_new);
786   - $te_so = get_valor_campo('so', 'te_so', 'te_so = "'.$te_so_new.'"');
  873 + $arrSO = getValores('so', 'id_so', 'id_so = '.$id_so_new);
  874 + $id_so = $arrSO['id_so'];
  875 +
  876 + $arrSO = getValores('so', 'te_so', 'te_so = "'.$te_so_new.'"');
  877 + $te_so = $arrSO['te_so'];
787 878  
788 879 if ($te_so == '' && $id_so <> '' && $id_so <> 0 && $te_so_new <> '') // Encontrei somente o Identificador Externo (ID_SO)
789 880 {
... ... @@ -897,30 +988,65 @@ function inclui_computador_caso_nao_exista( $te_node_address,
897 988 $result = mysql_query($query);
898 989 }
899 990  
  991 + // ******************************************************************************************************************************
  992 + // ******************************************************************************************************************************
  993 + // Novo Conceito:
  994 + // As estações poderão ter uma licença MS-Windows e n sabores de Linux
  995 + // Desta forma, será customizada a ocupação do banco e será mantida a versão do S.O. mais atual para fins de Gestão de Licenças e
  996 + // estatísticas
  997 + //
  998 + // Anderson Peterle - Dataprev/ES - 01/08/2008 12:04h
  999 + // ******************************************************************************************************************************
  1000 + // ******************************************************************************************************************************
  1001 + $arrSO = getValores('so', 'in_mswindows', 'te_so = "'.$te_so_new.'"');
  1002 + $in_mswindows = $arrSO['in_mswindows'];
  1003 +
  1004 + if ($in_mswindows == 'S')
  1005 + {
  1006 + $arrSO = getValores('so', 'id_so', 'te_so = "'.$te_so_new.'"');
  1007 + $id_so = $arrSO['id_so'];
  1008 + if (ChecaSO($te_node_address,$id_so))
  1009 + {
  1010 + //GravaTESTES('***** Forçando coletas ANVI COMP HARD MONI SOFT UNDI para a estação *****');
  1011 + $query = ' UPDATE computadores
  1012 + SET dt_hr_coleta_forcada_estacao = now(),
  1013 + te_nomes_curtos_modulos="COMP#HARD#SOFT#ANVI#MONI#UNDI"
  1014 + WHERE te_node_address="'.$te_node_address.'" AND
  1015 + id_so='.$id_so;
  1016 + $result = mysql_query($query);
  1017 + //GravaTESTES('======================================================================');
  1018 + }
  1019 + }
  1020 +
  1021 + // ******************************************************************************************************************************
  1022 + // ******************************************************************************************************************************
  1023 +
900 1024 return $arrRetorno;
901 1025 }
902 1026  
903 1027  
904 1028 /* --------------------------------------------------------------------------------------
905 1029 Função usada para recuperar valores de campos únicos. Útil para a tabela de configurações.
  1030 + Passou a retornar array com colunas a partir de 22/10/2008
906 1031 -------------------------------------------------------------------------------------- */
907   -function get_valor_campo($tabela, $campo, $where="1")
908   - {
  1032 +function getValores($tabela, $campos, $where="1")
  1033 + {
  1034 + $arrRetorno = array();
909 1035 conecta_bd_cacic();
910   - $query = 'SELECT '.$campo.'
911   - FROM '.$tabela.'
912   - WHERE '.$where.'
913   - LIMIT 1';
914   - $result = mysql_query($query);
915   - if (mysql_num_rows($result) > 0)
  1036 + $query_SEL = 'SELECT '.$campos.' FROM '.$tabela.' WHERE '.$where.' LIMIT 1';
  1037 +
  1038 + $result_SEL = mysql_query($query_SEL);
  1039 + if (mysql_num_rows($result_SEL) > 0)
916 1040 {
917   - $campos = mysql_fetch_array($result);
918   - return $campos[$campo];
  1041 + $row_SEL = mysql_fetch_array($result_SEL);
  1042 +
  1043 + for ($i=0;$i < mysql_num_fields($result_SEL);$i++)
  1044 + {
  1045 + $arrTMP = array(mysql_field_name($result_SEL,$i) => $row_SEL[$i]);
  1046 + $arrRetorno = array_merge($arrRetorno,$arrTMP);
  1047 + }
919 1048 }
920   - else
921   - {
922   - return '';
923   - }
  1049 + return $arrRetorno;
924 1050 }
925 1051  
926 1052  
... ... @@ -1050,24 +1176,30 @@ function atualiza_red_ver_mod_pagina($pp_te_serv_updates, $p_nm_modulo, $p_te_ve
1050 1176 $cs_tipo_so = (stripos2($p_nm_modulo,'.ini',false)?'MS-Windows':$cs_tipo_so);
1051 1177  
1052 1178 conecta_bd_cacic();
1053   - $query_SEL = ' SELECT id_ip_rede,
1054   - id_local
1055   - FROM redes
1056   - WHERE te_serv_updates = "'.$pp_te_serv_updates.'"';
  1179 +// $query_SEL = ' SELECT id_ip_rede,
  1180 +// id_local
  1181 +// FROM redes
  1182 +// WHERE te_serv_updates = "'.$pp_te_serv_updates.'"';
  1183 + $query_SEL = '
  1184 + SELECT id_ip_rede,
  1185 + nm_rede,
  1186 + id_local
  1187 + FROM redes
  1188 + WHERE te_serv_updates = "'.$pp_te_serv_updates.'"';
1057 1189 // AND id_local = '.$p_id_local;
1058 1190 //GravaTESTES('query_SEL: '.$query_SEL);
1059 1191 $result_SEL = mysql_query($query_SEL);
1060 1192  
1061   - $redes = '';
  1193 + $locais_redes = '';
1062 1194 while ($row = mysql_fetch_array($result_SEL))
1063 1195 {
1064   - if ($redes <> '') $redes .= ',';
1065   - $redes .= '"'.$row['id_ip_rede'].'"';
  1196 + if ($locais_redes <> '') $locais_redes .= ',';
  1197 + $locais_redes .= '"#'.$row['id_local'].$row['id_ip_rede'].'#"';
1066 1198 }
1067 1199  
1068 1200 $query_UPD = ' UPDATE redes
1069 1201 set dt_verifica_updates = NOW()
1070   - WHERE TRIM(id_ip_rede) IN ('.$redes.')';
  1202 + WHERE CONCAT("#",id_local,id_ip_rede,"#") IN ('.$locais_redes.')';
1071 1203 // AND id_local = '.$p_id_local;
1072 1204 //GravaTESTES('query_UPD: '.$query_UPD);
1073 1205 $result_UPD = mysql_query($query_UPD);
... ... @@ -1076,7 +1208,7 @@ function atualiza_red_ver_mod_pagina($pp_te_serv_updates, $p_nm_modulo, $p_te_ve
1076 1208 // No caso do Linux é um pacote, por isso mato pelo tipo de S.O.
1077 1209 $query_DEL = 'DELETE
1078 1210 FROM redes_versoes_modulos
1079   - WHERE TRIM(id_ip_rede) IN ('.$redes.') AND
  1211 + WHERE CONCAT("#",id_local,id_ip_rede,"#") IN ('.$locais_redes.') AND
1080 1212 trim(cs_tipo_so) = "'.$cs_tipo_so.'" ';
1081 1213  
1082 1214 if ($cs_tipo_so == 'MS-Windows')
... ... @@ -1334,7 +1466,7 @@ if ($handle = opendir($MainFolder . &#39;/repositorio&#39;))
1334 1466  
1335 1467 $caminho_arquivo = $MainFolder . '/repositorio/agentes_linux/' . $v_arquivo;
1336 1468  
1337   - if (isset($v_array_versoes_agentes) && $versao_agente = $v_array_versoes_agentes['PyCACIC'])
  1469 + if (isset($v_array_versoes_agentes) && $versao_agente = $v_array_versoes_agentes['pycacic'])
1338 1470 array_push($v_versoes_arquivos_REP, $v_arquivo . '#'.str_replace('.','',$versao_agente));
1339 1471 else
1340 1472 array_push($v_versoes_arquivos_REP, $v_arquivo . '#'. strftime("%Y%m%d%H%M", filemtime($caminho_arquivo)));
... ... @@ -1622,7 +1754,7 @@ function CheckFtpLogin($server, $user, $pass, $port)
1622 1754 $data = fgets($sck, 1024);
1623 1755 fputs($sck, "PASS $pass\n");
1624 1756 $data = fgets($sck, 1024);
1625   - if (ereg("230", $data) or ereg("220", $data))
  1757 + if (ereg("230", $data))
1626 1758 {
1627 1759 # User logged in
1628 1760 return 1;
... ...
include/multipagina.php 0 → 100755
... ... @@ -0,0 +1,264 @@
  1 +<?php
  2 +/*
  3 +================================================================================================================================
  4 +A classe navbar de Copyright Joao Prado Maia (jpm@phpbrasil.com) e tradução de
  5 +Thomas Gonzalez Miranda (thomasgm@hotmail.com) baixada do site www.phpbrasil.com
  6 +em 06/05/2002 foi modificada para melhor entendimento do seu funcionamento e
  7 +aperfeiçoada deste que apareceram alguns "bugs", sendo transformada como classe
  8 +Mult_Pag (Multiplas paginas).
  9 +As informações acima foram retiradas da versão 1.3 da classe navbar do arquivo
  10 +navbar.zip.
  11 +
  12 +Construi esta pequena classe para navegação dinâmica de links. Observe
  13 +por favor a simplicidade deste código. Este código é livre em
  14 +toda maneira que você puder imaginar. Se você o usar em seu
  15 +próprio script, por favor deixo os créditos como estão. Também,
  16 +envie-me um e-mail se você o fizer, isto me deixa feliz :-)
  17 +
  18 +Adaptações Realizadas / Motivos:
  19 +-------------------------------
  20 +06 a 09/05/2002 : Marco A. D. Freitas (madf@splicenet.com.br)
  21 +26/06/2006 : Paulo Enok Sawazaki (pauloeno@yahoo.com.br)
  22 +24/06/2008 : Anderson Peterle (anderson@peterles.com)
  23 + Motivo: adequação para uso no Sistema CACIC - Configurador Automático e Coletor de Informações Computacionais
  24 + http://www.softwarepublico.gov.br/ver-comunidade?community_id=3585
  25 +================================================================================================================================
  26 +*/
  27 +// classe que multiplica paginas
  28 +class Mult_Pag
  29 + {
  30 + // Valores padrão para a navegação dos links
  31 + var $num_pesq_pag;
  32 + var $str_anterior = " Anterior ";
  33 + var $str_proxima = " Próxima ";
  34 + var $str_primeira = " Primeira ";
  35 + var $str_ultima = "      Última ";
  36 + // Variáveis usadas internamente
  37 + var $nome_arq;
  38 + var $total_reg;
  39 + var $pagina;
  40 +
  41 + /*
  42 + Metodo construtor. Isto é somente usado para setar
  43 + o número atual de colunas e outros métodos que
  44 + podem ser re-usados mais tarde.
  45 + */
  46 + function Mult_Pag ()
  47 + {
  48 + global $pagina;
  49 + $this->pagina = $pagina ? $pagina : 0;
  50 + }
  51 +
  52 + /*
  53 + O próximo método roda o que é necessário para as queries.
  54 + É preciso rodá-lo para que ele pegue o total
  55 + de colunas retornadas, e em segundo para pegar o total de
  56 + links limitados.
  57 +
  58 + $sql parâmetro:
  59 + . o parâmetro atual da query que será executada
  60 +
  61 + $conexao parâmetro:
  62 + . a ligação da conexão do banco de dados
  63 +
  64 + $tipo parâmetro:
  65 + . "mysql" - usa funções php mysql
  66 + . "pgsql" - usa funções pgsql php
  67 + */
  68 + function Executar($sql, $conexao, $velocidade, $tipo)
  69 + {
  70 + $this->num_pesq_pag = ($this->num_pesq_pag > 0?$this->num_pesq_pag:1);
  71 + // variavel para o inicio das pesquisas
  72 + $inicio_pesq = $this->pagina * $this->num_pesq_pag;
  73 +
  74 + if ($velocidade == "otimizada")
  75 + {
  76 + $total_sql = preg_replace("/SELECT (.*?) FROM /sei", "'SELECT COUNT(*) FROM '", $sql);
  77 + }
  78 + else
  79 + {
  80 + $total_sql = $sql;
  81 + }
  82 +
  83 + // tipo da pesquisa
  84 + if ($tipo == "mysql")
  85 + {
  86 + $resultado = mysql_query($total_sql);
  87 + $this->total_reg = mysql_num_rows($resultado); // total de registros da pesquisa inteira
  88 + $sql .= " LIMIT $inicio_pesq, $this->num_pesq_pag";
  89 + $resultado = mysql_query($sql); // pesquisa com limites por pagina
  90 + }
  91 + else if ($tipo == "pgsql")
  92 + {
  93 + $resultado = pg_exec($conexao, $total_sql);
  94 + if ( pg_numrows( $resultado ) > 0 )
  95 + {
  96 + // total de registros da pesquisa inteira
  97 + $this->total_reg = pg_numrows( $resultado );//pg_Result($resultado, 0, 0);
  98 + }
  99 + $sql .= " LIMIT $this->num_pesq_pag, $inicio_pesq";
  100 + $resultado = pg_Exec($conexao, $sql);// pesquisa com limites por pagina
  101 + }
  102 + return $resultado;
  103 + }
  104 +
  105 + /*
  106 + Este método cria uma string que irá ser adicionada à
  107 + url dos links de navegação. Isto é especialmente importante
  108 + para criar links dinâmicos, então se você quiser adicionar
  109 + opções adicionais à estas queries, a classe de navegação
  110 + irá adicionar automaticamente aos links de navegação
  111 + dinâmicos.
  112 + */
  113 + function Construir_Url()
  114 + {
  115 + global $REQUEST_URI, $REQUEST_METHOD, $HTTP_GET_VARS, $HTTP_POST_VARS;
  116 +
  117 + // separa o link em 2 strings
  118 + @list($this->nome_arq, $voided) = @explode("?", $REQUEST_URI);
  119 +
  120 + if ($REQUEST_METHOD == "GET") $cgi = $HTTP_GET_VARS;
  121 + else $cgi = $HTTP_POST_VARS;
  122 + reset($cgi); // posiciona no inicio do array
  123 +
  124 + // separa a coluna com o seu respectivo valor
  125 + while (list($chave, $valor) = each($cgi))
  126 + if ($chave != "pagina")
  127 + $query_string .= "&" . $chave . "=" . $valor;
  128 +
  129 + return $query_string;
  130 + }
  131 +
  132 + /*
  133 + Este método cria uma ligação de todos os links da barra de
  134 + navegação. Isto é útil, pois é totalmente independete do layout
  135 + ou design da página. Este método retorna a ligação dos links
  136 + chamados no script php, sendo assim, você pode criar links de
  137 + navegação com o conteúdo atual da página.
  138 +
  139 + $opcao parâmetro:
  140 + . "todos" - retorna todos os links de navegação
  141 + . "numeracao" - retorna apenas páginas com links numerados
  142 + . "strings" - retornar somente os links 'Próxima' e/ou 'Anterior'
  143 +
  144 + $mostra_string parâmetro:
  145 + . "nao" - mostra 'Próxima' ou 'Anterior' apenas quando for necessários
  146 + . "sim" - mostra 'Próxima' ou 'Anterior' de qualqur maneira
  147 + */
  148 + function Construir_Links($opcao, $mostra_string)
  149 + {
  150 + $extra_vars = $this->Construir_Url();
  151 + $arquivo = $this->nome_arq;
  152 + $num_mult_pag = ceil($this->total_reg / $this->num_pesq_pag); // numero de multiplas paginas
  153 + $indice = -1; // indice do array final
  154 + $numero_links_proximos=4;
  155 +
  156 + for ($atual = 0; $atual < $num_mult_pag; $atual++)
  157 + {
  158 + // escreve a string esquerda (Pagina Anterior)
  159 + if ((($opcao == "todos") || ($opcao == "strings")) && ($atual == 0))
  160 + {
  161 + if ($this->pagina != 0)
  162 + {
  163 + $array[++$indice] = '<a href="' . $arquivo . '?pagina=' . $atual . $extra_vars . '">' . " Primeira" . '</a>';
  164 + $array[++$indice] = '<a href="' . $arquivo . '?pagina=' . ($this->pagina - 1) . $extra_vars . '">' . $this->str_anterior . '</a>';
  165 + }
  166 + elseif (($this->pagina == 0) && ($mostra_string == "sim"))
  167 + {
  168 + $array[++$indice] = $this->str_primeira;
  169 + $array[++$indice] = $this->str_anterior;
  170 + }
  171 + }
  172 +
  173 + // escreve a numeracao (1 2 3 ...)
  174 + if (($opcao == "todos") || ($opcao == "numeracao"))
  175 + {
  176 + if (($atual > $this->pagina - $numero_links_proximos)&&($atual < $this->pagina + $numero_links_proximos) )
  177 + {
  178 + if ($this->pagina == $atual)
  179 + {
  180 + $array[++$indice] = "<b>";
  181 + $array[++$indice] = ($atual > 0 ? ($atual + 1) : 1);
  182 + $array[++$indice] = "</b>";
  183 + }
  184 + else
  185 + {
  186 + if (($atual == ($this->pagina -($numero_links_proximos-1)))&&($atual != 0))
  187 + {
  188 + $array[++$indice] = "<b>...</b>";
  189 + }
  190 + $array[++$indice] = '<a href="' . $arquivo . '?pagina=' . $atual . $extra_vars . '">' . ($atual + 1) . '</a>';
  191 + if (($atual == ($this->pagina +($numero_links_proximos-1)))&&($atual != $num_mult_pag-1))
  192 + {
  193 + $array[++$indice] = "<b>...</b>";
  194 + }
  195 + }
  196 + }
  197 + }
  198 +
  199 +
  200 + // escreve a string direita (Proxima Pagina)
  201 + if ((($opcao == "todos") || ($opcao == "strings")) && ($atual == ($num_mult_pag - 1)))
  202 + {
  203 + if ($this->pagina != ($num_mult_pag - 1))
  204 + {
  205 + $array[++$indice] = '<a href="' . $arquivo . '?pagina=' . ($this->pagina + 1) . $extra_vars . '">' . $this->str_proxima . '</a>';
  206 + $array[++$indice] = '      <a href="' . $arquivo . '?pagina=' . ($num_mult_pag-1) . $extra_vars . '">' . " Última" . '</a>';
  207 + }
  208 + elseif (($this->pagina == ($num_mult_pag - 1)) && ($mostra_string == "sim"))
  209 + {
  210 + $array[++$indice] = $this->str_proxima;
  211 + $array[++$indice] = $this->str_ultima;
  212 + }
  213 + }
  214 + }
  215 + return $array;
  216 + }
  217 +
  218 + /*
  219 + Este método é uma extensão do método Construir_Links() para
  220 + que possa ser ajustado o limite 'n' de número de links na página.
  221 + Isto é muito útil para grandes bancos de dados que desejam não
  222 + ocupar todo o espaço da tela para mostrar toda a lista de links
  223 + paginados.
  224 +
  225 + $array parâmetro:
  226 + . retorna o array de Construir_Links()
  227 +
  228 + $atual parâmetro:
  229 + . a variável da 'pagina' atual das páginas paginadas. ex: pagina=1
  230 +
  231 + $tamanho_desejado parâmetro:
  232 + . o número desejado de links à serem exibidos
  233 + */
  234 + function Mostrar_Parte($array, $atual, $tam_desejado)
  235 + {
  236 + $size = count($array);
  237 + if (($size <= 2) || ($size < $tam_desejado))
  238 + {
  239 + $temp = $array;
  240 + }
  241 + else
  242 + {
  243 + $temp = array();
  244 + if (($atual + $tamanho_desejado) > $size)
  245 + {
  246 + $temp = array_slice($array, $size - $tam_desejado);
  247 + }
  248 + else
  249 + {
  250 + $temp = array_slice($array, $atual, $tam_desejado);
  251 + if ($size >= $tamanho_desejado)
  252 + {
  253 + array_push($temp, $array[$size - 1]);
  254 + }
  255 + }
  256 + if ($atual > 0)
  257 + {
  258 + array_unshift($temp, $array[0]);
  259 + }
  260 + }
  261 + return $temp;
  262 + }
  263 + }
  264 +?>
0 265 \ No newline at end of file
... ...
include/ods.php 0 → 100755
... ... @@ -0,0 +1,440 @@
  1 +<?php
  2 +/*
  3 +
  4 +ods-php a library to read and write ods files from php.
  5 +
  6 +This library has been forked from eyeOS project and licended under the LGPL3
  7 +terms available at: http://www.gnu.org/licenses/lgpl-3.0.txt (relicenced
  8 +with permission of the copyright holders)
  9 +
  10 +Copyright: Juan Lao Tebar (juanlao@eyeos.org) and Jose Carlos Norte (jose@eyeos.org) - 2008
  11 +
  12 +https://sourceforge.net/projects/ods-php/
  13 +
  14 +*/
  15 +
  16 +require_once('zip.lib.php');
  17 +
  18 +class ods {
  19 + var $fonts;
  20 + var $styles;
  21 + var $sheets;
  22 + var $lastElement;
  23 + var $fods;
  24 + var $currentSheet;
  25 + var $currentRow;
  26 + var $currentCell;
  27 + var $lastRowAtt;
  28 + var $repeat;
  29 +
  30 + function ods() {
  31 + $this->styles = array();
  32 + $this->fonts = array();
  33 + $this->sheets = array();
  34 + $this->currentRow = 0;
  35 + $this->currentSheet = 0;
  36 + $this->currentCell = 0;
  37 + $this->repeat = 0;
  38 + }
  39 +
  40 + function parse($data) {
  41 + $xml_parser = xml_parser_create();
  42 + xml_set_object ( $xml_parser, $this );
  43 + xml_set_element_handler($xml_parser, "startElement", "endElement");
  44 + xml_set_character_data_handler($xml_parser, "characterData");
  45 +
  46 + xml_parse($xml_parser, $data, strlen($data));
  47 +
  48 + xml_parser_free($xml_parser);
  49 + }
  50 +
  51 + function array2ods() {
  52 + $fontArray = $this->fonts;
  53 + $styleArray = $this->styles;
  54 + $sheetArray = $this->sheets;
  55 + // Header
  56 + $string = '<?xml version="1.0" encoding="UTF-8"?><office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">';
  57 +
  58 + // ToDo: scripts
  59 + $string .= '<office:scripts/>';
  60 +
  61 + // Fonts
  62 + $string .= '<office:font-face-decls>';
  63 + foreach ($fontArray as $fontName => $fontAttribs) {
  64 + $string .= '<style:font-face ';
  65 + foreach ($fontAttribs as $attrName => $attrValue) {
  66 + $string .= strtolower($attrName) . '="' . $attrValue . '" ';
  67 + }
  68 + $string .= '/>';
  69 + }
  70 + $string .= '</office:font-face-decls>';
  71 +
  72 + // Styles
  73 + $string .= '<office:automatic-styles>';
  74 + foreach ($styleArray as $styleName => $styleAttribs) {
  75 + $string .= '<style:style ';
  76 + foreach ($styleAttribs['attrs'] as $attrName => $attrValue) {
  77 + $string .= strtolower($attrName) . '="' . $attrValue . '" ';
  78 + }
  79 + $string .= '>';
  80 +
  81 + // Subnodes
  82 + foreach ($styleAttribs['styles'] as $nodeName => $nodeTree) {
  83 + $string .= '<' . $nodeName . ' ';
  84 + foreach ($nodeTree as $attrName => $attrValue) {
  85 + $string .= strtolower($attrName) . '="' . $attrValue . '" ';
  86 + }
  87 + $string .= '/>';
  88 + }
  89 +
  90 + $string .= '</style:style>';
  91 + }
  92 + $string .= '</office:automatic-styles>';
  93 +
  94 + // Body
  95 + $string .= '<office:body>';
  96 + $string .= '<office:spreadsheet>';
  97 + foreach ($sheetArray as $tableIndex => $tableContent) {
  98 + $string .= '<table:table table:name="' . $tableIndex . '" table:print="false">';
  99 + //$string .= '<office:forms form:automatic-focus="false" form:apply-design-mode="false"/>';
  100 +
  101 + foreach ($tableContent['rows'] as $rowIndex => $rowContent) {
  102 + $string .= '<table:table-row>';
  103 +
  104 + foreach($rowContent as $cellIndex => $cellContent) {
  105 + $string .= '<table:table-cell ';
  106 + foreach ($cellContent['attrs'] as $attrName => $attrValue) {
  107 + $string .= strtolower($attrName) . '="' . $attrValue . '" ';
  108 + }
  109 + $string .= '>';
  110 +
  111 + if (isset($cellContent['value'])) {
  112 + $string .= '<text:p>' . $cellContent['value'] . '</text:p>';
  113 + }
  114 +
  115 + $string .= '</table:table-cell>';
  116 + }
  117 +
  118 + $string .= '</table:table-row>';
  119 + }
  120 +
  121 + $string .= '</table:table>';
  122 + }
  123 +
  124 + $string .= '</office:spreadsheet>';
  125 + $string .= '</office:body>';
  126 +
  127 + // Footer
  128 + $string .= '</office:document-content>';
  129 +
  130 + return $string;
  131 + }
  132 +
  133 + function startElement($parser, $tagName, $attrs) {
  134 + $cTagName = strtolower($tagName);
  135 + if($cTagName == 'style:font-face') {
  136 + $this->fonts[$attrs['STYLE:NAME']] = $attrs;
  137 + } elseif($cTagName == 'style:style') {
  138 + $this->lastElement = $attrs['STYLE:NAME'];
  139 + $this->styles[$this->lastElement]['attrs'] = $attrs;
  140 + } elseif($cTagName == 'style:table-column-properties' || $cTagName == 'style:table-row-properties'
  141 + || $cTagName == 'style:table-properties' || $cTagName == 'style:text-properties') {
  142 + $this->styles[$this->lastElement]['styles'][$cTagName] = $attrs;
  143 + } elseif($cTagName == 'table:table-cell') {
  144 + $this->lastElement = $cTagName;
  145 + $this->sheets[$this->currentSheet]['rows'][$this->currentRow][$this->currentCell]['attrs'] = $attrs;
  146 + if(isset($attrs['TABLE:NUMBER-COLUMNS-REPEATED'])) {
  147 + $times = intval($attrs['TABLE:NUMBER-COLUMNS-REPEATED']);
  148 + $times--;
  149 + for($i=1;$i<=$times;$i++) {
  150 + $cnum = $this->currentCell+$i;
  151 + $this->sheets[$this->currentSheet]['rows'][$this->currentRow][$cnum]['attrs'] = $attrs;
  152 + }
  153 + $this->currentCell += $times;
  154 + $this->repeat = $times;
  155 + }
  156 + if(isset($this->lastRowAtt['TABLE:NUMBER-ROWS-REPEATED'])) {
  157 + $times = intval($this->lastRowAtt['TABLE:NUMBER-ROWS-REPEATED']);
  158 + $times--;
  159 + for($i=1;$i<=$times;$i++) {
  160 + $cnum = $this->currentRow+$i;
  161 + $this->sheets[$this->currentSheet]['rows'][$cnum][$i-1]['attrs'] = $attrs;
  162 + }
  163 + $this->currentRow += $times;
  164 + }
  165 + } elseif($cTagName == 'table:table-row') {
  166 + $this->lastRowAtt = $attrs;
  167 + }
  168 + }
  169 +
  170 + function endElement($parser, $tagName) {
  171 + $cTagName = strtolower($tagName);
  172 + if($cTagName == 'table:table') {
  173 + $this->currentSheet++;
  174 + $this->currentRow = 0;
  175 + } elseif($cTagName == 'table:table-row') {
  176 + $this->currentRow++;
  177 + $this->currentCell = 0;
  178 + } elseif($cTagName == 'table:table-cell') {
  179 + $this->currentCell++;
  180 + $this->repeat = 0;
  181 + }
  182 + }
  183 +
  184 + function characterData($parser, $data) {
  185 + if($this->lastElement == 'table:table-cell') {
  186 + $this->sheets[$this->currentSheet]['rows'][$this->currentRow][$this->currentCell]['value'] = $data;
  187 + if($this->repeat > 0) {
  188 + for($i=0;$i<$this->repeat;$i++) {
  189 + $cnum = $this->currentCell - ($i+1);
  190 + $this->sheets[$this->currentSheet]['rows'][$this->currentRow][$cnum]['value'] = $data;
  191 + }
  192 + }
  193 + }
  194 + }
  195 +
  196 + function getMeta($lang) {
  197 + $myDate = date('Y-m-j\TH:i:s');
  198 + $meta = '<?xml version="1.0" encoding="UTF-8"?>
  199 + <office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.0">
  200 + <office:meta>
  201 + <meta:generator>ods-php</meta:generator>
  202 + <meta:creation-date>'.$myDate.'</meta:creation-date>
  203 + <dc:date>'.$myDate.'</dc:date>
  204 + <dc:language>'.$lang.'</dc:language>
  205 + <meta:editing-cycles>2</meta:editing-cycles>
  206 + <meta:editing-duration>PT15S</meta:editing-duration>
  207 + <meta:user-defined meta:name="Info 1"/>
  208 + <meta:user-defined meta:name="Info 2"/>
  209 + <meta:user-defined meta:name="Info 3"/>
  210 + <meta:user-defined meta:name="Info 4"/>
  211 + </office:meta>
  212 + </office:document-meta>';
  213 + return $meta;
  214 + }
  215 +
  216 + function getStyle() {
  217 + return '<?xml version="1.0" encoding="UTF-8"?>
  218 + <office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" office:version="1.0"><office:font-face-decls><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:styles><style:default-style style:family="table-cell"><style:table-cell-properties style:decimal-places="2"/><style:paragraph-properties style:tab-stop-distance="1.25cm"/><style:text-properties style:font-name="Liberation Sans" fo:language="es" fo:country="ES" style:font-name-asian="DejaVu Sans" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="DejaVu Sans" style:language-complex="zxx" style:country-complex="none"/></style:default-style><number:number-style style:name="N0"><number:number number:min-integer-digits="1"/>
  219 + </number:number-style><number:currency-style style:name="N103P0" style:volatile="true"><number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/><number:text> </number:text><number:currency-symbol number:language="es" number:country="ES">€</number:currency-symbol></number:currency-style><number:currency-style style:name="N103"><style:text-properties fo:color="#ff0000"/><number:text>-</number:text><number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true"/><number:text> </number:text><number:currency-symbol number:language="es" number:country="ES">€</number:currency-symbol><style:map style:condition="value()&gt;=0" style:apply-style-name="N103P0"/></number:currency-style><style:style style:name="Default" style:family="table-cell"/><style:style style:name="Result" style:family="table-cell" style:parent-style-name="Default"><style:text-properties fo:font-style="italic" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" fo:font-weight="bold"/></style:style><style:style style:name="Result2" style:family="table-cell" style:parent-style-name="Result" style:data-style-name="N103"/><style:style style:name="Heading" style:family="table-cell" style:parent-style-name="Default"><style:table-cell-properties style:text-align-source="fix" style:repeat-content="false"/><style:paragraph-properties fo:text-align="center"/><style:text-properties fo:font-size="16pt" fo:font-style="italic" fo:font-weight="bold"/></style:style><style:style style:name="Heading1" style:family="table-cell" style:parent-style-name="Heading"><style:table-cell-properties style:rotation-angle="90"/></style:style></office:styles><office:automatic-styles><style:page-layout style:name="pm1"><style:page-layout-properties style:writing-mode="lr-tb"/><style:header-style><style:header-footer-properties fo:min-height="0.751cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="0.25cm"/></style:header-style><style:footer-style><style:header-footer-properties fo:min-height="0.751cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.25cm"/>
  220 + </style:footer-style></style:page-layout><style:page-layout style:name="pm2"><style:page-layout-properties style:writing-mode="lr-tb"/><style:header-style><style:header-footer-properties fo:min-height="0.751cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="0.25cm" fo:border="0.088cm solid #000000" fo:padding="0.018cm" fo:background-color="#c0c0c0"><style:background-image/></style:header-footer-properties></style:header-style><style:footer-style><style:header-footer-properties fo:min-height="0.751cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.25cm" fo:border="0.088cm solid #000000" fo:padding="0.018cm" fo:background-color="#c0c0c0"><style:background-image/></style:header-footer-properties></style:footer-style></style:page-layout></office:automatic-styles><office:master-styles><style:master-page style:name="Default" style:page-layout-name="pm1"><style:header><text:p><text:sheet-name>???</text:sheet-name></text:p></style:header><style:header-left style:display="false"/><style:footer><text:p>Página <text:page-number>1</text:page-number></text:p></style:footer><style:footer-left style:display="false"/></style:master-page><style:master-page style:name="Report" style:page-layout-name="pm2"><style:header><style:region-left><text:p><text:sheet-name>???</text:sheet-name> (<text:title>???</text:title>)</text:p></style:region-left><style:region-right><text:p><text:date style:data-style-name="N2" text:date-value="2008-02-18">18/02/2008</text:date>, <text:time>00:17:06</text:time></text:p></style:region-right></style:header><style:header-left style:display="false"/><style:footer><text:p>Página <text:page-number>1</text:page-number> / <text:page-count>99</text:page-count></text:p></style:footer><style:footer-left style:display="false"/></style:master-page></office:master-styles></office:document-styles>';
  221 + }
  222 +
  223 + function getSettings() {
  224 + return '<?xml version="1.0" encoding="UTF-8"?>
  225 + <office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.0"><office:settings><config:config-item-set config:name="ooo:view-settings"><config:config-item config:name="VisibleAreaTop" config:type="int">0</config:config-item><config:config-item config:name="VisibleAreaLeft" config:type="int">0</config:config-item><config:config-item config:name="VisibleAreaWidth" config:type="int">2258</config:config-item><config:config-item config:name="VisibleAreaHeight" config:type="int">903</config:config-item><config:config-item-map-indexed config:name="Views"><config:config-item-map-entry><config:config-item config:name="ViewId" config:type="string">View1</config:config-item><config:config-item-map-named config:name="Tables"><config:config-item-map-entry config:name="Hoja1"><config:config-item config:name="CursorPositionX" config:type="int">0</config:config-item><config:config-item config:name="CursorPositionY" config:type="int">1</config:config-item><config:config-item config:name="HorizontalSplitMode" config:type="short">0</config:config-item><config:config-item config:name="VerticalSplitMode" config:type="short">0</config:config-item><config:config-item config:name="HorizontalSplitPosition" config:type="int">0</config:config-item><config:config-item config:name="VerticalSplitPosition" config:type="int">0</config:config-item><config:config-item config:name="ActiveSplitRange" config:type="short">2</config:config-item><config:config-item config:name="PositionLeft" config:type="int">0</config:config-item><config:config-item config:name="PositionRight" config:type="int">0</config:config-item><config:config-item config:name="PositionTop" config:type="int">0</config:config-item><config:config-item config:name="PositionBottom" config:type="int">0</config:config-item></config:config-item-map-entry></config:config-item-map-named><config:config-item config:name="ActiveTable" config:type="string">Hoja1</config:config-item><config:config-item config:name="HorizontalScrollbarWidth" config:type="int">270</config:config-item><config:config-item config:name="ZoomType" config:type="short">0</config:config-item><config:config-item config:name="ZoomValue" config:type="int">100</config:config-item><config:config-item config:name="PageViewZoomValue" config:type="int">60</config:config-item><config:config-item config:name="ShowPageBreakPreview" config:type="boolean">false</config:config-item><config:config-item config:name="ShowZeroValues" config:type="boolean">true</config:config-item><config:config-item config:name="ShowNotes" config:type="boolean">true</config:config-item><config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item><config:config-item config:name="GridColor" config:type="long">12632256</config:config-item><config:config-item config:name="ShowPageBreaks" config:type="boolean">true</config:config-item><config:config-item config:name="HasColumnRowHeaders" config:type="boolean">true</config:config-item><config:config-item config:name="HasSheetTabs" config:type="boolean">true</config:config-item><config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">true</config:config-item><config:config-item config:name="IsSnapToRaster" config:type="boolean">false</config:config-item><config:config-item config:name="RasterIsVisible" config:type="boolean">false</config:config-item><config:config-item config:name="RasterResolutionX" config:type="int">1000</config:config-item><config:config-item config:name="RasterResolutionY" config:type="int">1000</config:config-item><config:config-item config:name="RasterSubdivisionX" config:type="int">1</config:config-item>
  226 + <config:config-item config:name="RasterSubdivisionY" config:type="int">1</config:config-item><config:config-item config:name="IsRasterAxisSynchronized" config:type="boolean">true</config:config-item></config:config-item-map-entry></config:config-item-map-indexed></config:config-item-set><config:config-item-set config:name="ooo:configuration-settings"><config:config-item config:name="ShowZeroValues" config:type="boolean">true</config:config-item><config:config-item config:name="ShowNotes" config:type="boolean">true</config:config-item><config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item><config:config-item config:name="GridColor" config:type="long">12632256</config:config-item><config:config-item config:name="ShowPageBreaks" config:type="boolean">true</config:config-item><config:config-item config:name="LinkUpdateMode" config:type="short">3</config:config-item><config:config-item config:name="HasColumnRowHeaders" config:type="boolean">true</config:config-item><config:config-item config:name="HasSheetTabs" config:type="boolean">true</config:config-item><config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">true</config:config-item><config:config-item config:name="IsSnapToRaster" config:type="boolean">false</config:config-item><config:config-item config:name="RasterIsVisible" config:type="boolean">false</config:config-item><config:config-item config:name="RasterResolutionX" config:type="int">1000</config:config-item><config:config-item config:name="RasterResolutionY" config:type="int">1000</config:config-item><config:config-item config:name="RasterSubdivisionX" config:type="int">1</config:config-item><config:config-item config:name="RasterSubdivisionY" config:type="int">1</config:config-item><config:config-item config:name="IsRasterAxisSynchronized" config:type="boolean">true</config:config-item><config:config-item config:name="AutoCalculate" config:type="boolean">true</config:config-item><config:config-item config:name="PrinterName" config:type="string">Generic Printer</config:config-item><config:config-item config:name="PrinterSetup" config:type="base64Binary">WAH+/0dlbmVyaWMgUHJpbnRlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU0dFTlBSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWAAMAngAAAAAAAAAFAFZUAAAkbQAASm9iRGF0YSAxCnByaW50ZXI9R2VuZXJpYyBQcmludGVyCm9yaWVudGF0aW9uPVBvcnRyYWl0CmNvcGllcz0xCm1hcmdpbmRhanVzdG1lbnQ9MCwwLDAsMApjb2xvcmRlcHRoPTI0CnBzbGV2ZWw9MApjb2xvcmRldmljZT0wClBQRENvbnRleERhdGEKUGFnZVNpemU6TGV0dGVyAAA=</config:config-item><config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item><config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item><config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item><config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item><config:config-item config:name="UpdateFromTemplate" config:type="boolean">false</config:config-item><config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item><config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item></config:config-item-set></office:settings></office:document-settings>';
  227 + }
  228 +
  229 + function getManifest() {
  230 + return '<?xml version="1.0" encoding="UTF-8"?>
  231 +<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
  232 + <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.spreadsheet" manifest:full-path="/"/>
  233 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/statusbar/"/>
  234 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/accelerator/"/>
  235 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/floater/"/>
  236 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/popupmenu/"/>
  237 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/progressbar/"/>
  238 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/menubar/"/>
  239 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/toolbar/"/>
  240 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/images/Bitmaps/"/>
  241 + <manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/images/"/>
  242 + <manifest:file-entry manifest:media-type="application/vnd.sun.xml.ui.configuration" manifest:full-path="Configurations2/"/>
  243 + <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
  244 + <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>
  245 + <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/>
  246 + <manifest:file-entry manifest:media-type="" manifest:full-path="Thumbnails/"/>
  247 + <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="settings.xml"/>
  248 +</manifest:manifest>';
  249 + }
  250 +
  251 + function addCell($sheet,$row,$cell,$value,$type) {
  252 + $this->sheets[$sheet]['rows'][$row][$cell]['attrs'] = array('OFFICE:VALUE-TYPE'=>$type,'OFFICE:VALUE'=>$value);
  253 + $this->sheets[$sheet]['rows'][$row][$cell]['value'] = $value;
  254 + }
  255 +
  256 + function editCell($sheet,$row,$cell,$value) {
  257 + $this->sheets[$sheet]['rows'][$row][$cell]['attrs']['OFFICE:VALUE'] = $value;
  258 + $this->sheets[$sheet]['rows'][$row][$cell]['value'] = $value;
  259 + }
  260 +
  261 + function output()
  262 + {
  263 + $name = 'doc.ods';
  264 + $tmp = get_tmp_dir();
  265 + $uid = uniqid();
  266 + mkdir($tmp.'/'.$uid);
  267 + $path = $tmp.'/'.$uid.'/'.basename('temp.ods');
  268 + saveOds($this, $path);
  269 + if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
  270 + {
  271 + header('Content-Type: application/force-download');
  272 + }
  273 + else
  274 + {
  275 + header('Content-Type: application/octet-stream');
  276 + }
  277 + $buffer = file_get_contents($path);
  278 + header('Content-Length: '.strlen($buffer));
  279 + header('Content-disposition: attachment; filename="'.$name.'"');
  280 + echo $buffer;
  281 + unlink($path);
  282 + rmdir($tmp.'/'.$uid);
  283 + }
  284 +}
  285 +
  286 +function parseOds($file)
  287 +{
  288 +
  289 + $tmp = get_tmp_dir();
  290 + copy($file,$tmp.'/'.basename($file));
  291 + $path = $tmp.'/'.basename($file);
  292 + $uid = uniqid();
  293 + mkdir($tmp.'/'.$uid);
  294 + #shell_exec('unzip '.escapeshellarg($path).' -d '.escapeshellarg($tmp.'/'.$uid));
  295 + unzip(escapeshellarg($path), escapeshellarg($tmp.'/'.$uid));
  296 + $obj = new ods();
  297 + $obj->parse(file_get_contents($tmp.'/'.$uid.'/content.xml'));
  298 + return $obj;
  299 +}
  300 +
  301 +function unzip($fln, $path)
  302 +{
  303 + $zip = zip_open($fln);
  304 + if ($zip)
  305 + {
  306 + while ($zip_entry = zip_read($zip))
  307 + {
  308 + if (zip_entry_filesize($zip_entry) > 0)
  309 + {
  310 + // str_replace must be used under windows to convert "/" into "\"
  311 + $complete_path = $path.str_replace('/','\\',dirname(zip_entry_name($zip_entry)));
  312 + $complete_name = $path.str_replace ('/','\\',zip_entry_name($zip_entry));
  313 + if(!file_exists($complete_path))
  314 + {
  315 + $tmp = '';
  316 + foreach(explode('\\',$complete_path) AS $k)
  317 + {
  318 + $tmp .= $k.'\\';
  319 + if(!file_exists($tmp))
  320 + {
  321 + mkdir($tmp, 0777);
  322 + }
  323 + }
  324 + }
  325 +
  326 + if (zip_entry_open($zip, $zip_entry, "r"))
  327 + {
  328 + $fd = fopen($complete_name, 'w');
  329 + fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
  330 + fclose($fd);
  331 + zip_entry_close($zip_entry);
  332 + }
  333 + }
  334 + }
  335 + zip_close($zip);
  336 + }
  337 +}
  338 +
  339 +function remove_directory($dir)
  340 +{
  341 + if ($handle = opendir("$dir"))
  342 + {
  343 + while (false !== ($item = readdir($handle)))
  344 + {
  345 + if ($item != "." && $item != "..")
  346 + {
  347 + if (is_dir("$dir/$item"))
  348 + {
  349 + remove_directory("$dir/$item");
  350 + }
  351 + else
  352 + {
  353 + unlink("$dir/$item");
  354 + }
  355 + }
  356 + }
  357 + closedir($handle);
  358 + rmdir($dir);
  359 + }
  360 +}
  361 +
  362 +function saveOds($obj,$file)
  363 +{
  364 + $charset = ini_get('default_charset');
  365 + ini_set('default_charset', 'UTF-8');
  366 + $tmp = get_tmp_dir();
  367 + $uid = uniqid();
  368 + mkdir($tmp.'/'.$uid);
  369 + file_put_contents($tmp.'/'.$uid.'/content.xml',$obj->array2ods());
  370 + file_put_contents($tmp.'/'.$uid.'/mimetype','application/vnd.oasis.opendocument.spreadsheet');
  371 + file_put_contents($tmp.'/'.$uid.'/meta.xml',$obj->getMeta('pt-BR'));
  372 + file_put_contents($tmp.'/'.$uid.'/styles.xml',$obj->getStyle());
  373 + file_put_contents($tmp.'/'.$uid.'/settings.xml',$obj->getSettings());
  374 + mkdir($tmp.'/'.$uid.'/META-INF/');
  375 + mkdir($tmp.'/'.$uid.'/Configurations2/');
  376 + mkdir($tmp.'/'.$uid.'/Configurations2/acceleator/');
  377 + mkdir($tmp.'/'.$uid.'/Configurations2/images/');
  378 + mkdir($tmp.'/'.$uid.'/Configurations2/popupmenu/');
  379 + mkdir($tmp.'/'.$uid.'/Configurations2/statusbar/');
  380 + mkdir($tmp.'/'.$uid.'/Configurations2/floater/');
  381 + mkdir($tmp.'/'.$uid.'/Configurations2/menubar/');
  382 + mkdir($tmp.'/'.$uid.'/Configurations2/progressbar/');
  383 + mkdir($tmp.'/'.$uid.'/Configurations2/toolbar/');
  384 + file_put_contents($tmp.'/'.$uid.'/META-INF/manifest.xml',$obj->getManifest());
  385 + $ziper = new zipfile();
  386 + $ziper->addFiles($tmp.'/'.$uid, array('META-INF', 'Configurations2', 'content.xml', 'meta.xml', 'mimetype', 'settings.xml', 'styles.xml'));
  387 + $ziper->output($file);
  388 + remove_directory($tmp.'/'.$uid);
  389 + ini_set('default_charset',$charset);
  390 +}
  391 +
  392 +function newOds() {
  393 + $content = '<?xml version="1.0" encoding="UTF-8"?>
  394 + <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0"><office:scripts/><office:font-face-decls><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="co1" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="2.267cm"/></style:style><style:style style:name="ro1" style:family="table-row"><style:table-row-properties style:row-height="0.453cm" fo:break-before="auto" style:use-optimal-row-height="true"/></style:style><style:style style:name="ta1" style:family="table" style:master-page-name="Default"><style:table-properties table:display="true" style:writing-mode="lr-tb"/></style:style></office:automatic-styles><office:body><office:spreadsheet><table:table table:name="Hoja1" table:style-name="ta1" table:print="false"><office:forms form:automatic-focus="false" form:apply-design-mode="false"/><table:table-column table:style-name="co1" table:default-cell-style-name="Default"/><table:table-row table:style-name="ro1"><table:table-cell/></table:table-row></table:table><table:table table:name="Hoja2" table:style-name="ta1" table:print="false"><table:table-column table:style-name="co1" table:default-cell-style-name="Default"/><table:table-row table:style-name="ro1"><table:table-cell/></table:table-row></table:table><table:table table:name="Hoja3" table:style-name="ta1" table:print="false"><table:table-column table:style-name="co1" table:default-cell-style-name="Default"/><table:table-row table:style-name="ro1"><table:table-cell/></table:table-row></table:table></office:spreadsheet></office:body></office:document-content>';
  395 + $obj = new ods();
  396 + $obj->parse($content);
  397 + return $obj;
  398 +}
  399 +
  400 +function get_tmp_dir() {
  401 + $path = '';
  402 + if(!function_exists('sys_get_temp_dir')){
  403 + $path = try_get_temp_dir();
  404 + }else{
  405 + $path = sys_get_temp_dir();
  406 + if(is_dir($path)){
  407 + return $path;
  408 + }else{
  409 + $path = try_get_temp_dir();
  410 + }
  411 + }
  412 + return $path;
  413 +}
  414 +
  415 +function try_get_temp_dir() {
  416 + // Try to get from environment variable
  417 + if(!empty($_ENV['TMP'])){
  418 + $path = realpath($_ENV['TMP']);
  419 + }else if(!empty($_ENV['TMPDIR'])){
  420 + $path = realpath( $_ENV['TMPDIR'] );
  421 + }else if(!empty($_ENV['TEMP'])){
  422 + $path = realpath($_ENV['TEMP']);
  423 + }
  424 + // Detect by creating a temporary file
  425 + else{
  426 + // Try to use system's temporary directory
  427 + // as random name shouldn't exist
  428 + $temp_file = tempnam(md5(uniqid(rand(),TRUE)),'');
  429 + if ($temp_file){
  430 + $temp_dir = realpath(dirname($temp_file));
  431 + unlink($temp_file);
  432 + $path = $temp_dir;
  433 + }else{
  434 + return "/tmp";
  435 + }
  436 + }
  437 + return $path;
  438 +}
  439 +
  440 +?>
... ...
include/zip.lib.php 0 → 100755
... ... @@ -0,0 +1,248 @@
  1 +<?php
  2 +/* $Id: zip.lib.php,v 1.1 2004/02/14 15:21:18 anoncvs_tusedb Exp $ */
  3 +// vim: expandtab sw=4 ts=4 sts=4:
  4 +
  5 +
  6 +/**
  7 + * Zip file creation class.
  8 + * Makes zip files.
  9 + *
  10 + * Last Modification and Extension By :
  11 + *
  12 + * Hasin Hayder
  13 + * HomePage : www.hasinme.info
  14 + * Email : countdraculla@gmail.com
  15 + * IDE : PHP Designer 2005
  16 + *
  17 + *
  18 + * Originally Based on :
  19 + *
  20 + * http://www.zend.com/codex.php?id=535&single=1
  21 + * By Eric Mueller <eric@themepark.com>
  22 + *
  23 + * http://www.zend.com/codex.php?id=470&single=1
  24 + * by Denis125 <webmaster@atlant.ru>
  25 + *
  26 + * a patch from Peter Listiak <mlady@users.sourceforge.net> for last modified
  27 + * date and time of the compressed file
  28 + *
  29 + * Official ZIP file format: http://www.pkware.com/appnote.txt
  30 + *
  31 + * @access public
  32 + */
  33 +class zipfile
  34 +{
  35 + /**
  36 + * Array to store compressed data
  37 + *
  38 + * @var array $datasec
  39 + */
  40 + var $datasec = array();
  41 +
  42 + /**
  43 + * Central directory
  44 + *
  45 + * @var array $ctrl_dir
  46 + */
  47 + var $ctrl_dir = array();
  48 +
  49 + /**
  50 + * End of central directory record
  51 + *
  52 + * @var string $eof_ctrl_dir
  53 + */
  54 + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
  55 +
  56 + /**
  57 + * Last offset position
  58 + *
  59 + * @var integer $old_offset
  60 + */
  61 + var $old_offset = 0;
  62 +
  63 +
  64 + /**
  65 + * Converts an Unix timestamp to a four byte DOS date and time format (date
  66 + * in high two bytes, time in low two bytes allowing magnitude comparison).
  67 + *
  68 + * @param integer the current Unix timestamp
  69 + *
  70 + * @return integer the current date in a four byte DOS format
  71 + *
  72 + * @access private
  73 + */
  74 + function unix2DosTime($unixtime = 0) {
  75 + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
  76 +
  77 + if ($timearray['year'] < 1980) {
  78 + $timearray['year'] = 1980;
  79 + $timearray['mon'] = 1;
  80 + $timearray['mday'] = 1;
  81 + $timearray['hours'] = 0;
  82 + $timearray['minutes'] = 0;
  83 + $timearray['seconds'] = 0;
  84 + } // end if
  85 +
  86 + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
  87 + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
  88 + } // end of the 'unix2DosTime()' method
  89 +
  90 +
  91 + /**
  92 + * Adds "file" to archive
  93 + *
  94 + * @param string file contents
  95 + * @param string name of the file in the archive (may contains the path)
  96 + * @param integer the current timestamp
  97 + *
  98 + * @access public
  99 + */
  100 + function addFile($data, $name, $time = 0)
  101 + {
  102 + $name = str_replace('\\', '/', $name);
  103 +
  104 + $dtime = dechex($this->unix2DosTime($time));
  105 + $hexdtime = '\x' . $dtime[6] . $dtime[7]
  106 + . '\x' . $dtime[4] . $dtime[5]
  107 + . '\x' . $dtime[2] . $dtime[3]
  108 + . '\x' . $dtime[0] . $dtime[1];
  109 + eval('$hexdtime = "' . $hexdtime . '";');
  110 +
  111 + $fr = "\x50\x4b\x03\x04";
  112 + $fr .= "\x14\x00"; // ver needed to extract
  113 + $fr .= "\x00\x00"; // gen purpose bit flag
  114 + $fr .= "\x08\x00"; // compression method
  115 + $fr .= $hexdtime; // last mod time and date
  116 +
  117 + // "local file header" segment
  118 + $unc_len = strlen($data);
  119 + $crc = crc32($data);
  120 + $zdata = gzcompress($data);
  121 + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
  122 + $c_len = strlen($zdata);
  123 + $fr .= pack('V', $crc); // crc32
  124 + $fr .= pack('V', $c_len); // compressed filesize
  125 + $fr .= pack('V', $unc_len); // uncompressed filesize
  126 + $fr .= pack('v', strlen($name)); // length of filename
  127 + $fr .= pack('v', 0); // extra field length
  128 + $fr .= $name;
  129 +
  130 + // "file data" segment
  131 + $fr .= $zdata;
  132 +
  133 + // "data descriptor" segment (optional but necessary if archive is not
  134 + // served as file)
  135 + $fr .= pack('V', $crc); // crc32
  136 + $fr .= pack('V', $c_len); // compressed filesize
  137 + $fr .= pack('V', $unc_len); // uncompressed filesize
  138 +
  139 + // add this entry to array
  140 + $this -> datasec[] = $fr;
  141 +
  142 + // now add to central directory record
  143 + $cdrec = "\x50\x4b\x01\x02";
  144 + $cdrec .= "\x00\x00"; // version made by
  145 + $cdrec .= "\x14\x00"; // version needed to extract
  146 + $cdrec .= "\x00\x00"; // gen purpose bit flag
  147 + $cdrec .= "\x08\x00"; // compression method
  148 + $cdrec .= $hexdtime; // last mod time & date
  149 + $cdrec .= pack('V', $crc); // crc32
  150 + $cdrec .= pack('V', $c_len); // compressed filesize
  151 + $cdrec .= pack('V', $unc_len); // uncompressed filesize
  152 + $cdrec .= pack('v', strlen($name) ); // length of filename
  153 + $cdrec .= pack('v', 0 ); // extra field length
  154 + $cdrec .= pack('v', 0 ); // file comment length
  155 + $cdrec .= pack('v', 0 ); // disk number start
  156 + $cdrec .= pack('v', 0 ); // internal file attributes
  157 + $cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
  158 +
  159 + $cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
  160 + $this -> old_offset += strlen($fr);
  161 +
  162 + $cdrec .= $name;
  163 +
  164 + // optional extra field, file comment goes here
  165 + // save to central directory
  166 + $this -> ctrl_dir[] = $cdrec;
  167 + } // end of the 'addFile()' method
  168 +
  169 +
  170 + /**
  171 + * Dumps out file
  172 + *
  173 + * @return string the zipped file
  174 + *
  175 + * @access public
  176 + */
  177 + function file()
  178 + {
  179 + $data = implode('', $this -> datasec);
  180 + $ctrldir = implode('', $this -> ctrl_dir);
  181 +
  182 + return
  183 + $data .
  184 + $ctrldir .
  185 + $this -> eof_ctrl_dir .
  186 + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
  187 + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
  188 + pack('V', strlen($ctrldir)) . // size of central dir
  189 + pack('V', strlen($data)) . // offset to start of central dir
  190 + "\x00\x00"; // .zip file comment length
  191 + } // end of the 'file()' method
  192 +
  193 +
  194 + /**
  195 + * A Wrapper of original addFile Function
  196 + *
  197 + * Created By Hasin Hayder at 29th Jan, 1:29 AM
  198 + *
  199 + * @param array An Array of files with relative/absolute path to be added in Zip File
  200 + *
  201 + * @access public
  202 + */
  203 + function addFiles($base, $files /*Only Pass Array*/)
  204 + {
  205 + foreach($files as $file)
  206 + {
  207 + if (is_file($base . '/' . $file)) //directory check
  208 + {
  209 + $data = file_get_contents($base . '/' . $file);
  210 + $this->addFile($data,$file);
  211 + }
  212 + else if (is_dir($base . '/' . $file))
  213 + {
  214 + if ($handle = opendir($base . '/' . $file))
  215 + {
  216 + while (FALSE !== ($f = readdir($handle)))
  217 + {
  218 + if ($f != "." && $f != "..")
  219 + {
  220 + $this->addFiles($base, array($file.'/'.$f));
  221 + }
  222 + }
  223 + closedir($handle);
  224 + }
  225 + }
  226 + }
  227 + }
  228 +
  229 + /**
  230 + * A Wrapper of original file Function
  231 + *
  232 + * Created By Hasin Hayder at 29th Jan, 1:29 AM
  233 + *
  234 + * @param string Output file name
  235 + *
  236 + * @access public
  237 + */
  238 + function output($file)
  239 + {
  240 + $fp=fopen($file,"w");
  241 + fwrite($fp,$this->file());
  242 + fclose($fp);
  243 + }
  244 +
  245 +
  246 +
  247 +} // end of the 'zipfile' class
  248 +?>
... ...
language/en_US/menu_adm.txt
... ... @@ -13,6 +13,7 @@
13 13 ..<b>Cadastros</b>||mainFrame|imgs/config_gerais.gif
14 14 ...Aquisições|admin/gerencia_licencas/arquivo/aquisicoes.php|mainFrame||
15 15 ...Locais|admin/locais/index.php|mainFrame||Cadastro de Locais para Controle Centralizado
  16 +...Domínios|admin/dominios/index.php|mainFrame||Cadastro de Domínios para Autenticação do srCACIC
16 17 ...SubRedes|admin/redes/index.php|mainFrame||Cadastro de SubRedes
17 18 ...Perfis Sistemas|admin/perfis_aplicativos_monitorados/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
18 19 ...Usuários|admin/usuarios/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
... ...
language/es_UR/menu_adm.txt
... ... @@ -13,6 +13,7 @@
13 13 ..<b>Registros</b>||mainFrame|imgs/config_gerais.gif
14 14 ...Aquisiciones|admin/gerencia_licencas/arquivo/aquisicoes.php|mainFrame||
15 15 ...Locales|admin/locais/index.php|mainFrame||Cadastro de Locais para Controle Centralizado
  16 +...Domínios|admin/dominios/index.php|mainFrame||Cadastro de Domínios para Autenticação do srCACIC
16 17 ...SubRedes|admin/redes/index.php|mainFrame||Cadastro de SubRedes
17 18 ...Perfiles Sistemas|admin/perfis_aplicativos_monitorados/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
18 19 ...Usuarios|admin/usuarios/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
... ... @@ -76,4 +77,4 @@
76 77 ..Cambio de Clave|admin/usuarios/troca_senha.php|mainFrame||
77 78 .<b>Repositório|repositorio_install.php|mainFrame||Repositório do Sistema CACIC
78 79 .<b>Projecto CACIC<b>|tribo/|new||Link de Acesso à Home Page do Projeto CACIC
79   -.<b>Comunidad CACIC<b>|http://www.softwarepublico.gov.br/spb/ver-comunidade?community_id=3585|new||Link de Acesso à Home Page da Comunidade CACIC
  80 +.<b>Comunidad CACIC<b>|http://www.softwarepublico.gov.br/spb/ver-comunidade?community_id=3585|new||Link de Acesso à Home Page da Comunidade CACIC
... ...
language/pt_BR/menu_adm.txt
... ... @@ -13,6 +13,7 @@
13 13 ..<b>Cadastros</b>||mainFrame|imgs/config_gerais.gif
14 14 ...Aquisições|admin/gerencia_licencas/arquivo/aquisicoes.php|mainFrame||
15 15 ...Locais|admin/locais/index.php|mainFrame||Cadastro de Locais para Controle Centralizado
  16 +...Domínios|admin/dominios/index.php|mainFrame||Cadastro de Domínios para Autenticação do srCACIC
16 17 ...SubRedes|admin/redes/index.php|mainFrame||Cadastro de SubRedes
17 18 ...Perfis Sistemas|admin/perfis_aplicativos_monitorados/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
18 19 ...Usuários|admin/usuarios/index.php|mainFrame||Cadastro de Perfis de Aplicativos Monitorados
... ...
ldap.php 0 → 100755
... ... @@ -0,0 +1,91 @@
  1 +<?
  2 +// LDAP variables
  3 +
  4 +$ldaphost = "dataprevasdfdsf"; // your ldap servers
  5 +$ldapport = 389; // your ldap server's port number
  6 +
  7 +// Connecting to LDAP
  8 +$ldapconn = ldap_connect($ldaphost, $ldapport)
  9 + or die("Could not connect to $ldaphost");
  10 +echo 'OK!';
  11 +
  12 +$strMessage = '';
  13 +if ($_POST['btLogin']==' Login ')
  14 + {
  15 +
  16 + function ldap_binder($strDomainName,$strUserName,$strUserPassword)
  17 + {
  18 + $ldap_addr = $strDomainName; // Change this to the IP address of the LDAP server
  19 + $ldap_conn = ldap_connect($ldap_addr) or die("Couldn't connect!");
  20 + ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
  21 + $ldap_rdn = $strDomainName."\\".$strUserName;
  22 + $ldap_pass = $strUserPassword;
  23 +
  24 + // Authenticate the user against the domain controller
  25 + $flag_ldap = ldap_bind($ldap_conn,$ldap_rdn,$ldap_pass);
  26 + return $flag_ldap;
  27 + }
  28 +
  29 + // bind with appropriate dn to give update access
  30 + $r = ldap_binder($_POST['frmDomainName'],$_POST['frmUserName'], $_POST['frmUserPassword']);
  31 + echo 'R=> '.$r. "<br />";
  32 +
  33 +
  34 +
  35 +$attrs = get_entry_system_attrs( $ldap_conn, $ldap_rdn, $deref=LDAP_DEREF_NEVER );
  36 +
  37 +for ($i=0; $i < count($attrs); $i++)
  38 + echo '=> '.$attrs[$i] . "<br />";
  39 +
  40 + $strMessage = '<font size=2 color=';
  41 + // verify binding
  42 + echo 'r0=>'.$r[0].'<br>';
  43 + echo 'r1=>'.$r[1].'<br>';
  44 + if ($r)
  45 + $strMessage .= 'blue>Conexão Efetuada no Domínio!';
  46 + else
  47 + $strMessage .= 'red>Conexão NÃO Efetuada no Domínio!';
  48 +
  49 + $strMessage .= '</font>';
  50 + }
  51 +?>
  52 +<form id="form1" name="form1" method="post" action="">
  53 +<table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
  54 +
  55 + <tr>
  56 + <td><div align="center">Dom&iacute;nio</div></td>
  57 + <td><div align="center"></div></td>
  58 + <td><div align="center">Usu&aacute;rio</div></td>
  59 + <td><div align="center"></div></td>
  60 + <td><div align="center">Senha</div></td>
  61 + </tr>
  62 + <tr>
  63 + <td>
  64 + <label>
  65 + <div align="center">
  66 + <input name="frmDomainName" type="text" id="frmDomainName" size="20" maxlength="20" />
  67 + </div>
  68 + </label> </td>
  69 + <td><div align="center"></div></td>
  70 + <td><div align="center">
  71 + <input name="frmUserName2" type="text" id="frmUserName2" size="20" maxlength="20" />
  72 + </div></td>
  73 + <td><div align="center"></div></td>
  74 + <td><div align="center">
  75 + <input name="frmUserPassword" type="password" id="frmUserPassword" size="20" maxlength="20" />
  76 + </div></td>
  77 + </tr>
  78 + <tr>
  79 + <td colspan="5"><div align="center"><? echo $strMessage;?>
  80 + </div>
  81 + <div align="center"></div></td>
  82 + </tr>
  83 +
  84 + <tr>
  85 + <td colspan="5"><div align="center">
  86 + <input type="submit" name="btLogin" id="btLogin" value=" Login " />
  87 + </div></td>
  88 + </tr>
  89 +</table>
  90 +
  91 +</form>
0 92 \ No newline at end of file
... ...
principal.php
... ... @@ -42,7 +42,8 @@ require_once(&quot;include/library.php&quot;);
42 42 session_unregister('te_exibe_graficos');
43 43  
44 44 // Resgato a configuração sobre exibição dos gráficos da página principal
45   -$_SESSION['te_exibe_graficos'] = get_valor_campo('configuracoes_locais', 'te_exibe_graficos', 'id_local='.$_SESSION['id_local']);
  45 +$arrConfiguracoesLocais = getValores('configuracoes_locais', 'te_exibe_graficos', 'id_local='.$_SESSION['id_local']);
  46 +$_SESSION['te_exibe_graficos'] = $arrConfiguracoesLocais['te_exibe_graficos'];
46 47  
47 48 // Caso o usuário atual não esteja logado, mostro apenas os números de acessos por local
48 49 if (!session_is_registered('cs_nivel_administracao'))
... ...
relatorios/antivirus/rel_antivirus.php
... ... @@ -10,7 +10,8 @@ if($_POST[&#39;submit&#39;])
10 10 $_SESSION["list12"] = $_POST['list12'];
11 11 $_SESSION["cs_situacao"] = $_POST["cs_situacao"];
12 12 $_SESSION["cs_exibe_info_patrimonial"] = $_POST["frmCsExibeInfoPatrimonial"];
13   - $_SESSION["te_servidor"] = '';
  13 + $_SESSION["te_servidor"] = '';
  14 + $_SESSION['orderby'] = '';
14 15 if (count($_POST["frm_te_serv_sel"]) > 0)
15 16 {
16 17 for ( $i = 0; $i < count($_POST["frm_te_serv_sel"]); $i++ )
... ... @@ -52,6 +53,8 @@ if($_POST[&#39;submit&#39;])
52 53  
53 54 }
54 55 ?>
  56 +<?php
  57 +/*
55 58 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
56 59 <html>
57 60 <head>
... ... @@ -89,8 +92,15 @@ function MM_openBrWindow(theURL,winName,features) { //v2.0
89 92 <br>
90 93 <br>
91 94 <br>
  95 +*/
  96 +?>
92 97 <?
93 98 require_once('../../include/library.php');
  99 +require_once('../../include/RelatorioHTML.php');
  100 +require_once('../../include/RelatorioPDF.php');
  101 +require_once('../../include/RelatorioODS.php');
  102 +require_once('../../include/RelatorioCSV.php');
  103 +
94 104 AntiSpy();
95 105 conecta_bd_cacic();
96 106  
... ... @@ -133,14 +143,24 @@ for( $i = 0; $i &lt; count($_SESSION[&quot;list6&quot;] ); $i++ )
133 143 // Aqui substitui todas as strings \ por vazio que a variável $campos_hardware retorna
134 144 $campos_software = str_replace('\\', '', $campos_software);
135 145  
136   -if ($_GET['orderby'])
  146 +if (isset($_GET['orderby']))
  147 +{
137 148 $orderby = $_GET['orderby'];
  149 + $_SESSION['orderby'] = $orderby;
  150 +}
  151 +else if ($_SESSION['orderby'] != '')
  152 +{
  153 + $orderby = $_SESSION['orderby'];
  154 +}
138 155 else
  156 +{
139 157 $orderby = 'computadores.te_nome_computador';
  158 +}
140 159  
141   -$query = 'SELECT distinct computadores.te_node_address,
142   - so.id_so,
143   - computadores.te_nome_computador as "Nome Comp.",
  160 +$query = 'SELECT DISTINCT computadores.te_node_address,
  161 + so.id_so,
  162 + UNIX_TIMESTAMP(computadores.dt_hr_ult_acesso) as "ult_acesso",
  163 + computadores.te_nome_computador as "Nome Comp.",
144 164 so.sg_so as "S.O.",
145 165 computadores.te_ip as "IP"' .
146 166 $campos_software .
... ... @@ -161,25 +181,53 @@ $result = mysql_query($query) or die(&#39;Erro no select ou sua sessão expirou!&#39;);
161 181 $cor = 0;
162 182 $num_registro = 1;
163 183  
  184 +if (isset($_GET['formato']))
  185 +{
  186 + $formato = $_GET['formato'];
  187 +}
  188 +else
  189 +{
  190 + $formato = $_POST['formato'];
  191 +}
  192 +switch ($formato)
  193 +{
  194 + case "pdf":
  195 + $relatorio = new RelatorioPDF();
  196 + break;
  197 + case "ods":
  198 + $relatorio = new RelatorioODS();
  199 + break;
  200 + case "csv":
  201 + $relatorio = new RelatorioCSV();
  202 + break;
  203 + default:
  204 + $relatorio = new RelatorioHTML();
  205 + break;
  206 +}
  207 +
  208 +$relatorio->setTitulo('CACIC - Relatório de Configurações do Antivírus OfficeScan');
  209 +
164 210 $fields=mysql_num_fields($result);
165   -echo '<table cellpadding="2" cellspacing="0" border="1" bordercolor="#999999" bordercolordark="#E1E1E1">
166   - <tr bgcolor="#E1E1E1" >
167   - <td nowrap align="left"><font size="1" face="Verdana, Arial">&nbsp;</font></td>';
168 211  
169 212 $intColunaDHI = 0; // Coluna apenas para ordenar pela Data/Hora de Instalacao
170   -$strTripaColunasValidas = '#';
171   -for ($i=2; $i < mysql_num_fields($result); $i++)
172   - {//Table Header
  213 +$strTripaColunasValidas = array();
  214 +$tra = array();
  215 +$header = array('#');
  216 +for ($i=3; $i < mysql_num_fields($result); $i++)
  217 +{//Table Header
173 218 $iAux = $i;
174 219 $iAux = ($iAux==6?7:$iAux);
175 220 $iAux = ($iAux==8?9:$iAux);
176 221 // Não posso mostrar as colunas datas/horas usadas para ordenação
177 222 if (mysql_field_name($result, $i)<>'DHI' && mysql_field_name($result, $i)<>'DHUC')
178   - {
179   - print '<td nowrap align="left"><b><font size="1" face="Verdana, Arial"><a href="?orderby=' . ($iAux+1) . '">'. mysql_field_name($result, $i) .'</a></font><b></td>';
180   - $strTripaColunasValidas .= $i . '#';
181   - }
  223 + {
  224 + #print '<td nowrap align="left"><b><font size="1" face="Verdana, Arial"><a href="?orderby=' . ($iAux+1) . '">'. mysql_field_name($result, $i) .'</a></font><b></td>';
  225 + $header[] = '<b><font size="1" face="Verdana, Arial"><a href="?orderby=' . ($iAux+1) . '">'. mysql_field_name($result, $i) .'</a></font></b>';
  226 + $strTripaColunasValidas[] = $i;
  227 + $tra[$i] = mysql_field_name($result, $i);
182 228 }
  229 +}
  230 +
183 231  
184 232 // Caso seja selecionada a exibição de Informações Patrimoniais...
185 233 if ($_SESSION['cs_exibe_info_patrimonial']<>'')
... ... @@ -233,7 +281,8 @@ if ($_SESSION[&#39;cs_exibe_info_patrimonial&#39;]&lt;&gt;&#39;&#39;)
233 281 if ($boolMostraColuna)
234 282 {
235 283 $iAux ++;
236   - print '<td nowrap align="left"><b><font size="1" face="Verdana, Arial">'. $row_pat['te_etiqueta'] .'</font><b></td>';
  284 + #print '<td nowrap align="left"><b><font size="1" face="Verdana, Arial">'. $row_pat['te_etiqueta'] .'</font><b></td>';
  285 + $header[] = '<b><font size="1" face="Verdana, Arial">'. $row_pat['te_etiqueta'] .'</font></b>';
237 286 }
238 287 }
239 288  
... ... @@ -271,92 +320,163 @@ if ($_SESSION[&#39;cs_exibe_info_patrimonial&#39;]&lt;&gt;&#39;&#39;)
271 320 }
272 321  
273 322  
274   -echo '</tr>';
  323 +#echo '</tr>';
  324 +$relatorio->setTableHeader($header);
275 325  
  326 +$table = array();
276 327 while ($row = mysql_fetch_row($result))
277   - {//Table body
278   - echo '<tr ';
279   - if ($cor) { echo 'bgcolor="#E1E1E1"'; }
280   - echo '>';
281   - echo '<td nowrap align="right"><font size="1" face="Verdana, Arial">' . $num_registro . '</font></td>';
282   - echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[2] ."</a>&nbsp;</td>";
283   - for ($i=3; $i < $fields; $i++)
  328 +{//Table body
  329 +
  330 + // ja existe entrada para este MAC?
  331 + if (isset($table[$row[0]]))
  332 + {
  333 + // acesso mais rencente?
  334 + if ($row[2] > $table[$row[0]][2])
284 335 {
285   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial" ';
286   - if ($row[$i] == 'N')
287   - echo 'color="#FF0000"><strong>N</strong>';
288   - else
289   - {
290   - echo '>';
  336 + $table[$row[0]] = $row;
  337 + }
  338 + }
  339 + else
  340 + {
  341 + $table[$row[0]] = $row;
  342 + }
  343 +}
291 344  
292   - // Não posso mostrar as colunas datas/horas usadas para ordenação
293   - $boolExibe = false;
294   - $j = $i-1;
295   - while ($j < $fields && !$boolExibe)
296   - {
297   - $j++;
298   - $boolExibe = stripos2($strTripaColunasValidas, '#'.$j.'#',false);
299   - }
300   - $i = $j;
  345 +// adiciona informacoes patrimoniais
  346 +foreach ($table as $row)
  347 +{
  348 + #exibe_row($num_registro, $cor, $row, $fields, $strTripaColunasValidas);
301 349  
302   - echo $row[$i];
303   - }
304   - echo '&nbsp;</td>';
305   - }
306 350 if ($_SESSION['cs_exibe_info_patrimonial']<>'')
307   - {
308   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
309   - echo $arrMacSO[$row[0].'_'.$row[1]]['uon1'];
310   - echo '&nbsp;</td>';
  351 + {
  352 + #echo '<td nowrap align="left">';
  353 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['uon1'].'</font>';
  354 + #echo '&nbsp;</td>';
311 355  
312   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
313   - echo $arrMacSO[$row[0].'_'.$row[1]]['uon1a'];
314   - echo '&nbsp;</td>';
  356 + #echo '<td nowrap align="left">';
  357 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['uon1a'].'</font>';
  358 + #echo '&nbsp;</td>';
315 359  
316   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
317   - echo $arrMacSO[$row[0].'_'.$row[1]]['uon2'];
318   - echo '&nbsp;</td>';
  360 + #echo '<td nowrap align="left">';
  361 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['uon2'].'</font>';
  362 + #echo '&nbsp;</td>';
319 363  
320   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
321   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_localizacao_complementar'];
322   - echo '&nbsp;</td>';
  364 + #echo '<td nowrap align="left">';
  365 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_localizacao_complementar'].'</font>';
  366 + #echo '&nbsp;</td>';
323 367  
324   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
325   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio1'];
326   - echo '&nbsp;</td>';
  368 + #echo '<td nowrap align="left">';
  369 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio1'].'</font>';
  370 + #echo '&nbsp;</td>';
327 371  
328   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
329   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio2'];
330   - echo '&nbsp;</td>';
  372 + #echo '<td nowrap align="left">';
  373 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio2'].'</font>';
  374 + #echo '&nbsp;</td>';
331 375  
332   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
333   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio3'];
334   - echo '&nbsp;</td>';
  376 + #echo '<td nowrap align="left">';
  377 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio3'].'</font>';
  378 + #echo '&nbsp;</td>';
335 379  
336   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
337   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio4'];
338   - echo '&nbsp;</td>';
  380 + #echo '<td nowrap align="left">';
  381 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio4'].'</font>';
  382 + #echo '&nbsp;</td>';
339 383  
340   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
341   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio5'];
342   - echo '&nbsp;</td>';
  384 + #echo '<td nowrap align="left">';
  385 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio5'].'</font>';
  386 + #echo '&nbsp;</td>';
343 387  
344   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">';
345   - echo $arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio6'];
346   - echo '&nbsp;</td>';
  388 + #echo '<td nowrap align="left">';
  389 + $row[] = '<font size="1" face="Verdana, Arial">'.$arrMacSO[$row[0].'_'.$row[1]]['te_info_patrimonio6'].'</font>';
  390 + #echo '&nbsp;</td>';
347 391  
348   - }
349   - $cor=!$cor;
  392 + }
  393 + $cor = !$cor;
  394 +
  395 + $relatorio->addRow(gera_row($num_registro, $row, $fields, $strTripaColunasValidas, $tra));
350 396 $num_registro++;
351   - echo '</tr>';
  397 +}
  398 +#echo '</table><br><br>';
  399 +
  400 +function gera_row($num_registro, $row, $fields, $strTripaColunasValidas, $tra)
  401 +{
  402 + $c1 = '<font size="1" face="Verdana, Arial">' . $num_registro . '</font>';
  403 + $c2 = "<font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[3] ."</a>";
  404 +
  405 + unset($row[0]);
  406 + unset($row[1]);
  407 + unset($row[2]);
  408 + unset($row[3]);
  409 +
  410 + for ($i=4; $i < $fields; $i++)
  411 + {
  412 +
  413 + if ($row[$i] == 'N')
  414 + {
  415 + $row[$i] = '<font size="1" face="Verdana, Arial" color="#FF0000"><center><strong>N</strong></center</font>';
  416 + }
  417 + else
  418 + {
  419 + if (array_search($i, $strTripaColunasValidas) !== FALSE)
  420 + {
  421 + $row[$i] = '<font size="1" face="Verdana, Arial" >'.$row[$i].'</font>';
  422 + }
  423 + else
  424 + {
  425 + unset($row[$i]);
  426 + }
  427 + }
352 428 }
353   -echo '</table><br><br>';
  429 +
  430 + array_unshift($row, $c1, $c2);
  431 + #print_r($row);
  432 + #die();
  433 + return $row;
  434 +}
  435 +
  436 +function exibe_row($num_registro, $cor, $row, $fields, $strTripaColunasValidas)
  437 +{
  438 + global $tra;
  439 +
  440 + echo '<tr ';
  441 + if ($cor) { echo 'bgcolor="#E1E1E1"'; }
  442 + echo '>';
  443 + echo '<td nowrap align="right"><font size="1" face="Verdana, Arial">' . $num_registro . '</font></td>';
  444 + echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[3] ."</a>&nbsp;</td>";
  445 +
  446 + for ($i=4; $i < $fields; $i++)
  447 + {
  448 +
  449 + if ($row[$i] == 'N')
  450 + {
  451 + echo '<td nowrap align="left"><font size="1" face="Verdana, Arial" ';
  452 + echo 'color="#FF0000"><strong>N</strong>';
  453 + echo '&nbsp;</td>';
  454 + }
  455 + else
  456 + {
  457 + if (array_search($i, $strTripaColunasValidas) !== FALSE)
  458 + {
  459 + echo '<td nowrap align="left"><font size="1" face="Verdana, Arial" >';
  460 + echo /*$i." - ".$tra[$i]." - ".*/$row[$i];
  461 + echo '&nbsp;</td>';
  462 + }
  463 + }
  464 + }
  465 +}
  466 +
  467 +$relatorio->output();
  468 +
  469 +/*
354 470 if (count($_SESSION["list8"])>0)
355 471 {
356 472 $v_opcao = 'antivirus'; // Nome do pie que será chamado por tabela_estatisticas
357 473 require_once('../../include/tabela_estatisticas.php');
358 474 }
359   -?></p>
  475 +*/
  476 +?>
  477 +<?
  478 +/*
  479 +</p>
360 480  
361 481 <p align="left"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Relat&oacute;rio
362 482 gerado pelo <strong>CACIC</strong> - Configurador Autom&aacute;tico e Coletor
... ... @@ -365,3 +485,5 @@ if (count($_SESSION[&quot;list8&quot;])&gt;0)
365 485 pela Dataprev - Unidade Regional Esp&iacute;rito Santo</font></p>
366 486 </body>
367 487 </html>
  488 +*/
  489 +?>
... ...
relatorios/hardware/rel_hardware.php
... ... @@ -70,7 +70,11 @@ function MM_openBrWindow(theURL,winName,features) { //v2.0
70 70 <br>
71 71 <?
72 72 require_once('../../include/library.php');
73   -AntiSpy();
  73 +require_once('../../include/RelatorioHTML.php');
  74 +require_once('../../include/RelatorioPDF.php');
  75 +require_once('../../include/RelatorioODS.php');
  76 +require_once('../../include/RelatorioCSV.php');
  77 +// Comentado temporariamente - AntiSpy();
74 78 conecta_bd_cacic();
75 79  
76 80 $redes_selecionadas = '';
... ... @@ -119,58 +123,332 @@ for( $i = 1; $i &lt; count($_SESSION[&quot;list4&quot;] ); $i++ )
119 123  
120 124 $campos_hardware = '';
121 125 // Aqui pego todas as configurações de hardware que deseja exibir
  126 +$campos_hardware = '';
  127 +$campo_componentes_estacoes = '';
  128 +$join_componentes_estacoes = '';
  129 +$cs_componentes_estacoes = array();
  130 +$exibe_componentes = array();
  131 +$where_operador = FALSE;
  132 +
  133 +$componentes_estacoes[0]['value'] = 'te_cpu_desc';
  134 +$componentes_estacoes[0]['tipo'] = 'CPU';
  135 +
  136 +$componentes_estacoes[1]['value'] = 'te_cdrom_desc';
  137 +$componentes_estacoes[1]['tipo'] = 'CDROM';
  138 +
  139 +$componentes_estacoes[2]['value'] = 'te_placa_rede_desc';
  140 +$componentes_estacoes[2]['tipo'] = 'TCPIP';
  141 +
122 142 for( $i = 0; $i < count($_SESSION["list6"] ); $i++ )
123 143 {
124   - $campos_hardware .= ($campos_hardware <> ''?',':'');
125   - $campos_hardware = $campos_hardware . $_SESSION["list6"][$i];
  144 + $campo = $_SESSION['list6'][$i];
  145 + $pcampo = explode('###', $campo);
  146 +
  147 + for ( $j = 0; $j < count($componentes_estacoes); $j++)
  148 + {
  149 + $pos = strpos($campo, $componentes_estacoes[$j]['value']);
  150 + if ($pos !== FALSE)
  151 + {
  152 + $campo_componentes_estacoes = ', ce.te_valor, ce.cs_tipo_componente';
  153 + $join_componentes_estacoes = 'LEFT OUTER JOIN componentes_estacoes ce ON (a.te_node_address = ce.te_node_address AND a.id_so = ce.id_so)';
  154 + $cs_componentes_estacoes[] = $componentes_estacoes[$j]['tipo'];
  155 +
  156 + $exibe_componentes[] = $pcampo[1];
  157 +
  158 + break;
  159 + }
  160 + }
  161 + $campos_hardware = $campos_hardware . ', '.$pcampo[0];//.' AS "'.$pcampo[1].'"';
126 162 }
127 163 // Aqui substitui todas as strings \ por vazio que a variável $campos_hardware retorna
128 164 $campos_hardware = str_replace('\\', '', $campos_hardware);
129 165  
130   -if ($_GET['orderby']) { $orderby = $_GET['orderby']; }
131   -else { $orderby = '3'; } //por Nome Comp.
132   - $query = ' SELECT distinct a.te_node_address,
133   - so.id_so,
  166 +// Monta a a clausula WHERE referente a tabela componentes_estacoes
  167 +if (isset($_GET['orderby']))
  168 +{
  169 + $orderby = $_GET['orderby'];
  170 + $_SESSION['orderby'] = $orderby;
  171 +}
  172 +else if ($_SESSION['orderby'] != '')
  173 +{
  174 + $orderby = $_SESSION['orderby'];
  175 +}
  176 +else
  177 +{
  178 + $orderby = '4'; //por Nome Comp.
  179 +}
  180 + $query = ' SELECT a.te_node_address,
  181 + so.id_so,
  182 + UNIX_TIMESTAMP(a.dt_hr_ult_acesso) as ult_acesso,
134 183 a.te_nome_computador as "Nome Comp.",
135 184 sg_so as "S.O.",
136   - a.te_ip as "IP"' .
137   - $select . ($campos_hardware?','.$campos_hardware:"") . '
138   - FROM so LEFT JOIN computadores a ON (a.id_so = so.id_so) '.
139   - $from . '
  185 + a.te_ip as "IP"' .
  186 + $campo_componentes_estacoes .
  187 + $campos_hardware .
  188 + $select .'
  189 + FROM so LEFT OUTER JOIN computadores a ON (a.id_so = so.id_so)
  190 + '.$join_componentes_estacoes.'
  191 + '.$from . '
140 192 WHERE TRIM(a.te_nome_computador) <> "" AND
141   - a.id_so IN ('. $so_selecionados .') '.
142   - $query_redes .'
143   - ORDER BY ' . $orderby;
144   -// $campos_hardware .
145   -
146   -$result = mysql_query($query) or die('Erro no select ou sua sessão expirou!');
147   -
  193 + a.id_so IN ('. $so_selecionados .') '
  194 + .$query_redes .'
  195 + ORDER BY ' . $orderby;
  196 +$result = mysql_query($query) or die('Erro na query SQL ou sua Sessão expirou! '.mysql_error());
  197 +#echo('<br><br>'.$query.'<br><br>');
148 198 $cor = 0;
149 199 $num_registro = 1;
150 200  
151 201 $fields=mysql_num_fields($result);
  202 +/* PRE CLASSES RELATORIO (REMOVER)
152 203 echo '<table cellpadding="2" cellspacing="0" border="1" bordercolor="#999999" bordercolordark="#E1E1E1">
153 204 <tr bgcolor="#E1E1E1" >
154   - <td nowrap align="left"><font size="1" face="Verdana, Arial">&nbsp;</font></td>';
  205 + <td nowrap align="left"><font size="1" face="Verdana, Arial"> </font></td>';
  206 +*/
  207 +
  208 +if (isset($_GET['formato']))
  209 +{
  210 + $formato = $_GET['formato'];
  211 +}
  212 +else
  213 +{
  214 + $formato = $_POST['formato'];
  215 +}
  216 +switch ($formato)
  217 +{
  218 + case "pdf":
  219 + $relatorio = new RelatorioPDF();
  220 + break;
  221 + case "ods":
  222 + $relatorio = new RelatorioODS();
  223 + break;
  224 + case "csv":
  225 + $relatorio = new RelatorioCSV();
  226 + break;
  227 + default:
  228 + $relatorio = new RelatorioHTML();
  229 + break;
  230 +}
  231 +
  232 +$relatorio->setTitulo('CACIC - Relatório de Configurações de Hardware');
  233 +
  234 +$dicionario = carrega_dicionario();
  235 +
  236 +// incializa com o header da coluna para o numero dos registros
  237 +$header = array('#');
  238 +for ($i=3; $i < mysql_num_fields($result); $i++) { //Table Header
  239 + $name = mysql_field_name($result, $i);
  240 +
  241 + // se nao constar no dicionario assumir que ja existe o alias
  242 + if (isset($dicionario[$name]))
  243 + {
  244 + $name_tra = $dicionario[mysql_field_name($result, $i)];
  245 + }
  246 + else
  247 + {
  248 + $name_tra = $name;
  249 + }
  250 +
  251 + if ($name != 'te_valor' AND $name != 'cs_tipo_componente')
  252 + {
  253 + if ($name == 'te_cpu_desc' OR $name == 'te_cdrom_desc' OR $name == 'te_placa_rede_desc')
  254 + {
  255 + $header[] = '<b><font size="1" face="Verdana, Arial">'. $name_tra .'</font></b>';
  256 + }
  257 + else
  258 + {
  259 + $header[] = '<b><font size="1" face="Verdana, Arial"><a href="?orderby=' . ($i + 1) . '">'. $name_tra .'</a></font></b>';
  260 + }
  261 + }
  262 +}
  263 +$relatorio->setTableHeader($header);
  264 +
  265 +
  266 +
  267 +
  268 +$table = array();
  269 +while ($row = mysql_fetch_assoc($result)) //Table body
  270 +{
  271 + for ($i = 0; $i < count($componentes_estacoes); $i++)
  272 + {
  273 + if (array_search($componentes_estacoes[$i]['tipo'], $cs_componentes_estacoes) !== FALSE)
  274 + {
  275 + $row[$componentes_estacoes[$i]['value']] = array();
  276 + }
  277 + }
  278 +
  279 + if (isset($table[$row['te_node_address']]))
  280 + {
  281 + // $trow referencia a linha no array (ao inves de copiar)
  282 + $trow = &$table[$row['te_node_address']];
  283 + if ($row['ult_acesso'] > $trow['ult_acesso'])
  284 + {
  285 + $table[$row['te_node_address']] = $row;
  286 + $trow = &$table[$row['te_node_address']];
  287 + }
  288 + }
  289 + else
  290 + {
  291 + $table[$row['te_node_address']] = $row;
  292 + $trow = &$table[$row['te_node_address']];
  293 + }
  294 +
  295 +
  296 + if ($row['id_so'] == $trow['id_so'])
  297 + {
  298 + // concatena componentes
  299 + if (array_search($row['cs_tipo_componente'], $cs_componentes_estacoes) !== FALSE)
  300 + {
  301 + switch ($row['cs_tipo_componente'])
  302 + {
  303 + case 'CPU':
  304 + $trow['te_cpu_desc'][] = $row['te_valor'];
  305 + break;
  306 + case 'CDROM':
  307 + $trow['te_cdrom_desc'][] = $row['te_valor'];
  308 + break;
  309 + case 'TCPIP':
  310 + $trow['te_placa_rede_desc'][] = $row['te_valor'];
  311 + break;
  312 + }
  313 + }
  314 + }
  315 +}
155 316  
156   -for ($i=2; $i < mysql_num_fields($result); $i++) { //Table Header
157   - print '<td nowrap align="left"><b><font size="1" face="Verdana, Arial"><a href="?orderby=' . ($i + 1) . '">'. mysql_field_name($result, $i) .'</a></font><b></td>';
  317 +foreach ($table as $row)
  318 +{
  319 + $relatorio->addRow(geraRow($row, $num_registro++, $dicionario));
  320 + #exibe_row($row, $num_registro++, $cor, $dicionario);
158 321 }
159   -echo '</tr>';
160   -
161   -while ($row = mysql_fetch_row($result)) { //Table body
162   - echo '<tr ';
163   - if ($cor) { echo 'bgcolor="#E1E1E1"'; }
164   - echo '>';
165   - echo '<td nowrap align="right"><font size="1" face="Verdana, Arial">' . $num_registro . '</font></td>';
166   - echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[2] ."</a>&nbsp;</td>";
167   - for ($i=3; $i < $fields; $i++) {
168   - echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">' . $row[$i] .'&nbsp;</td>';
169   - }
170   - $cor=!$cor;
171   - $num_registro++;
  322 +
  323 +function geraRow($row, $num_registro, $dicionario)
  324 +{
  325 + # adiciona numero e nome no inicio da linha
  326 + $c1 = '<font size="1" face="Verdana, Arial">' . $num_registro . '</font>';
  327 + $c2 = "<font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row['te_node_address'] ."&id_so=". $row['id_so'] ."' target='_blank'>" . $row['Nome Comp.'] ."</a></font>";
  328 +
  329 +
  330 + unset($row['te_node_address']);
  331 + unset($row['id_so']);
  332 + unset($row['Nome Comp.']);
  333 + unset($row['cs_tipo_componente']);
  334 + unset($row['te_valor']);
  335 + unset($row['ult_acesso']);
  336 +
  337 + // processa tripas
  338 + if (isset($row['te_cpu_desc']))
  339 + {
  340 + $row['te_cpu_desc'] = exibe_tripa($row['te_cpu_desc'], $dicionario);
  341 + }
  342 + if (isset($row['te_cdrom_desc']))
  343 + {
  344 + $row['te_cdrom_desc'] = exibe_tripa($row['te_cdrom_desc'], $dicionario);
  345 + }
  346 + if (isset($row['te_placa_rede_desc']))
  347 + {
  348 + $row['te_placa_rede_desc'] = exibe_tripa($row['te_placa_rede_desc'], $dicionario);
  349 + }
  350 +
  351 + foreach ($row as $key => $value)
  352 + {
  353 + $row[$key] = '<font size="1" face="Verdana, Arial">' . $value .' </font>';
  354 + }
  355 +
  356 + array_unshift($row, $c1, $c2);
  357 + return $row;
  358 +}
  359 +
  360 +function carrega_dicionario()
  361 +{
  362 + $query = 'SELECT nm_campo, te_descricao_campo FROM descricoes_colunas_computadores';
  363 + $result = mysql_query($query) or die("Erro MySQL: ".mysql_error());
  364 + while ($row = mysql_fetch_row($result))
  365 + {
  366 + $dicionario[$row[0]] = $row[1];
  367 + }
  368 + return $dicionario;
  369 +}
  370 +
  371 +function exibe_tripa($tripas, $dicionario)
  372 +{
  373 + $ret = array();
  374 +
  375 + if (!is_array($tripas))
  376 + {
  377 + return $tripas;
  378 + }
  379 +
  380 + foreach ($tripas as $tripa)
  381 + {
  382 + $item = array();
  383 + $pares = explode('#FIELD#', $tripa);
  384 + foreach ($pares as $par)
  385 + {
  386 + $cv = explode('###', $par);
  387 + $chave = $cv[0];
  388 + $valor = $cv[1];
  389 + $item[] = $dicionario[$cv[0]].": ".$cv[1];
  390 + }
  391 + $ret[] = implode("<br>", $item);
  392 + }
  393 + return implode("<br><br>", $ret);
  394 +}
  395 +
  396 +function exibe_row($relatorio, $row, $num_registro, $cor, $dicionario)
  397 +{
  398 +
  399 + echo '<td nowrap align="right"><font size="1" face="Verdana, Arial">' . $num_registro . '</font></td>';
  400 + echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row['te_node_address'] ."&id_so=". $row['id_so'] ."' target='_blank'>" . $row['Nome Comp.'] ."</a></font> </td>";
  401 + unset($row['te_node_address']);
  402 + unset($row['id_so']);
  403 + unset($row['Nome Comp.']);
  404 + unset($row['cs_tipo_componente']);
  405 + unset($row['te_valor']);
  406 + unset($row['ult_acesso']);
  407 +
  408 + // processa tripas
  409 + if (isset($row['te_cpu_desc']))
  410 + {
  411 + $row['te_cpu_desc'] = exibe_tripa($row['te_cpu_desc'], $dicionario);
  412 + }
  413 + if (isset($row['te_cdrom_desc']))
  414 + {
  415 + $row['te_cdrom_desc'] = exibe_tripa($row['te_cdrom_desc'], $dicionario);
  416 + }
  417 + if (isset($row['te_placa_rede_desc']))
  418 + {
  419 + $row['te_placa_rede_desc'] = exibe_tripa($row['te_placa_rede_desc'], $dicionario);
  420 + }
  421 +
  422 + if ($formato == "html")
  423 + {
  424 + foreach ($row as $key => $value)
  425 + {
  426 + if ($value == '') $value = '&nbsp';
  427 + echo '<td nowrap align="left"><font size="1" face="Verdana, Arial">' . $value .' </td>';
  428 + }
  429 + }
  430 + else
  431 + {
  432 + // processa tripas
  433 + if (isset($row['te_cpu_desc']))
  434 + {
  435 + $row['te_cpu_desc'] = $row['te_cpu_desc'];
  436 + }
  437 + if (isset($row['te_cdrom_desc']))
  438 + {
  439 + $row['te_cdrom_desc'] = $row['te_cdrom_desc'];
  440 + }
  441 + if (isset($row['te_placa_rede_desc']))
  442 + {
  443 + $row['te_placa_rede_desc'] = $row['te_placa_rede_desc'];
  444 + }
  445 + $relatorio->addRow($row);
  446 + }
172 447 echo '</tr>';
173 448 }
  449 +$relatorio->output();
  450 +#ob_end_flush();
  451 +/*
174 452 echo '</table>';
175 453 echo '<br><br>';
176 454 if (count($_SESSION["list8"])>0)
... ... @@ -186,3 +464,4 @@ if (count($_SESSION[&quot;list8&quot;])&gt;0)
186 464 pela Dataprev - Unidade Regional Esp&iacute;rito Santo</font></p>
187 465 </body>
188 466 </html>
  467 +*/
... ...
relatorios/patrimonio/rel_patrimonio.php
... ... @@ -262,6 +262,7 @@ else
262 262 }
263 263 $query = " SELECT DISTINCT computadores.te_node_address,
264 264 so.id_so,
  265 + UNIX_TIMESTAMP(computadores.dt_hr_ult_acesso),
265 266 computadores.te_nome_computador as 'Nome Comp.',
266 267 sg_so as 'S.O.',
267 268 computadores.te_ip as 'IP'" .
... ... @@ -299,7 +300,7 @@ else
299 300 if ($in_destacar_duplicidade_total) $arr_in_destacar_duplicidade_total = explode('#',$in_destacar_duplicidade_total);
300 301  
301 302 $in_destacar_duplicidade_tmp = '';
302   - for ($i=2; $i < mysql_num_fields($result); $i++)
  303 + for ($i=3; $i < mysql_num_fields($result); $i++)
303 304 { //Table Header
304 305 print '<td nowrap align="left"><font size="1" face="Verdana, Arial"><b><a href="?orderby=' . ($i + 1) . '">'. mysql_field_name($result, $i) .'</a></b></font></td>';
305 306 if ($in_destacar_duplicidade_total && in_array(mysql_field_name($result, $i),$arr_in_destacar_duplicidade_total))
... ... @@ -357,6 +358,24 @@ else
357 358 $num_registro = 1;
358 359 @mysql_data_seek($result,0);
359 360 while ($row = mysql_fetch_row($result))
  361 + {//pre Table body
  362 +
  363 + // ja existe entrada para este MAC?
  364 + if (isset($table[$row[0]]))
  365 + {
  366 + // acesso mais rencente?
  367 + if ($row[2] > $table[$row[0]][2])
  368 + {
  369 + $table[$row[0]] = $row;
  370 + }
  371 + }
  372 + else
  373 + {
  374 + $table[$row[0]] = $row;
  375 + }
  376 + }
  377 +
  378 + foreach ($table as $row)
360 379 { //Table body
361 380 $v_key_campos_valores_duplicados = strpos($v_campos_valores_duplicados,'r='.$num_registro.'#',0);
362 381 echo '<tr ';
... ... @@ -369,9 +388,9 @@ else
369 388 echo '>';
370 389  
371 390 echo '<td nowrap align="right"><font size="1" face="Verdana, Arial">' . $num_registro . '</font></td>';
372   - echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[2] ."</a>&nbsp;</td>";
  391 + echo "<td nowrap align='left'><font size='1' face='Verdana, Arial'><a href='../computador/computador.php?te_node_address=". $row[0] ."&id_so=". $row[1] ."' target='_blank'>" . $row[3] ."</a>&nbsp;</td>";
373 392  
374   - for ($i=3; $i < $fields; $i++)
  393 + for ($i=4; $i < $fields; $i++)
375 394 {
376 395 $v_bold='';
377 396  
... ...
relatorios/software/rel_software.php
... ... @@ -15,6 +15,7 @@
15 15 */
16 16 session_start();
17 17  
  18 +require_once ('../../include/multipagina.php');
18 19 /*
19 20 * verifica se houve login e também regras para outras verificações (ex: permissões do usuário)!
20 21 */
... ... @@ -24,9 +25,9 @@ else { // Inserir regras para outras verificações (ex: permissões do usuário)!
24 25 }
25 26  
26 27 require_once('../../include/library.php');
  28 +
27 29 AntiSpy();
28 30  
29   -require_once ('../../include/multipagina.class.php');
30 31 $DbConnect = conecta_bd_cacic();
31 32  
32 33 if ($_GET['principal'])
... ... @@ -40,6 +41,7 @@ if ($_GET[&#39;principal&#39;])
40 41 if ($_SESSION["list4"] <> '') $_SESSION["list4"] .= '#';
41 42 $_SESSION["list4"] .= $row['id_so'];
42 43 }
  44 +
43 45 $_SESSION["list4"] = explode('#',$_SESSION["list4"]);
44 46  
45 47 //if ($_GET['orderby']=='6')
... ... @@ -61,6 +63,7 @@ elseif($_POST[&#39;submit&#39;])
61 63 $_SESSION["list12"] = $_POST['list12'];
62 64 $_SESSION["cs_situacao"] = $_POST["cs_situacao"];
63 65 }
  66 +
64 67 ?>
65 68 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
66 69 <html>
... ... @@ -144,8 +147,8 @@ else
144 147 </table>
145 148 <br>
146 149 <?
147   -$from = ' ,redes ';
148   -$local = '';
  150 +$from = ' ,redes ';
  151 +$local = '';
149 152 $redes_selecionadas = '';
150 153 if ($_SESSION['cs_nivel_administracao']<>1 && $_SESSION['cs_nivel_administracao']<>2)
151 154 {
... ... @@ -251,7 +254,7 @@ $max_res = ($cfgStdData[&#39;nu_rel_maxlinhas&#39;])?$cfgStdData[&#39;nu_rel_maxlinhas&#39;]:10
251 254 $mult_pag = new Mult_Pag($max_res); // cria um novo objeto navbar
252 255  
253 256 // metodo que realiza a pesquisa
254   -$resultado = $mult_pag->executar($query, $DbConnect, "", "mysql");
  257 +$resultado = $mult_pag->Executar($query, $DbConnect, "", "mysql");
255 258 $reg_pag = mysql_num_rows($resultado); // total de registros por paginas ou telas
256 259  
257 260 echo '<table cellpadding="2" cellspacing="0" border="1" bordercolor="#999999" bordercolordark="#E1E1E1">
... ...
top.php
... ... @@ -101,7 +101,8 @@ function scrollit(seed)
101 101 else
102 102 {
103 103 require_once('include/library.php');
104   - echo get_valor_campo('configuracoes_padrao', 'nm_organizacao');
  104 + $arrConfiguracoesPadrao = getValores('configuracoes_padrao', 'nm_organizacao');
  105 + echo $arrConfiguracoesPadrao['nm_organizacao'];
105 106 }
106 107 ?>
107 108 </font></b></div></td>
... ...
ws/get_config.php
... ... @@ -80,6 +80,7 @@ if (trim(DeCrypt($key,$iv,$_POST[&#39;in_chkcacic&#39;],$v_cs_cipher,$v_cs_compress,$str
80 80 $retorno_xml_values .= '<CACIC2>' . EnCrypt($key,$iv,$v_array_versoes_agentes['cacic2.exe'] ,$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey) . '<' . '/CACIC2>';
81 81 $retorno_xml_values .= '<GER_COLS>' . EnCrypt($key,$iv,$v_array_versoes_agentes['ger_cols.exe'],$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey) . '<' . '/GER_COLS>';
82 82 $retorno_xml_values .= '<CHKSIS>' . EnCrypt($key,$iv,$v_array_versoes_agentes['chksis.exe'] ,$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey) . '<' . '/CHKSIS>';
  83 + $retorno_xml_values .= '<SRCACIC>' . EnCrypt($key,$iv,$v_array_versoes_agentes['srcacic.exe'] ,$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey) . '<' . '/SRCACIC>';
83 84 }
84 85 }
85 86 }
... ...
ws/set_hardware.php
... ... @@ -78,11 +78,21 @@ $arrTiposComponentes = array( &#39;CDROM&#39;,
78 78 // Criação das "Tripas" na memória com os dados dos componentes a serem tratados
79 79 for ($intTiposComponentes = 0;$intTiposComponentes < count($arrTiposComponentes);$intTiposComponentes++)
80 80 {
81   - $strNomeTripaMemoria = 'strTripa_'.$arrTiposComponentes[$intTiposComponentes];
82   - $strNomeTripaRecebida = 'te_Tripa_'.$arrTiposComponentes[$intTiposComponentes];
83   - $$strNomeTripaMemoria = DeCrypt($key,$iv,$_POST[$strNomeTripaRecebida] ,$v_cs_cipher, $v_cs_compress, $strPaddingKey);
  81 + $strNomeTripaMemoria = 'strTripa_'.$arrTiposComponentes[$intTiposComponentes];
  82 + $strNomeTripaRecebida = 'te_Tripa_'.$arrTiposComponentes[$intTiposComponentes];
  83 + $$strNomeTripaMemoria = DeCrypt($key,$iv,$_POST[$strNomeTripaRecebida] ,$v_cs_cipher, $v_cs_compress, $strPaddingKey);
84 84 }
85 85  
  86 +// Devido à grande variação de frequência, causada pelo recurso de gerenciamento de energia existentes nos processadores atuais,
  87 +// o bloco abaixo retira a informação referente à Frequência da CPU.
  88 +if ($strTripa_CPU)
  89 + {
  90 + $strTripa_CPUaux = $strTripa_CPU;
  91 + $intPos = stripos2($strTripa_CPUaux,'#FIELD#te_cpu_frequencia',true);
  92 + if ($intPos)
  93 + $strTripa_CPU = substr($strTripa_CPUaux,0,$intPos);
  94 + }
  95 +
86 96 // Todas as vezes em que é feita a recuperação das configurações por um agente, é incluído
87 97 // o computador deste agente no BD, caso ainda não esteja inserido.
88 98 if ($te_node_address <> '')
... ... @@ -148,7 +158,8 @@ if ($te_node_address &lt;&gt; &#39;&#39;)
148 158 }
149 159  
150 160 // Verifico se há emails para notificação de alteração na configuração de hardware.
151   - if (trim($strEmailsDestinatarios = get_valor_campo('configuracoes_locais', 'te_notificar_mudanca_hardware','id_local='.$v_dados_rede['id_local'])) <> '')
  161 + $arrConfiguracoesLocais = getValores('configuracoes_locais', 'te_notificar_mudanca_hardware','id_local='.$v_dados_rede['id_local']);
  162 + if (trim($strEmailsDestinatarios = $arrConfiguracoesLocais['te_notificar_mudanca_hardware']) <> '')
152 163 {
153 164 // Obtenho os nomes do hardware passível de controle
154 165 $arrDescricoesColunasComputadores = getDescricoesColunasComputadores();
... ...
ws/set_patrimonio.php 100755 → 100644
... ... @@ -72,7 +72,8 @@ if ($te_node_address &lt;&gt; &#39;&#39;)
72 72 { // Atualização das informações de patrimônio (e não inclusão).
73 73  
74 74 // Agora, verifica se os administradores deverão ser notificados da alteração nas informações de patrimônio.
75   - if (trim($destinatarios = get_valor_campo('configuracoes_locais', 'te_notificar_mudanca_patrim','id_local = '.$v_dados_rede['id_local'])) != '')
  75 + $arrConfiguracoesLocais = getValores('configuracoes_locais', 'te_notificar_mudanca_patrim','id_local = '.$v_dados_rede['id_local']);
  76 + if (trim($destinatarios = $arrConfiguracoesLocais['te_notificar_mudanca_patrim']) != '')
76 77 {
77 78 $query = " SELECT te_etiqueta,nm_campo_tab_patrimonio
78 79 FROM patrimonio_config_interface
... ...
ws/srcacic_get_config.php 0 → 100755
... ... @@ -0,0 +1,112 @@
  1 +<?
  2 + /*
  3 + Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
  4 +
  5 + Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
  6 +
  7 + O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
  8 + publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opnião) qualquer versão.
  9 +
  10 + Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
  11 + MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
  12 +
  13 + Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
  14 + Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15 +
  16 + Objetivo:
  17 + ---------
  18 + Esse script tem como objetivo enviar ao servidor de suporte remoto na estação(srcacic.exe) as configurações (em XML) que são específicas para a
  19 + estação/usuário em questão. São levados em consideração a rede do agente, sistema operacional e Mac-Address.
  20 +
  21 + Retorno:
  22 + 1) <DOMINIOS>Domínios cadastrados no Gerente WEB. O domínio referente à subrede da estação será acrescido de "*".</DOMINIOS>
  23 + 2) <STATUS>Retornará OK se a palavra chave informada "bater" com a chave armazenada previamente no BD</STATUS>
  24 +*/
  25 +
  26 +require_once('../include/library.php');
  27 +
  28 +// Definição do nível de compressão (Default = 9 => máximo)
  29 +//$v_compress_level = 9;
  30 +$v_compress_level = 0; // Mantido em 0(zero) para desabilitar a Compressão/Decompressão
  31 + // Há necessidade de testes para Análise de Viabilidade Técnica
  32 +
  33 +$retorno_xml_header = '<?xml version="1.0" encoding="iso-8859-1" ?>';
  34 +$retorno_xml_values = '';
  35 +
  36 +// Essas variáveis conterão os indicadores de criptografia e compactação
  37 +$v_cs_cipher = (trim($_POST['cs_cipher']) <> ''?trim($_POST['cs_cipher']) : '4');
  38 +$v_cs_compress = (trim($_POST['cs_compress']) <> ''?trim($_POST['cs_compress']) : '4');
  39 +
  40 +$v_cs_cipher = '1';
  41 +
  42 +$strPaddingKey = '';
  43 +
  44 +/*
  45 +LimpaTESTES();
  46 +GravaTESTES('Valores POST Recebidos:');
  47 +foreach($HTTP_POST_VARS as $i => $v)
  48 + GravaTESTES('Nome/Valor do POST_Request: "'.$i.'"/"'.$v.'"');
  49 +
  50 +GravaTESTES('Valores GET Recebidos:');
  51 +foreach($HTTP_GET_VARS as $i => $v)
  52 + GravaTESTES('Nome/Valor do GET_Request: "'.$i.'"/"'.$v.'"');
  53 +
  54 +GravaTESTES('');
  55 +GravaTESTES('');
  56 +*/
  57 +
  58 +// Autenticação da Estação Visitada
  59 +$te_node_address = DeCrypt($key,$iv,$_POST['te_node_address'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  60 +$te_so = DeCrypt($key,$iv,$_POST['te_so'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  61 +$te_palavra_chave = DeCrypt($key,$iv,$_POST['te_palavra_chave'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  62 +
  63 +// ATENÇÃO: Apenas retornará um ARRAY contendo "id_so" e "te_so".
  64 +$arrSO = inclui_computador_caso_nao_exista( $te_node_address,
  65 + '',
  66 + $te_so,
  67 + '',
  68 + '',
  69 + '',
  70 + '');
  71 +
  72 +$arrComputadores = getValores('computadores', 'te_palavra_chave,id_ip_rede' , 'te_node_address = "'.$te_node_address.'" and id_so = '.$arrSO['id_so']);;
  73 +$strTePalavraChave = $arrComputadores['te_palavra_chave'];
  74 +$strIdIpRede = $arrComputadores['id_ip_rede'];
  75 +
  76 +/*
  77 +LimpaTESTES();
  78 +GravaTESTES('strTePalavraChave:'.$strTePalavraChave);
  79 +GravaTESTES('strIdIpRede:'.$strIdIpRede);
  80 +*/
  81 +
  82 +// Valido a Palavra-Chave e monto a tripa com os nomes e ids dos domínios
  83 +if ($te_palavra_chave == $strTePalavraChave)
  84 + {
  85 + $arrRedes = getValores('redes','id_dominio','id_ip_rede = "'.$strIdIpRede.'"');
  86 + $strIdDominio = $arrRedes['id_dominio'];
  87 +
  88 + conecta_bd_cacic();
  89 + $query_SEL = 'SELECT id_dominio,
  90 + nm_dominio
  91 + FROM dominios
  92 + WHERE in_ativo = "S"
  93 + ORDER BY nm_dominio';
  94 + $result_SEL = mysql_query($query_SEL);
  95 +
  96 + $strTripaDominios = '';
  97 + while ($row_SEL = mysql_fetch_array($result_SEL))
  98 + $strTripaDominios .= $row_SEL['id_dominio'].';'.$row_SEL['nm_dominio'].($row_SEL['id_dominio']==$strIdDominio?'*':'').';';
  99 +
  100 + if ($strTripaDominios <> '')
  101 + $retorno_xml_values = '<DOMINIOS>'.EnCrypt($key,$iv,$strTripaDominios ,$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</DOMINIOS>';
  102 + }
  103 +
  104 +if ($retorno_xml_values <> '')
  105 + $retorno_xml_values = '<STATUS>'.EnCrypt($key,$iv,'OK',$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</STATUS>'.$retorno_xml_values;
  106 +else
  107 + $retorno_xml_values = '<STATUS>'.EnCrypt($key,$iv,'ERRO!',$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</STATUS>';
  108 +
  109 +$retorno_xml = $retorno_xml_header . $retorno_xml_values;
  110 +
  111 +echo $retorno_xml;
  112 +?>
... ...
ws/srcacic_set_session.php 0 → 100755
... ... @@ -0,0 +1,176 @@
  1 +<?
  2 + /*
  3 + Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
  4 +
  5 + Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
  6 +
  7 + O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
  8 + publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opnião) qualquer versão.
  9 +
  10 + Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
  11 + MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
  12 +
  13 + Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software
  14 + Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15 +
  16 + Objetivo:
  17 + ---------
  18 + Esse script tem como objetivo enviar ao servidor de suporte remoto na estação as configurações (em XML) que são específicas para a
  19 + estação em questão. São levados em consideração a rede do agente, sistema operacional e Mac-Address.
  20 +*/
  21 +
  22 +require_once('../include/library.php');
  23 +
  24 +// Definição do nível de compressão (Default = 9 => máximo)
  25 +//$v_compress_level = 9;
  26 +$v_compress_level = 0; // Mantido em 0(zero) para desabilitar a Compressão/Decompressão
  27 + // Há necessidade de testes para Análise de Viabilidade Técnica
  28 +
  29 +$retorno_xml_header = '<?xml version="1.0" encoding="iso-8859-1" ?>';
  30 +$retorno_xml_values = '';
  31 +
  32 +// Essas variáveis conterão os indicadores de criptografia e compactação
  33 +$v_cs_cipher = (trim($_POST['cs_cipher']) <> ''?trim($_POST['cs_cipher']) : '4');
  34 +$v_cs_compress = (trim($_POST['cs_compress']) <> ''?trim($_POST['cs_compress']) : '4');
  35 +
  36 +$v_cs_cipher = '1';
  37 +
  38 +$strPaddingKey = '';
  39 +
  40 +// Autenticação da Estação Visitada
  41 +$te_node_address = DeCrypt($key,$iv,$_POST['te_node_address'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  42 +$te_so = DeCrypt($key,$iv,$_POST['te_so'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  43 +$te_palavra_chave = DeCrypt($key,$iv,$_POST['te_palavra_chave'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  44 +
  45 +// ATENÇÃO: Apenas retornará um ARRAY contendo "id_so" e "te_so".
  46 +$arrSO = inclui_computador_caso_nao_exista( $te_node_address,
  47 + '',
  48 + $te_so,
  49 + '',
  50 + '',
  51 + '',
  52 + '');
  53 +
  54 +$arrComputadores = getValores('computadores', 'te_palavra_chave' , 'te_node_address = "'.$te_node_address.'" and id_so = '.$arrSO['id_so']);
  55 +$strTePalavraChave = $arrComputadores['te_palavra_chave'];
  56 +
  57 +// Valido a Palavra-Chave e monto a tripa com os nomes e ids dos domínios
  58 +if ($te_palavra_chave == $strTePalavraChave)
  59 + {
  60 + GravaTESTES('Palavra-Chave OK!');
  61 + conecta_bd_cacic();
  62 +
  63 + if (!$_POST['id_sessao'])
  64 + {
  65 + // Identificador para Autenticação no Domínio
  66 + $id_dominio = DeCrypt($key,$iv,$_POST['id_dominio'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  67 + $nm_nome_acesso_dominio = DeCrypt($key,$iv,$_POST['nm_nome_acesso_dominio'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  68 + $te_senha_acesso_dominio = DeCrypt($key,$iv,$_POST['te_senha_acesso_dominio'] ,$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  69 +
  70 + $arrDominios = getValores('dominios', 'nm_dominio,
  71 + te_ip_dominio,
  72 + id_tipo_protocolo,
  73 + nu_versao_protocolo,
  74 + te_string_DN' , 'id_dominio = '.$id_dominio.' AND in_ativo="S"');
  75 +
  76 + // Comunicação com o servidor de Domínio, para autenticação
  77 + $ldap = ldap_connect($arrDominios['te_ip_dominio']);
  78 + if (ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, $arrDominios['nu_versao_protocolo']))
  79 + {
  80 + ldap_bind($ldap);
  81 + if (ldap_errno($ldap) == 0)
  82 + {
  83 + ldap_bind($ldap, $arrDominios['nm_dominio']."\\".$nm_nome_acesso_dominio,$te_senha_acesso_dominio);
  84 + if (ldap_errno($ldap) == 0)
  85 + {
  86 + $searchResults = ldap_search($ldap, $arrDominios['te_string_DN'], 'cn=*'.$nm_nome_acesso_dominio.'*');
  87 +
  88 + // OK! Dados encontrados!
  89 + if (!$searchResults === false)
  90 + {
  91 + $result = @ldap_get_entries($ldap, $searchResults);
  92 + $nm_nome_completo = getBindedValue($result,'name');
  93 + $te_email = getBindedValue($result,'mail');
  94 + $dt_hr_inicio_sessao = date('Y-m-d H:i:s');
  95 +
  96 + if ($te_email <> '')
  97 + {
  98 + // Envio e-mail informando da abertura de sessão
  99 + $corpo_mail = "Prezado usuário ".$nm_nome_completo.",\n\n
  100 + informamos que foi iniciada uma sessão para Suporte Remoto Seguro através do Sistema CACIC em ".$dt_hr_inicio_sessao . "\n\n\n\n
  101 + _______________________________________________________________________
  102 + CACIC - Configurador Automático e Coletor de Informações Computacionais\n
  103 + srCACIC - Módulo para Suporte Remoto Seguro do Sistema CACIC\n
  104 + Desenvolvido pela Dataprev - Unidade Regional Espírito Santo";
  105 +
  106 + // Manda mail para os administradores.
  107 + mail("$te_email", "Sistema CACIC - Módulo srCACIC - Abertura de Sessão para Suporte Remoto Seguro", "$corpo_mail", "From: cacic@{$_SERVER['SERVER_NAME']}");
  108 + }
  109 + $query_SESSAO = "INSERT INTO srcacic_sessoes
  110 + (dt_hr_inicio_sessao,
  111 + nm_nome_acesso_visitado,
  112 + nm_nome_completo_visitado,
  113 + te_node_address_visitado,
  114 + id_so_visitado)
  115 + VALUES ('" . $dt_hr_inicio_sessao . "',
  116 + '" . $nm_nome_acesso_dominio . "',
  117 + '" . $nm_nome_completo . "',
  118 + '" . $te_node_address . "',
  119 + '" . $arrSO['id_so'] . "')";
  120 + $result_SESSAO = mysql_query($query_SESSAO);
  121 + $arrSessoes = getValores('srcacic_sessoes','id_sessao','dt_hr_inicio_sessao="'.$dt_hr_inicio_sessao.'" AND
  122 + te_node_address_visitado="'.$te_node_address.'" AND
  123 + id_so_visitado = "'.$arrSO['id_so'].'"');
  124 +
  125 + $retorno_xml_values .= '<NM_COMPLETO>'.EnCrypt($key,$iv,$nm_nome_completo,$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</NOME_COMPLETO>';
  126 + $retorno_xml_values .= '<ID_SESSAO>'.EnCrypt($key,$iv,$arrSessoes['id_sessao'],$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</ID_SESSAO>';
  127 + }
  128 + }
  129 + }
  130 + }
  131 + }
  132 + else
  133 + {
  134 + $id_sessao = DeCrypt($key,$iv,$_POST['id_sessao'],$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  135 + $id_usuario_visitante = DeCrypt($key,$iv,$_POST['id_usuario_visitante'],$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  136 + $te_node_address_visitante = DeCrypt($key,$iv,$_POST['te_node_address_visitante'],$v_cs_cipher,$v_cs_compress,$strPaddingKey);
  137 + $query_SESSAO = "UPDATE srcacic_sessoes
  138 + SET id_usuario_visitante = ".$id_usuario_visitante.",
  139 + te_node_address_visitante = ".$te_node_address_visitante.",
  140 + dt_hr_ultimo_contato = '".date('d/m/Y às H:i')."'
  141 + WHERE id_sessao = ".$id_sessao;
  142 + $result_SESSAO = mysql_query($query_SESSAO);
  143 + $retorno_xml_values .= '<OK>'.EnCrypt($key,$iv,'OK',$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</OK>';
  144 + }
  145 + }
  146 +
  147 +if ($retorno_xml_values <> '')
  148 + $retorno_xml_values = '<STATUS>'.EnCrypt($key,$iv,'OK',$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</STATUS>'.$retorno_xml_values;
  149 +else
  150 + $retorno_xml_values = '<STATUS>'.EnCrypt($key,$iv,'ERRO!',$v_cs_cipher,$v_cs_compress,$v_compress_level,$strPaddingKey).'</STATUS>';
  151 +
  152 +$retorno_xml = $retorno_xml_header . $retorno_xml_values;
  153 +
  154 +echo $retorno_xml;
  155 +
  156 +// Função para resgatar valores contidos no BIND retornado na autenticação no domínio
  157 +function getBindedValue($arrBINDED,$strValue)
  158 + {
  159 + global $getBindedValue;
  160 + for ($intVetor=0; $intVetor < count($arrBINDED);$intVetor++)
  161 + {
  162 + if (strtolower(gettype(current($arrBINDED)))=='array')
  163 + getBindedValue(current($arrBINDED),$strValue);
  164 + else
  165 + if (current($arrBINDED) == $strValue)
  166 + {
  167 + $getBindedValue = $arrBINDED[current($arrBINDED)][0];
  168 + break;
  169 + }
  170 + next($arrBINDED);
  171 + }
  172 + return $getBindedValue;
  173 + }
  174 +
  175 +//
  176 +?>
... ...