Example #1
0
 function __construct()
 {
     // Obtengo IP del visitante
     $ip = new RemoteAddress();
     $this->ip = $ip->getIpAddress();
     $this->destinatario = "*****@*****.**";
     $this->cc = "*****@*****.**";
 }
Example #2
0
 private function prepareDataProvider($providerData)
 {
     $remote = new RemoteAddress();
     $ipClient = $remote->getIpAddress();
     $providerData['status'] = 0;
     $providerData['categories'] = '0';
     $providerData['approved'] = 0;
     $providerData['active'] = 0;
     $providerData['ip'] = $ipClient;
     $providerData['token'] = md5(uniqid(mt_rand(), true));
     return $providerData;
 }
/**
 * Tarkistaa käyttäjän IP:n ja lähettää ylläpitäjälle sähköpostin epäilyttävästä käytöksestä.
 * Lisäksi, jos löytää uuden sijainnin, päivittää sen tietokantaan.
 * Huom. toimii vain staattisilla IP-osoitteilla.
 * @param DByhteys $db
 * @param stdClass $user
 */
function check_IP_address(DByhteys $db, stdClass $user)
{
    $remoteaddr = new RemoteAddress();
    // Haetaan asiakkaan oikea ip osoite
    $ip = $remoteaddr->getIpAddress();
    $details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
    //Haetaan kaupunki lähettämällä asiakkaan ip ipinfo.io serverille
    $nykyinen_sijainti = $details->city;
    if ($nykyinen_sijainti != "") {
        //Jos sijainti tiedossa
        if ($user->viime_sijainti != "") {
            $match = strcmp($nykyinen_sijainti, $user->viime_sijainti);
            if ($match != 0) {
                laheta_ilmoitus_epailyttava_IP($db, $user->sahkoposti, $user->viime_sijainti, $nykyinen_sijainti);
                //lähetetään ylläpidolle ilmoitus
            }
        }
        //päivitetään sijainti tietokantaan
        $query = "\tUPDATE\tkayttaja\n\t\t\t\t\tSET\t\tviime_sijainti = {$nykyinen_sijainti}\n\t\t\t\t\tWHERE\tsahkoposti = ? ";
        $db->query($query, [$user->sahkoposti]);
    }
}
 public function registertienda()
 {
     $Response = array();
     if ($this->request->isPost()) {
         $Verificador = new ReCaptcha(KeyReCaptcha);
         $ResponseC = $Verificador->verifyResponse($_SERVER['REMOTE_ADDR'], $this->data['g-recaptcha-response']);
         if ($ResponseC->success) {
             //////////////////// Registro Usuario //////////////////////
             //try{
             $this->loadModel('Tienda.Usuario');
             $Total = $this->Usuario->find('count', array('conditions' => array('Usuario.email' => $this->data['email'])));
             if ($Total == 0) {
                 $this->loadModel('Tienda.ColoniaM');
                 $Colonia = $this->ColoniaM->find('first', array('entity' => true, 'conditions' => array('ColoniaM.cp' => $this->data['cp'])));
                 if ($Colonia != null) {
                     $IP = new RemoteAddress();
                     $this->Usuario->entity = true;
                     $Usuario = $this->Usuario->newEntity(array());
                     $Usuario->user_group_id = 5;
                     $Usuario->first_name = $this->data['nombre'];
                     $Usuario->middle_name = $this->data['apellidop'];
                     $Usuario->last_name = $this->data['apellidom'];
                     $Usuario->email = $this->data['email'];
                     $Usuario->username = $this->data['email'];
                     $Usuario->password = $this->UserAuth->makePassword($this->data['pass']);
                     $Usuario->salt = md5($Usuario->password);
                     $Usuario->email_verified = 0;
                     $Usuario->active = 0;
                     $Usuario->ip_address = $IP->getIpAddress();
                     $Usuario->created = date("Y-m-d H:i:s");
                     $Usuario->modified = date("Y-m-d H:i:s");
                     if ($this->Usuario->save($Usuario)) {
                         $Usuario->id = $this->Usuario->id;
                         $this->loadModel('Tienda.DireccionUsuario');
                         $Direccion = $this->DireccionUsuario->newEntity(array());
                         $Direccion->cp = $this->data['cp'];
                         $Direccion->calle = $this->data['calle'];
                         $Direccion->no_int = $this->data['numeroint'];
                         $Direccion->no_ext = $this->data['numeroext'];
                         $Direccion->id_colonias = $Colonia->id_colonias;
                         $Direccion->users_id = $this->Usuario->id;
                         $Direccion->activa = 1;
                         if ($this->DireccionUsuario->save($Direccion)) {
                             $this->loadModel('Tienda.DetalleUsuario');
                             $Detalles = $this->DetalleUsuario->newEntity(array());
                             $Fecha = split("-", $this->data['cumple']);
                             if (count($Fecha) == 3) {
                                 $Detalles->anio = $Fecha[0];
                                 $Detalles->mes = $Fecha[1];
                                 $Detalles->dia = $Fecha[2];
                             }
                             $Detalles->users_id = $this->Usuario->id;
                             $Detalles->telefono = $this->data['telefono'];
                             $Detalles->id_cat_redes = $this->data['redsocial'];
                             $Detalles->id_cat_estudios = $this->data['estudios'];
                             $Detalles->id_cat_ocupaciones = $this->data['ocupacion'];
                             $Detalles->genero = $this->data['genero'];
                             $Detalles->edo_civiles_id_edo_civiles = $this->data['civil'];
                             $Detalles->primera_compra = 0;
                             $Detalles->id_think = '--';
                             if ($this->DetalleUsuario->save($Detalles)) {
                                 if (!empty($this->data['titular'])) {
                                     $this->loadModel('Tienda.DatosTarjetaM');
                                     $this->loadModel('Tienda.Banco');
                                     $Banco = $this->Banco->find('first', array('entity' => true, 'conditions' => array('Banco.id_bancos' => $this->data['banco'])));
                                     if ($Banco != null) {
                                         $Seguridad = new Cifrado();
                                         $Tarjeta = $this->DatosTarjetaM->newEntity(array());
                                         $Tarjeta->titulas = $this->data['titular'];
                                         $Tarjeta->no_tarjeta = $Seguridad->cifrar('cifrar', $this->data['tarjeta'], KeyEncriptData);
                                         $Tarjeta->codigo_reguridad = $Seguridad->cifrar('cifrar', $this->data['cvc'], KeyEncriptData);
                                         $Tarjeta->fecha_expiracion = $Seguridad->cifrar('cifrar', $this->data['mes'] . '-' . $this->data['anio'], KeyEncriptData);
                                         $Tarjeta->tipo_tarjeta = $Seguridad->cifrar('cifrar', $this->data['tipo'], KeyEncriptData);
                                         $Tarjeta->id_bancos = $Banco->id_bancos;
                                         $Tarjeta->procesador_pago = 1;
                                         $Tarjeta->id_users = $this->Usuario->id;
                                         $this->DatosTarjetaM->save($Tarjeta);
                                     }
                                 }
                                 if (count($this->data['intereses']) > 0) {
                                     $this->loadModel('Tienda.InteresUser');
                                     foreach ($this->data['intereses'] as $key => $value) {
                                         $Interes = $this->InteresUser->newEntity(array());
                                         $Interes->id_cat_intereses = $value;
                                         $Interes->iduser_details = $this->DetalleUsuario->id;
                                         $this->InteresUser->save($Interes);
                                     }
                                 }
                                 $Usuario->keyActive = md5($Usuario->password . $Usuario->salt);
                                 $Email = new CakeEmail('smtp');
                                 $Email->viewVars(array('Usuario' => $Usuario));
                                 if ($Email->template('Tienda.registro', 'Tienda.usuario')->emailFormat('html')->subject("Activar Cuenta")->to($Usuario->email)->send()) {
                                     $Response['resp'] = "Ok";
                                     $Response['men'] = "<strong>Te has registrado con éxito, por favor revisa tu correo para confirmar tu cuenta.</strong>";
                                 } else {
                                     $Response["resp"] = "error";
                                     $Response["men"] = "<strong>Surgio un error al enviar el correo</strong>";
                                 }
                             } else {
                                 $Response['resp'] = "Error";
                                 $Response['men'] = "<strong>No se pudo registrar la información de detalle, contacte al administrado por favor.</strong>";
                             }
                         } else {
                             $Response['resp'] = "Error";
                             $Response['men'] = "<strong>No se pudo registrar su dirección, contacte al administrado por favor.</strong>";
                         }
                     } else {
                         $Response['resp'] = "Error";
                         $Response['men'] = "<strong>No se pudo registrar su información, intente de nuevo o contacte al administrado.</strong>";
                     }
                 } else {
                     $Response['resp'] = "Error";
                     $Response['men'] = "<strong>El código postal que ingreso no se pudo localizar.</strong>";
                 }
             } else {
                 $Response["resp"] = "error";
                 $Response["men"] = '<strong>El email "' . strip_tags($this->data['email']) . '" ya se encuentra registrado </strong>';
             }
             /*}catch(Exception $e) {
               		/////////////////// Regresamos estado anterior //////
               		$Response["resp"] ="error";
                   		     	    $Response["men"] ="<strong>Surgio un error inesperado</strong>";
               }*/
         } else {
             $Response["resp"] = "error";
             $Response["men"] = "<strong>El código de verificación es incorrecto</strong>";
         }
     } else {
         $Response["resp"] = "error";
         $Response["men"] = "<strong>No se recibierón los datos</strong>";
     }
     $this->set('response', $Response);
     $this->set('_serialize', array('response'));
 }