Commit d9dedd7ddfb97e9d02b2f0cfc597e4b428d780c6

Authored by Edmar Moretti
1 parent 5e46d3be

Implantação do log de transações #62

Showing 2 changed files with 192 additions and 127 deletions   Show diff stats
admin/admin.db
No preview for this file type
admin/php/menutemas.php
@@ -880,8 +880,7 @@ function alteraMenus() @@ -880,8 +880,7 @@ function alteraMenus()
880 i3GeoAdminUpdate($dbhw,"i3geoadmin_menus",$dataCol,"WHERE id_menu = $id_menu"); 880 i3GeoAdminUpdate($dbhw,"i3geoadmin_menus",$dataCol,"WHERE id_menu = $id_menu");
881 $retorna = "ok"; 881 $retorna = "ok";
882 } 882 }
883 - else  
884 - { 883 + else{
885 $dataCol = array( 884 $dataCol = array(
886 "en" => "", 885 "en" => "",
887 "es" => "", 886 "es" => "",
@@ -898,13 +897,11 @@ function alteraMenus() @@ -898,13 +897,11 @@ function alteraMenus()
898 $dbh = null; 897 $dbh = null;
899 return $retorna; 898 return $retorna;
900 } 899 }
901 - catch (PDOException $e)  
902 - { 900 + catch (PDOException $e){
903 return "Error!: " . $e->getMessage(); 901 return "Error!: " . $e->getMessage();
904 } 902 }
905 } 903 }
906 -function alteraPerfis()  
907 -{ 904 +function alteraPerfis(){
908 global $perfil,$id,$esquemaadmin; 905 global $perfil,$id,$esquemaadmin;
909 try 906 try
910 { 907 {
@@ -912,69 +909,88 @@ function alteraPerfis() @@ -912,69 +909,88 @@ function alteraPerfis()
912 include("conexao.php"); 909 include("conexao.php");
913 if($convUTF) $perfil = utf8_encode($perfil); 910 if($convUTF) $perfil = utf8_encode($perfil);
914 $retorna = ""; 911 $retorna = "";
915 - if($id != "")  
916 - { 912 + if($id != ""){
917 $original = ""; 913 $original = "";
918 - foreach($dbh->query("select * from ".$esquemaadmin."i3geoadmin_perfis where id_perfil = $id") as $row)  
919 - { 914 + foreach($dbh->query("select * from ".$esquemaadmin."i3geoadmin_perfis where id_perfil = $id") as $row){
920 $original = $row["perfil"]; 915 $original = $row["perfil"];
921 } 916 }
922 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_perfis SET perfil = '$perfil' WHERE id_perfil = $id");  
923 - if($original != "")  
924 - { 917 + $dataCol = array(
  918 + "perfil" => $perfil
  919 + );
  920 + i3GeoAdminUpdate($dbhw,"i3geoadmin_perfis",$dataCol,"WHERE id_perfil = $id");
  921 +
  922 + if($original != ""){
925 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_mapas"); 923 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_mapas");
926 - foreach($q as $row)  
927 - { 924 + foreach($q as $row){
928 $t = $row['perfil_mapa']; 925 $t = $row['perfil_mapa'];
929 $i = $row['id_mapa']; 926 $i = $row['id_mapa'];
930 $ts = str_replace($original,$perfil,$t); 927 $ts = str_replace($original,$perfil,$t);
931 - if($t != $ts)  
932 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_mapas SET perfil_mapa = '$ts' WHERE id_mapa = $i"); 928 + if($t != $ts){
  929 + $dataCol = array(
  930 + "perfil_mapa" => $ts
  931 + );
  932 + i3GeoAdminUpdate($dbhw,"i3geoadmin_mapas",$dataCol,"WHERE id_mapa = $i");
  933 + }
933 } 934 }
934 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_menus"); 935 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_menus");
935 - foreach($q as $row)  
936 - { 936 + foreach($q as $row){
937 $t = $row['perfil_menu']; 937 $t = $row['perfil_menu'];
938 $i = $row['id_menu']; 938 $i = $row['id_menu'];
939 $ts = str_replace($original,$perfil,$t); 939 $ts = str_replace($original,$perfil,$t);
940 - if($t != $ts)  
941 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_menus SET perfil_menu = '$ts' WHERE id_menu = $i"); 940 + if($t != $ts){
  941 + $dataCol = array(
  942 + "perfil_menu" => $ts
  943 + );
  944 + i3GeoAdminUpdate($dbhw,"i3geoadmin_menus",$dataCol,"WHERE id_menu = $i");
  945 + }
942 } 946 }
943 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n1"); 947 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n1");
944 - foreach($q as $row)  
945 - { 948 + foreach($q as $row){
946 $t = $row['n1_perfil']; 949 $t = $row['n1_perfil'];
947 $i = $row['id_n1']; 950 $i = $row['id_n1'];
948 $ts = str_replace($original,$perfil,$t); 951 $ts = str_replace($original,$perfil,$t);
949 - if($t != $ts)  
950 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_n1 SET n1_perfil = '$ts' WHERE id_n1 = $i"); 952 + if($t != $ts){
  953 + $dataCol = array(
  954 + "n1_perfil" => $ts
  955 + );
  956 + i3GeoAdminUpdate($dbhw,"i3geoadmin_n1",$dataCol,"WHERE id_n1 = $i");
  957 + }
951 } 958 }
952 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n2"); 959 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n2");
953 - foreach($q as $row)  
954 - { 960 + foreach($q as $row){
955 $t = $row['n2_perfil']; 961 $t = $row['n2_perfil'];
956 $i = $row['id_n2']; 962 $i = $row['id_n2'];
957 $ts = str_replace($original,$perfil,$t); 963 $ts = str_replace($original,$perfil,$t);
958 - if($t != $ts)  
959 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_n2 SET n2_perfil = '$ts' WHERE id_n2 = $i"); 964 + if($t != $ts){
  965 + $dataCol = array(
  966 + "n2_perfil" => $ts
  967 + );
  968 + i3GeoAdminUpdate($dbhw,"i3geoadmin_n2",$dataCol,"WHERE id_n2 = $i");
  969 + }
960 } 970 }
961 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n3"); 971 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_n3");
962 - foreach($q as $row)  
963 - { 972 + foreach($q as $row){
964 $t = $row['n3_perfil']; 973 $t = $row['n3_perfil'];
965 $i = $row['id_n3']; 974 $i = $row['id_n3'];
966 $ts = str_replace($original,$perfil,$t); 975 $ts = str_replace($original,$perfil,$t);
967 - if($t != $ts)  
968 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_n3 SET n3_perfil = '$ts' WHERE id_n3 = $i"); 976 + if($t != $ts){
  977 + $dataCol = array(
  978 + "n3_perfil" => $ts
  979 + );
  980 + i3GeoAdminUpdate($dbhw,"i3geoadmin_n3",$dataCol,"WHERE id_n3 = $i");
  981 + }
969 } 982 }
970 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_raiz"); 983 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_raiz");
971 - foreach($q as $row)  
972 - { 984 + foreach($q as $row){
973 $t = $row['perfil']; 985 $t = $row['perfil'];
974 $i = $row['id_raiz']; 986 $i = $row['id_raiz'];
975 $ts = str_replace($original,$perfil,$t); 987 $ts = str_replace($original,$perfil,$t);
976 - if($t != $ts)  
977 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_raiz SET perfil = '$ts' WHERE id_raiz = $i"); 988 + if($t != $ts){
  989 + $dataCol = array(
  990 + "perfil" => $ts
  991 + );
  992 + i3GeoAdminUpdate($dbhw,"i3geoadmin_raiz",$dataCol,"WHERE id_raiz = $i");
  993 + }
978 } 994 }
979 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_sistemas"); 995 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_sistemas");
980 foreach($q as $row) 996 foreach($q as $row)
@@ -982,24 +998,33 @@ function alteraPerfis() @@ -982,24 +998,33 @@ function alteraPerfis()
982 $t = $row['perfil_sistema']; 998 $t = $row['perfil_sistema'];
983 $i = $row['id_sistema']; 999 $i = $row['id_sistema'];
984 $ts = str_replace($original,$perfil,$t); 1000 $ts = str_replace($original,$perfil,$t);
985 - if($t != $ts)  
986 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_sistemas SET perfil_sistema = '$ts' WHERE id_sistema = $i"); 1001 + if($t != $ts){
  1002 + $dataCol = array(
  1003 + "perfil_sistema" => $ts
  1004 + );
  1005 + i3GeoAdminUpdate($dbhw,"i3geoadmin_sistemas",$dataCol,"WHERE id_sistema = $i");
  1006 + }
987 } 1007 }
988 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_sistemasf"); 1008 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_sistemasf");
989 - foreach($q as $row)  
990 - { 1009 + foreach($q as $row){
991 $t = $row['perfil_funcao']; 1010 $t = $row['perfil_funcao'];
992 $i = $row['id_funcao']; 1011 $i = $row['id_funcao'];
993 $ts = str_replace($original,$perfil,$t); 1012 $ts = str_replace($original,$perfil,$t);
994 - if($t != $ts)  
995 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_sistemasf SET perfil_funcao = '$ts' WHERE id_funcao = $i"); 1013 + if($t != $ts){
  1014 + $dataCol = array(
  1015 + "perfil_funcao" => $ts
  1016 + );
  1017 + i3GeoAdminUpdate($dbhw,"i3geoadmin_sistemasf",$dataCol,"WHERE id_funcao = $i");
  1018 + }
996 } 1019 }
997 } 1020 }
998 $retorna = $id; 1021 $retorna = $id;
999 } 1022 }
1000 - else  
1001 - {  
1002 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_perfis (perfil) VALUES ('$perfil')"); 1023 + else{
  1024 + $dataCol = array(
  1025 + "perfil" => $perfil
  1026 + );
  1027 + i3GeoAdminInsert($dbhw,"i3geoadmin_perfis",$dataCol);
1003 $id = $dbh->query("SELECT * FROM ".$esquemaadmin."i3geoadmin_perfis"); 1028 $id = $dbh->query("SELECT * FROM ".$esquemaadmin."i3geoadmin_perfis");
1004 $id = $id->fetchAll(); 1029 $id = $id->fetchAll();
1005 $id = intval($id[count($id)-1]['id_perfil']); 1030 $id = intval($id[count($id)-1]['id_perfil']);
@@ -1009,37 +1034,36 @@ function alteraPerfis() @@ -1009,37 +1034,36 @@ function alteraPerfis()
1009 $dbh = null; 1034 $dbh = null;
1010 return $retorna; 1035 return $retorna;
1011 } 1036 }
1012 - catch (PDOException $e)  
1013 - { 1037 + catch (PDOException $e){
1014 return "Error!: " . $e->getMessage(); 1038 return "Error!: " . $e->getMessage();
1015 } 1039 }
1016 } 1040 }
1017 -function alteraTags()  
1018 -{ 1041 +function alteraTags(){
1019 global $nome,$id,$esquemaadmin; 1042 global $nome,$id,$esquemaadmin;
1020 - try  
1021 - { 1043 + try{
1022 $dbh = ""; 1044 $dbh = "";
1023 include("conexao.php"); 1045 include("conexao.php");
1024 if($convUTF) $nome = utf8_encode($nome); 1046 if($convUTF) $nome = utf8_encode($nome);
1025 $retorna = ""; 1047 $retorna = "";
1026 - if($id != "")  
1027 - {  
1028 - if(!verificaDuplicados("select * from ".$esquemaadmin."i3geoadmin_tags where nome = '$nome'",$dbh))  
1029 - { 1048 + if($id != ""){
  1049 + if(!verificaDuplicados("select * from ".$esquemaadmin."i3geoadmin_tags where nome = '$nome'",$dbh)){
1030 $original = ""; 1050 $original = "";
1031 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_tags where id_tag = $id"); 1051 $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_tags where id_tag = $id");
1032 - foreach($q as $row)  
1033 - { 1052 + foreach($q as $row){
1034 $original = $row["nome"]; 1053 $original = $row["nome"];
1035 } 1054 }
1036 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_tags SET nome = '$nome' WHERE id_tag = $id"); 1055 + $dataCol = array(
  1056 + "nome" => $nome
  1057 + );
  1058 + i3GeoAdminUpdate($dbhw,"i3geoadmin_tags",$dataCol,"WHERE id_tag = $id");
1037 } 1059 }
1038 $retorna = $id; 1060 $retorna = $id;
1039 } 1061 }
1040 - else  
1041 - {  
1042 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_tags (nome) VALUES ('$nome')"); 1062 + else{
  1063 + $dataCol = array(
  1064 + "nome" => $nome
  1065 + );
  1066 + i3GeoAdminInsert($dbhw,"i3geoadmin_tags",$dataCol);
1043 $id = $dbh->query("SELECT * FROM ".$esquemaadmin."i3geoadmin_tags"); 1067 $id = $dbh->query("SELECT * FROM ".$esquemaadmin."i3geoadmin_tags");
1044 $id = $id->fetchAll(); 1068 $id = $id->fetchAll();
1045 $id = intval($id[count($id)-1]['id_tag']); 1069 $id = intval($id[count($id)-1]['id_tag']);
@@ -1049,8 +1073,7 @@ function alteraTags() @@ -1049,8 +1073,7 @@ function alteraTags()
1049 $dbh = null; 1073 $dbh = null;
1050 return $retorna; 1074 return $retorna;
1051 } 1075 }
1052 - catch (PDOException $e)  
1053 - { 1076 + catch (PDOException $e){
1054 return "Error!: " . $e->getMessage(); 1077 return "Error!: " . $e->getMessage();
1055 } 1078 }
1056 } 1079 }
@@ -1060,35 +1083,40 @@ Altera o registro de um grupo. Se id for vazio acrescenta o registro @@ -1060,35 +1083,40 @@ Altera o registro de um grupo. Se id for vazio acrescenta o registro
1060 function alteraGrupos() 1083 function alteraGrupos()
1061 { 1084 {
1062 global $nome_grupo,$desc_grupo,$id_grupo,$en,$es,$it,$esquemaadmin; 1085 global $nome_grupo,$desc_grupo,$id_grupo,$en,$es,$it,$esquemaadmin;
1063 - try  
1064 - { 1086 + try{
1065 require(dirname(__FILE__)."/conexao.php"); 1087 require(dirname(__FILE__)."/conexao.php");
1066 - if($convUTF)  
1067 - { 1088 + if($convUTF){
1068 $nome_grupo = utf8_encode($nome_grupo); 1089 $nome_grupo = utf8_encode($nome_grupo);
1069 $desc_grupo = utf8_encode($desc_grupo); 1090 $desc_grupo = utf8_encode($desc_grupo);
1070 $en = utf8_encode($en); 1091 $en = utf8_encode($en);
1071 $es = utf8_encode($es); 1092 $es = utf8_encode($es);
1072 $it = utf8_encode($it); 1093 $it = utf8_encode($it);
1073 } 1094 }
1074 - if($id_grupo != "")  
1075 - {  
1076 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_grupos SET en = '$en', es = '$es', it = '$it', nome_grupo = '$nome_grupo', desc_grupo = '$desc_grupo' WHERE id_grupo = $id_grupo"); 1095 + if($id_grupo != ""){
  1096 + $dataCol = array(
  1097 + "en" => $en,
  1098 + "es" => $es,
  1099 + "it" => $it,
  1100 + "nome_grupo" => $nome_grupo,
  1101 + "desc_grupo" => $desc_grupo
  1102 + );
  1103 + i3GeoAdminUpdate($dbhw,"i3geoadmin_grupos",$dataCol,"WHERE id_grupo = $id_grupo");
1077 } 1104 }
1078 - else  
1079 - {  
1080 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_grupos (nome_grupo, desc_grupo, en, es, it) VALUES ('$nome_grupo', '','','','')");  
1081 - $sql = "SELECT * from ".$esquemaadmin."i3geoadmin_grupos where nome_grupo = '$nome_grupo'";  
1082 - $q = $dbh->query($sql,PDO::FETCH_ASSOC);  
1083 - $resultado = $q->fetchAll();  
1084 - $id_grupo = $resultado[0]["id_grupo"]; 1105 + else{
  1106 + $dataCol = array(
  1107 + "nome_grupo" => $nome_grupo,
  1108 + "desc_grupo" => "",
  1109 + "en" => "",
  1110 + "es" => "",
  1111 + "it" => ""
  1112 + );
  1113 + $id_grupo = i3GeoAdminInsertUnico($dbhw,"i3geoadmin_grupos",$dataCol,"nome_grupo","id_grupo");
1085 } 1114 }
1086 $dbhw = null; 1115 $dbhw = null;
1087 $dbh = null; 1116 $dbh = null;
1088 return $id_grupo; 1117 return $id_grupo;
1089 } 1118 }
1090 - catch (PDOException $e)  
1091 - { 1119 + catch (PDOException $e){
1092 return "Error!: " . $e->getMessage(); 1120 return "Error!: " . $e->getMessage();
1093 } 1121 }
1094 } 1122 }
@@ -1109,14 +1137,24 @@ function alteraSubGrupos() @@ -1109,14 +1137,24 @@ function alteraSubGrupos()
1109 } 1137 }
1110 $retorna = ""; 1138 $retorna = "";
1111 if($id_subgrupo != ""){ 1139 if($id_subgrupo != ""){
1112 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_subgrupos SET en = '$en', es = '$es', it = '$it', nome_subgrupo = '$nome_subgrupo', desc_subgrupo = '$desc_subgrupo' WHERE id_subgrupo = $id_subgrupo"); 1140 + $dataCol = array(
  1141 + "en" => $en,
  1142 + "es" => $es,
  1143 + "it" => $it,
  1144 + "nome_subgrupo" => $nome_subgrupo,
  1145 + "desc_subgrupo" => $desc_subgrupo
  1146 + );
  1147 + i3GeoAdminUpdate($dbhw,"i3geoadmin_subgrupos",$dataCol,"WHERE id_subgrupo = $id_subgrupo");
1113 } 1148 }
1114 else{ 1149 else{
1115 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_subgrupos (nome_subgrupo, desc_subgrupo, en, es, it) VALUES ('$nome_subgrupo', '','','','')");  
1116 - $sql = "SELECT * from ".$esquemaadmin."i3geoadmin_subgrupos where nome_subgrupo = '$nome_subgrupo'";  
1117 - $q = $dbh->query($sql,PDO::FETCH_ASSOC);  
1118 - $resultado = $q->fetchAll();  
1119 - $id_subgrupo = $resultado[0]["id_subgrupo"]; 1150 + $dataCol = array(
  1151 + "nome_subgrupo" => $nome_subgrupo,
  1152 + "desc_subgrupo" => "",
  1153 + "en" => "",
  1154 + "es" => "",
  1155 + "it" => ""
  1156 + );
  1157 + $id_subgrupo = i3GeoAdminInsertUnico($dbhw,"i3geoadmin_subgrupos",$dataCol,"nome_subgrupo","id_subgrupo");
1120 } 1158 }
1121 $dbhw = null; 1159 $dbhw = null;
1122 $dbh = null; 1160 $dbh = null;
@@ -1139,16 +1177,26 @@ function registraTema() @@ -1139,16 +1177,26 @@ function registraTema()
1139 include("conexao.php"); 1177 include("conexao.php");
1140 $sql = "SELECT * from ".$esquemaadmin."i3geoadmin_temas where codigo_tema = '$codigo_tema'"; 1178 $sql = "SELECT * from ".$esquemaadmin."i3geoadmin_temas where codigo_tema = '$codigo_tema'";
1141 $dados = pegaDados($sql); 1179 $dados = pegaDados($sql);
1142 - if(count($dados) == 0)  
1143 - {  
1144 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_temas (tipoa_tema,nome_tema,codigo_tema,kml_tema,kmz_tema,ogc_tema,download_tema,tags_tema,link_tema,desc_tema) VALUES ('','$codigo_tema','$codigo_tema','SIM','NAO','SIM','SIM','','','')"); 1180 + if(count($dados) == 0){
  1181 + $dataCol = array(
  1182 + "tipoa_tema" => '',
  1183 + "nome_tema" => $codigo_tema,
  1184 + "codigo_tema" => $codigo_tema,
  1185 + "kml_tema" => 'SIM',
  1186 + "kmz_tema" => 'NAO',
  1187 + "ogc_tema" => 'SIM',
  1188 + "download_tema" => 'SIM',
  1189 + "tags_tema" => '',
  1190 + "link_tema" => '',
  1191 + "desc_tema" => ''
  1192 + );
  1193 + i3GeoAdminInsert($dbhw,"i3geoadmin_temas",$dataCol);
1145 } 1194 }
1146 $dbhw = null; 1195 $dbhw = null;
1147 $dbh = null; 1196 $dbh = null;
1148 return "ok"; 1197 return "ok";
1149 } 1198 }
1150 - catch (PDOException $e)  
1151 - { 1199 + catch (PDOException $e){
1152 return "Error!: " . $e->getMessage(); 1200 return "Error!: " . $e->getMessage();
1153 } 1201 }
1154 } 1202 }
@@ -1164,8 +1212,7 @@ function alteraTemas() @@ -1164,8 +1212,7 @@ function alteraTemas()
1164 $retorna = "ok"; 1212 $retorna = "ok";
1165 include("conexao.php"); 1213 include("conexao.php");
1166 $nomeo = $nome; 1214 $nomeo = $nome;
1167 - if($convUTF)  
1168 - { 1215 + if($convUTF){
1169 $nome = utf8_encode($nome); 1216 $nome = utf8_encode($nome);
1170 $desc = utf8_encode($desc); 1217 $desc = utf8_encode($desc);
1171 $tags = utf8_encode($tags); 1218 $tags = utf8_encode($tags);
@@ -1173,12 +1220,26 @@ function alteraTemas() @@ -1173,12 +1220,26 @@ function alteraTemas()
1173 $es = utf8_encode($es); 1220 $es = utf8_encode($es);
1174 $it = utf8_encode($it); 1221 $it = utf8_encode($it);
1175 } 1222 }
1176 - if($id != "")  
1177 - {  
1178 - if(!isset($kmz))  
1179 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_temas SET es='$es', it='$it', en='$en', tags_tema='$tags', link_tema='$link', nome_tema ='$nome',desc_tema='$desc',codigo_tema='$codigo',tipoa_tema='$tipoa',download_tema='$download',ogc_tema='$ogc',kml_tema='$kml' WHERE id_tema = $id");  
1180 - else  
1181 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_temas SET es='$es', it='$it', en='$en',tags_tema='$tags', link_tema='$link', nome_tema ='$nome',desc_tema='$desc',codigo_tema='$codigo',tipoa_tema='$tipoa',download_tema='$download',ogc_tema='$ogc',kml_tema='$kml',kmz_tema='$kmz' WHERE id_tema = $id"); 1223 + if($id != ""){
  1224 + $dataCol = array(
  1225 + "en" => $en,
  1226 + "es" => $es,
  1227 + "it" => $it,
  1228 + "tags_tema" => $tags,
  1229 + "link_tema" => $link,
  1230 + "nome_tema" => $nome,
  1231 + "desc_tema" => $desc,
  1232 + "codigo_tema" => $codigo,
  1233 + "tipoa_tema" => $tipoa,
  1234 + "download_tema" => $download,
  1235 + "ogc_tema" => $ogc,
  1236 + "kml_tema" => $kml
  1237 + );
  1238 + if(isset($kmz))
  1239 + $dataCol["kmz_tema"] = $kmz;
  1240 + }
  1241 + i3GeoAdminUpdate($dbhw,"i3geoadmin_temas",$dataCol,"WHERE id_tema = $id");
  1242 +
1182 $retorna = $id; 1243 $retorna = $id;
1183 if(!isset($kmz)){ 1244 if(!isset($kmz)){
1184 $kmz = "nao"; 1245 $kmz = "nao";
@@ -1189,12 +1250,10 @@ function alteraTemas() @@ -1189,12 +1250,10 @@ function alteraTemas()
1189 $mapfile = $resultado[0]["codigo_tema"]; 1250 $mapfile = $resultado[0]["codigo_tema"];
1190 if(file_exists($locaplic."/temas/".$mapfile.".map")){ 1251 if(file_exists($locaplic."/temas/".$mapfile.".map")){
1191 $mapfile = $locaplic."/temas/".$mapfile.".map"; 1252 $mapfile = $locaplic."/temas/".$mapfile.".map";
1192 - if($mapa = @ms_newMapObj($mapfile))  
1193 - { 1253 + if($mapa = @ms_newMapObj($mapfile)){
1194 $mapa = ms_newMapObj($mapfile); 1254 $mapa = ms_newMapObj($mapfile);
1195 $numlayers = $mapa->numlayers; 1255 $numlayers = $mapa->numlayers;
1196 - for ($i=0;$i < $numlayers;$i++)  
1197 - { 1256 + for ($i=0;$i < $numlayers;$i++){
1198 $layer = $mapa->getlayer($i); 1257 $layer = $mapa->getlayer($i);
1199 $layer->setmetadata("permitedownload",strtolower($download)); 1258 $layer->setmetadata("permitedownload",strtolower($download));
1200 $layer->setmetadata("download",strtolower($download)); 1259 $layer->setmetadata("download",strtolower($download));
@@ -1207,8 +1266,7 @@ function alteraTemas() @@ -1207,8 +1266,7 @@ function alteraTemas()
1207 $layer->setmetadata("METAESTAT_ID_MEDIDA_VARIAVEL",""); 1266 $layer->setmetadata("METAESTAT_ID_MEDIDA_VARIAVEL","");
1208 $layer->setmetadata("metaestat",""); 1267 $layer->setmetadata("metaestat","");
1209 } 1268 }
1210 - if(count($nomes) == 1)  
1211 - { 1269 + if(count($nomes) == 1){
1212 $layer->setmetadata("tema",$nomeo); 1270 $layer->setmetadata("tema",$nomeo);
1213 } 1271 }
1214 } 1272 }
@@ -1217,35 +1275,42 @@ function alteraTemas() @@ -1217,35 +1275,42 @@ function alteraTemas()
1217 } 1275 }
1218 } 1276 }
1219 } 1277 }
1220 - else  
1221 - {  
1222 - $idtemp = (rand (9000,10000)) * -1;  
1223 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_temas (nome_tema) VALUES ('$idtemp')");// (link_tema,kml_tema,ogc_tema,download_tema,nome_tema,desc_tema,codigo_tema,tipoa_tema,tags_tema) VALUES ('','', '','','','','','','')");  
1224 - $id = $dbh->query("SELECT * ".$esquemaadmin."FROM i3geoadmin_temas WHERE nome_tema = '$idtemp'");  
1225 - $id = $id->fetchAll();  
1226 - $id = intval($id[0]['id_tema']);  
1227 - if(!isset($kmz))  
1228 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_temas SET tags_tema='', link_tema='', nome_tema ='',desc_tema='',codigo_tema='',tipoa_tema='',download_tema='',ogc_tema='',kml_tema='' WHERE id_tema = $id");  
1229 - else  
1230 - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_temas SET tags_tema='', link_tema='', nome_tema ='',desc_tema='',codigo_tema='',tipoa_tema='',download_tema='',ogc_tema='',kml_tema='',kmz_tema='' WHERE id_tema = $id");  
1231 - $retorna = $id; 1278 + else{
  1279 + $dataCol = array(
  1280 + "en" => "",
  1281 + "es" => "",
  1282 + "it" => "",
  1283 + "tags_tema" => "",
  1284 + "link_tema" => "",
  1285 + "nome_tema" => "",
  1286 + "desc_tema" => "",
  1287 + "codigo_tema" => "",
  1288 + "tipoa_tema" => "",
  1289 + "download_tema" => "",
  1290 + "ogc_tema" => "",
  1291 + "kml_tema" => ""
  1292 + );
  1293 + if(isset($kmz))
  1294 + $dataCol["kmz_tema"] = "";
  1295 + }
  1296 + $retorna = i3GeoAdminInsertUnico($dbhw,"i3geoadmin_temas",$dataCol,"nome_tema","id_tema");
1232 } 1297 }
1233 //verifica se &eacute; necess&aacute;rio adicionar algum tag novo 1298 //verifica se &eacute; necess&aacute;rio adicionar algum tag novo
1234 $tags = explode(" ",$tags); 1299 $tags = explode(" ",$tags);
1235 1300
1236 - foreach($tags as $tag)  
1237 - {  
1238 - if(!(verificaDuplicados("select * from ".$esquemaadmin."i3geoadmin_tags where nome = '$tag'",$dbh)))  
1239 - {  
1240 - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_tags (nome) VALUES ('$tag')"); 1301 + foreach($tags as $tag){
  1302 + if(!(verificaDuplicados("select * from ".$esquemaadmin."i3geoadmin_tags where nome = '$tag'",$dbh))){
  1303 + $dataCol = array(
  1304 + "nome" => $tag
  1305 + );
  1306 + i3GeoAdminInsert($dbhw,"i3geoadmin_tags",$dataCol);
1241 } 1307 }
1242 } 1308 }
1243 $dbhw = null; 1309 $dbhw = null;
1244 $dbh = null; 1310 $dbh = null;
1245 return $retorna; 1311 return $retorna;
1246 } 1312 }
1247 - catch (PDOException $e)  
1248 - { 1313 + catch (PDOException $e){
1249 return "Error!: " . $e->getMessage(); 1314 return "Error!: " . $e->getMessage();
1250 } 1315 }
1251 } 1316 }
@@ -1474,14 +1539,14 @@ function removeCabecalho($arq,$symbolset=true) @@ -1474,14 +1539,14 @@ function removeCabecalho($arq,$symbolset=true)
1474 $teste = preg_replace('/[\n\r\t ]*/', '', $teste); 1539 $teste = preg_replace('/[\n\r\t ]*/', '', $teste);
1475 $testar = array("KEYIMAGE","TILEINDEX","TILEITEM","SYMBOL","LABELITEM","FILTERITEM","GROUP","ENCODING","TIP","CLASSE","ITENSDESC","CLASSESNOME","ITENSLINK","ESCALA","CLASSESSIMBOLO","MENSAGEM","EXTENSAO","CLASSESITEM","ESCONDIDO","CLASSESCOR","DOWNLOAD","CLASSESTAMANHO","ITENS","TEMA","APLICAEXTENSAO","IDENTIFICA"); 1540 $testar = array("KEYIMAGE","TILEINDEX","TILEITEM","SYMBOL","LABELITEM","FILTERITEM","GROUP","ENCODING","TIP","CLASSE","ITENSDESC","CLASSESNOME","ITENSLINK","ESCALA","CLASSESSIMBOLO","MENSAGEM","EXTENSAO","CLASSESITEM","ESCONDIDO","CLASSESCOR","DOWNLOAD","CLASSESTAMANHO","ITENS","TEMA","APLICAEXTENSAO","IDENTIFICA");
1476 $passou = true; 1541 $passou = true;
1477 - foreach ($testar as $t)  
1478 - { 1542 + foreach ($testar as $t){
1479 if($teste == $t){ 1543 if($teste == $t){
1480 $passou = false; 1544 $passou = false;
1481 } 1545 }
1482 } 1546 }
1483 - if($passou) 1547 + if($passou){
1484 fwrite($handle,$f); 1548 fwrite($handle,$f);
  1549 + }
1485 } 1550 }
1486 fclose($handle); 1551 fclose($handle);
1487 chmod($arq, 0666); 1552 chmod($arq, 0666);