Commit 2f527742f8cc116bf52f7789fede5bfcbd429db1
1 parent
cf807889
Exists in
master
and in
7 other branches
adicionada crítica para verificar se os aerquivos com a base geoip existe e se a…
…conexão com o banco deu certo
Showing
1 changed file
with
21 additions
and
16 deletions
Show diff stats
ms_registraip.php
| ... | ... | @@ -56,6 +56,8 @@ Free Software Foundation, Inc., no endereço |
| 56 | 56 | 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
| 57 | 57 | |
| 58 | 58 | */ |
| 59 | +if (!file_exists($locaplic."/pacotes/geoip/GeoLiteCity.dat")) | |
| 60 | +{exit;} | |
| 59 | 61 | if (file_exists($locaplic."/pacotes/geoip")) |
| 60 | 62 | { |
| 61 | 63 | $r["latitude"] = ""; |
| ... | ... | @@ -74,26 +76,29 @@ if (file_exists($locaplic."/pacotes/geoip")) |
| 74 | 76 | if(($r["latitude"] != null) && ($r["latitude"] != "")) |
| 75 | 77 | { |
| 76 | 78 | $pgconn = pg_connect($conexao); |
| 77 | - // | |
| 78 | - $sqlVerificaExistencia = "select * from visitantes_i3geo where latitude = ".$r["latitude"]." and longitude = ".$r["longitude"]; | |
| 79 | - // | |
| 80 | - $result = pg_query($pgconn, $sqlVerificaExistencia); | |
| 81 | - $numrows = pg_num_rows($result); | |
| 82 | - if ($numrows != 0) | |
| 79 | + if($pgconn) | |
| 83 | 80 | { |
| 84 | 81 | // |
| 85 | - $sqlGravaMaisUm = "update visitantes_i3geo set n = n+1 where (latitude = ".$r["latitude"]." and longitude = ".$r["longitude"].")"; | |
| 82 | + $sqlVerificaExistencia = "select * from visitantes_i3geo where latitude = ".$r["latitude"]." and longitude = ".$r["longitude"]; | |
| 86 | 83 | // |
| 87 | - $result = pg_query($pgconn, $sqlGravaMaisUm); | |
| 84 | + $result = pg_query($pgconn, $sqlVerificaExistencia); | |
| 85 | + $numrows = pg_num_rows($result); | |
| 86 | + if ($numrows != 0) | |
| 87 | + { | |
| 88 | + // | |
| 89 | + $sqlGravaMaisUm = "update visitantes_i3geo set n = n+1 where (latitude = ".$r["latitude"]." and longitude = ".$r["longitude"].")"; | |
| 90 | + // | |
| 91 | + $result = pg_query($pgconn, $sqlGravaMaisUm); | |
| 92 | + } | |
| 93 | + else | |
| 94 | + { | |
| 95 | + // | |
| 96 | + $sqlGravaNovo = "insert into visitantes_i3geo (gid,latitude,longitude,n) values(default,".$r["latitude"].",".$r["longitude"].",1)"; | |
| 97 | + // | |
| 98 | + $result = pg_query($pgconn, $sqlGravaNovo); | |
| 99 | + } | |
| 100 | + pg_close($pgconn); | |
| 88 | 101 | } |
| 89 | - else | |
| 90 | - { | |
| 91 | - // | |
| 92 | - $sqlGravaNovo = "insert into visitantes_i3geo (gid,latitude,longitude,n) values(default,".$r["latitude"].",".$r["longitude"].",1)"; | |
| 93 | - // | |
| 94 | - $result = pg_query($pgconn, $sqlGravaNovo); | |
| 95 | - } | |
| 96 | - pg_close($pgconn); | |
| 97 | 102 | } |
| 98 | 103 | } |
| 99 | 104 | ?> |
| 100 | 105 | \ No newline at end of file | ... | ... |