admin.php
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/*
Title: Funções gerais
About: Licença
I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br
Este programa é software livre; você pode redistribuí-lo
e/ou modificá-lo sob os termos da Licença Pública Geral
GNU conforme publicada pela Free Software Foundation;
tanto a versão 2 da Licença.
Este programa é distribuído na expectativa de que seja útil,
porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
Consulte a Licença Pública Geral do GNU para mais detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral do
GNU junto com este programa; se não, escreva para a
Free Software Foundation, Inc., no endereço
59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
File: i3geo/admin/mapfiles.php
19/6/2007
*/
if(!isset($locaplic))
{
$locaplic = "";
if(file_exists("../../../ms_configura.php"))
{include_once("../../../ms_configura.php");}
else
{
if(file_exists("../../ms_configura.php"))
{include_once("../../ms_configura.php");}
else
{
if(file_exists("../ms_configura.php"))
{include_once("../ms_configura.php");}
else
{include_once("ms_configura.php");}
}
}
}
include_once($locaplic."/classesphp/pega_variaveis.php");
error_reporting(0);
//
//carrega o phpmapscript
//
include_once ($locaplic."/classesphp/carrega_ext.php");
include_once($locaplic."/pacotes/cpaint/cpaint2.inc.php");
set_time_limit(120);
//
//verifica se o cliente pode editar
//se funcao for verificaEditores vai para case específico
//
if($funcao != "verificaEditores")
{if(verificaEditores($editores) == "nao"){exit;}}
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
{
$mapfile = "geral1windows";
}
else
{
$mapfile = "geral1";
}
if($funcao == "limpar")
{
$tabelas = array("i3geoadmin_atlas","i3geoadmin_atlasp","i3geoadmin_atlast","i3geoadmin_grupos","i3geoadmin_identifica","i3geoadmin_mapas","i3geoadmin_menus","i3geoadmin_n1","i3geoadmin_n2","i3geoadmin_n3","i3geoadmin_raiz","i3geoadmin_sistemas","i3geoadmin_sistemasf","i3geoadmin_subgrupos","i3geoadmin_tags","i3geoadmin_temas","i3geoadmin_ws");
include("conexao.php");
foreach($tabelas as $t)
{
$dbhw->query("DELETE from $t");
}
$dbhw = null;
$dbh = null;
exit;
}
function verificaDuplicados($sql,$dbh)
{
$res = $dbh->query($sql,PDO::FETCH_ASSOC);
if(count($res->fetchAll())>0)
return true;
else
return false;
}
/*
Function: verificaEditores
Verifica se o usuário atual está cadastrado como editor
Parameters:
editores - array com a lista de editores obtido do ms_configura.php
Return:
string - sim|nao
*/
function verificaEditores($editores)
{
$editor = "nao";
foreach ($editores as $e)
{
$e = gethostbyname($e);
$ip = "UNKNOWN";
if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";
if ($e == $ip){$editor="sim";}
}
return $editor;
}
/*
Function: exclui
Exlcui um registro de uma tabela
*/
function exclui()
{
global $tabela,$coluna,$id;
try
{
include("conexao.php");
$dbhw->query("DELETE from $tabela WHERE $coluna = $id");
$dbhw = null;
return "ok";
}
catch (PDOException $e)
{
return "Error!: " . $e->getMessage();
}
}
/*
Function: pegaDados
Executa um sql de busca de dados
*/
function pegaDados($sql)
{
try
{
$resultado = array();
include("conexao.php");
$q = $dbh->query($sql,PDO::FETCH_ASSOC);
$resultado = $q->fetchAll();
$dbh = null;
return $resultado;
}
catch (PDOException $e)
{
return "Error!: " . $e->getMessage();
}
}
?>