include ("config.php"); date_default_timezone_set("America/Sao_Paulo"); function By2M($size){ $filesizename = array(" MB"); return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes'; } function formatCPFCNPJ ($string) { $output = preg_replace("[' '-./ t]", '', $string); $size = (strlen($output) -2); if ($size != 9 && $size != 12) return false; $mask = ($size == 9) ? '###.###.###-##' : '##.###.###/####-##'; $index = -1; for ($i=0; $i < strlen($mask); $i++): if ($mask[$i]=='#') $mask[$i] = $output[++$index]; endfor; return $mask; } function geraTimestamp($data) { $partes = explode('/', $data); return mktime(0, 0, 0, $partes[1], $partes[0], $partes[2]); } function limpaCPF_CNPJ($valor){ $valor = trim($valor); $valor = str_replace(".", "", $valor); $valor = str_replace(",", "", $valor); $valor = str_replace("-", "", $valor); $valor = str_replace("/", "", $valor); return $valor; } function removerAcento($str){ $from = ''; $to = 'AAAAEEIOOOUUCaaaaeeiooouuc'; return strtr($str, $from, $to); } function anti_injection($sql){ $sql = preg_replace("/( from |select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/", "" ,$sql); $sql = trim($sql); $sql = strip_tags($sql); $sql = (get_magic_quotes_gpc()) ? $sql : addslashes($sql); return $sql; } function gdcode($string) { $co = (base64_decode(strrev(base64_decode($string)))); return $co; } function gcode($string) { $co = trim(strip_tags(base64_encode(strrev(base64_encode($string))))); return $co; } function dtBanco($data) { $data = trim($data); if (strlen($data) != 10) { $rs = ""; } else { $arr_data = explode("/",$data); $data_banco = $arr_data[2]."-".$arr_data[1]."-".$arr_data[0]; $rs = $data_banco; } return $rs; } function dtPadrao($data) { $data = trim($data); if (strlen($data) < 10) { $rs = ""; } else { $arr_data = explode(" ",$data); $data_db = $arr_data[0]; $arr_data = explode("-",$data_db); $data_form = $arr_data[2]."/".$arr_data[1]."/".$arr_data[0]; $rs = $data_form; } return $rs; } function addMes($date,$days) { $thisyear = substr ( $date, 0, 4 ); $thismonth = substr ( $date, 4, 2 ); $thisday = substr ( $date, 6, 2 ); $nextdate = mktime ( 0, 0, 0, $thismonth + $days, $thisday, $thisyear ); return strftime("%Y%m%d", $nextdate); } function createUniqName($fileName, $path) { $path = "$path"; $uniq = 1; $name = substr($fileName, 0, strrpos($fileName, '.')); $extension = substr($fileName, strrpos($fileName, '.')+1); if(file_exists($path.'/'.$fileName)){ $unico=0; while ($unico==0) { if (file_exists($path.'/'.$name.'_'.$uniq.'.'.$extension)) { $uniq++; } else{ $unico=1; } } return ($name.'_'.$uniq.'.'.$extension); } else{ return ($fileName); } } ?>
Saiba como podemos ajudar sua empresa
Conheça nossas soluções empresariais e residenciais
Clique o botão abaixo para entrar em contato