subirsimbolo.php
2.96 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
<?php
include_once(dirname(__FILE__)."/login.php");
if(in_array(strtoupper($funcao),$funcoesEdicao)){
if(verificaOperacaoSessao("admin/html/editortexto") == false){
retornaJSON("Vc nao pode realizar essa operacao.");exit;
}
}
//locaplic e usado para definir a pasta de destino
if(empty($locaplic)){
exit;
}
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../css/input.css" />
<link rel="stylesheet" type="text/css" href="../../css/geral.css" />
<title></title>
</head>
<body bgcolor="white" style="background-color:white;text-align:left;">
<p>
<?php
if (isset($_FILES['i3GEOuploadsimboloarq']['name']) && strlen(basename($_FILES['i3GEOuploadsimboloarq']['name'])) < 200){
$dirDestino = $_GET["dirDestino"];
$dirDestino = str_replace(".","",$dirDestino);
$dirDestino = $locaplic."/".$dirDestino;
$checkphp = fileContemString($_FILES['i3GEOuploadsimboloarq']['tmp_name'],"<?php");
if($checkphp == true){
echo "Arquivo invalido";
exit;
}
if(isset($logExec) && $logExec["upload"] == true){
i3GeoLog("prog: uploadsimbolo filename:" . $_FILES['i3GEOuploadsimboloarq']['name'],$dir_tmp);
}
echo "<p class='paragrafo' >Carregando o arquivo...</p>";
ob_flush();
flush();
sleep(1);
if(!file_exists($dirDestino)){
if(!file_exists($dirDestino)){
echo "<p class='paragrafo' >Pasta não existe no servidor";
paraAguarde();
exit;
}
}
//verifica nomes
$nome = $_FILES['i3GEOuploadsimboloarq']['name'];
$nome = str_replace(".png","",$nome);
$nome = str_replace(".","",$nome).".png";
$nome = strip_tags($nome);
$nome = htmlspecialchars($nome, ENT_QUOTES);
//$nome = $nome . md5(uniqid(rand(), true));
verificaNome($nome);
//sobe arquivo
$Arquivo = $_FILES['i3GEOuploadsimboloarq']['tmp_name'];
$destino = $dirDestino."/".$nome;
$check = getimagesize($Arquivo);
if($check === false) {
exit;
}
if(file_exists($destino))
{echo "<p class='paragrafo' >Já existe um arquivo com o nome ";paraAguarde();exit;}
$status = move_uploaded_file($Arquivo,$destino);
if($status != 1)
{echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo. Pode ser uma limitação quanto ao tamanho do arquivo.";paraAguarde();exit;}
if(!file_exists($destino))
{echo "<p class='paragrafo' >Ocorreu algum problema no envio do arquivo ";paraAguarde();exit;}
echo "<p class='paragrafo' >Arquivo enviado.</p>";
}
else
{
echo "<p class='paragrafo' >Erro ao enviar o arquivo. Talvez o tamanho do arquivo seja maior do que o permitido.</p>";
}
paraAguarde();
function paraAguarde(){
echo "<script>try{window.scrollTo(0,10000);window.parent.i3GEOF.upload.aguarde.visibility='hidden';}catch(e){};</script>";
}
function verificaNome($nome)
{
$nome = strtolower($nome);
$lista = explode(".",$nome);
$extensao = $lista[count($lista) - 1];
if(($extensao != "png") && ($extensao != "jpg"))
{
echo "Nome de arquivo inválido.";
paraAguarde();
exit;
}
}
?>
</body>
</html>