Deprecated: Optional parameter $page declared before required parameter $totalrecords is implicitly treated as a required parameter in /home/demoweb/public_html/bigan/php/PDOModel.php on line 1462
function esEmail($email){
return preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/',$email);
//return preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$email);
}
function mostrarError($error){
global $URL_ROOT,$DOC_ROOT,$idioma,$txt,$seccion,$subseccion;
require_once($DOC_ROOT."site/error.php");
exit();
}
function posicion($array,$key){
return array_search($key,array_keys($array));
}
function anterior($array,$key){
$keys = array_keys($array);
$pos=array_search($key,$keys);
if(isset($keys[$pos-1])) {
return $array[$keys[$pos-1]];
}
return false;
}
function siguiente($array,$key){
$keys = array_keys($array);
$pos=array_search($key,$keys);
if(isset($keys[$pos+1])) {
return $array[$keys[$pos+1]];
}
return false;
}
function esCifNif($cif) {
return true; //Descativar la comprobación, para permitir DNI extránjeros.
$cif = strtoupper($cif);
if (!ereg('((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)', $cif)) return false;
for ($i = 0; $i < 9; $i ++) $num[$i] = substr($cif, $i, 1);
//comprobacion de NIFs estandar
if (ereg('(^[0-9]{8}[A-Z]{1}$)', $cif))
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($cif, 0, 8) % 23, 1)) return true;
else return false;
//algoritmo para comprobacion de codigos tipo CIF
$suma = $num[2] + $num[4] + $num[6];
for ($i = 1; $i < 8; $i += 2) $suma += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1);
$n = 10 - substr($suma, strlen($suma) - 1, 1);
//comprobacion de NIFs especiales (se calculan como CIFs)
if (ereg('^[KLM]{1}', $cif))
if ($num[8] == chr(64 + $n)) return true;
else return false;
//comprobacion de CIFs
if (ereg('^[ABCDEFGHJNPQRSUVW]{1}', $cif))
if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) return true;
else return false;
//comprobacion de NIEs (extranjeros) con T
if (ereg('^[T]{1}', $cif))
if ($num[8] == ereg('^[T]{1}[A-Z0-9]{8}$', $cif)) return true;
else return false;
//comprobacion de NIEs (extranjeros) con XYZ
if (ereg('^[XYZ]{1}', $cif))
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $cif), 0, 8) % 23, 1)) return true;
else return false;
return false;
}
function encode_email($string){
$encoded = "";
for ($n=0;$n $max)
{
$string = wordwrap($string, $max);
$string = substr($string, 0, strpos($string, "\n"));
$string.= '...';
}
return $string;
}
function formatSizeUnits($bytes) {
if ($bytes >= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
}
elseif ($bytes >= 1024)
{
$bytes = number_format($bytes / 1024, 2) . ' KB';
}
elseif ($bytes > 1)
{
$bytes = $bytes . ' bytes';
}
elseif ($bytes == 1)
{
$bytes = $bytes . ' byte';
}
else
{
$bytes = '0 bytes';
}
return $bytes;
}
function getLastPathSegment($url) {
$path = parse_url($url, PHP_URL_PATH); // to get the path from a whole URL
$pathTrimmed = trim($path, '/'); // normalise with no leading or trailing slash
$pathTokens = explode('/', $pathTrimmed); // get segments delimited by a slash
if (substr($path, -1) !== '/') {
array_pop($pathTokens);
}
return end($pathTokens); // get the last segment
}
function fecha_lng($date,$lng) {
if ($lng=="es" or $lng=="ca") {
$dia = explode("-", $date, 3);
$year = $dia[0];
$month = (string)(int)$dia[1];
$day = (string)(int)$dia[2];
return $day."/".$month."/".$year;
} else {
return $year."/".$month."/".$day;
}
}
function fecha_mes($mes,$lng) {
$mes = intval($mes);
switch ($lng) {
case 'ca':
$mesesN=array(1=>"Gener","Febrer","Març","Abril","Maig","Juny","Juliol",
"Agost","Setembre","Octubre","Novembre","Desembre");
break;
case 'es':
$mesesN=array(1=>"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio",
"Agosto","Septiembre","Octubre","Noviembre","Diciembre");
break;
case 'en':
$mesesN=array(1=>"January","February","March","April","May","June","July",
"August","September","October","November","December");
break;
}
return $mesesN[$mes];
}
// Originally found here: http://blog.maverickgroups.com/php/parse-youtube-url-to-get-video-id-thumbnail-image-or-embed-code/
// Modified for use in WordPress
/*
* parse_youtube_url() PHP function
* @param string $url URL to be parsed, eg:
* http://youtu.be/BLxI_1iKYgc,
* http://www.youtube.com/embed/BLxI_1iKYgc
* http://www.youtube.com/watch?v=BLxI_1iKYgc
* @param string $return what to return
* - embed, return embed code
* - thumb, return URL to thumbnail image
* - hqthumb, return URL to high quality thumbnail image.
* @param string $width width of embeded video, default 560
* @param string $height height of embeded video, default 349
* @param string $rel whether embeded video to
show related video after play or not.
* How to Use...
* // return thumb image
echo parse_youtube_url('http://youtu.be/ML2KAaR26Pk','mqthumb');
* // return embed url
echo parse_youtube_url('http://www.youtube.com/watch?v=ML2KAaR26Pk','embedurl');
*/
function parse_youtube_url($url,$return='embed',$width='',$height='',$rel=0){
$urls = parse_url($url);
// url is http://youtu.be/abcd
if($urls['host'] == 'youtu.be'){
$id = ltrim($urls['path'],'/');
}
// url is http://www.youtube.com/embed/abcd
else if(strpos($urls['path'],'embed') == 1){
$id = end(explode('/',$urls['path']));
}
// url is xxxx only
else if(strpos($url,'/')===false){
$id = $url;
}
// http://www.youtube.com/watch?feature=player_embedded&v=ML2KAaR26Pk
// url is http://www.youtube.com/watch?v=ML2KAaR26Pk
else{
parse_str($urls['query']);
$id = $v;
if(!empty($feature)){
$id = end(explode('v=',$urls['query']));
}
}
// return embed iframe
if($return == 'embed'){
return '';
}
// return embed only
else if($return == 'embedurl'){
return '//www.youtube.com/embed/'.$id;
}
// return normal thumb
else if($return == 'thumb'){
return '//i1.ytimg.com/vi/'.$id.'/default.jpg';
}
// return mqthumb
else if($return == 'mqthumb'){
return '//i1.ytimg.com/vi/'.$id.'/mqdefault.jpg';
}
// else return id
else{
return $id;
}
}
function truncate_html($html, $length = 100, $ending = '...')
{
if (!is_string($html)) {
trigger_error('Function \'truncate_html\' expects argument 1 to be an string', E_USER_ERROR);
return false;
}
if (mb_strlen(strip_tags($html)) <= $length) {
return $html;
}
$total = mb_strlen($ending);
$open_tags = array();
$return = '';
$finished = false;
$final_segment = '';
$self_closing_elements = array(
'area',
'base',
'br',
'col',
'frame',
'hr',
'img',
'input',
'link',
'meta',
'param'
);
$inline_containers = array(
'a',
'b',
'abbr',
'cite',
'em',
'i',
'kbd',
'span',
'strong',
'sub',
'sup'
);
while (!$finished) {
if (preg_match('/^<(\w+)[^>]*>/', $html, $matches)) { // Does the remaining string start in an opening tag?
// If not self-closing, place tag in $open_tags array:
if (!in_array($matches[1], $self_closing_elements)) {
$open_tags[] = $matches[1];
}
// Remove tag from $html:
$html = substr_replace($html, '', 0, strlen($matches[0]));
// Add tag to $return:
$return .= $matches[0];
} elseif (preg_match('/^<\/(\w+)>/', $html, $matches)) { // Does the remaining string start in an end tag?
// Remove matching opening tag from $open_tags array:
$key = array_search($matches[1], $open_tags);
if ($key !== false) {
unset($open_tags[$key]);
}
// Remove tag from $html:
$html = substr_replace($html, '', 0, strlen($matches[0]));
// Add tag to $return:
$return .= $matches[0];
} else {
// Extract text up to next tag as $segment:
if (preg_match('/^([^<]+)(<\/?(\w+)[^>]*>)?/', $html, $matches)) {
$segment = $matches[1];
// Following code taken from https://trac.cakephp.org/browser/tags/1.2.1.8004/cake/libs/view/helpers/text.php?rev=8005.
// Not 100% sure about it, but assume it deals with utf and html entities/multi-byte characters to get accureate string length.
$segment_length = mb_strlen(preg_replace('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $segment));
// Compare $segment_length + $total to $length:
if ($segment_length + $total > $length) { // Truncate $segment and set as $final_segment:
$remainder = $length - $total;
$entities_length = 0;
if (preg_match_all('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', $segment, $entities, PREG_OFFSET_CAPTURE)) {
foreach($entities[0] as $entity) {
if ($entity[1] + 1 - $entities_length <= $remainder) {
$remainder--;
$entities_length += mb_strlen($entity[0]);
} else {
break;
}
}
}
// Otherwise truncate $segment and set as $final_segment:
$finished = true;
$final_segment = mb_substr($segment, 0, $remainder + $entities_length);
} else {
// Add $segment to $return and increase $total:
$return .= $segment;
$total += $segment_length;
// Remove $segment from $html:
$html = substr_replace($html, '', 0, strlen($segment));
}
} else {
$finshed = true;
}
}
}
// Check for spaces in $final_segment:
if (strpos($final_segment, ' ') === false && preg_match('/<(\w+)[^>]*>$/', $return)) { // If none and $return ends in an opening tag: (we ignore $final_segment)
// Remove opening tag from end of $return:
$return = preg_replace('/<(\w+)[^>]*>$/', '', $return);
// Remove opening tag from $open_tags:
$key = array_search($matches[3], $open_tags);
if ($key !== false) {
unset($open_tags[$key]);
}
} else { // Otherwise, truncate $final_segment to last space and add to $return:
// $spacepos = strrpos($final_segment, ' ');
$return .= mb_substr($final_segment, 0, mb_strrpos($final_segment, ' '));
}
$return = trim($return);
$len = strlen($return);
$last_char = substr($return, $len - 1, 1);
if (!preg_match('/[a-zA-Z0-9]/', $last_char)) {
$return = substr_replace($return, '', $len - 1, 1);
}
// Add closing tags:
$closing_tags = array_reverse($open_tags);
$ending_added = false;
foreach($closing_tags as $tag) {
if (!in_array($tag, $inline_containers) && !$ending_added) {
$return .= $ending;
$ending_added = true;
}
$return .= '' . $tag . '>';
}
if ($ending_added) {
return $return;
} else {
return $return . $ending;
}
}
function cons_contenido($idContenido,$class=NULL,$data=NULL,$type=NULL) {
global $pdo;
$query="SELECT * FROM web_bloques_contenidos WHERE (id_contenido='$id_contenido' OR slug='$idContenido') AND visible='1'";
$data=$pdo->executeQuery($query);
$data=$data[0];
$idioma=$_SESSION['w_idioma'];
$idiomadef=$_SESSION['w_idiomadef'];
switch ($data['cfg_tipo']) {
case 'img':
global $IMG_ROOT;
if ($data['cfg_multilang']==1) {
$alt=$data['titulo_'.$idioma];
$src=$data['contenido_'.$idioma];
} else {
$alt=$data['titulo_'.$idiomadef];
$src=$data['contenido_'.$idiomadef];
}
if ($type=="plain") {
$contenido=$src;
} else {
$contenido='
';
}
break;
default:
if ($data['cfg_multilang']==1) {
$contenido=$data['contenido_'.$idioma];
} else {
$contenido=$data['contenido_'.$idiomadef];
}
break;
}
if (session_id()=="SONOSMEDIA_AUTH_SSID") {
return '';
} else {
return $contenido;
}
}
function cons_seccion($pdo,$slug) {
$data=cons_table_one('web_secciones',"WHERE slug='$slug'");
if($data){
return($data);
} else {
//exit;
}
}
?>
Bigan - BIGAN