JFIF # -$)%7&).0444#9?92>-240 5+#+4;224;652252222225222220222522225222522;2225222222"B!1AQa"q2B#R3br5CS/!12AQ"aRq#3 ??;}q7:bd%Ո>L8/$rsrQٷf=+e: Rb0Z6pN۰7b 1S`JAT K,-֥7(bNRb9CsD/s,9?}+KA]`,EΞ@@ 3ukq14""tD@D@D@D@D@D@D@D@D@D@D@ȓ|:^Yw-)G%AI/9pwVSнm@6=g7AA5tg18gj>F'J,{C3(q<*#AzX?[$va:Q4SԽ7Uԥ&,c}nF;3mO$DN}RySm\*I"}b%7GLj;gp{{FYs(p_xOJFtStǸMU蓰s95"#H'Uq>7F5[}>v%'Y,&CqMzn}m*Xo vl˳hrӦ V)))g`7$sz^%I-1leE]y%݉>?f}( *BNNñ𜤢S[i'T1 ӥԊ>NlHď~)pKw1.UsD LI/k]Sr\r=ߴMAZNKi+P}| qBS*G*z:Imk\_|l6A7߉H\z0賈'Zt_\u>4 {\#O[ERxzLvP wOLT C0ȴ]BAʷ7uNNINS,(DDDDDDDL8MY݂N$ dMK׭i2FesmNQ=?omKv]OVl^@&pɴ[t5+E`oy.E]Ϳ}$g(7y7&X+imcT\(cHɤ|=. C =yȗXʧpv=&cX*[X_i4 GtfFՓnbMjR@ thv4LO I0zlU-_*G!cH9`nԿ \k-~rS*c[}9]qbi~+%)(h($ s;dՒG_\ё[Q,plq!pEſA RZU0*\n]a~Md_3EZ { &8e:jR*dAkyۛs\B˞0Z5%6e`3;0slSx+Xȇ"*ozkE"vܬWاQ8r @ m5$ [/KNFycgrۑ@ {""""""|xd*@s7o~7BSG|܎vøGtЍL١ѬnK/, f~^~l/Ij+!JI'^;{˚*hӤJarʮ)ڱ[P^$;%.V FLJW̔?2ԭUpJe,~b%iW Yhz̻FAl|3ln"M4kM@$2wmͣp8JY)ݬ.]3vԩİ(P*Tb/1FXTg KŮ*C9jE[69d!GZȩMu!5`H\Cp"=wSAmJjCn&/*Q[kQ~b"zΕ~)aA(2EZ0(FÑp.66_φk}T5 YdRarK ɽLSj"SnR-N-Mz~F^Igb Jq(~X fH'Ӵp5_HN(ܰ,Ȍ䶛DK%a~?FuI}"p=U+j}'p&I_ɑ-x!IٮM:w|q;9M?.6x:ODѪ̬zTL`t^?8xJ$ Q cL4d/_xy ˔ SPGNgwSrrS/`5ӧKj ,hTpI=LѦ(,Pc4*4iESO?5sMz<`&_bsTO)fkX[ xqq::h9ifVۉ\_R }JVg~Jzm`(]:O &6IOghX6+HM 7X]RkUr{HL-"< >~28b{[><@6gF5&\1̹nVŕonZM7 (SF$l\sM];owE+IֹȫzɲDߌPcMQMG)b,N ;*!uo&rHT`s^7įĴz0?P&Ҫ3]@H:hڢFҢM~p{&0s?k}+Ι9׵mw >?"fs+Odٯ̌m(R9T:UpbkW=F*ZQh urk8C8@ҧeUԀyKS '.UP,NBcpFS6n=AJl*7 4<(XY_Cda/D=()b,{yHL>[jrǹ7#M7fO`o/w]GȈEU2f\?7a)#봙݂͠SEg>VRdPfF@PV"Ꮷ_(qCJG_0?1[% NKu$7&ۭ ߡ26U$`/ 3ES:/nek |\tmSg5 س}6/qDT "(*sP4SrX)%T(6y%_ Z9<%]B}oyyY"]76*U*vjijw i3D̍IS \Jnn9ۋ>%o;~)5u56槡'z* B5#5

5#a`,>1TW{Xɘ}G4"ҕ4z5F>e6*[\;%*U0LUUr2cpnݢkɜY͌3+bG0#el۴oe,,jO*M1X/3z)W^,p>s{ İQs:ޝd|w :fIe$~+ajXjnT80'S>KIUP&kNϒT=XlȞNڞ]Yz_K[Qׂގ\gq!nB@IoG *l;_뼳\RUeэkm)qh傢5KNz٘6ba:671k{  $N vfN]S7gxg=VjG;wBx t~l/"ʭl=ԝ6n[Dٛ]@"x)# E):\8Bvkcpv4O*;coJ?4ªMCA'.\zVð'w1USݻSlTyj/ gʕ,:S')ܴ]7!A^b%P׶ٮհU3 o\}XTp,e 597n}dk6UFrVǧ3qaR:BWn>Ѻ}oxKӦK)kܑKL tCs1#?升 v{r:u)?#ZxM=ڝYـ#e}JHBGTG>GsܞG2+~R̅Hש)$[*Hfx-ugx({ I7λwvYm~ |e'X#db@hW,0H8*J5AъA`;jȊY*&sh8Jn]"M>l3z%Րsy=Um'qF sX %,Uv|0W`Gzcy*V0'3R`5ޓ Hڙ>PWbw7;)[U(:krm>/ QU+)P>Hm!r -evY>wT7ԝe)^6_SN⚓ϫ('?2Sj5,[پd|+_Pv'[]t'mΝ2l}z/dz^E|"'J qED)R2ƂSg`9Ոu5~ d!G%>M6%pdcP-P L`ϼTQnA_,24G GneRn,XnߕSzV$ReBfZuE ,Z(yi?vO!clOYA [; c I|vCom+Hꡤ\eaӴ;XS|v4%FcϷAQ[yϢ_s+Ơ&pt}=%^Sb"#gĀ'[ oAUPzr;ȔZTy4t>f種ً>T؟GRgC^-WЖukS,G LV$ܱO餰%cp)[*X_v$@DDӢ3bE-V0֍?zySyadd\ j5": Bxi?;3a]1]ZFD澙rc|8uz/ CȎ3UTqb4'ҥX 6KʖYT2fPe$6 lGzSQTP} OL1q^*rxջQ_K?'?=V MR K IS HERE

MRKShell
Server IP : 104.21.73.244  /  Your IP : 104.23.243.235
Web Server : nginx/1.14.1
System : Linux comtuc2-s-2vcpu-8gb-160gb-intel-nyc3 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User : nginx ( 991)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/comunicacion/produccion/hitadmin/application/libraries/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/comunicacion/produccion/hitadmin/application/libraries/Varios_lb.php
<?php
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Varios_lb
{
	private $ci;
	private $client_type;
	
	public function extraer_string($str, $left, $right)
	{
		$str = substr(stristr($str, $left), strlen($left));
		$leftLen = strlen(stristr($str, $right));
		$leftLen = $leftLen ? -($leftLen) : strlen($str);
		$str = substr($str, 0, $leftLen);
		return $str;
	}
	
	public function limpiarurl($frase)
	{
		$url = trim($frase);
		$url = str_replace("á","a",$url);
		$url = str_replace("é","e",$url);
		$url = str_replace("í","i",$url);
		$url = str_replace("ó","o",$url);
		$url = str_replace("ú","u",$url);
		$url = str_replace("ü","u",$url);
		$url = str_replace("Ñ","N",$url);
		$url = str_replace("ñ","n",$url);
		$url = str_replace(" un "," ",$url);
		$url = str_replace("Un ","",$url);
		$url = str_replace(" a "," ",$url);
		$url = str_replace(" su "," ",$url);
		$url = str_replace("Su ","",$url);
		$url = str_replace(" es "," ",$url);
		$url = str_replace("Es ","",$url);
		$url = str_replace(" una "," ",$url);
		$url = str_replace(" una","",$url);
		$url = str_replace("Una ","",$url);
		$url = str_replace(" la "," ",$url);
		$url = str_replace("La ","",$url);
		$url = str_replace(" las "," ",$url);
		$url = str_replace("Las ","",$url);
		$url = str_replace(" los "," ",$url);
		$url = str_replace("Los ","",$url);
		$url = str_replace(" el "," ",$url);
		$url = str_replace("El ","",$url);
		$url = str_replace(" del "," ",$url);
		$url = str_replace(" con "," ",$url);
		$url = str_replace(" por "," ",$url);
		$url = str_replace(" en "," ",$url);
		$url = str_replace("En ","",$url);
		$url = str_replace(" que "," ",$url);
		$url = str_replace(" y "," ",$url);
		$url = str_replace(" de "," ",$url);
		$url = str_replace(",","",$url);
		$url = str_replace(";","",$url);
		$url = str_replace(":","",$url);
		$url = str_replace("%","por-ciento",$url);
		$url = str_replace(".","",$url);
		$url = str_replace("@","",$url);
		$url = str_replace("?","",$url);
		$url = str_replace("¿","",$url);
		$url = str_replace("!","",$url);
		$url = str_replace("¡","",$url);
		$url = str_replace("“","",$url);
		$url = str_replace("”","",$url);
		$url = str_replace("¡","",$url);
		$url = str_replace("°","",$url);
		$url = str_replace("#","",$url);
		$url = str_replace("'","",$url);
		$url = str_replace('"','',$url);
		$url = str_replace("(","",$url);
		$url = str_replace(")","",$url);
		$url = str_replace("-","",$url);
		$url = str_replace("/","-",$url);
		$url = str_replace("´","",$url);
		$url = str_replace("  "," ",$url);
		$url = str_replace(" ","-",$url);
		$url = str_replace("›","",$url);		
		$url = str_replace("|","",$url);
		$url = str_replace('​','',$url);//limpia el simbolo invisible
		$url = preg_replace("/[^A-Za-z0-9-]/",'', $url);	
		
		$url = strtolower($url);
		$url = str_replace("--", "-", $url);

		return $url;
	}
	
public function amigar_cadena($cadena)
	{
		$cadena = str_replace("á","a",$cadena);
		$cadena = str_replace("Á","a",$cadena);
		$cadena = str_replace("é","e",$cadena);
		$cadena = str_replace("É","e",$cadena);
		$cadena = str_replace("í","i",$cadena);
		$cadena = str_replace("Í","i",$cadena);
		$cadena = str_replace("ó","o",$cadena);
		$cadena = str_replace("Ó","o",$cadena);
		$cadena = str_replace("ú","u",$cadena);
		$cadena = str_replace("Ú","u",$cadena);
		$cadena = str_replace("ü","u",$cadena);
		$cadena = str_replace("Ñ","N",$cadena);
		$cadena = str_replace("ñ","n",$cadena);
		$cadena = str_replace(",","",$cadena);
		$cadena = str_replace("´","",$cadena);
		$cadena = str_replace(";","",$cadena);
		$cadena = str_replace(":","",$cadena);
		$cadena = str_replace(".","",$cadena);
		$cadena = str_replace("+","mas",$cadena);
		$cadena = str_replace("@","",$cadena);
		$cadena = str_replace("&","y",$cadena);
		$cadena = str_replace("$","",$cadena);
		$cadena = str_replace("%","por-ciento",$cadena);
		$cadena = str_replace("?","",$cadena);
		$cadena = str_replace("¿","",$cadena);
		$cadena = str_replace("¡","",$cadena);
		$cadena = str_replace("!","",$cadena);
		$cadena = str_replace("°","",$cadena);
		$cadena = str_replace("#","",$cadena);
		$cadena = str_replace("(","",$cadena);
		$cadena = str_replace(")","",$cadena);
		$cadena = str_replace("'","",$cadena);
		$cadena = str_replace('"','',$cadena);
		$cadena = str_replace("“","",$cadena);
		$cadena = str_replace("”","",$cadena);
		$cadena = str_replace("/","-",$cadena);
		$cadena = str_replace("´","",$cadena);
		$cadena = str_replace(" ","-",$cadena);
		$cadena = str_replace("-un-","-",$cadena);
		$cadena = str_replace("-una-","-",$cadena);
		$cadena = str_replace("-el-","-",$cadena);
		$cadena = str_replace("-la-","-",$cadena);
		$cadena = str_replace("-a-","-",$cadena);
		$cadena = str_replace("-con-","-",$cadena);
		$cadena = str_replace("-y-","-",$cadena);
		$cadena = str_replace("-en-","-",$cadena);
		$cadena = str_replace("-los-","-",$cadena);
		$cadena = str_replace("-las-","-",$cadena);
		$cadena = str_replace("-de-","-",$cadena);
		$cadena = str_replace("-que-","-",$cadena);
		$cadena = str_replace("--","-",$cadena);
		$cadena = str_replace("---","-",$cadena);
		$cadena = str_replace("----","-",$cadena);
		$cadena = str_replace("›","",$cadena);
		$cadena = str_replace('​','',$cadena);//limpia el simbolo invisible
		
		$cadena = strtolower($cadena);
		
		return $cadena;
	}


	public function fechaLarga($fecha,$sin_dia=false)
	{
		/*Dias de la semana y meses del anio en array*/
		$dias_semana = array("0"=>"Domingo","1"=>"Lunes","2"=>"Martes","3"=>"Mi&eacute;rcoles","4"=>"Jueves", 
		"5"=>"Viernes","6"=>"S&aacute;bado");
		
		$meses_anio = array("01"=>"Enero","02"=>"Febrero","03"=>"Marzo","04"=>"Abril","05"=>"Mayo","06"=>"Junio", 
		"07"=>"Julio","08"=>"Agosto","09"=>"Septiembre","10"=>"Octubre","11"=>"Noviembre","12"=>"Diciembre");
		/*******************************************/
		
		$dia = substr($fecha,0,2);
		$mes = substr($fecha,3,2);
		$anio = substr($fecha,6,4);
		
		$fecha_dia = date('w',mktime(0,0,0, $mes, $dia, $anio));
		$fecha_dia_letra = $dias_semana[$fecha_dia];
		$fecha_mes_letra = $meses_anio[$mes];
		
		if (!$sin_dia)
			$fecha_armada = $fecha_dia_letra . " " . $dia . " de " . $fecha_mes_letra . " de " . $anio;
		else
			$fecha_armada = $dia . " de " . $fecha_mes_letra . " de " . $anio;
		return $fecha_armada;
	}
	
	public function fechaRSS($fecha)
	{
		/*Dias de la semana y meses del anio en array*/
		$dias_semana = array("0"=>"Sun","1"=>"Mon","2"=>"Tue","3"=>"Wed","4"=>"Thu", 
		"5"=>"Fri","6"=>"Sat");
		
		$meses_anio = array("01"=>"Jan","02"=>"Feb","03"=>"Mar","04"=>"Apr","05"=>"May","06"=>"Jun", 
		"07"=>"Jul","08"=>"Aug","09"=>"Sep","10"=>"Oct","11"=>"Nov","12"=>"Dec");
		/*******************************************/
		
		$dia = substr($fecha,0,2);
		$mes = substr($fecha,3,2);
		$anio = substr($fecha,6,4);
		$hora = substr($fecha,11,8);
		
		$fecha_dia = date('w',mktime(0,0,0, $mes, $dia, $anio));
		$fecha_dia_letra = $dias_semana[$fecha_dia];
		$fecha_mes_letra = $meses_anio[$mes];
		
		$fecha_armada = $fecha_dia_letra . ", " . $dia ." ". $fecha_mes_letra ." ". $anio;
		return $fecha_armada;
	}
	
	public function fechaMedia($fecha)
	{
		/*Dias de la semana y meses del anio en array*/
		$dias_semana = array("0"=>"Domingo","1"=>"Lunes","2"=>"Martes","3"=>"Mi&eacute;rcoles","4"=>"Jueves", 
		"5"=>"Viernes","6"=>"S&aacute;bado");
		
		/*******************************************/
		
		$dia = substr($fecha,0,2);
		$mes = substr($fecha,3,2);
		$anio = substr($fecha,6,4);
		
		$fecha_dia = date('w',mktime(0,0,0, $mes, $dia, $anio));
		$fecha_dia_letra = $dias_semana[$fecha_dia];
				
		$fecha_armada = $fecha_dia_letra . " " . $dia . "/" . $mes . "/" . $anio;
		return $fecha_armada;
	}

	public function fechaDiaLetras($fecha)
	{
		/*Dias de la semana y meses del anio en array*/
		$dias_semana = array("0"=>"Domingo","1"=>"Lunes","2"=>"Martes","3"=>"Mi&eacute;rcoles","4"=>"Jueves", 
		"5"=>"Viernes","6"=>"S&aacute;bado");
		$meses = array("01"=>"Enero","02"=>"Febrero","03"=>"Marzo","04"=>"Abril","05"=>"Mayo","06"=>"Junio","07"=>"Julio",
		"08"=>"Agosto","09"=>"Septiembre","10"=>"Octubre","11"=>"Noviembre","12"=>"Diciembre");
		
		/*******************************************/
		if ($this->validaFecha($fecha))
		{
			$dia = substr($fecha,0,2);
			$mes = substr($fecha,3,2);
			$anio = substr($fecha,6,4);
			
			$fecha_dia = date('w',mktime(0,0,0, $mes, $dia, $anio));
			$fecha_dia_letra = $dias_semana[$fecha_dia];
			$mes_letra = $meses[$mes];
					
			$fecha_armada = $fecha_dia_letra . " " . $dia . " de " . $mes_letra;
			return $fecha_armada;
		}
		else
			return "";
	}


	public function fechaDiaLetrasCompleto($fecha)
	{
		/*Dias de la semana y meses del anio en array*/
		$dias_semana = array("0"=>"Domingo","1"=>"Lunes","2"=>"Martes","3"=>"Mi&eacute;rcoles","4"=>"Jueves", 
		"5"=>"Viernes","6"=>"S&aacute;bado");
		$meses = array("01"=>"Enero","02"=>"Febrero","03"=>"Marzo","04"=>"Abril","05"=>"Mayo","06"=>"Junio","07"=>"Julio",
		"08"=>"Agosto","09"=>"Septiembre","10"=>"Octubre","11"=>"Noviembre","12"=>"Diciembre");
		
		/*******************************************/
		if ($this->validaFecha($fecha))
		{
			$dia = substr($fecha,0,2);
			$mes = substr($fecha,3,2);
			$anio = substr($fecha,6,4);
			
			$fecha_dia = date('w',mktime(0,0,0, $mes, $dia, $anio));
			$fecha_dia_letra = $dias_semana[$fecha_dia];
			$mes_letra = $meses[$mes];
					
			$fecha_armada = $fecha_dia_letra . " " . $dia . " de " . $mes_letra . " de " .$anio;
			return $fecha_armada;
		}
		else
			return "";
	}


	public function calcular_tiempo($time)
	{
		if ($time!="")
		{
			$partes = explode(":", $time);
			if (count($partes) == 2)
			{
				$hora = $partes[0];
				$minutos = $partes[1];
				if ($hora > date('H'))
					$hora = 0;
				$diferencia = date('H') - $hora;
				if ($diferencia > 0)
				{
					$msj = "Hace ".$diferencia." hora";
					if ($diferencia > 1)
						$msj .= "s";
				}
				else
				{
					$dif_min = date('i') - $minutos;
					if ($dif_min > 1)
						$msj = "Hace ".$dif_min." minutos";
					else
						$msj = "Hace 1 minuto";
				}
				return $msj;
			}
			else
				return "";
		}
		else
			return "";
	}
	
	public function xml2array($contents, $get_attributes=1, $priority = 'tag') 
	{
    	if(!$contents) return array();

    	if(!function_exists('xml_parser_create')) 
    	{
        	return array();
    	}

    	$parser = xml_parser_create('');
    	xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
    	xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    	xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    	xml_parse_into_struct($parser, trim($contents), $xml_values);
    	xml_parser_free($parser);

    	if(!$xml_values) return;

	    //Initializations
    	$xml_array = array();
    	$parents = array();
    	$opened_tags = array();
    	$arr = array();

	    $current = &$xml_array; 

	    //Go through the tags.
    	$repeated_tag_index = array();
    	//Multiple tags with same name will be turned into an array
    	foreach($xml_values as $data) 
    	{
    		//Remove existing values, or there will be trouble
        	unset($attributes,$value);

	        //This command will extract these variables into the foreach scope
        	extract($data);

    	    $result = array();
        	$attributes_data = array();
        
        	if(isset($value)) 	
        	{
            	if($priority == 'tag')
            	{ 
            		$result = $value;
            	}
            	else
            	{
            		//Put the value in a assoc array if we are in the 'Attribute' mode 
            		$result['value'] = $value;
            	} 
        	}

	        //Set the attributes too.
    	    if(isset($attributes) and $get_attributes) 
    	    {
            	foreach($attributes as $attr => $val) 
            	{
                	if($priority == 'tag')
                	{ 
                		$attributes_data[$attr] = $val;
                	}
                	else 
                	{
                		//Set all the attributes in a array called 'attr'
                		$result['attr'][$attr] = $val; 
                	}
            	}
        	}

	        //See tag status and do the needed.
    	    if($type == "open") 
    	    {
            	$parent[$level-1] = &$current;
            	if(!is_array($current) or (!in_array($tag, array_keys($current)))) 
            	{ 
            		//Insert New tag
                	$current[$tag][0] = $result;
                	if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
                	$repeated_tag_index[$tag.'_'.$level] = 1;

                	$current = &$current[$tag][0];

            	}
            	else 
            	{ 
            		//There was another element with the same tag name

                	if(isset($current[$tag][0])) 
                	{
                		//If there is a 0th element it is already an array
                    	$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
                    	$repeated_tag_index[$tag.'_'.$level]++;
                	} 
                	else 
                	{
                		//This section will make the value an array if multiple tags with the same name appear together
                    	$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
                    	$repeated_tag_index[$tag.'_'.$level] = 2;
                    
                    	if(isset($current[$tag.'_attr'])) 
                    	{ 
                    		//The attribute of the last(0th) tag must be moved as well
                        	$current[$tag]['0_attr'] = $current[$tag.'_attr'];
                        	unset($current[$tag.'_attr']);
                    	}

                	}
                	$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
                	$current = &$current[$tag][$last_item_index];
            	}

        	} 
        	elseif($type == "complete") 
        	{ 
        		//Tags that ends in 1 line '<tag />'
            	//See if the key is already taken.
            	if(!isset($current[$tag])) 
            	{ 
            		//New Key
                	$current[$tag] = $result;
                	$repeated_tag_index[$tag.'_'.$level] = 1;
                	if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;

            	} 
            	else 
            	{ 
            		//If taken, put all things inside a list(array)
                	if(isset($current[$tag][0]) and is_array($current[$tag])) 
                	{
                		//If it is already an array...

                    	// ...push the new element into that array.
                    	$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
                    
                    	if($priority == 'tag' and $get_attributes and $attributes_data) {
                        	$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
                    	}
                    	$repeated_tag_index[$tag.'_'.$level]++;

                	} 
                	else 
                	{ 
                		//If it is not an array...
                    	$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
                    	$repeated_tag_index[$tag.'_'.$level] = 1;
                    	if($priority == 'tag' and $get_attributes) 
                    	{
                        	if(isset($current[$tag.'_attr'])) 
                        	{ 
                        		//The attribute of the last(0th) tag must be moved as well
                            
                            	$current[$tag]['0_attr'] = $current[$tag.'_attr'];
                            	unset($current[$tag.'_attr']);
                        	}
                        
                        	if($attributes_data) 
                        	{
                            	$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
                        	}
                    	}
                    	$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
                	}
            	}

        	} 
        	elseif($type == 'close') 
        	{ 
        		//End of tag '</tag>'
            	$current = &$parent[$level-1];
        	}
    	}
    
    	return($xml_array); 
	}
	
	//YYYY-mm-dd a dd/mm/YYYY
	public function transformar_fecha($fecha,$separador="/")
	{
		if ($fecha != "")
		{
			$dia = substr($fecha, 8, 2);
			$mes = substr($fecha, 5, 2);
			$anio = substr($fecha, 0, 4);
			return $dia.$separador.$mes.$separador.$anio;
			/*$fecha_info = explode("-",$fecha);
			if (count($fecha_info) == 3)
			{
				$dia = $fecha_info[2];
				$mes = $fecha_info[1];
				$anio = $fecha_info[0];
				return $dia.$separador.$mes.$separador.$anio;
			}
			else
				return "";*/
		}
		else
			return "";
	}
	
	/*dd/mm/YYYY a YYYY-mm-dd*/
	public function transformar_fecha_inversa($fecha,$separador="/")
	{
		if ($this->validaFecha($fecha,$separador))
		{
			$dia = substr($fecha, 0, 2);
			$mes = substr($fecha, 3, 2);
			$anio = substr($fecha, 6, 4);
			
			return $anio."-".$mes."-".$dia;
		}
		else
			return "";
	}
	
	//dd/mm/YYYY
	public function validaFecha($date,$separador="/")
	{
		$day = substr($date, 0, 2);
		$mes = substr($date, 3, 2);
		$anio = substr($date, 6, 4);
		if (strlen($date) == 10)
		{
			if ($day <= 31)
			{
				if ($mes == "01" or $mes == "03" or $mes == "05" or $mes == "07" or $mes == "08" or $mes == "10" or $mes == "12")
				{
					return true;
				}
				else
				{
					if (($mes == "04" or $mes == "06" or $mes == "09" or $mes == "11") and $day <= "30")
					{
						return true;
					}
					else
					{
						if ($mes == "02")
						{
							if (fmod($anio,4) == 0 and $day <= 29)
								return true;
							else
								if ($day <= 28)
									return true;
								else
									return false;
						}
						else
							return false;
					}
				}
			}
			else
				return false;
		}
		else
			return false;
	}
	
	//Formato de fecha aaaa/mm/dd
	public function validaFechaInversa($date,$separador="/")
	{
		$fecha = explode($separador,$date);
		if (strlen($date) == 10 and count($fecha) == 3)
		{
			$day = $fecha[2];
			$mes = $fecha[1];
			$anio = $fecha[0];
			if ($day <= 31)
			{
				if ($mes == "01" or $mes == "03" or $mes == "05" or $mes == "07" or $mes == "08" or $mes == "10" or $mes == "12")
				{
					return true;
				}
				else
				{
					if (($mes == "04" or $mes == "06" or $mes == "09" or $mes == "11") and $day <= "30")
					{
						return true;
					}
					else
					{
						if ($mes == "02")
						{
							if (fmod($anio,4) == 0 and $day <= 29)
								return true;
							else
								if ($day <= 28)
									return true;
								else
									return false;
						}
						else
							return false;
					}
				}
			}
			else
				return false;
		}
		else
			return false;
	}
	
	public function formatear_fecha_GTZ($fecha, $formato){
		/* $fecha = Y-m-dTH:i:sZ(+/-)zzzz*/
		/* separar fecha, hora y zona */
		$separar = explode("T", $fecha);
		$fecha	 = $separar[0];
		$separar2 = explode("Z", $separar[1]);
		$hora	= $separar2[0];
		$zona	= $separar2[1];
		
		$separar_fecha = explode("-", $fecha);
		$anio	= $separar_fecha[0];
		$mes	= $separar_fecha[1];
		$dia	= $separar_fecha[2];

		$separar_hora = explode(":", $hora);
		$hora	= $separar_hora[0];
		$min	= $separar_hora[1];
		$seg	= $separar_hora[2];

		$retorno	= $formato;
		$retorno	= str_replace("Y", $anio, $retorno);
		$retorno	= str_replace("m", $mes, $retorno);
		$retorno	= str_replace("d", $dia, $retorno);
		$retorno        = str_replace("H", $hora, $retorno);
		$retorno        = str_replace("i", $min, $retorno);
		$retorno        = str_replace("s", $seg, $retorno);

		return $retorno;
		
	}

	public function obtenerHora($fecha){
	  $hora=date_create($fecha);
      $hora=date_format($hora , 'H:i');
       return $hora;
	}
	
	public function isMovil($ver_movil=false)
	{
		$ver_version_movil = false;
		$movil = false;
		$origen = "agente: ".$_SERVER['HTTP_USER_AGENT'];
		$origen = strtolower($origen);
		//echo $origen; die();
		if(strrpos($origen,"blackberry") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		elseif (strrpos($origen,"ipod") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		elseif (strrpos($origen,"iphone") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		elseif (strrpos($origen,"android") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		elseif (strrpos($origen,"mobile") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		elseif (strrpos($origen,"opera mini") > 0 and !$cookie_guardada)
		{
			$movil = true;
		}
		
		if(strrpos($origen,"ipad") > 0)
		{
			$movil = false;
		}
		
		if($movil == true)
		{
			//usa m.lagaceta
			if($ver_movil == "movil")
			{
					$ver_version_movil = true;
			}
			//quier ver clasica
			elseif($ver_movil == "clasica")
			{
				//no quier ver movil supuestamente
				setcookie("movil", "1", time() + (300));
				$ver_version_movil = false;
			}
			//entro con www
			elseif($ver_movil == '')
			{
				if (isset($_COOKIE['movil']))
					$ver_version_movil = false;
				else
					$ver_version_movil = true;
			}
		}
		else
		{
			if($ver_movil == "movil")
			{
				$ver_version_movil = true;	
			}
		}
		
		//echo $_COOKIE['movil']."<br><br>";
		
		/*if ($viene_movil)
		{
			//setcookie("movil", "1", time() + (7 * 86400), "", "lagaceta.com.ar" ); 	
			setcookie("movil", "1", time() + (300));
			$cookie_guardada = true;
			$movil = true;
			if($ver_movil == false)
			{
				$movil = false;
			}
		}
		else
		{
			//$cookie_guardada = false;
			if (isset($_COOKIE['movil']))
				$cookie_guardada = true;
		}*/
		
		return $ver_version_movil;
	}
	
	public function dame_theme_movil($seccion_id)
	{
		
		switch($seccion_id)
		{
			case 1:
					$var = THEME_MOVIL_LG;
					break;
			case 4:
					$var = THEME_MOVIL_DEPORTES;
					break;
			case 134:
					$var = THEME_MOVIL_TUCUMANOS;
					break;
			default:
					$var = THEME_DEFAULT;
					break;
		}
		
		return $var;
	} 
	
	public function cortar_texto($string, $limit, $break=".", $pad="…")
	{
		// return with no change if string is shorter than $limit 
		if(strlen($string) <= $limit)
		return $string;
		// is $break present between $limit and the end of the string? 
		if(false !== ($breakpoint = strpos($string, $break, $limit)))
		{
			if($breakpoint < (strlen($string)-1))
			{
				$string = substr($string, 0, $breakpoint) . $pad;
			}
		}
		return $string;
	}
	
	public function is_bot()
	{
		
		$user_agent = $_SERVER['HTTP_USER_AGENT'];
		//var_dump($user_agent); 
	  //if no user agent is supplied then assume it's a bot
	  if($user_agent == "")
	    return 1;
	
	  //array of bot strings to check for
	  $bot_strings = Array(  "google",     "bot",
	            "yahoo",     "spider",
	            "archiver",   "curl",
	            "python",     "nambu",
	            "twitt",     "perl",
	            "sphere",     "PEAR",
	            "java",     "wordpress",
	            "radian",     "crawl",
	            "yandex",     "eventbox",
	            "monitor",   "mechanize",
	            "facebookexternal"
	          );
	  foreach($bot_strings as $bot)
	  {
	    if(strpos($user_agent,$bot) !== false)
	    { return 1; }
	  }
	  
	  return 0;
	}

	public function validaEmail($email)
	{
	    $mail_correcto = 0;
	    //compruebo unas cosas primeras
	    if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){
	       if ((!strstr($email,"'")) && (!strstr($email,'"')) && (!strstr($email,'\\')) && (!strstr($email,'$')) && (!strstr($email,' '))) {
	          //miro si tiene caracter .
	          if (substr_count($email,".")>= 1){
	             //obtengo la terminacion del dominio
	             $term_dom = substr(strrchr ($email, '.'),1);
	             //compruebo que la terminación del dominio sea correcta
	             if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
	                //compruebo que lo de antes del dominio sea correcto
	                $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
	                $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
	                if ($caracter_ult != "@" && $caracter_ult != "."){
	                   $mail_correcto = 1;
	                }
	             }
	          }
	       }
	    }
	    if ($mail_correcto)
	       return 1;
	    else
	       return 0;
	}

	public function diasDiferencia($fecha_mayor, $fecha_menor)
	{
		if ($this->validaFecha($fecha_mayor) and $this->validaFecha($fecha_menor))
		{
			$dia_mayor = substr($fecha_mayor, 0, 2);
			$mes_mayor = substr($fecha_mayor, 3, 2);
			$anio_mayor = substr($fecha_mayor, 6, 4);

			$dia_menor = substr($fecha_menor, 0, 2);
			$mes_menor = substr($fecha_menor, 3, 2);
			$anio_menor = substr($fecha_menor, 6, 4);

			$segundos_mayor = mktime(0,0,0,$mes_mayor,$dia_mayor,$anio_mayor);
			$segundos_menor = mktime(0,0,0,$mes_menor,$dia_menor,$anio_menor);

			$diferencia_segundos = $segundos_mayor - $segundos_menor;
			if ($diferencia_segundos < 0)
			{
				$diferencia_segundos = $diferencia_segundos * (-1);
				return 0;
			}
			elseif($diferencia_segundos > 0)
			{
				$diferencia_dias = $diferencia_segundos / (60 * 60 * 24);
				return $diferencia_dias;
			}
			else
				return 0;
		}
		else
			return 0;
	}

	public function diasDiferenciaConcurso($fecha_mayor, $fecha_menor)
	{
		if ($this->validaFecha($fecha_mayor) and $this->validaFecha($fecha_menor))
		{
			$dia_mayor = substr($fecha_mayor, 0, 2);
			$mes_mayor = substr($fecha_mayor, 3, 2);
			$anio_mayor = substr($fecha_mayor, 6, 4);

			$dia_menor = substr($fecha_menor, 0, 2);
			$mes_menor = substr($fecha_menor, 3, 2);
			$anio_menor = substr($fecha_menor, 6, 4);

			$segundos_mayor = mktime(0,0,0,$mes_mayor,$dia_mayor,$anio_mayor);
			$segundos_menor = mktime(0,0,0,$mes_menor,$dia_menor,$anio_menor);

			$diferencia_segundos = $segundos_mayor - $segundos_menor;
			if ($diferencia_segundos < 0)
			{
				return -1;
			}
			elseif($diferencia_segundos > 0)
			{
				$diferencia_dias = $diferencia_segundos / (60 * 60 * 24);
				return $diferencia_dias;
			}
			else
				return 0;
		}
		else
			return 0;
	}

	public function horasDiferencia($hora_mayor, $hora_menor)
	{
		$h_mayor = substr($hora_mayor, 0, 2);
		$m_mayor = substr($hora_mayor, 3, 2);

		$h_menor = substr($hora_menor, 0, 2);
		$m_menor = substr($hora_menor, 3, 2);

		$segundos_mayor = mktime($h_mayor,$m_mayor,0,date('m'),date('d'),date('Y'));
		$segundos_menor = mktime($h_menor,$m_menor,0,date('m'),date('d'),date('Y'));

		$valor2="";
		$tipo2="";

		$diferencia_segundos = $segundos_mayor - $segundos_menor;
		if ($diferencia_segundos < 0)
		{
			return 0;
		}
		elseif($diferencia_segundos > 0)
		{
			$diferencia = $diferencia_segundos / (60 * 60);
			$val = explode(".", $diferencia);
			if (count($val) > 1)
			{
				if ($val[0] > 0)
				{
					$valor1 = $val[0];
					$tipo1 = "h";
					$decimales = "0.".$val[1];
					$valor2 = $decimales * 60;
					$valor2 = (int)$valor2;
					$tipo2 = "min";
				}
				else
				{
					$diferencia = $diferencia_segundos / (60);
					$valor1 = $diferencia;
					$tipo1 = "min";
				}
			}
			else
			{
				$valor1 = $val[0];
				$tipo1 = "h";
			}

			if ($tipo1 == "h" and $valor1 > 1)
				$tipo1 .= "s";

			$return['valor1'] = $valor1;
			$return['tipo1'] = $tipo1;
			$return['valor2'] = $valor2;
			$return['tipo2'] = $tipo2;
			
			return $return;
		}
		else
			return 0;
	}

	public function restarDiasFecha($fecha,$dia,$separador="-")
	{
		//list($day,$mon,$year) = explode($separador,$fecha);
		$day = substr($fecha, 0,2);
		$mon = substr($fecha, 3,2);
		$year = substr($fecha, 6,4);
    	return date('Y-m-d',mktime(0,0,0,$mon,$day-$dia,$year));       
	}

	public function calcularEdad($fecha)
	{
		if ($fecha)
		{
			$dia = substr($fecha,0,2);
			$mes = substr($fecha,3,2);
			$anio = substr($fecha,6,4);

			$dif = date('Y') - $anio;
			if ($mes > date('m'))
				$dif--;
			if ($mes == date('m') and $dia > date('d'))
				$dif--;

			return $dif;
		}
		else
			return 0;
	}

	public function obtenerCumple($fecha,$sep="/")
	{
		if ($fecha)
		{
			$dia = substr($fecha,0,2);
			$mes = substr($fecha,3,2);

			return $dia.$sep.$mes;
		}
		else
			return "";
	}

	public function armarPaginador($total,$porpagina,$pagina)
	{
		if ($total > $porpagina)
		{
			
		}
		else
			return '';
	}

	public function devolverIMG($foto,$w,$h)
	{
		if ($foto!="")
	    {
	        if (file_exists(PATH_BASE_FILE."fotos/".$foto))
	        {
	        	$info_imagen = @getimagesize(PATH_BASE_FILE."fotos/".$foto);
		        $ancho = $info_imagen[0];
		        $alto = $info_imagen[1];
		        $path_image = URL_BASE_FILE . "fotos/".$foto;
		        $width = '';
		        $height = '';

	        	if ($h==0)
	        	{
	        		if ($ancho > $w)
	        		{
	        			$width = 'width="'.$w.'"';
	        		}
	        		else
	        			$width = 'width="'.$ancho.'"';
	        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="">';
	        	}
	        	elseif($w==0)
	        	{
	        		if ($alto > $h)
	        		{
	        			$height = 'height="'.$h.'"';
	        		}
	        		else
	        			$height = 'height="'.$alto.'"';
	        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="">';
	        	}
	        	else
	        	{
		            $alto_d = floor(($w*$alto) /$ancho);
		            $ancho_d = floor(($h*$ancho) /$alto);
		            
		            if ($alto_d <= $h and $ancho_d > $w)
		            {
		                $width = 'width="'.$w.'"';
		            }
		            elseif ($ancho_d <= $w and $alto_d > $h)
		            {                        
		                $height = 'height="'.$h.'"';
		            }
		            else
		            {
		                $width = 'width="'.$w.'"';  
		                $height = 'height="'.$h.'"'; 
		            }

		            $image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="">';
	        	}
	        }
	        else
	            $image = '';
	    }
	    else
	        $image = '';

	    return $image;
	}

	public function devolverIMGAvanzado($foto,$w,$h,$class="")
	{
		if ($foto!="")
	    {
	    	$clase_foto = '';
	    	if ($class != "")
	    		$clase_foto = 'class="'.$class.'"';

	    	$foto_orig = str_replace("tmb2_", "", $foto);
	    	if (file_exists(PATH_BASE_FILE."fotos/".$foto_orig))
	    	{
		        if (file_exists(PATH_BASE_FILE."fotos/".$foto))
		        {
		        	$info_imagen = @getimagesize(PATH_BASE_FILE."fotos/".$foto);
			        $ancho = $info_imagen[0];
			        $alto = $info_imagen[1];
			        $path_image = URL_BASE_FILE . "fotos/".$foto;
			        $width = '';
			        $height = '';

		        	if ($h==0)
		        	{
		        		if ($ancho > $w)
		        		{
		        			$width = 'width="'.$w.'"';
		        		}
		        		else
		        			$width = 'width="'.$ancho.'"';
		        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        	elseif($w==0)
		        	{
		        		if ($alto > $h)
		        		{
		        			$height = 'height="'.$h.'"';
		        		}
		        		else
		        			$height = 'height="'.$alto.'"';
		        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        	else
		        	{
			            $alto_d = floor(($w*$alto) /$ancho);
			            $ancho_d = floor(($h*$ancho) /$alto);
			            
			            if ($alto_d <= $h and $ancho_d > $w)
			            {
			                $width = 'width="'.$w.'"';
			            }
			            elseif ($ancho_d <= $w and $alto_d > $h)
			            {                        
			                $height = 'height="'.$h.'"';
			            }
			            else
			            {
			                $width = 'width="'.$w.'"';  
			                $height = 'height="'.$h.'"'; 
			            }

			            $image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        }
		        else
		        {
		        	$foto_sola = end(explode("/",$foto));
		        	$ruta = str_replace($foto_sola, "", $foto);
		        	$ruta = str_replace("/","-",$ruta);
		        	$foto_sola = str_replace("tmb2_","",$foto_sola);
		        	$path_image = site_url("foto/cropear2013/".$ruta."/".$foto_sola."/".$w."/".$h);
		        	$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        }
	    	}
	        else
	            $image = '';
	    }
	    else
	        $image = '';

	    return $image;
	}

	public function devolverImgCropVertical($foto,$width,$height,$class="")
	{
		$imagen = '';
		if ($foto!="")
	    {
			$clase_foto = '';
	    	if ($class != "")
	    		$clase_foto = 'class="'.$class.'"';

	    	$foto_nueva = str_replace("tmb1_","tmb4_",$foto);
	    	
	    	if(!file_exists(PATH_BASE_FILE."fotos/".$foto_nueva))
	    	{
	    		
	    		//genero
	    		if(!file_exists(PATH_BASE_FILE."fotos/".$foto))
	    		{
	    			$foto = str_replace("tmb1_","",$foto);
	    		}

	    		if(file_exists(PATH_BASE_FILE."fotos/".$foto))
	    		{
	    			//genero la imagen
	    			include_once(PATH_BASE."controllers/herramientas/imageresize.class.php");
	    			
	    			@$oResize = new ImageResize(PATH_BASE_FILE."fotos/".$foto);

	    			$info_imagen = @getimagesize(PATH_BASE_FILE."fotos/".$foto);
			        $ancho = $info_imagen[0];
			        $alto = $info_imagen[1];

			        $aux_height = ($width * $alto / $ancho);
			       if($aux_height < $height)
		        	{
		        		//resize a $height
		        		@$oResize->resizeHeight($height);
		        		@$oResize->save(PATH_BASE_FILE."fotos/".$foto_nueva);

		        		@$oResize = new ImageResize(PATH_BASE_FILE."fotos/".$foto_nueva);
		        		$aux_width =(int) ($height * $ancho / $alto);
		        		$aux_espacio = (int)($aux_width - $width)/2;
		        		@$oResize->resizeWidthHeight2($width,$height,$aux_espacio);
		        		@$oResize->save(PATH_BASE_FILE."fotos/".$foto_nueva);
		        	}
		        	else
		        	{
		        		//resize a $height
		        		@$oResize->resizeHeight($height);
		        		@$oResize->save(PATH_BASE_FILE."fotos/".$foto_nueva);

		        		//resize a $width
		        		@$oResize->resizeWidth($width);
		        		@$oResize->save(PATH_BASE_FILE."fotos/".$foto_nueva);

		        		@$oResize = new ImageResize(PATH_BASE_FILE."fotos/".$foto_nueva);
		        		$aux_width =(int) ($height * $ancho / $alto);
		        		$aux_espacio = (int)($aux_width - $width)/2;
		        		@$oResize->resizeWidthHeight2($width,$height,$aux_espacio);
		        		@$oResize->save(PATH_BASE_FILE."fotos/".$foto_nueva);
		        	}
	    		}
	    	}

	    		//width="'.$width.'" height="'.$height.'" 
			$image = '<img src="'.URL_BASE_FILE."fotos/".$foto_nueva.'" alt="" '.$clase_foto.'>';	    	

	    	/*$foto_orig = str_replace("tmb2_", "", $foto);
	    	if (file_exists(PATH_BASE_FILE."fotos/".$foto_orig))
	    	{
		        if (file_exists(PATH_BASE_FILE."fotos/".$foto))
		        {
		        	$info_imagen = @getimagesize(PATH_BASE_FILE."fotos/".$foto);
			        $ancho = $info_imagen[0];
			        $alto = $info_imagen[1];
			        $path_image = URL_BASE_FILE . "fotos/".$foto;
			        $width = '';
			        $height = '';

		        	if ($h==0)
		        	{
		        		if ($ancho > $w)
		        		{
		        			$width = 'width="'.$w.'"';
		        		}
		        		else
		        			$width = 'width="'.$ancho.'"';
		        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        	elseif($w==0)
		        	{
		        		if ($alto > $h)
		        		{
		        			$height = 'height="'.$h.'"';
		        		}
		        		else
		        			$height = 'height="'.$alto.'"';
		        		$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        	else
		        	{
			            $alto_d = floor(($w*$alto) /$ancho);
			            $ancho_d = floor(($h*$ancho) /$alto);
			            
			            if ($alto_d <= $h and $ancho_d > $w)
			            {
			                $width = 'width="'.$w.'"';
			            }
			            elseif ($ancho_d <= $w and $alto_d > $h)
			            {                        
			                $height = 'height="'.$h.'"';
			            }
			            else
			            {
			                $width = 'width="'.$w.'"';  
			                $height = 'height="'.$h.'"'; 
			            }

			            $image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        	}
		        }
		        else
		        {
		        	$foto_sola = end(explode("/",$foto));
		        	$ruta = str_replace($foto_sola, "", $foto);
		        	$ruta = str_replace("/","-",$ruta);
		        	$foto_sola = str_replace("tmb2_","",$foto_sola);
		        	$path_image = site_url("foto/cropear2013/".$ruta."/".$foto_sola."/".$w."/".$h);
		        	$image = '<img src="'.$path_image.'" '.$width.' '.$height.' alt="" '.$clase_foto.'>';
		        }
	    	}
	        else
	            $image = '';*/
	    }
	    else
	        $image = '';

	    return $image;
	}

	public function ranking($titulo_ranking="",$tag_id=0,$es_blog=false,$estilo="home",$sietedias=false,$origen="nota")
	{

		$CI =& get_instance();
		$CI->load->model("nota_modelo","nota_modelo",true);
		$CI->load->library("memcached_library");
		$CI->load->library("varios_library");
		$agrgado_url = "";
		if ($origen=="nota")
			$agrgado_url = "?=rank-nota";
		if ($origen=="um")
			$agrgado_url = "?=rank-um";
		if ($origen=="tag")
			$agrgado_url = "?=rank-tag";
		if ($origen=="ea")
			$agrgado_url = "?=rank-eanterior";

		$edicion_info = $CI->memcached_library->get('edicion_publicada');
		if (!$edicion_info)
		{
			$CI->load->model("edicion","edicion",true);
			$edicion_info = $CI->edicion->dameEdicionPublicada();
			$CI->memcached_library->add('edicion_publicada', $edicion_info,72000);
		}
		$edicion_id = $edicion_info['id'];
		$edicion_fecha = $edicion_info['fechabuscador'];
		if ($sietedias)
		{
			$edicion_id_ant = $edicion_info['id'] - 6;
			$edicion_fecha_ant = $this->restarDiasFecha($edicion_info['fecha'],6);
			$nom_cache = "_semana";
		}
		else
		{
			$edicion_id_ant = $edicion_info['id'];
			$edicion_fecha_ant = $edicion_info['fechabuscador'];
			$nom_cache = "";
		}

		if ($es_blog)
		{
			$edicion_id_ant = $edicion_id-60;
			$edicion_id_ant_com = $edicion_id-7;
			$edicion_fecha_ant = $this->restarDiasFecha($edicion_info['fecha'],60,'/');
			$edicion_fecha_ant_com = $this->restarDiasFecha($edicion_info['fecha'],7,'/');
			
			if ($tag_id > 0)
				$nom_cache_blog = "_".$tag_id;
			else
				$nom_cache_blog = "";

			/*Mas Vistas Blog*/
			$masvistas = $CI->memcached_library->get('ranking_masvistas_blog'.$nom_cache_blog);
			if (!$masvistas)
			{
				$masvistas = $CI->nota_modelo->rankingMasVistasRecomendadas(0, $edicion_fecha, 0, $edicion_fecha_ant, $tag_id, 'visitas', 4);	
				if (!$masvistas)
					$masvistas = "vacio";
				$CI->memcached_library->add('ranking_masvistas_blog'.$nom_cache_blog, $masvistas, 1200);
			}

			/*Mas Compartidas Blog*/
			$mascompartidas = $CI->memcached_library->get('ranking_mascompartidas_blog'.$nom_cache_blog);
			if (!$mascompartidas)
			{
				$mascompartidas = $CI->nota_modelo->rankingMasVistasRecomendadas(0, $edicion_fecha, 0, $edicion_fecha_ant, $tag_id, 'compartidas', 4);	
				if (!$mascompartidas)
					$mascompartidas = "vacio";
				$CI->memcached_library->add('ranking_mascompartidas_blog'.$nom_cache_blog, $mascompartidas, 1200);
			}

			/*Mas Comentadas Blog*/
			$mascomentadas = $CI->memcached_library->get('ranking_mascomentadas_blog'.$nom_cache_blog);
			if (!$mascomentadas)
			{
				$mascomentadas = $CI->nota_modelo->rankingMasComentadas(0, $edicion_fecha, 0, $edicion_fecha_ant_com, $tag_id, 4);	
				if (!$mascomentadas)
					$mascomentadas = "vacio";
				$CI->memcached_library->add('ranking_mascomentadas_blog'.$nom_cache_blog, $mascomentadas, 1200);
			}
		}
		else
		{
			if ($tag_id == 0)
			{
				/*Mas Vistas Home*/
				$masvistas = $CI->memcached_library->get('ranking_masvistas'.$nom_cache);
				if (!$masvistas)
				{
					$masvistas = $CI->nota_modelo->rankingMasVistasRecomendadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, 0, 'visitas', 4);	
					if (!$masvistas)
						$masvistas = "vacio";
					$CI->memcached_library->add('ranking_masvistas'.$nom_cache, $masvistas, 1200);
				}

				/*Mas Compartidas Home*/
				$mascompartidas = $CI->memcached_library->get('ranking_mascompartidas'.$nom_cache);
				if (!$mascompartidas)
				{
					$mascompartidas = $CI->nota_modelo->rankingMasVistasRecomendadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, 0, 'compartidas', 4);	
					if (!$mascompartidas)
						$mascompartidas = "vacio";
					$CI->memcached_library->add('ranking_mascompartidas'.$nom_cache, $mascompartidas, 1200);
				}

				/*Mas Comentadas Home*/
				$mascomentadas = $CI->memcached_library->get('ranking_mascomentadas'.$nom_cache);
				if (!$mascomentadas)
				{
					$mascomentadas = $CI->nota_modelo->rankingMasComentadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, 0, 4);	
					if (!$mascomentadas)
						$mascomentadas = "vacio";
					$CI->memcached_library->add('ranking_mascomentadas'.$nom_cache, $mascomentadas, 1200);
				}
			}
			else
			{
				/*Mas Vistas Seccion*/
				$masvistas = $CI->memcached_library->get('ranking_masvistas_'.$tag_id.$nom_cache);
				if (!$masvistas)
				{
					$masvistas = $CI->nota_modelo->rankingMasVistasRecomendadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, $tag_id, 'visitas', 4);	
					if (!$masvistas)
						$masvistas = "vacio";
					$CI->memcached_library->add('ranking_masvistas_'.$tag_id.$nom_cache, $masvistas, 1200);
				}

				/*Mas Compartidas Seccion*/
				$mascompartidas = $CI->memcached_library->get('ranking_mascompartidas_'.$tag_id.$nom_cache);
				if (!$mascompartidas)
				{
					$mascompartidas = $CI->nota_modelo->rankingMasVistasRecomendadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, $tag_id, 'compartidas', 4);	
					if (!$mascompartidas)
						$mascompartidas = "vacio";
					$CI->memcached_library->add('ranking_mascompartidas_'.$tag_id.$nom_cache, $mascompartidas, 1200);
				}

				/*Mas Comentadas Seccion*/
				$mascomentadas = $CI->memcached_library->get('ranking_mascomentadas_'.$tag_id.$nom_cache);
				if (!$mascomentadas)
				{
					$mascomentadas = $CI->nota_modelo->rankingMasComentadas($edicion_id, $edicion_fecha, $edicion_id_ant, $edicion_fecha_ant, $tag_id, 4);	
					if (!$mascomentadas)
						$mascomentadas = "vacio";
					$CI->memcached_library->add('ranking_mascomentadas_'.$tag_id.$nom_cache, $mascomentadas, 1200);
				}
			}
		}

		$variables['es_blog'] = $es_blog;
		$variables['tag_rank_id'] = $tag_id;
		$variables['estilo'] = $estilo;
		$variables['titulo_ranking'] = $titulo_ranking;
		$variables['masvistas'] = $masvistas;
		$variables['mascompartidas'] = $mascompartidas;
		$variables['mascomentadas'] = $mascomentadas;
		$variables['sietedias'] = $sietedias;
		$variables['agregado_url'] = $agrgado_url;

		$CI->load->view("2012/ranking",$variables);
	}

	public function ranking_usuarios()
	{
		$CI =& get_instance();
		$CI->load->model("usuario","usuario",true);
		$CI->load->library("memcached_library");
		$CI->load->library("varios_library");

		/*Mas Activos*/
		/*$masactivos = $CI->memcached_library->get('ranking_usuarios_masactivos');
		if (!$masactivos)
		{
			$masactivos = $CI->usuario->masActivos(5);	
			$CI->memcached_library->add('ranking_usuarios_masactivos', $masactivos, 1200);
		}*/
		$masactivos = false;

		/*Mas Aplaudidos*/
		$masaplaudidos = $CI->memcached_library->get('ranking_usuarios_masaplaudidos');
		if (!$masaplaudidos)
		{
			$masaplaudidos = $CI->usuario->masAplaudidosPolemicos('positivo',5);	
			$CI->memcached_library->add('ranking_usuarios_masaplaudidos', $masaplaudidos, 1200);
		}

		/*Mas Polemicos*/
		$maspolemicos = $CI->memcached_library->get('ranking_usuarios_maspolemicos');
		if (!$maspolemicos)
		{
			$maspolemicos = $CI->usuario->masAplaudidosPolemicos('negativo',5);	
			$CI->memcached_library->add('ranking_usuarios_maspolemicos', $maspolemicos, 1200);
		}

		/*Mas Seguidos*/
		$masseguidos = $CI->memcached_library->get('ranking_usuarios_masseguidos');
		//$masseguidos = NULL;
		if (!$masseguidos)
		{
			$masseguidos = $CI->usuario->masSeguidos(5);	
			$CI->memcached_library->add('ranking_usuarios_masseguidos', $masseguidos, 1200);
		}

		$variables['activos'] = $masactivos;
		$variables['aplaudidos'] = $masaplaudidos;
		$variables['polemicos'] = $maspolemicos;
		$variables['seguidos'] = $masseguidos;

		$CI->load->view("2012/ranking_usuarios",$variables);
	}

	public function validaHora($hora)
	{
		if ($hora!="")
		{
			$H = substr($hora, 0,2);
			$m = substr($hora, 3,2);
			$separador = substr($hora, 2,1);
			if ($separador==":")
			{
				if (is_numeric($H))
				{
					if ($H >= 0 and $H <= 23)
					{
						if (is_numeric($m))
						{
							if ($m >=0 and $m <=59)
								return true;
							else
								return false;
						}
						else
							return false;
					}
					else
						return false;
				}
				else
					return false;
			}
			else
				return flase;
		}
		else
			return false;
	}

	public function encuestas_opinion_derecha()
	{
		$html = "";
		$CI =& get_instance();
		$CI->load->library('varios_library');
		$CI->load->library('memcached_library');

		$encuestas = $CI->memcached_library->get('encuestas_opinion_home');
		if (!$encuestas)
		{
			$CI->load->model("encuesta","encuesta",true);
			$encuestas = $CI->encuesta->dameEncuestasOpinion();
			$CI->memcached_library->add('encuestas_opinion_home', $encuestas, 36000);
		}

		if ($encuestas)
		{
			$html = '<div class="caja">';
			$html .= '<div class="pubtop bopin">¿Qué opinás de?</div>';
			foreach ($encuestas as $enc)
			{
				$total_votos = $enc['opciones'][0]['votos'];
				$total_votos = $total_votos + $enc['opciones'][1]['votos'];
				if ($total_votos > 0)
				{
					$porc_neg = ($enc['opciones'][1]['votos'] * 100) / $total_votos;
					$part = explode(".", $porc_neg);
					$porc_neg = $part[0];
				}
				else
					$porc_neg = 0;
				$image = $CI->varios_library->devolverIMG($enc['ruta_img'].$enc['imagen'],67,67);

				$html .= '<div class="slu2b">';

				if ($image!="")
					$html .= $image;
				else
					$html .= '<img src="'.site_url("img/2012/dp-fondo.jpg").'" width="67" height="67" class="sli fl">';

				$html .= '<div class="posne"><span class="h14 fbit cecon">'.$enc['encuesta'].'</span>';
				$html .= '<div style="margin-bottom:7px; margin-top:7px"></div>';
				$html .= '<div class="posneg">
                        	<div class="posneg2" id="barra_'.$enc['id'].'" style="width:'.$porc_neg.'%;"></div>
                    	  </div>';
                $html .= '<div class="bc">
                    		<a href="javascript:void(0)" id="negativo_btn_'.$enc['id'].'" onclick="votar_encuesta_op('.$enc['id'].','.$enc['opciones'][1]['id'].',-1,'.$total_votos.')"><img src="'.site_url("img/2012/bot-negativo-color.png").'" width="20" height="20" class="fl"></a>
                    		<img src="'.site_url("img/2012/loading.gif").'" id="negativo_cargando_'.$enc['id'].'" width="20" height="20" class="fl" style="display:none">
                        	<div class="bcfle"> </div>
                        	<div class="bcnum" id="negativo_'.$enc['id'].'">'.$enc['opciones'][1]['votos'].'</div>
                    	  </div>';
                $html .= '<div class="bc">
                    		<a href="javascript:void(0)" id="positivo_btn_'.$enc['id'].'" onclick="votar_encuesta_op('.$enc['id'].','.$enc['opciones'][0]['id'].',1,'.$total_votos.')"><img src="'.site_url("img/2012/bot-positivo-color.png").'" width="20" height="20" class="fl"></a>
                    		<img src="'.site_url("img/2012/loading.gif").'" id="positivo_cargando_'.$enc['id'].'" width="20" height="20" class="fl" style="display:none">
                        	<div class="bcfle"> </div>
                        	<div class="bcnum" id="positivo_'.$enc['id'].'">'.$enc['opciones'][0]['votos'].'</div>
                    	  </div>';
                $html .= '<div class="limpia"></div>';
                $html .= '<div class="posvot" id="total_'.$enc['id'].'">Votos: '.$total_votos.'</div>';
                $html .= '</div>';
                $html .= '<div class="limpia"></div>';

				$html .= '</div>';
			}
			$html .= '</div>';
		}

		return $html;
	}

	public function armar_link_seccion($titulo)
	{

		$link = strtolower($titulo);
		$validar = explode("-", $link);
		if (count($validar) == 1)
			$link = site_url($this->limpiarurl($link));
		else
			$link = site_url($link);

		return $link;

	}

	public function armar_link_encabezado($id)
	{
		if($id!=0)
		{
			$CI =& get_instance();
			$CI->load->model("seccion_modelo","seccion",true);

			$seccion = $CI->seccion->dameInfoSeccion($id);

			$titulo = $seccion['nombre'];

			if($id==99)

				return 'numeros-oro?=derecha';
			
			else

				return $this->armar_link_seccion($titulo);

		}
		else
		{
			return false;
		}
	}

	public function devolverIMGVideo($video_id,$codigo,$tipo=0)
	{
		$path_local = PATH_BASE_FILE ."fotos/videos/".$video_id."_".$tipo.".jpg"; 
		$url_local = URL_BASE_FILE ."fotos/videos/".$video_id."_".$tipo.".jpg";
		$url_youtube = "http://img.youtube.com/vi/".$codigo."/".$tipo.".jpg";

		if (file_exists($path_local))
			return $url_local;
		else
			return $url_youtube;
	}


	//funcion que devuelve una imagen con el tamaño exacto cropeada desde la original
	//$ruta_origen = //ruta de la imagen de origen
	//$imagen_origen = //imagen de origen
	//$ruta_destino = //ruta de la imagen de destino
	//$width=	//ancho de la imagen
	//$height= //alto de la imagen
	//$class= //clase de la imagen
	//$alt= //alt de la imagen
	//$title= //titulo de la imagen
	//$pos_vertical = // 0 - top, 1 - middle, 2 - bottom
	public function dameImagen($ruta_origen,$imagen_origen,$ruta_destino,$width,$height,$class="",$alt="",$title="",$pos_vertical = 0)
    {
        $imagen = '';
        if ($ruta_origen!="" && $imagen_origen!="")
        {
            $clase_foto = '';
            if ($class != "")
                $clase_foto = 'class="'.$class.'" ';


            //***creamos las carpetas necesarias
            //$carpetas = explode('/',$ruta_destino);
            if(!file_exists(PATH_BASE_FILE."fotos/".$ruta_destino))
            {
            	mkdir(PATH_BASE_FILE."fotos/".$ruta_destino, 0777, true);
            }
            //***
  
            //$foto_nueva = str_replace("tmb1_","tmb4_",$foto);
			$foto_nueva = $width.'x'.$height.'_'.$imagen_origen;
			
			$path_origen = PATH_BASE_FILE."fotos/".$ruta_origen.'orig_'.$imagen_origen; 
			if(!file_exists($path_origen))
				$path_origen = PATH_BASE_FILE."fotos/".$ruta_origen.$imagen_origen;
			$path_destino = PATH_BASE_FILE."fotos/".$ruta_destino.$foto_nueva;
             
            if(!file_exists($path_destino))
            {
                 
               	if(file_exists($path_origen))
                {
                    //genero la imagen
                    include_once(PATH_BASE."controllers/admin/herramientas/imageresize.class.php");
                     
                    @$oResize = new ImageResize($path_origen);
  
                    $info_imagen = @getimagesize($path_origen);
                    $ancho = $info_imagen[0];
                    $alto = $info_imagen[1];
  
                    $aux_height = ($width * $alto / $ancho);
                   	if($aux_height < $height)
                    {
                        //resize a $height
                        @$oResize->resizeHeight($height);
                        //if(@$oResize->save_part($path_destino))
  						//{
	                        //@$oResize = new ImageResize($path_destino);
	                        $aux_width =(int) ($height * $ancho / $alto);
	                        $aux_espacio = (int)($aux_width - $width)/2;
							if($width>$ancho)
								$aux_espacio = 0;
							$oResize->gd_s = $oResize->gd_d;
	                        if(@$oResize->resizeWidthHeight2($width,$height,$aux_espacio))
	                        {
	                        	@$oResize->save($path_destino);
	                        }
	                        else
	                        {
	                        	@unlink($path_destino);
	                        	return '';
	                        }
	                    //}
	                    //else
	                    	//return '';
                    }
                    else
                    {
                        //resize a $width
                        @$oResize->resizeWidth($width);
						//if(@$oResize->save_part($path_destino))
						//{
	                        //@$oResize = new ImageResize($path_destino);
							if($width>$ancho)
								$aux_espacio = 0;
							$oResize->gd_s = $oResize->gd_d;
	                        @$oResize->resizeWidthHeight2($width,$height,0);
	                        @$oResize->save($path_destino);
	                   	//}
                    }
                }
                else
                {
                	return '';
                }
            }
  
            $image = '<img '.$clase_foto.'src="'.URL_BASE_FILE."fotos/".$ruta_destino.$foto_nueva.'" alt="'.$alt.'" title="'.$title.'" width="'.$width.'" height="'.$height.'" '.$clase_foto.' />';        
  
            
        }
        else
            $image = '';
  
        return $image;
    }

    public function generaThumb($ruta_origen,$imagen_origen,$ruta_destino,$width,$height,$th='th_')
    {
        $imagen = '';
        if ($ruta_origen!="" && $imagen_origen!="")
        {
              
            //$foto_nueva = str_replace("tmb1_","tmb4_",$foto);

			$foto_nueva = $th.$imagen_origen;
			
			$path_origen = PATH_BASE_FILE."fotos/".$ruta_origen.'orig_'.$imagen_origen; 
			if(!file_exists($path_origen))
				$path_origen = PATH_BASE_FILE."fotos/".$ruta_origen.$imagen_origen;
			$path_destino = PATH_BASE_FILE."fotos/".$ruta_destino.$foto_nueva;
             
            if(!file_exists($path_destino))
            {
                 
               	if(file_exists($path_origen))
                {
                    //genero la imagen
                    include_once(PATH_BASE."controllers/admin/herramientas/imageresize.class.php");
                     
                    @$oResize = new ImageResize($path_origen);
  
                    $info_imagen = @getimagesize($path_origen);
                    $ancho = $info_imagen[0];
                    $alto = $info_imagen[1];
  
                    $aux_height = ($width * $alto / $ancho);
                   	if($aux_height < $height)
                    {
                        //resize a $height
                        @$oResize->resizeHeight($height);
                        $aux_width =(int) ($height * $ancho / $alto);
                        $aux_espacio = (int)($aux_width - $width)/2;
						if($width>$ancho)
							$aux_espacio = 0;
						$oResize->gd_s = $oResize->gd_d;
                        if(@$oResize->resizeWidthHeight2($width,$height,$aux_espacio))
                        {
                        	@$oResize->save($path_destino);
                        }
                        else
                        {
                        	@unlink($path_destino);
                        	return '';
                        }
                    }
                    else
                    {
                        //resize a $width
                        @$oResize->resizeWidth($width);
						if($width>$ancho)
							$aux_espacio = 0;
						$oResize->gd_s = $oResize->gd_d;
                        @$oResize->resizeWidthHeight2($width,$height,0);
                        @$oResize->save($path_destino);
                    }
                }
                else
                {
                	return '';
                }
            }

            return true;
            
        }
        else
            return '';
    }


	public function cantidadCompartidas($url)
	{
		$total = 0;
		$total_face = 0;
		$total_twitter = 0;
		if ($url!="")
		{
			//Para Facebook
			$opts = array(
		    	'http' => array(
			        'user_agent' => 'PHP libxml agent',
			        'proxy' => PROXY_HOST_TCP,
				    )
			);
			$context = stream_context_create($opts);
			libxml_set_streams_context($context);
			$xml = new DOMDocument();
			$xml->load('https://api.facebook.com/method/fql.query?query=SELECT like_count,share_count,total_count FROM link_stat WHERE url="'.$url.'"');
			$total_face = $xml->getElementsByTagName("total_count")->item(0)->nodeValue;
			if (!$total_face)
				$total_face = 0;
			

			//Para Twitter
			$aContext = array(
                'http' => array(
                    'proxy' => PROXY_HOST_TCP,
                    'request_fulluri' => true,
                ),
            );
            $cxContext = stream_context_create($aContext);
            $contenido = file_get_contents("http://urls.api.twitter.com/1/urls/count.json?url=".$url, false, $cxContext);
			$contenido = json_decode($contenido);
			$total_twitter = $contenido->count;
			if (!$total_twitter)
				$total_twitter = 0;

			$result['total'] = $total_face + $total_twitter;
			$result['facebook']= $total_face;
			$result['twitter']= $total_twitter;
		}
		
		return $result;
	}

	public function quitaEspacios($cadena)
	{
		$cadena_validar = trim($cadena);
		$partes_cadena = explode(" ", $cadena_validar);
		if (count($partes_cadena) > 1)
		{
			$cadena_validar = "";
			foreach ($partes_cadena as $parte)
			{
				if ($parte!="")
					$cadena_validar .= $parte . " ";
			}
			$cadena_validar = trim($cadena_validar);
		}
			
		return $cadena_validar;	
	}

	public function obtengo_banners($lugar,$nombre="")
	{
		$CI =& get_instance();
		$CI->load->library('memcached_library');
		$tiempo_expiracion_banner = 72000;
		/*Obtengo banner*/
		$CI->load->model("banner_modelo","banner",true);
		$estado_banners = $CI->memcached_library->get('banner_estado_gral');
		if (!$estado_banners)
		{
			$estado_banners = $CI->banner->estadoBanners();
			$CI->memcached_library->add('banner_estado_gral', $estado_banners, $tiempo_expiracion_banner);
		}
		
		if ($estado_banners)
		{
			$banners = $CI->memcached_library->get('banner_'.$nombre.'_'.$lugar);
			if (!$banners)
			{
				$banners = $CI->banner->dameBanners($lugar);
				if (!$banners)
					$banners = "vacio";
				$CI->memcached_library->add('banner_'.$nombre.'_'.$lugar, $banners, $tiempo_expiracion_banner);
			}
			return $banners;
		}
		else
			return "";
		/**Fin Banners**/
	}

	public function generar_url($tipo,$id,$titulo,$seccion="")
	{
		$url = "";
		switch ($tipo) 
		{
			case '3':
				$url = site_url("usuarios/".$id."/".$this->limpiarurl($titulo).".html");
			break;
			case '32':
				//$url=site_url('nota/'.$id.'/'.$this->limpiarurl($seccion).'/'.$this->limpiarurl($titulo).'.html');
				$url=site_url('nota/'.$this->limpiarurl($seccion).'/'.$id.'/'.$this->limpiarurl($titulo).'.html');
			break;
			case '8':
				if($seccion!="")
					$url=limpiaurl($seccion);
				else
					$url=site_url('tags/'.$id.'/'.$this->limpiarurl($titulo).'.html');
			break;
		}
		return $url;
	}

	public function compartidas_google($url)
	{
		$curl = curl_init();
	    curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
	    curl_setopt($curl, CURLOPT_POST, true);
	    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	    curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.$url.'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
	    $curl_results = curl_exec($curl);
	    curl_close ($curl);
	    $array = json_decode($curl_results, true);
	    if (isset($array[0]['result']['metadata']['globalCounts']['count']))
	        $cant_plus = intval($array[0]['result']['metadata']['globalCounts']['count']);
	    else
	        $cant_plus = 0;

	    return $cant_plus;
	}

	public function valida_hora($hora)
	{
		$partes = explode(":",$hora);
		if (is_array($partes) and count($partes)>1)
		{
			$hora = $partes[0];
			$minutos = $partes[1];
			if ($hora < 24 and $minutos <= 59)
			{
				if (strlen($hora)< 2)
					$hora = "0".$hora;
				if (strlen($minutos)< 2)
					$minutos = "0".$minutos;
					
				return $hora.":".$minutos;
			}
			else
				return false;
		}
		elseif (is_numeric($hora) and $hora > 0 and $hora < 24)
            return $hora;
        else
			return false;
	}


	public function marca_agua($imgoriginal){

				// Cargar la estampa y la foto para aplicarle la marca de agua
		$im = imagecreatefromjpeg($imgoriginal);

		// Primero crearemos nuestra imagen de la estampa manualmente desde GD
		$estampa = imagecreatetruecolor(100, 50);
		//imagefilledrectangle($estampa, 0, 0, 99, 69, 0x0000FF);
		//imagefilledrectangle($estampa, 9, 9, 90, 60, 0xFFFFFF);
		$im = imagecreatefromjpeg($imgoriginal);
		imagestring($estampa, 5, 20, 20, 'OPINION', 0xe6e6e6);
		//imagestring($estampa, 3, 20, 40, '', 0xe6e6e6);

		// Establecer los márgenes para la estampa y obtener el alto/ancho de la imagen de la estampa
		$margen_dcho = 10;
		$margen_inf = 10;
		$sx = imagesx($estampa);
		$sy = imagesy($estampa);

		// Fusionar la estampa con nuestra foto con una opacidad del 50%
		imagecopymerge($im, $estampa, imagesx($im) - $sx - $margen_dcho, imagesy($im) - $sy - $margen_inf, 0, 0, imagesx($estampa), imagesy($estampa), 50);

		// Guardar la imagen en un archivo y liberar memoria
		imagepng($im, $imgoriginal);
		imagedestroy($im);



			}
}

?>
 

Anon7 - 2022
AnonSec Team