= '2') { return true; } else { return false; } } function UrlAtual(){ $dominio= $_SERVER['HTTP_HOST']; $url = "http://" . $dominio. $_SERVER['REQUEST_URI']; return $url; } function diasemanaDigito($data, $slug="-") { $data = explode($slug , $data); $dia = $data[0]; $mes = $data[1]; $ano = $data[2]; $diasemana = date("w", mktime(0,0,0,$mes,$dia,$ano)); return $diasemana; } function resize($original, $newx, $newy, $resized) { $backup = $resized.'_BAK.JPG'; // NAME OF BACKUP copy ($original, $backup); // COPY SOURCE TO BACKUP $properties = getimagesize($backup); // GET IMAGE PROPERTIES if($properties[2] != '2') { // IF THE IMAGE IS NOT A .JPG return(0); // RETURN ERROR } else { $source = imagecreatefromjpeg($backup); // CREATE IMAGE IDENTIFIER $sourcex = imagesx($source); // GET WIDTH $sourcey = imagesy($source); // GET HEIGHT $destination = imagecreatetruecolor($newx, $newy); // CREATE A NEW TRUE COLOR IMAGE unlink($backup); // DELETE BACKUP FILE if(!imagecopyresampled($destination, $source, 0, 0, 0, 0, $newx, $newy, $sourcex, $sourcey)) { imagedestroy($source); // FREE MEMORY FROM $source imagedestroy($destination); // FREE MEMORY FROM $destination return(0); // RETURN ERROR } else { imagedestroy($source); if(imagejpeg($destination, $resized)) { // CREATE RESIZED IMAGE imagedestroy($destination); return(1); // RETURN SUCCESS } imagedestroy($destination); } return(0); } } ##################################################################################################### ##################### FUN��O REDIMENCIONAR 1 IMAGEM ############################################################## function Send_Resize($foto, $dir_temp, $dir_img, $img_size){ // generate icode $icode = substr(time().rand(10000,99999),-15); // copy image to temp folder $tempname = './'.$dir_temp . $icode.'-TEMP.JPG'; copy($foto, $tempname); unlink($foto); // get iamge properties $properties = getimagesize($tempname); if($properties[2] == 2) { // if the image is a .jpg $source = imagecreatefromjpeg($tempname); // create image identifier $imagex = imagesx($source); $imagey = imagesy($source); // copy image to images folder $imagename = $icode.'-IMG.JPG'; // this will be stored in db $image_loc = $dir_img . $imagename; copy($tempname, $image_loc); unlink($tempname); // resize the image if neccessary if($imagex > $img_size) { $newy = round(($img_size * $imagey) / $imagex); $_SESSION["RESIZE"] = resize($image_loc, $img_size, $newy, $image_loc); } } $_SESSION["IMG"] = $imagename; return(0); } ####################FUNCAO PARA GERAR E REDIMENSDIONAR THUMB E IMAGEM############################## function Send_ResizeIT($foto, $dir_temp, $dir_img, $dir_tmb, $img_size, $x_tmb, $y_tmb){ // generate icode $icode = substr(time().rand(10000,99999),-15); // copy image to temp folder $tempname = './'.$dir_temp . $icode.'-TEMP.JPG'; copy($foto, $tempname); unlink($foto); // get iamge properties $properties = getimagesize($tempname); if($properties[2] == 2) { // if the image is a .jpg $source = imagecreatefromjpeg($tempname); // create image identifier $imagex = imagesx($source); $imagey = imagesy($source); // copy image to images folder $imagename = $icode.'-IMG.JPG'; // this will be stored in db $image_loc = $dir_img . $imagename; copy($tempname, $image_loc); unlink($tempname); // resize the image if neccessary if($imagex > $img_size) { $newy = round(($img_size * $imagey) / $imagex); resize($image_loc, $img_size, $newy, $image_loc); } // create thumbnail $thumbname = $icode.'-TMB.JPG'; // this will be stored in db $thumb_loc = $dir_tmb . $thumbname; $thumbx = $x_tmb; $thumby = round(($imagey * $thumbx) / $imagex); if($thumby > $y_tmb) { $thumbx = round(($thumbx * $y_tmb) / $thumby); $thumby = $y_tmb; } $_SESSION["RESIZE"] = resize($image_loc, $thumbx, $thumby, $thumb_loc); } $_SESSION["IMG"] = $imagename; $_SESSION["TMB"] = $thumbname; return(0); } ############### DIFEREN�A ENTRE DUAS DATAS ########################## #### EXEMPLO: DataDif( "10/10/2008", "11/10/2008", "d") ##### #### � a diferenca de dias entre as duas datas ##### ############################################################## function DataDif($Data1, $Data2, $Intervalo){ switch($Intervalo){ case 'm' : $Q = 2592000; break; //mes case 'd' : $Q = 86400; break; //dia case 'h' : $Q = 3600; break; //hora case 'n' : $Q = 60; break; //minuto default : $Q = 1; break; //segundo } return round ((strtotime($Data2) - strtotime($Data1)) / $Q); } ############### VALOR POR EXTENSO ################################# #### EXEMPLO: valorPorExtenso( "100,00" ) ##### #### retorna cem reais ##### ############################################################## function valorPorExtenso($valor=0) { $singular = array("centavo", "real", "mil", "milh�o", "bilh�o", "trilh�o", "quatrilh�o"); $plural = array("centavos", "reais", "mil", "milh�es", "bilh�es", "trilh�es", "quatrilh�es"); $c = array("", "cem", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"); $d = array("", "dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"); $d10 = array("dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezesete", "dezoito", "dezenove"); $u = array("", "um", "dois", "tr�s", "quatro", "cinco", "seis", "sete", "oito", "nove"); $z=0; $valor = number_format($valor, 2, ".", "."); $inteiro = explode(".", $valor); for($i=0;$i 0 ? 1 : 2); for ($i=0;$i 100) && ($valor < 200)) ? "cento" : $c[$valor[0]]; $rd = ($valor[1] < 2) ? "" : $d[$valor[1]]; $ru = ($valor > 0) ? (($valor[1] == 1) ? $d10[$valor[2]] : $u[$valor[2]]) : ""; $r = $rc.(($rc && ($rd || $ru)) ? " e " : "").$rd.(($rd && $ru) ? " e " : "").$ru; $t = count($inteiro)-1-$i; $r .= $r ? " ".($valor > 1 ? $plural[$t] : $singular[$t]) : ""; if ($valor == "000")$z++; elseif ($z > 0) $z--; if (($t==1) && ($z>0) && ($inteiro[0] > 0)) $r .= (($z>1) ? " de " : "").$plural[$t]; if ($r) $rt = $rt . ((($i > 0) && ($i <= $fim) && ($inteiro[0] > 0) && ($z < 1)) ? ( ($i < $fim) ? ", " : " e ") : " ") . $r; } return($rt ? $rt : "zero"); } ############### FORMATA DATA ##################################### ## Utiliza��o: ## ## formataData($datetime, $formato, $horaEx); ## ## $datatime: data que sera convertida; ## ## $formato: �en� ou �br�; ## ## $horaEX : 1 para imprimir a hora e 0 para n�o imprimir; ## ## ## ## Se eu quero retirar uma data do meu banco de dados que vem no formato 2007-07-26 11:21:45 e ## ## quero imprimi-la no formato portugu�s basta chamar a fun��o: ## ## ## ## formataData($datadobanco, �br�, 0); ## ## ## ## Ou se eu tenho uma data no formato nacional como 26/07/2006 e quero adiciona-la no banco, ## ## uso os seguintes parametros: ## ## ## ## formataData($datanacional, �en�, 0); ## ##################### ######################################### function formataData($datetime, $formato, $horaEx) { if($formato == "en") { $separa = explode(" ",$datetime); $data = explode("/",$separa[0]); $hora = explode(":",$separa[1]); $dataExt = $data[2]."-".$data[1]."-".$data[0]; if($horaEx == 1) $dataExt .= " at ".$hora[0]."h".$hora[1]; } else { $separa = explode(" ",$datetime); $data = explode("-",$separa[0]); @$hora = explode(":",$separa[1]); $dataExt = $data[2]."/".$data[1]."/".$data[0]; if($horaEx == 1) $dataExt .= " �s ".$hora[0]."h".$hora[1]; } return $dataExt; } ############### ARRAY COM O NOME DOS MESES########################## #### EXEMPLO ##### #### ValidaHora($hora) ##### ############################################################## function ValidaHora($horario) { $horaminuto = explode(":", $horario); if (($horaminuto[0] < 0) || ($horaminuto[0] >24)) { return false; } if (($horaminuto[1] < 0) || ($horaminuto[1] >59)) { return false; } } ############### ARRAY COM O NOME DOS MESES########################## #### EXEMPLO ##### #### $MM['1'] = JANEIRO ##### ############################################################## $MM = array(1 => 'Jan', 2 => 'Fev', 3 => 'Mar', 4 => 'Abr', 5 => 'Mai', 6 => 'Jun', 7 => 'Jul', 8 => 'Ago', 9 => 'Set', 10 => 'Out', 11 => 'Nov', 12 => 'Dez'); $DS = array(0 => 'Domingo', 1 => 'Segunda-Feira', 2 => 'Terça-Feira', 3 => 'Quarta-Feira', 4 => 'Quinta-Feira', 5 => 'Sexta-Feira', 6 => 'Sábado'); $SMN = array("Sun" => "Domingo", "Mon" => "Segunda-feira", "Tue" => "Ter�a-feira", "Wed" => "Quarta-feira", "Thu" => "Quinta-feira", "Fri" => "Sexta-feira", "Sat" => "S�bado"); /* Dias da Semana. */ ############### CRIA SELECT COM ID E NOME ########################## # EXEMPLO /* */ # OBS select com 2 posicoes ID E DESCRITIVO ############################################################## function Create_Select($sql, $lTXTSlcName, $lVlrSLC){ $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $option = "