Home Files
Adminer
Execute Command
PHP Eval
Symlink
File Upload
Owner :
www-data
PHP Version
8.1.8
Disk Space
203.89 GB
Server Addr
171.9.3.2
Your IP
171.9.3.1
Edit File
File:
<?php class Utilidades { public function retornaGet($var) { return filter_input(INPUT_GET, $var, FILTER_SANITIZE_SPECIAL_CHARS); } public function retornaPost($var) { return filter_input(INPUT_POST, $var, FILTER_SANITIZE_SPECIAL_CHARS); } public function retornaServ($var) { return filter_input(INPUT_SERVER, $var, FILTER_SANITIZE_SPECIAL_CHARS); } public function mask($val, $mask) { $maskared = ''; $k = 0; for ($i = 0; $i <= strlen($mask) - 1; $i++) { if ($mask[$i] == '#') { if (isset($val[$k])) $maskared .= $val[$k++]; } else { if (isset($mask[$i])) $maskared .= $mask[$i]; } } return $maskared; } function ComboBox($valorset, $valorlista, $nomeCombo) { if ($valorset != '') { if ($valorset == $valorlista) : $Selec = "selected='selected'"; else : $Selec = ""; endif; } return "<option " . $Selec . " value='" . $valorlista . "'>" . $nomeCombo . "</option>"; } function verifyCPF($cpf) { $cpf = "$cpf"; if (strpos($cpf, "-") !== false) { $cpf = str_replace("-", "", $cpf); } if (strpos($cpf, ".") !== false) { $cpf = str_replace(".", "", $cpf); } $sum = 0; $cpf = str_split($cpf); $cpftrueverifier = array(); $cpfnumbers = array_splice($cpf, 0, 9); $cpfdefault = array(10, 9, 8, 7, 6, 5, 4, 3, 2); for ($i = 0; $i <= 8; $i++) { $sum += $cpfnumbers[$i] * $cpfdefault[$i]; } $sumresult = $sum % 11; if ($sumresult < 2) { $cpftrueverifier[0] = 0; } else { $cpftrueverifier[0] = 11 - $sumresult; } $sum = 0; $cpfdefault = array(11, 10, 9, 8, 7, 6, 5, 4, 3, 2); $cpfnumbers[9] = $cpftrueverifier[0]; for ($i = 0; $i <= 9; $i++) { $sum += $cpfnumbers[$i] * $cpfdefault[$i]; } $sumresult = $sum % 11; if ($sumresult < 2) { $cpftrueverifier[1] = 0; } else { $cpftrueverifier[1] = 11 - $sumresult; } $returner = false; if ($cpf == $cpftrueverifier) { $returner = true; } $cpfver = array_merge($cpfnumbers, $cpf); if (count(array_unique($cpfver)) == 1 || $cpfver == array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)) { $returner = false; } return $returner; } function verifyCnpj ( $cnpj ) { $cnpj = preg_replace( '/[^0-9]/', '', $cnpj ); $cnpj = (string)$cnpj; $cnpj_original = $cnpj; $primeiros_numeros_cnpj = substr( $cnpj, 0, 12 ); function multiplica_cnpj( $cnpj, $posicao = 5 ) { $calculo = 0; for ( $i = 0; $i < strlen( $cnpj ); $i++ ) { $calculo = $calculo + ( $cnpj[$i] * $posicao ); $posicao--; if ( $posicao < 2 ) { $posicao = 9; } } return $calculo; } $primeiro_calculo = multiplica_cnpj( $primeiros_numeros_cnpj ); $primeiro_digito = ( $primeiro_calculo % 11 ) < 2 ? 0 : 11 - ( $primeiro_calculo % 11 ); $primeiros_numeros_cnpj .= $primeiro_digito; $segundo_calculo = multiplica_cnpj( $primeiros_numeros_cnpj, 6 ); $segundo_digito = ( $segundo_calculo % 11 ) < 2 ? 0 : 11 - ( $segundo_calculo % 11 ); $cnpj = $primeiros_numeros_cnpj . $segundo_digito; if ( $cnpj === $cnpj_original ) { return true; } } function retiraAcentos($nome = '', $espacos = '_') { $text = preg_replace("/[^\w\s]/", "", iconv("UTF-8", "ASCII//TRANSLIT", $nome)); $text = str_replace(" ", $espacos, $text); $text = strtolower($text); return $text; } function convertDataMysql($data) { //AAAA-MM-DD $data = implode('-', array_reverse(explode('/', $data))); return $data; } function MontarLink($texto) { if (!is_string($texto)) return $texto; $er = "/(http(s)?:\/\/(www|.*?\/)?((\.|\/)?[a-zA-Z0-9&%_?=-]+)+)/i"; preg_match_all($er, $texto, $match); foreach ($match[0] as $link) { $link = strtolower($link); $link_len = strlen($link); //troca "&" por "&", tornando o link v�lido pela W3C $web_link = str_replace("&", "&", $link); $texto = str_ireplace($link, "<a href=\"" . $web_link . "\" target=\"_blank\" title=\"" . $web_link . "\" rel=\"nofollow\">" . (($link_len > 60) ? substr($web_link, 0, 25) . "..." . substr($web_link, -15) : $web_link) . "</a>", $texto); } return $texto; } function Criptonita($action, $string) { $output = false; $encrypt_method = "AES-256-CBC"; $secret_key = 'SuperSaiadimx#@$%'; $secret_iv = 'SupostamenteUmaSenhaForte@#$%'; $key = hash('sha256', $secret_key); $iv = substr(hash('sha256', $secret_iv), 0, 16); if( $action == 'en' ) { $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); } else if ( $action == 'de' ){ $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); } return $output; } function mascaraEmail($email){ $mascara = explode("@", $email); $part1Email = $mascara[0]; $part2Email = $mascara[1]; $quantidadeCarac = strlen($part1Email); $inicio = $quantidadeCarac / 4; $inicioString = substr($part1Email, 0, $inicio); $restanteString = str_replace($inicioString, "", $part1Email); $restanteString = preg_replace( "/[^0-9_-]/", "_", $restanteString); $quantidadeCarac2 = strlen($part2Email); $finalParte2 = substr($part2Email, 2, $quantidadeCarac2); $inicioParte2 = str_replace($finalParte2, "", $part2Email); $inicioParte2 = preg_replace( "/[^0-9_-]/", "_", $inicioParte2); $mascaraNova = $inicioString.$restanteString."@".$inicioParte2.$finalParte2; return $mascaraNova; } function quantidadeDias ($DataInf) { $data_inicio = new DateTime($DataInf); $data_fim = new DateTime(date('Y-m-d')); $dateInterval = $data_inicio->diff($data_fim); if ($dateInterval->days == 0) { $dataTempo = "Hoje"; } else if ($dateInterval->days >= 365) { $dataTempo = "Há " . $dateInterval->y . " ano(s)"; } else { $dataTempo = "Há " . $dateInterval->days . " dias"; } return $dataTempo; } function normalizaURL($str){ $str = strtolower(utf8_decode($str)); $i=1; $str = strtr($str, utf8_decode('àáâãäåæçèéêëìíîïñòóôõöøùúûýýÿ'), 'aaaaaaaceeeeiiiinoooooouuuyyy'); $str = preg_replace("/([^a-z0-9])/",'-',utf8_encode($str)); while($i>0) $str = str_replace('--','-',$str,$i); if (substr($str, -1) == '-') $str = substr($str, 0, -1); return $str; } function request_limit(string $key, int $limit = 5, int $seconds = 60): bool { $session = new Session(); if ($session->has($key) && $session->$key->time >= time() && $session->$key->requests < $limit) { $session->set($key, [ "time" => time() + $seconds, "requests" => $session->$key->requests + 1 ]); return false; } if ($session->has($key) && $session->$key->time >= time() && $session->$key->requests >= $limit) { return true; } $session->set($key, [ "time" => time() + $seconds, "requests" => 1 ]); return false; } function romano($integer) { $table = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); $return = ''; while($integer > 0) { foreach($table as $rom=>$arb) { if($integer >= $arb) { $integer -= $arb; $return .= $rom; break; } } } return $return; } function hex2rgba($color, $opacity = false) { $default = '0,0,0'; if(empty($color)) return $default; if ($color[0] == '#' ) { $color = substr( $color, 1 ); } if (strlen($color) == 6) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) == 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } $rgb = array_map('hexdec', $hex); if($opacity){ if(abs($opacity) > 1) $opacity = 1.0; $output = implode(",",$rgb).','.$opacity; } else { $output = implode(",",$rgb); } return $output; } /*function verificaURL($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return ($code == 200); // verifica se recebe "status OK" } */ }