<?php

class repass extends main_controller{
    function __construct(){
        $this->mod = $this->model("repass_model");
    }
    
    function send(){
        $arr_key = explode('/',$_GET['url']);
        $key = $arr_key[count($arr_key)-1];
        
        //comparar key
        $this->setCss( array("init.css") );
        $this->setJs( array( "init.js") );
        
        $datax = array();
        $datax['main'] = $this->_obtener_main($key);
        $datax['titulo']= "Administracion";
        //$datax['key']= $key;
                
        $this->set_layout("repass.php");
        
        $this->render($datax);
        
        
    }
    
    function init(){
        //$this->_get_loged();
        $this->setCss( array("init.css") );
        $this->setJs( array( "init.js") );
        
        $datax = array();
        $datax['main'] = $this->_obtener_main();
        $datax['titulo']= "Administracion";
        
        $this->set_layout("login_main.php");
        
        $this->render($datax);
    }
    

    
    function _obtener_main($key){
        $data['fecha'] = $this->get_fecha();
        $data['modulo'] =  "";
        $data['key'] = $key;
        
        return $this->view("login", $data);
    }
    
    function x_send_repass(){
        $nueva = $_POST['nueva'];
        $key = $_POST['key'];
        $ret = $this->mod->send_repass($nueva, $key);
        
        echo $ret;
                           
        
    }
    
/*
    
    function x_recordar_clave(){
                
        $email = $_POST['email'];
        
        $ret = $this->mod->recordar_clave($email);
                
        if ($ret){
            //enviar mail
            $link = DOMINIO_LINK_REPASS . "repass.php?key=345tgfg42354tredf2134sdf";
            
            $asunto = "Recordar Password";
            $headers = "MIME-Version: 1.0\r\n"; 
            $headers .= "Content-type: text/html; charset=utf-8\r\n"; 
            $headers .= "From: Desarrollo Web Foca Software <".EMAIL_FROM.">\r\n"; 
            //$headers .= "Reply-To: mariano@desarrolloweb.com\r\n"; 
            //$headers .= "Return-path: holahola@desarrolloweb.com\r\n"; 
            //$headers .= "Cc: maria@foca.com\r\n"; 
            //$headers .= "Bcc: pepe@foca.com,juan@foca.com\r\n";
            
            $cuerpo = ' 
            <html> 
            <head> 
               <title>Recordar Contraseña</title> 
            </head> 
            <body> 
            <h1>Hola</h1> 
            <p> 
            <b>Solicitaste un cambio de contraseña. Ingresa al siguiente link para cambiar tu contraseña.</b>
            </p> 
            <p> 
            <b><a href="'.$link.'">Cambiar Contraseña</a></b>
            </p>
            <p> 
            <b>Si no visualisas el link anterior, copia y pega este codigo en tu navegador.</b>
            </p>
            <p> 
            http://localhost/repass.php?key=kwbb3543hb4fjkbadhfb4bjh4rbj
            </p>
            </body> 
            </html> 
            ';
            
            mail ($ret['email'], $asunto, $cuerpo,$headers);
            echo $ret['email'];
            
        }
        else{
            echo 0;
        }
        
    }
*/

}


