Commit 58f874b1f3831732cc4c901f14dc9bd2c54a9bb0
1 parent
b52d0009
Exists in
master
Novas variáveis de configuração disponíveis em ms_configura.php para controle das opções de login
Showing
13 changed files
with
185 additions
and
37 deletions
Show diff stats
admin/php/admin.php
| ... | ... | @@ -33,10 +33,8 @@ Arquivo: |
| 33 | 33 | |
| 34 | 34 | i3geo/admin/php/admin.php |
| 35 | 35 | */ |
| 36 | -if(!isset($locaplic) || !isset($dir_tmp)){ | |
| 37 | - $locaplic = ""; | |
| 38 | - include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 39 | -} | |
| 36 | +include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 37 | + | |
| 40 | 38 | if(!file_exists($dir_tmp)){ |
| 41 | 39 | @mkdir ($dir_tmp,0744); |
| 42 | 40 | chmod($dir_tmp,0744); | ... | ... |
admin/php/criabanco.php
| ... | ... | @@ -50,6 +50,15 @@ |
| 50 | 50 | //echo dirname(__FILE__); |
| 51 | 51 | $esquemaadmin = ""; |
| 52 | 52 | include("admin.php"); |
| 53 | + //verifica se o login pode ser realizado | |
| 54 | + if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 55 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 56 | + exit (); | |
| 57 | + } | |
| 58 | + //$i3geoPermiteLoginIp vem de ms_configura.php | |
| 59 | + if(isset($i3geoPermiteLoginIp)){ | |
| 60 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 61 | + } | |
| 53 | 62 | error_reporting(0); |
| 54 | 63 | $tabelas = array( |
| 55 | 64 | //tabelas gerais do sistema de administracao | ... | ... |
admin/php/incluiMAP.php
| ... | ... | @@ -36,6 +36,15 @@ i3geo/admin/php/incluiMAP.php |
| 36 | 36 | $funcao = ""; |
| 37 | 37 | $locaplic = dirname(__FILE__)."/../.."; |
| 38 | 38 | include_once("admin.php"); |
| 39 | +//verifica se o login pode ser realizado | |
| 40 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 41 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 42 | + exit (); | |
| 43 | +} | |
| 44 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 45 | +if(isset($i3geoPermiteLoginIp)){ | |
| 46 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 47 | +} | |
| 39 | 48 | include_once("conexao.php"); |
| 40 | 49 | if(empty($_POST["senha"]) || empty($_POST["usuario"])){ |
| 41 | 50 | formularioLoginMaster("incluiMAP.php"); | ... | ... |
admin/php/login.php
| ... | ... | @@ -64,6 +64,17 @@ error_reporting(0); |
| 64 | 64 | // |
| 65 | 65 | include_once(dirname(__FILE__)."/../safe.php"); |
| 66 | 66 | include_once(dirname(__FILE__)."/admin.php"); |
| 67 | + | |
| 68 | +//verifica se o login pode ser realizado | |
| 69 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 70 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 71 | + exit (); | |
| 72 | +} | |
| 73 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 74 | +if(isset($i3geoPermiteLoginIp)){ | |
| 75 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 76 | +} | |
| 77 | + | |
| 67 | 78 | error_reporting(0); |
| 68 | 79 | session_write_close(); |
| 69 | 80 | session_name("i3GeoLogin"); | ... | ... |
admin/php/upgradebanco44_45.php
| ... | ... | @@ -48,6 +48,16 @@ i3geo/admin/php/criabanco.php |
| 48 | 48 | */ |
| 49 | 49 | $funcao = ""; |
| 50 | 50 | include_once("admin.php"); |
| 51 | +//verifica se o login pode ser realizado | |
| 52 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 53 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 54 | + exit (); | |
| 55 | +} | |
| 56 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 57 | +if(isset($i3geoPermiteLoginIp)){ | |
| 58 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 59 | +} | |
| 60 | + | |
| 51 | 61 | include_once("conexao.php"); |
| 52 | 62 | |
| 53 | 63 | if(empty($_POST["senha"]) || empty($_POST["usuario"])){ |
| ... | ... | @@ -75,7 +85,7 @@ if($conexaoadmin == "") |
| 75 | 85 | } |
| 76 | 86 | else |
| 77 | 87 | { |
| 78 | - include($conexaoadmin); | |
| 88 | + include($conexaoadmin); | |
| 79 | 89 | } |
| 80 | 90 | */ |
| 81 | 91 | foreach($tabelas as $tabela) | ... | ... |
admin/php/upgradebanco46_47.php
| ... | ... | @@ -51,6 +51,16 @@ i3geo/admin/php/criabanco.php |
| 51 | 51 | $funcao = ""; |
| 52 | 52 | $locaplic = dirname(__FILE__)."/../.."; |
| 53 | 53 | include_once("admin.php"); |
| 54 | +//verifica se o login pode ser realizado | |
| 55 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 56 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 57 | + exit (); | |
| 58 | +} | |
| 59 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 60 | +if(isset($i3geoPermiteLoginIp)){ | |
| 61 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 62 | +} | |
| 63 | + | |
| 54 | 64 | include_once("conexao.php"); |
| 55 | 65 | if(!empty($esquemaadmin)){ |
| 56 | 66 | $esquemaadmin = str_replace(".","",$esquemaadmin)."."; | ... | ... |
classesjs/compactajs.php
| ... | ... | @@ -44,6 +44,16 @@ i3geo/classesjs/compactajs.php |
| 44 | 44 | |
| 45 | 45 | $locaplic = dirname(__FILE__)."/.."; |
| 46 | 46 | include_once(dirname(__FILE__)."/../admin/php/admin.php"); |
| 47 | +//verifica se o login pode ser realizado | |
| 48 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 49 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 50 | + exit (); | |
| 51 | +} | |
| 52 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 53 | +if(isset($i3geoPermiteLoginIp)){ | |
| 54 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 55 | +} | |
| 56 | + | |
| 47 | 57 | include_once(dirname(__FILE__)."/../admin/php/conexao.php"); |
| 48 | 58 | if(empty($_POST["senha"]) || empty($_POST["usuario"])){ |
| 49 | 59 | formularioLoginMaster("compactajs.php"); | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -2095,15 +2095,24 @@ Retorno: |
| 2095 | 2095 | |
| 2096 | 2096 | {string} |
| 2097 | 2097 | */ |
| 2098 | -function pegaIPcliente() | |
| 2099 | -{ | |
| 2100 | - $ip = "UNKNOWN"; | |
| 2101 | - if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP"); | |
| 2102 | - else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR"); | |
| 2103 | - else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR"); | |
| 2104 | - else $ip = "UNKNOWN"; | |
| 2105 | - //$ip = "200.252.111.1";//teste | |
| 2106 | - return $ip; | |
| 2098 | +function pegaIPcliente(){ | |
| 2099 | + $ipaddress = ''; | |
| 2100 | + if (getenv('HTTP_CLIENT_IP')) | |
| 2101 | + $ipaddress = getenv('HTTP_CLIENT_IP'); | |
| 2102 | + else if(getenv('HTTP_X_FORWARDED_FOR')) | |
| 2103 | + $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); | |
| 2104 | + else if(getenv('HTTP_X_FORWARDED')) | |
| 2105 | + $ipaddress = getenv('HTTP_X_FORWARDED'); | |
| 2106 | + else if(getenv('HTTP_FORWARDED_FOR')) | |
| 2107 | + $ipaddress = getenv('HTTP_FORWARDED_FOR'); | |
| 2108 | + else if(getenv('HTTP_FORWARDED')) | |
| 2109 | + $ipaddress = getenv('HTTP_FORWARDED'); | |
| 2110 | + else if(getenv('REMOTE_ADDR')) | |
| 2111 | + $ipaddress = getenv('REMOTE_ADDR'); | |
| 2112 | + else | |
| 2113 | + $ipaddress = 'UNKNOWN'; | |
| 2114 | + | |
| 2115 | + return $ipaddress; | |
| 2107 | 2116 | } |
| 2108 | 2117 | /* |
| 2109 | 2118 | Function: pegaIPcliente2 |
| ... | ... | @@ -3051,4 +3060,28 @@ function i3GeoLog($txt,$dir_tmp=""){ |
| 3051 | 3060 | "-------------------------".PHP_EOL; |
| 3052 | 3061 | file_put_contents($dir_tmp.'/.log_i3geo_'.date("j.n.Y"), $log, FILE_APPEND); |
| 3053 | 3062 | } |
| 3063 | +/** | |
| 3064 | + * valida o IP do usuario em uma lista branca | |
| 3065 | + */ | |
| 3066 | +function validaIpUsuario($lista){ | |
| 3067 | + if($lista == ""){ | |
| 3068 | + return true; | |
| 3069 | + } | |
| 3070 | + $ip = pegaIPcliente(); | |
| 3071 | + if(in_array($ip,$lista)){ | |
| 3072 | + return true; | |
| 3073 | + } else { | |
| 3074 | + return false; | |
| 3075 | + } | |
| 3076 | +} | |
| 3077 | +function checaLoginIp($lista){ | |
| 3078 | + if(empty($lista)){ | |
| 3079 | + return; | |
| 3080 | + } | |
| 3081 | + $r = validaIpUsuario($lista); | |
| 3082 | + if($r == false){ | |
| 3083 | + header ( "HTTP/1.1 403 Login nao permitido" ); | |
| 3084 | + exit (); | |
| 3085 | + } | |
| 3086 | +} | |
| 3054 | 3087 | ?> | ... | ... |
ferramentas/loginusuario/dependencias.php
| ... | ... | @@ -6,6 +6,15 @@ |
| 6 | 6 | * javascript i3GEOF.loginusuario.MUSTACHE |
| 7 | 7 | * O template e substituido pelos valores definidos em index.js no momento da inicializacao da ferramenta |
| 8 | 8 | */ |
| 9 | + | |
| 10 | +//verifica se o login pode ser realizado | |
| 11 | +include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 12 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 13 | + echo "alert('ferramenta de login desativada');"; | |
| 14 | + //header ( "HTTP/1.1 403 Login desativado" ); | |
| 15 | + exit (); | |
| 16 | +} | |
| 17 | + | |
| 9 | 18 | if(extension_loaded('zlib')){ |
| 10 | 19 | ob_start('ob_gzhandler'); |
| 11 | 20 | } | ... | ... |
geraminiatura.php
| ... | ... | @@ -82,14 +82,18 @@ if (!function_exists('ms_GetVersion')) |
| 82 | 82 | else |
| 83 | 83 | {dl('php_mapscript.so');} |
| 84 | 84 | } |
| 85 | -/* | |
| 86 | -include($locaplic."/ms_configura.php"); | |
| 87 | -if(!function_exists("versao")) | |
| 88 | -{include($locaplic."/classesphp/funcoes_gerais.php");} | |
| 89 | -require_once($locaplic."/classesphp/pega_variaveis.php"); | |
| 90 | -include_once ($locaplic."/classesphp/carrega_ext.php"); | |
| 91 | -*/ | |
| 85 | + | |
| 92 | 86 | include_once (dirname(__FILE__)."/admin/php/admin.php"); |
| 87 | +//verifica se o login pode ser realizado | |
| 88 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 89 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 90 | + exit (); | |
| 91 | +} | |
| 92 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 93 | +if(isset($i3geoPermiteLoginIp)){ | |
| 94 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 95 | +} | |
| 96 | + | |
| 93 | 97 | $versao = versao(); |
| 94 | 98 | $versao = $versao["principal"]; |
| 95 | 99 | // |
| ... | ... | @@ -134,7 +138,7 @@ if($tipo == "mini" || $tipo == "todos" || $tipo == "grande" || $tipo == "") |
| 134 | 138 | { |
| 135 | 139 | $arq = str_replace(" ","xxxx",$arq); |
| 136 | 140 | $temp = explode(".",$arq); |
| 137 | - | |
| 141 | + | |
| 138 | 142 | if(file_exists($locaplic.'/temas/'.$arq) && $temp[(count($temp) - 1)] == "map" && !(strpos($temp[0],"_") === 0) ) |
| 139 | 143 | { |
| 140 | 144 | echo "<b>$arq</b><br>"; |
| ... | ... | @@ -253,7 +257,7 @@ function verificaMiniatura($map,$tipo,$admin=false) |
| 253 | 257 | } |
| 254 | 258 | } |
| 255 | 259 | } |
| 256 | - | |
| 260 | + | |
| 257 | 261 | zoomTemaMiniatura($pegarext,$mapa); |
| 258 | 262 | } |
| 259 | 263 | if($extensao == ".gvp"){ | ... | ... |
ms_configura.php
| ... | ... | @@ -63,6 +63,29 @@ $i3geomaster = array( |
| 63 | 63 | array("usuario"=>"admin", "senha"=>"admin") |
| 64 | 64 | ); |
| 65 | 65 | /* |
| 66 | +Variable: $i3geoPermiteLogin | |
| 67 | + | |
| 68 | +Permite ou impede que sejam executadas as funcionalidades que exigem login | |
| 69 | + | |
| 70 | +Tipo: | |
| 71 | +{boolean} | |
| 72 | +*/ | |
| 73 | +$i3geoPermiteLogin = true; | |
| 74 | +/* | |
| 75 | +Variable: $i3geoPermiteLoginIp | |
| 76 | + | |
| 77 | +Lista de IPs que podem fazer login. Valido apenas se $i3geoPermiteLogin for true | |
| 78 | + | |
| 79 | +A lista e um array, permitindo a inclusao de varios IPs | |
| 80 | + | |
| 81 | +Para nao fazer a verificacao, ou seja, permitir que qualquer IP faca login, deixe essa variavel em branco | |
| 82 | + | |
| 83 | +Exemplo de uso: | |
| 84 | + | |
| 85 | +$i3geoPermiteLoginIp = array("127.0.0.1","200.200.200.200"); | |
| 86 | +*/ | |
| 87 | +$i3geoPermiteLoginIp = array(); | |
| 88 | +/* | |
| 66 | 89 | Variable: $logTransacoes |
| 67 | 90 | |
| 68 | 91 | Define se as transacoes no banco de dados de administracao serao mantidas em uma tabela de logs | ... | ... |
testainstal/index.php
| ... | ... | @@ -32,7 +32,7 @@ include "../init/head.php"; |
| 32 | 32 | <div class="container-fluid"> |
| 33 | 33 | <div class="row"> |
| 34 | 34 | <ol class="breadcrumb"> |
| 35 | - <li><a href="../init/index.php">i3Geo</a></li> | |
| 35 | + <li><a href="../init/index.php?home=">i3Geo</a></li> | |
| 36 | 36 | <li class="active">Teste de instalação</li> |
| 37 | 37 | </ol> |
| 38 | 38 | </div> |
| ... | ... | @@ -74,8 +74,15 @@ include "../init/head.php"; |
| 74 | 74 | */ |
| 75 | 75 | $locaplic = dirname(dirname(__FILE__)); |
| 76 | 76 | include_once("../admin/php/admin.php"); |
| 77 | - include_once("../ms_configura.php"); | |
| 78 | - | |
| 77 | + //verifica se o login pode ser realizado | |
| 78 | + if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 79 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 80 | + exit (); | |
| 81 | + } | |
| 82 | + //$i3geoPermiteLoginIp vem de ms_configura.php | |
| 83 | + if(isset($i3geoPermiteLoginIp)){ | |
| 84 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 85 | + } | |
| 79 | 86 | ?> |
| 80 | 87 | <script src='../classesjs/compactados/dicionario_compacto.js'></script> |
| 81 | 88 | <script src='../classesjs/compactados/classe_util_compacto.js'></script> |
| ... | ... | @@ -221,10 +228,10 @@ HTML; |
| 221 | 228 | if(!empty($_POST["criaPastaMstmp"]) && $_POST["criaPastaMstmp"] == "on"){ |
| 222 | 229 | echo "Criando a pasta $dir_tmp"; |
| 223 | 230 | if(!file_exists($dir_tmp)){ |
| 224 | - @mkdir ($dir_tmp,0777); | |
| 231 | + @mkdir ($dir_tmp,0744); | |
| 225 | 232 | } |
| 226 | 233 | else{ |
| 227 | - chmod($dir_tmp,0777); | |
| 234 | + chmod($dir_tmp,0744); | |
| 228 | 235 | } |
| 229 | 236 | if(!file_exists($dir_tmp)){ |
| 230 | 237 | echo "<span style=color:red >Arquivo $dir_tmp não pode ser criado"; |
| ... | ... | @@ -243,7 +250,7 @@ HTML; |
| 243 | 250 | @symlink($dir_tmp,$d); |
| 244 | 251 | } |
| 245 | 252 | else{ |
| 246 | - chmod($d,0777); | |
| 253 | + chmod($d,0744); | |
| 247 | 254 | } |
| 248 | 255 | if(!file_exists($d)){ |
| 249 | 256 | echo "<span style=color:red >Link $d não pode ser criado\n"; |
| ... | ... | @@ -258,10 +265,10 @@ HTML; |
| 258 | 265 | if(!empty($_POST["criaPastaMstmp"]) && $_POST["permPastaI3geo"] == "on"){ |
| 259 | 266 | echo "Alterando permissões i3geo i3geo/temas i3geo/admin i3geo/admin/admin.db\n"; |
| 260 | 267 | if(file_exists($locaplic)){ |
| 261 | - chmod($locaplic,0777); | |
| 262 | - chmod($locaplic."/temas",0777); | |
| 263 | - chmod($locaplic."/admin",0777); | |
| 264 | - chmod($locaplic."/admin/admin.db",0777); | |
| 268 | + chmod($locaplic,0744); | |
| 269 | + chmod($locaplic."/temas",0744); | |
| 270 | + chmod($locaplic."/admin",0744); | |
| 271 | + chmod($locaplic."/admin/admin.db",0744); | |
| 265 | 272 | echo "...OK\n"; |
| 266 | 273 | } |
| 267 | 274 | } | ... | ... |
testamapfile.php
| ... | ... | @@ -55,9 +55,21 @@ tabela - (opcional) testa a tabela de atributos |
| 55 | 55 | |
| 56 | 56 | set_time_limit(300); |
| 57 | 57 | ini_set('max_execution_time', 300); |
| 58 | +include_once (dirname(__FILE__)."/classesphp/sani_request.php"); | |
| 59 | +$_GET = array_merge($_GET,$_POST); | |
| 58 | 60 | include("ms_configura.php"); |
| 61 | +//verifica se o login pode ser realizado | |
| 62 | +if(isset($i3geoPermiteLogin) && $i3geoPermiteLogin == false){ | |
| 63 | + header ( "HTTP/1.1 403 Login desativado" ); | |
| 64 | + exit (); | |
| 65 | +} | |
| 59 | 66 | include("classesphp/funcoes_gerais.php"); |
| 60 | -require_once("classesphp/pega_variaveis.php"); | |
| 67 | + | |
| 68 | +//$i3geoPermiteLoginIp vem de ms_configura.php | |
| 69 | +if(isset($i3geoPermiteLoginIp)){ | |
| 70 | + checaLoginIp($i3geoPermiteLoginIp); | |
| 71 | +} | |
| 72 | + | |
| 61 | 73 | include_once ("classesphp/carrega_ext.php"); |
| 62 | 74 | // |
| 63 | 75 | //carrega o phpmapscript |
| ... | ... | @@ -114,9 +126,14 @@ if ($tipo == "") |
| 114 | 126 | echo $combo."</select></form><br>"; |
| 115 | 127 | echo '<br><input type=button value="Testa tabela" id="rodatabela" />'; |
| 116 | 128 | } |
| 129 | + | |
| 130 | +$solegenda = $_GET["solegenda"]; | |
| 131 | +$iniciar = $_GET["iniciar"]; | |
| 132 | +$map = $_GET["map"]; | |
| 133 | + | |
| 117 | 134 | if (isset($map) && $map != "") |
| 118 | 135 | { |
| 119 | - if(!isset($solegenda)){$solegenda = "nao";} | |
| 136 | + if(!isset($solegenda) || $solegenda == ""){$solegenda = "nao";} | |
| 120 | 137 | if ($map == "todos"){ |
| 121 | 138 | $tipo = "todos"; |
| 122 | 139 | $conta = 0; |
| ... | ... | @@ -187,8 +204,6 @@ function verifica($map,$solegenda,$tabela,$cache="sim"){ |
| 187 | 204 | {$tema = 'temas/'.$map;} |
| 188 | 205 | if (file_exists('temas/'.$map.'.map')) |
| 189 | 206 | {$tema = 'temas/'.$map.".map";} |
| 190 | - if (file_exists('temas/'.$map.'.php')) | |
| 191 | - {$tema = 'temas/'.$map.".php";} | |
| 192 | 207 | if (file_exists('temas/'.$map.'.gvp')) |
| 193 | 208 | {$tema = 'temas/'.$map.".gvp";} |
| 194 | 209 | } | ... | ... |