editortexto.php
3.12 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Editor texto</title>
<style type="text/css">
body {
margin: 20;
padding: 20;
font-size: 14px;
}
</style>
<link rel="stylesheet" type="text/css" href="../html/admin.css">
</head>
<body class=" yui-skin-sam fundoPonto">
<div class="bordaSuperior"> </div>
<div class="mascaraPrincipal" id="divGeral" style="width: 80%">
<div id=cabecalhoPrincipal></div>
<h1>Editor de mapfiles</h1>
<a href="http://mapserver.org/mapfile/index.html#mapfile"
target="_new">Documentação do Mapserver</a><br> <br> <a
href="../html/editormapfile.html" target="_self">Voltar</a><br> <br>
<form action="editortexto.php?mapfile=<?php echo $_GET["mapfile"];?>"
method=post>
<input type=submit value="Salvar" /><input type=button value="Testar"
onclick="testar()" /><input type=button value="Testar no i3Geo"
onclick="abrirI3geo()" /> (Salve antes de testar)<br> <br>
<div id="comboMapfiles">Aguarde...</div>
<br>
<?php
//evita erros removendo caracteres PHP
if(isset($_POST["texto"])){
$gravarTexto = $_POST["texto"];
$_POST["texto"] = "";
}
include_once(__DIR__."/login.php");
if(verificaOperacaoSessao("admin/php/editortexto") == false){
echo "Vc nao pode realizar essa operacao.";exit;
}
error_reporting(0);
$mapfile = $locaplic."/temas/".$_GET["mapfile"].".map";
if(!file_exists($mapfile))
{
echo "Arquivo $mapfile não existe.";exit;
}
if($_POST["tipo"] == "gravar"){
$fp = fopen($mapfile,"w");
fwrite($fp,$gravarTexto);
fclose($fp);
}
echo "Edite:<br>";
echo "<TEXTAREA name=texto cols=100 rows=20 style='width:100%'>";
echo file_get_contents($mapfile);
echo "</TEXTAREA>";
echo "<input type=hidden name=tipo value=gravar />";
$mapa = ms_newMapObj($mapfile);
$n = $mapa->numlayers;
echo "Colunas dos layers:<br><br>";
for($i=0;$i<$n;$i++){
$l = $mapa->getlayer($i);
echo $l->name.": ".(implode(",",pegaItens($l)))."<br><br>";
}
?>
</form>
</div>
<script type="text/javascript" src="../js/core.js"></script>
<script src="../../classesjs/classe_util.js" type="text/javascript"></script>
<script>
function comboMapfiles(){
var n = $mapfiles.length,
i,ins;
ins = "<select onchange='mudaMapfile(this)'><option value=''>Edite outro mapfile</option>";
for(i=0;i<n;i++){
if($mapfiles[i].extensao === "map"){
ins += "<option value='"+$mapfiles[i].codigo+"'>"+$mapfiles[i].codigo+" - "+$mapfiles[i].nome+"</optiona>";
}
}
ins += "</select>";
$i("comboMapfiles").innerHTML = ins;
};
core_pegaMapfiles("comboMapfiles()","","");
function mudaMapfile(obj){
if(obj.value != ""){
window.location.href = "editortexto.php?mapfile="+obj.value;
}
}
function testar(){
window.open("../../testamapfile.php?map=<?php echo $_GET["mapfile"]; ?>");
}
function abrirI3geo(){
window.open("../../ms_criamapa.php?layers=<?php echo $_GET["mapfile"]; ?>");
}
</script>