document.location=\"$url\"; "; } function Alert($str){ echo " "; } function AlertRedirect($str,$url){ echo " "; } function Fecha(){ echo " "; } function formataData($data){ $nData = substr($data,8,2) . "/" .substr($data,5,2) . "/" . substr($data,0,4); return $nData; } function formataHora($hora){ $nHora = substr($hora,0,2) . "h" .substr($hora,3,2) . "min"; return $nHora; } //CONTADORES function countRows($sql){ $count=mysql_num_rows($sql); return $count; } function mostraTotal($sql){ return mysql_num_rows($sql); } function verArray($array){ echo "
";
	echo print_r($array);
	echo "
"; } function uppercase($string) { $string = strtoupper($string); $string = str_replace ("á", "Á", $string); $string = str_replace ("é", "É", $string); $string = str_replace ("í", "Í", $string); $string = str_replace ("ó", "Ó", $string); $string = str_replace ("ú", "Ú", $string); $string = str_replace ("â", "Â", $string); $string = str_replace ("ê", "Ê", $string); $string = str_replace ("ô", "Ô", $string); $string = str_replace ("Î", "I", $string); $string = str_replace ("Û", "U", $string); $string = str_replace ("ã", "Ã", $string); $string = str_replace ("õ", "Õ", $string); $string = str_replace ("ç", "Ç", $string); $string = str_replace ("à", "A", $string); return $string; } ///////////////////////////////////////////////////////////////////////////// //Funções MySQL function PrintQuery($string){ print "
Printing SQL query
String: ".$string."
"; } function SQLError($error){ print "
SQL ERROR!
Details:".$error."
"; } function Select($string,$execute=true){ $query = mysql_query($string); if(!$execute){ PrintQuery($string); } else{ return $query; } if(mysql_error()) SQLError(mysql_error()); } /* function Select($string,$execute=true){ $query = mysql_query($string); if(!$execute) PrintQuery($string); else{ if($query){ $num = mysql_num_rows($query); if($num > 0){ for($i=0; $i<$num; $i++){ $valor[$i] = mysql_fetch_array($query); } return $valor; } } } if(mysql_error()) SQLError(mysql_error()); } */ function Insert($tabela,$campos,$valores,$execute=true){ $string = "INSERT INTO ".$tabela." (".$campos.") VALUES (".$valores.")"; if(!$execute) PrintQuery($string); else $query = mysql_query($string); if(mysql_error()) SQLError(mysql_error()); else return $query; } function Update($tabela,$condicao,$execute=true){ $string = "UPDATE ".$tabela." SET ".$condicao; if(!$execute) PrintQuery($string); else $query = mysql_query($string); if(mysql_error()) SQLError(mysql_error()); else return $query; } function Delete($tabela,$condicao,$execute=true){ $string = "DELETE FROM ".$tabela." WHERE ".$condicao; if(!$execute) PrintQuery($string); else $query = mysql_query($string); if(mysql_error()) SQLError(mysql_error()); else return $query; } function Optimize($tabela){ $query = mysql_query("OPTIMIZE TABLE ".$tabela); if($query==true){ return $query; } if(mysql_error()) SQLError(mysql_error()); else return $query; } ///////////////////////////////////////////////////////////////////////////// //VERIFICA O TOTAL DE FOTOS ANEXAS function totalFotosNoticia($id){ $rs = Select("SELECT id_foto FROM fotos_noticias WHERE id_noticia = '".$id."'"); if(countRows($rs)) return true; else return false; } function totalFotosEvento($id){ $rs = Select("SELECT id_foto FROM fotos_eventos WHERE id_evento = '".$id."'"); if(countRows($rs)) return true; else return false; } function totalFotosArtigos($id){ $rs = Select("SELECT id_foto FROM fotos_artigos WHERE id_artigo = '".$id."'"); if(countRows($rs)) return true; else return false; } function totalFotosPortfolios($id){ $rs = Select("SELECT id_foto FROM fotos_portfolios WHERE id_portfolio = '".$id."'"); if(countRows($rs)) return true; else return false; } function mostraCategoria($id){ $cmdSQL = mysql_query("SELECT nome_categoria FROM categorias WHERE id_categoria='$id'") or die ("Erro buscando nome da categoria. ".mysql_error()); $rs = mysql_fetch_array($cmdSQL); return $rs['nome_categoria']; } ?>