ok

Mini Shell

Direktori : /home/institutonamaste/www/class/
Upload File :
Current File : /home/institutonamaste/www/class/functions.php

<?php
function Meta($titulo, $meta, $key, $link, $img)
{
	$word = '
	<title>'.$titulo.'</title>
	
	<meta charset="utf-8">
	<meta name="robots" 				content="index, follow">
	<meta name="viewport" 				content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">		

	<meta name="description" 			content="'.$meta.'" />
	<meta name="keywords" 				content="'.$key.'" />
	<meta name="author" 				content="Agência Suhet">
	
	<meta property="og:locale" 			content="pt_BR"> 
	<meta property="og:type" 			content="website">
	<meta property="og:url" 			content="'.$link.'"> 
	<meta property="og:title" 			content="'.$titulo.'">
	<meta property="og:site_name" 		content="Instituto Ricardo Melo"> 
	<meta property="og:description" 	content="'.$meta.'"> 
	<meta property="og:image" 			content="'.$img.'">
	<meta property="og:image:type" 		content="image/jpeg">';	
	
	return $word; 	
}

function LinkAlert($link, $text)
{
	echo (!empty($text)) ? "<script type=\"text/javascript\">alert(\"".$text."\");</script>" : "";
	echo (!empty($link)) ? "<META HTTP-EQUIV=REFRESH CONTENT='0; URL=".$link."'>" : "<script language=\"javascript\">parent.history.back(1);</script>";;		
	exit();		
}

function Paginacao($qnt, $p, $link, $where, $table, $ttal = FALSE)
{	
	$sql = DBRead($table, $where);
	$total 	= (!$sql) ? $qnt : mysqli_num_rows($sql);
	
	if($ttal != "")
		$total = $ttal;
	
	$pags 	= ceil($total/$qnt);
	$max_links = 2;
	
	$ini = ($p-1 > 0) ? $p-1 : $p;
	$ind = ($p-1 > 0) ? '' 	 : 'disabled';
	
	$fim = ($p+1 <= $pags) ? $p+1 	: $p;
	$fid = ($p+1 <= $pags) ? '' 	: 'disabled';

	if($total > $qnt)
	{
		$paginacao .= '
		<nav aria-label="..." class="paginacao col-12">
			<ul class="pagination">
				<li class="page-item '.$ind.'">
				  <a class="page-link" href="'.$link.'p='.$ini.'" tabindex="-1" aria-label="Previous"><span aria-hidden="true">&laquo;</span><span class="sr-only">Voltar</span></a>
				</li>';
					
				for($i = $p-$max_links; $i <= $p-1; $i++){
					if($i > 0)
						$paginacao .= '<li class="page-item"><a class="page-link" href="'.$link.'p='.$i.'">'.$i.'</a></li>';
				}
					
				$paginacao .= '<li class="page-item active"><a class="page-link" href="#">'.$p.'<span class="sr-only">(current)</span></a></li>';
					
				for($i = $p+1; $i <= $p+$max_links; $i++){
					if($i <= $pags)
						$paginacao .= '<li class="page-item"><a class="page-link" href="'.$link.'p='.$i.'">'.$i.'</a></li>';
				}
						
				$paginacao .= '			
				<li class="page-item '.$fid.'">
				  <a class="page-link" href="'.$link.'p='.$fim.'" aria-label="Next"><span aria-hidden="true">&raquo;</span><span class="sr-only">Próximo</span></a>
				</li>
			</ul>
		</nav>';
	}
	
	return $paginacao;
}

function Youtube($video, $titulo)
{
	if(!empty($video)){
		return '
		<div class="image">
			<img src="http://i1.ytimg.com/vi/'.$video.'/mqdefault.jpg">
			
			<div class="link">
				<a href="https://www.youtube.com/embed/'.$video.'?rel=0" frameborder="0" data-title="'.$titulo.'" data-toggle="lightbox" data-width="60%" class="fa fa-youtube-play"></a>
			</div>
		</div><!-- image -->';
	}
}

function AddThis()
{
	return '<div class="sharethis-inline-share-buttons share"></div><!-- share -->';
}

function AddFacebookComents($link)
{
	$face = '
	<!-- Add Facebook -->
	<div id="fb-root"></div>
	<script>(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v2.0";
	  fjs.parentNode.insertBefore(js, fjs);'."
	  }(document, 'script', 'facebook-jssdk'));".'
	</script>      
	<div class="fb-comments" data-href="'.$link.'" data-width="100%" data-numposts="5" data-colorscheme="light"></div>'; 
	
	return $face;     
}

function Resumo($texto, $limite)
{	
	$texto = strip_tags($texto);

	$tamanho = strlen($texto);
	if($tamanho <= $limite){
		if(stristr($texto, "</iframe>") == TRUE){
			$newtexto = explode("</iframe>", $texto);
			$novo_texto = $newtexto[1]." ...";
		}else{
			$novo_texto = $texto;	
		}
	}else{
		if(stristr($texto, "</iframe>") == TRUE){
			$newtexto = explode("</iframe>", $texto);
			
			$ultimo_espaco = strrpos(substr($newtexto[1], 0, $limite), " ");
			$novo_texto = trim(substr($newtexto[1], 0, $ultimo_espaco))." ...";;
		}else{
			$ultimo_espaco = strrpos(substr($texto, 0, $limite), " ");
			$novo_texto = trim(substr($texto, 0, $ultimo_espaco))." ...";;
		}
	}
	
	return $novo_texto;
}

function MesMin($mes)
{
	if($mes == 1)
		return 'JAN';
	elseif($mes == 2)
		return 'FEV';	
	elseif($mes == 3)
		return 'MAR';	
	elseif($mes == 4)
		return 'ABR';	
	elseif($mes == 5)
		return 'MAI';
	elseif($mes == 6)
		return 'JUN';	
	elseif($mes == 7)
		return 'JUL';	
	elseif($mes == 8)
		return 'AGO';	
	elseif($mes == 9)
		return 'SET';	
	elseif($mes == 10)
		return 'OUT';	
	elseif($mes == 11)
		return 'NOV';	
	elseif($mes == 12)
		return 'DEZ';					
}

function MesName($mes)
{
	if($mes == 1)
		return 'Janeiro';
	elseif($mes == 2)
		return 'Fevereiro';	
	elseif($mes == 3)
		return 'Março';	
	elseif($mes == 4)
		return 'Abril';	
	elseif($mes == 5)
		return 'Maio';
	elseif($mes == 6)
		return 'Junho';	
	elseif($mes == 7)
		return 'Julho';	
	elseif($mes == 8)
		return 'Agosto';	
	elseif($mes == 9)
		return 'Setembro';	
	elseif($mes == 10)
		return 'Outubro';	
	elseif($mes == 11)
		return 'Novembro';	
	elseif($mes == 12)
		return 'Dezembro';					
}

function ValMailSend($mail, $link = '')
{
	if (!preg_match("/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+.([a-zA-Z]{2,4})$/", $mail) or empty($mail))
		LinkAlert($link, "Informe o e-mail corretamente!");
	else
		return $mail;	
}

function ValidData($data)
{
	list($dia, $mes, $ano) = explode("/", $data);
		
	if(strlen(trim($ano)) == 4)
		return $ano.'-'.$mes.'-'.$dia;
	elseif(strlen(trim($ano)) == 2 && strlen(trim($dia)) == 4)
		return $data;
	else
		LinkAlert('', "Data inválida.");
}
?>

Zerion Mini Shell 1.0