upload.php
2.8 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
<?php
require_once(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
include_once (dirname(__FILE__)."/../../classesphp/carrega_ext.php");
//error_reporting(0);
session_name("i3GeoPHP");
if (isset($_POST["g_sid"]))
{session_id($_POST["g_sid"]);}
session_start();
$map_file = $_SESSION["map_file"];
?>
<html>
<head>
</head>
<body bgcolor="white" style="background-color:white;text-align:left;">
<p>
<?php
include_once (dirname(__FILE__)."/../../classesphp/sani_request.php");
//error_reporting(0);
require_once (dirname(__FILE__)."/../../ms_configura.php");
include(dirname(__FILE__)."/../blacklist.php");
verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false);
error_reporting(0);
$dirmap = dirname($map_file);
$arquivo = "";
if(isset($logExec) && $logExec["upload"] == true){
i3GeoLog("prog: importarwmc filename:" . $_FILES['i3GEOimportarwmc']['name'],$dir_tmp);
}
if(isset($_FILES['i3GEOimportarwmc']['name']) && strlen(basename($_FILES['i3GEOimportarwmc']['name'])) < 200)
{
echo "<p class='paragrafo' >Carregando o arquivo...</p>";
//verifica nomes
$ArquivoDest = $_FILES['i3GEOimportarwmc']['name'];
$ArquivoDest = $ArquivoDest . md5(uniqid(rand(), true));
$ArquivoDest = str_replace(".xml","",$ArquivoDest);
$ArquivoDest = str_replace(".","",$ArquivoDest).".xml";
$ArquivoDest = strip_tags($ArquivoDest);
$ArquivoDest = htmlspecialchars($ArquivoDest, ENT_QUOTES);
verificaNome($ArquivoDest);
//sobe arquivo
$checkphp = fileContemString($_FILES['i3GEOimportarwmc']['tmp_name'],"<?php");
if($checkphp == true){
echo "Arquivo invalido";
exit;
}
$Arquivo = $_FILES['i3GEOimportarwmc']['tmp_name'];
$status = move_uploaded_file($Arquivo,$dirmap."/".$ArquivoDest);
$arquivo = $dirmap."/".$ArquivoDest;
}
if($arquivo != "" && file_exists($arquivo)){
incluiWMC();
}
paraAguarde();
function incluiWMC(){
global $map_file,$arquivo;
$mapa = ms_newMapObj($map_file);
$proj = $mapa->getprojection();
$mapa->loadMapContext($arquivo,true);
unlink($arquivo);
$layers = $mapa->getalllayernames();
foreach($layers as $nome){
$l = $mapa->getlayerbyname($nome);
$con = $l->connectiontype;
if(($con == 7 || $con == 9) && $l->getmetadata("tema") == ""){
if($l->getmetadata("wms_title") != "")
{$l->setmetadata("tema",$l->getmetadata("wms_title"));}
else
{$l->setmetadata("tema",$l->getmetadata("wms_name"));}
}
}
$mapa->setprojection($proj);
$mapa->save($map_file);
echo "Arquivo carregado com sucesso!";
}
function paraAguarde(){
echo "<script>window.parent.i3GEO.atualiza();window.parent.i3GEOF.importarwmc.doneok()</script>";
}
function verificaNome($nome)
{
$nome = strtolower($nome);
$lista = explode(".",$nome);
$extensao = $lista[count($lista) - 1];
if($extensao != "xml")
{
echo "Nome de arquivo inválido.";
paraAguarde();
exit;
}
}
?>
</body>
</html>