retorna_mes($ex[1])." de ".$ex[0]; } public function convdata4($data) { $ex=explode("-",$data); $dia_semana=$this->retorna_dia_semana(date('w',strtotime($data))); return $ex[2]." ".substr($this->retorna_mes($ex[1]),0,3)." ".$dia_semana; } public function convdiasql($dia) { if($dia<10){ return "0".$dia; }else{ return $dia; } } public function convdatahora($data) { $ex=explode(" ",$data); $ex2=explode("-",$ex[0]); return ''.$ex2[2]."/".$ex2[1]."/".$ex2[0].' às '.$ex[1].''; } public function convdatahora2($data) { $ex=explode(" ",$data); $ex2=explode("-",$ex[0]); return $ex2[2]."/".$ex2[1]."/".$ex2[0]."
".$ex[1]; } public function data_para_mysql($data) { $t=explode("/",$data); $ANO=$t[2]; $MES=$t[1]; $DIA=$t[0]; return $ANO."-".$MES."-".$DIA; } public function convhora($data) { $ex=explode(":",$data); return $ex[0].":".$ex[1]; } public function hora_para_mysql($hora) { $t=explode(":",$hora); $HORA=$t[0]; $MIN=$t[1]; $SEG="00"; return $HORA.":".$MIN.":".$SEG; } public function str_para_html($texto) { $tmp=str_replace("\r\n","\n",$texto); $tmp=str_replace("\n","
",$tmp); $tmp=str_replace("`","'",$tmp); $tmp=str_replace("“","\"",$tmp); $tmp=str_replace("”","\"",$tmp); return $tmp; } public function limitar($texto,$limite){ if(strlen($texto)>$limite){ return substr($texto,0,$limite)."..."; }else{ return $texto; } return $tmp; } public function enviar_email($para_nome,$para_email,$de_nome,$assunto,$conteudo,$template){ if(!file_exists("templates_email/$template") AND !empty($template)){ $body=file_get_contents("templates_email/$template",true); $body=str_replace("{TEXTO}",$this->str_para_html($conteudo),$body); }else{ $body=$conteudo; } if(Config::$cfg_tipo_de_envio=="mail"){ $headers .= "From: ".utf8_decode($de_nome)." <".Config::$email_remetente.">\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; //$headers .= "Return-Path: <$email_remetente>\n"; mail($para_email, utf8_decode($assunto), utf8_decode($body), $headers); } if(Config::$cfg_tipo_de_envio=="smtp"){ require_once('phpmailer/class.phpmailer.php'); require_once("phpmailer/class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // chamar class SMTP $mail->Host = Config::$cfg_smtp_servidor; // SMTP server $mail->SMTPDebug = 0; // Ativar debug SMTP // 1 = erros e mensagens // 2 = mensagens apenas $mail->SMTPSecure = Config::$cfg_smtp_secure; $mail->SMTPAuth = Config::$cfg_smtp_autenticacao; // ativar autenticação SMTP $mail->Host = Config::$cfg_smtp_servidor; // Host $mail->Port = Config::$cfg_smtp_porta; // Porta $mail->Username = Config::$cfg_smtp_usuario; // SMTP usuario $mail->Password = Config::$cfg_smtp_senha; //SMTP senha $mail->SetFrom(Config::$email_remetente, $de_nome); $mail->AddReplyTo(Config::$email_remetente,Config::$nome_remetente); $mail->Subject = '=?UTF-8?B?'.base64_encode($assunto).'?='; $mail->AltBody = ""; $mail->Body = "$body"; //$mail->MsgHTML($body); $address = $para_email; $mail->AddAddress($address, $para_nome); //$mail->AddAttachment("images/phpmailer.gif"); // anexo //$mail->AddAttachment("images/phpmailer_mini.gif"); // anexo if(!$mail->Send()) { //echo "Mailer Error: " . $mail->ErrorInfo; return false; } else { //echo "Mensagen enviada!"; return true; } } } public function enviar_email_html($para_nome,$para_email,$de_nome,$assunto,$conteudo,$template){ if(!file_exists("templates_email/$template") AND !empty($template)){ $body=file_get_contents("templates_email/$template",true); $body=str_replace("{TEXTO}",$this->str_para_html($conteudo),$body); }else{ $body=$conteudo; } if(Config::$cfg_tipo_de_envio=="mail"){ $headers .= "From: ".utf8_decode($de_nome)." <".Config::$email_remetente.">\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; //$headers .= "Return-Path: <$email_remetente>\n"; mail($para_email, utf8_decode($assunto), utf8_decode($body), $headers); } if(Config::$cfg_tipo_de_envio=="smtp"){ require_once('phpmailer/class.phpmailer.php'); require_once("phpmailer/class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // chamar class SMTP $mail->Host = Config::$cfg_smtp_servidor; // SMTP server $mail->SMTPDebug = 0; // Ativar debug SMTP // 1 = erros e mensagens // 2 = mensagens apenas $mail->SMTPSecure = Config::$cfg_smtp_secure; $mail->SMTPAuth = Config::$cfg_smtp_autenticacao; // ativar autenticação SMTP $mail->Host = Config::$cfg_smtp_servidor; // Host $mail->Port = Config::$cfg_smtp_porta; // Porta $mail->Username = Config::$cfg_smtp_usuario; // SMTP usuario $mail->Password = Config::$cfg_smtp_senha; //SMTP senha $mail->SetFrom(Config::$email_remetente, $de_nome); $mail->AddReplyTo(Config::$email_remetente,Config::$nome_remetente); $mail->Subject = '=?UTF-8?B?'.base64_encode($assunto).'?='; $mail->AltBody = ""; //$mail->Body = "$body"; $mail->MsgHTML($body); $address = $para_email; $mail->AddAddress($address, $para_nome); //$mail->AddAttachment("images/phpmailer.gif"); // anexo //$mail->AddAttachment("images/phpmailer_mini.gif"); // anexo if(!$mail->Send()) { //echo "Mailer Error: " . $mail->ErrorInfo; return false; } else { //echo "Mensagen enviada!"; return true; } } } public function moeda($valor){ $tmp=number_format($valor, 2, ',', '.'); return $tmp; } public function moeda2($valor){ $tmp=number_format($valor, 1, '', ''); return $tmp; } public function float_number ($number , $decimals = 2 , $dec_point = '.' , $sep = ',', $group=3 ){ $num = sprintf("%0.{$decimals}f",$number); $num = explode('.',$num); while (strlen($num[0]) % $group) $num[0]= ' '.$num[0]; $num[0] = str_split($num[0],$group); $num[0] = join($sep[0],$num[0]); $num[0] = trim($num[0]); $num = join($dec_point[0],$num); return $num; } public function filtra_site($valor){ $tmp=str_replace("http://","",$valor); return $tmp; } public function retorna_mes($num){ switch ($num) { case 1: $ret="Janeiro"; break; case 2: $ret="Fevereiro"; break; case 3: $ret="Março"; break; case 4: $ret="Abril"; break; case 5: $ret="Maio"; break; case 6: $ret="Junho"; break; case 7: $ret="Julho"; break; case 8: $ret="Agosto"; break; case 9: $ret="Setembro"; break; case 10: $ret="Outubro"; break; case 11: $ret="Novembro"; break; case 12: $ret="Dezembro"; break; } return $ret; } public function retorna_dia_semana($num){ switch ($num) { case 0: $ret="domingo"; break; case 1: $ret="segunda-feira"; break; case 2: $ret="terça-feira"; break; case 3: $ret="quarta-feira"; break; case 4: $ret="quinta-feira"; break; case 5: $ret="sexta-feira"; break; case 6: $ret="sábado"; break; } return $ret; } public function cropar_imagem_jpg($arq,$tb_w,$tb_h,$x,$y,$w,$h,$path_final){ //$x=411; //START X //$y=21; //START Y //$w=83; //LARGURA CROP //$h=83; //ALTURA CROP //$tb_w=45; //LARGURA DO THUMB //$tb_h=45; //ALTURA DO THUMB //$arq="imagem.jpg"; //ARQUIVO //$path_final="imagem_cropada.jpg"; //Saida Final $cropW = $w; $cropH = $h; $origimg = imagecreatefromjpeg($arq); //Gerar THUMB SEM CROP/////// if(empty($cropW) OR empty($cropH)){ $cropW=imagesx($origimg); $cropH=imagesy($origimg); $x=0; $y=0; } $w_real= imagesx($origimg); $h_real= imagesy($origimg); if($tb_h==0){ $tb_h=($h_real*$tb_w)/$w_real; } if($tb_w==0){ $tb_w=($w_real*$tb_h)/$h_real; } ////////////////////////////// $cropimg = imagecreatetruecolor($cropW,$cropH); $cropStartX = $x; $cropStartY = $y; list($width, $height) = getimagesize($arq); imagecopyresampled($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height); $cropimg2=imagecreatetruecolor($tb_w,$tb_h); imagecopyresampled($cropimg2, $cropimg, 0, 0, 0, 0, $tb_w, $tb_h, $cropW, $cropH); return imagejpeg($cropimg2,$path_final,90); } public function cropar_imagem_png($arq,$tb_w,$tb_h,$x,$y,$w,$h,$path_final){ //$x=411; //START X //$y=21; //START Y //$w=83; //LARGURA CROP //$h=83; //ALTURA CROP //$tb_w=45; //LARGURA DO THUMB //$tb_h=45; //ALTURA DO THUMB //$arq="imagem.jpg"; //ARQUIVO //$path_final="imagem_cropada.jpg"; //Saida Final $cropW = $w; $cropH = $h; $origimg = imagecreatefrompng($arq); //Gerar THUMB SEM CROP/////// if(empty($cropW) OR empty($cropH)){ $cropW=imagesx($origimg); $cropH=imagesy($origimg); $x=0; $y=0; } $w_real= imagesx($origimg); $h_real= imagesy($origimg); if($tb_h==0){ $tb_h=($h_real*$tb_w)/$w_real; } if($tb_w==0){ $tb_w=($w_real*$tb_h)/$h_real; } ////////////////////////////// $cropimg = imagecreatetruecolor($cropW,$cropH); $white = imagecolorallocate($cropimg, 255, 255, 255); imagefill($cropimg,0,0,$white); $cropStartX = $x; $cropStartY = $y; list($width, $height) = getimagesize($arq); imagecopyresampled($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height); $cropimg2=imagecreatetruecolor($tb_w,$tb_h); imagecopyresampled($cropimg2, $cropimg, 0, 0, 0, 0, $tb_w, $tb_h, $cropW, $cropH); return imagejpeg($cropimg2,$path_final,90); } public function cropar_imagem_gif($arq,$tb_w,$tb_h,$x,$y,$w,$h,$path_final){ //$x=411; //START X //$y=21; //START Y //$w=83; //LARGURA CROP //$h=83; //ALTURA CROP //$tb_w=45; //LARGURA DO THUMB //$tb_h=45; //ALTURA DO THUMB //$arq="imagem.jpg"; //ARQUIVO //$path_final="imagem_cropada.jpg"; //Saida Final $cropW = $w; $cropH = $h; $origimg = imagecreatefromgif($arq); //Gerar THUMB SEM CROP/////// if(empty($cropW) OR empty($cropH)){ $cropW=imagesx($origimg); $cropH=imagesy($origimg); $x=0; $y=0; } $w_real= imagesx($origimg); $h_real= imagesy($origimg); if($tb_h==0){ $tb_h=($h_real*$tb_w)/$w_real; } if($tb_w==0){ $tb_w=($w_real*$tb_h)/$h_real; } $cropimg = imagecreatetruecolor($cropW,$cropH); $white = imagecolorallocate($cropimg, 255, 255, 255); imagefill($cropimg,0,0,$white); $cropStartX = $x; $cropStartY = $y; list($width, $height) = getimagesize($arq); imagecopyresampled($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height); $cropimg2=imagecreatetruecolor($tb_w,$tb_h); imagecopyresampled($cropimg2, $cropimg, 0, 0, 0, 0, $tb_w, $tb_h, $cropW, $cropH); return imagejpeg($cropimg2,$path_final,90); } public function cropar_imagem($url,$img_path,$width,$height,$x=0,$y=0,$w=0,$h=0){ $img=getimagesize($url); if(($img['mime']=="image/jpeg" OR $img['mime']=="image/png" OR $img['mime']=="image/gif") AND ($img[0]>10 AND $img[1]>10) ){ switch($img['mime']){ case "image/jpeg": $this->cropar_imagem_jpg($url,$width,$height,$x,$y,$w,$h,$img_path); break; case "image/png": $this->cropar_imagem_png($url,$width,$height,$x,$y,$w,$h,$img_path); break; case "image/gif": $this->cropar_imagem_gif($url,$width,$height,$x,$y,$w,$h,$img_path); break; } return true; }else{ return false; } } public function buscar_extensao($nome){ $nome_tmp=explode(".",$nome); $total=count($nome_tmp); return $nome_tmp[$total-1]; } public function url($valor){ $saida=utils::limpar_url($valor); $saida=urlencode($saida); $saida=str_ireplace("%20","-",$saida); $saida=str_ireplace("%3A","_",$saida); $saida=str_ireplace("%2C","_",$saida); $saida=str_ireplace(" ","-",$saida); $saida=str_ireplace("?","",$saida); $saida=str_ireplace("+","-",$saida); $saida=str_ireplace("\"","",$saida); return $saida; } public function limpar_url($str, $enc = 'UTF-8'){ $acentos = array( 'A' => '/À|Á|Â|Ã|Ä|Å/', 'a' => '/à|á|â|ã|ä|å/', 'C' => '/Ç/', 'c' => '/ç/', 'E' => '/È|É|Ê|Ë/', 'e' => '/è|é|ê|ë/', 'I' => '/Ì|Í|Î|Ï/', 'i' => '/ì|í|î|ï/', 'N' => '/Ñ/', 'n' => '/ñ/', 'O' => '/Ò|Ó|Ô|Õ|Ö/', 'o' => '/ò|ó|ô|õ|ö/', 'U' => '/Ù|Ú|Û|Ü/', 'u' => '/ù|ú|û|ü/', 'Y' => '/Ý/', 'y' => '/ý|ÿ/', 'a.' => '/ª/', 'o.' => '/º/' ); $saida=preg_replace($acentos, array_keys($acentos), htmlentities($str,ENT_NOQUOTES, $enc)); $saida=str_replace("\\","-",$saida); $saida=str_replace("/","-",$saida); $saida=str_replace(" ","-",$saida); $saida=str_replace("#","",$saida); $saida=str_replace("!","",$saida); $saida=str_replace("%","",$saida); $saida=str_replace("^","",$saida); $saida=str_replace("&","",$saida); $saida=str_replace("(","",$saida); $saida=str_replace(")","",$saida); $saida=str_replace("}","",$saida); $saida=str_replace("|","",$saida); $saida=str_replace("?","",$saida); $saida=str_replace("'","",$saida); $saida=str_replace("\"","",$saida); $saida=str_replace(":","",$saida); $saida=str_replace(";","",$saida); return $saida; } public function retornar_total_paginas($total_reg,$total_por_pag){ $total_paginas=ceil($total_reg/$total_por_pag); if($total_paginas<1){ return 1; }else{ return $total_paginas; } } public function sim_nao($valor){ if($valor==1){ return "Sim"; }else{ return "Não"; } } public function primeiro_nome($data) { $ex=explode(" ",$data); return $ex[0]; } public function csv($res,$res2) { $row = bd::fetch_array($res); $line = ""; $comma = ""; $num=0; $num_nao=""; foreach($row as $name => $value) { $num=$num+1; if($name=="deletado"){ $num_nao=$num; }else{ $line .= $comma . '"' . str_replace('"', '""', $name) . '"'; $comma = ";"; } } $line .= "\n"; //bd::data_seek($res, 0); while($row = bd::fetch_array($res2)) { $comma = ""; $num=0; foreach($row as $value) { $num=$num+1; if($num!=$num_nao){ $data=str_replace(";","-",$value); $line .= $comma . '"' . str_replace('"', '""', utf8_decode($data)) . '"'; $comma = ";"; } } $line .= "\n"; } echo $line; } } ?>