Foros del Web » Programando para Internet » PHP »

Enviar datos cifrados a la base de datos.

Estas en el tema de Enviar datos cifrados a la base de datos. en el foro de PHP en Foros del Web. Hola amigos, antes que nada presentarme ya que soy nuevo en el Foro. Mi nombre es Robets, soy de Puerto Rico, la isla del encanto, ...
  #1 (permalink)  
Antiguo 03/11/2011, 18:15
 
Fecha de Ingreso: noviembre-2011
Ubicación: En este planeta.
Mensajes: 2
Antigüedad: 12 años, 5 meses
Puntos: 0
Enviar datos cifrados a la base de datos.

Hola amigos, antes que nada presentarme ya que soy nuevo en el Foro.

Mi nombre es Robets, soy de Puerto Rico, la isla del encanto, =).

He estado buscando información en la web sobre algo necesito hacer con mi sitio Web, y me tope con este foro. Es un gran aporte para todos los profesionales y aficionados como yo.

Le comento, para ver si pueden darme una mano con esto, cualquier tipo de ayuda es bienvenida.

El sitio que estoy desarrollando es una tienda en linea, acepto pago con PayPal, pero recientemente me ha dado por incluir el pago directo con tarjeta de crédito y débito, pero según las leyes sobre protección de datos, para eso debo cumplir algunas normas: Certificados SSL, Cifrado de datos, etc, etc, etc...

He creado el siguiente Script:

Código PHP:
$data['PageName']='CREDIT CARD INFORMATION';
$data['PageFile']='card';

include(
'../config.php');

if(!
$_SESSION['login']){
        
header("Location:{$data['Host']}/index.php");
        echo(
'ACCESS DENIED.');
        exit;
}

if(
is_info_empty($uid)){
        
header("Location:{$data['Host']}/profile.php");
        echo(
'ACCESS DENIED.');
        exit;
}

$post=select_info($uid$post);
if(!
$post['step'])$post['step']=1;

if(
$post['send']){
        if(
$post['step']==1){
                
$post['step']++;
        }elseif(
$post['step']==2){
          if(!
$post['ctype']){
                
$data['Error']='Please choose your credit card type.';
          }elseif(!
$post['cname']){
                
$data['Error']='Please enter your full name from credit card.';
          }else  if(!
$post['cnumber']||!is_number($post['cnumber'])){
                
$data['Error']='Please enter your valid credit card number.';
          }elseif(!
$post['ccvv']||!is_number($post['ccvv'])){
                
$data['Error']='Please enter your valid credit card CVV number.';
          }elseif(!
$post['cmonth']){
                
$data['Error']='Please choose month for expired date.';
          }elseif(!
$post['cyear']){
                
$data['Error']='Please choose year for expired date.';
          }else{ 

                if(!
$post['gid'])insert_card_info($post$uid); 
                else 
update_card_info($post$post['gid'], $uid);
                
$post['step']--;
          }
        }
}elseif(
$post['cancel'])$post['step']--;
if(
$post['action']=='update'){
        
$card=select_cards($uidtrue$post['gid'], true);
        foreach(
$card[0] as $key=>$value)if(!$post[$key])$post[$key]=$value;
        
$post['actn']='update';
        
$post['step']++;
}elseif(
$post['action']=='delete'){
        
delete_card($post['gid']);
}
if(
$post['step']==1){
        
$data['Cards']=select_cards($uid);
}

display('members');

?> 
Lo que debo hacer es cifrar los datos del "cnumber" que es el numero de la tarjeta, y el "cvv" que son los últimos 3 o 4 dígitos del dorso. Para que ni yo pueda tener acceso a ellos entrando al Cpanel. (esto para cumplir con las normas)

Este es un Script que copie de otro archivo que si envía los datos cifrado en md5 a la base de datos, este primer archivo es el de registro:

Código PHP:
$data['PageName']='SIGN UP FOR YOUR FREE ACCOUNT TODAY';
$data['PageFile']='signup';

include(
'../config.php');

if(
$post['action']=='go')optimize('coomonds');
if(
$post['send']){
    if(!
$post['newuser']){
        
$data['Error']='Your username can not be empty.';
    }elseif(
verify_username($post['newuser'])){
        
$data['Error']='For your username you can use only next letters [A..Z, a..z, 0..9].';
    }elseif(!
$post['newpass']){
        
$data['Error']='Your password can not be empty.';
    }elseif(
strlen($post['newpass'])<$data['PassLen']){
        
$data['Error']="Your password must be at least {$data['PassLen']} characters long.";
    }elseif(
$post['newpass']!=$post['cfmpass']){
        
$data['Error']='Your password and confirm should be not different.';
    }elseif(
$post['newuser']==$post['newpass']){
        
$data['Error']='Your password can not be same as your username.';
    }elseif(!
$post['newtrapass']){
        
$data['Error']='Your transfer password can not be empty.';
    }elseif(!
$post['newques']){
        
$data['Error']='Please enter a valid security question.';
    }elseif(!
$post['newansw']){
        
$data['Error']='Please enter a valid security answer.';
    }elseif(!
$post['newmail']||verify_email($post['newmail'])){
        
$data['Error']='Please enter your valid e-mail address.';
   }elseif(
$data['UseExtRegForm']&&!$post['newfname']){
        
$data['Error']='Please enter your first name.';
   }elseif(
$data['UseExtRegForm']&&!$post['newlname']){
        
$data['Error']='Please enter your last name.';
   }elseif(
$data['UseExtRegForm']&&!$post['newaddress']){
        
$data['Error']='Please enter your address.';
   }elseif(
$data['UseExtRegForm']&&!$post['newcity']){
        
$data['Error']='Please enter your city.';
   }elseif(
$data['UseExtRegForm']&&!$post['newcountry']){
        
$data['Error']='Please enter your country.';
   }elseif(
$data['UseExtRegForm']&&!$post['newzip']){
      
$data['Error']='Please enter your postal code.';
   }elseif(
$data['UseExtRegForm']&&!$post['newphone']){
      
$data['Error']='Please enter your telephone number.';
    }elseif(
$data['UseTuringNumber']&&
        (!
$post['turing']||strtoupper($post['turing'])!=$_SESSION['turing'])
    ){
        
$data['Error']='Please enter valid turing number.';
    }elseif(
$post['terms']!='on'){
        
$data['Error']='Please read our Terms and Conditions before signup.';
    }elseif(!
is_user_available($post['newuser'])){
        
$data['Error']='Sorry but this username already taken.';
    }elseif(!
is_mail_available($post['newmail'])){
        
$data['Error']='Sorry but this e-mail address already taken.';
    }else{
        
$mypasrd=md5($post['newpass']);
        
$myusr_id=create_confirmation(
            
$post['newuser'],
            
$mypasrd,
            
$post['newtrapass'],
            
$post['newques'],
            
$post['newansw'],
            
$post['newmail'],
            
$post['newfname'],
            
$post['newlname'],
            
$post['newcompany'],
            
$post['newregnum'],
            
$post['newdrvnum'],
            
$post['newaddress'],
            
$post['newcity'],
            
$post['newcountry'],
            
$post['newstate'],
            
$post['newzip'],
            
$post['newphone'],
            
$post['newfax'],
            
get_member_id($_SESSION['sponsor'])
        );
        
dcryptpass($post['newuser'],$post['newpass'],$myusr_id);
        unset(
$_SESSION['turing']);
        
$data['PostSent']=true;
    }
}else{
    if(
$data['UseTuringNumber'])$_SESSION['turing']=gencode();
}

display('members');

?> 
Y este es el archivo de inicial sesión que descifra los datos de la contraseña ya cifrada.

Código PHP:
$data['PageName']='MEMBER LOGIN';
$data['PageFile']='login';

include(
'../config.php');

if(!
$_SESSION['attempts'])$_SESSION['attempts']=0;

if(
$post['send']){
   if(
$_SESSION['attempts']<$data['PassAtt']-1){
        
$mypass=md5($post['password']);
        if(!
$post['username']){
                
$data['Error']='Your username can not be empty.';
        }elseif(!
md5($post['password'])){
                
$data['Error']='Your password can not be empty.';
        }elseif(
$data['UseTuringNumber']&&
                (!
$post['turing']||strtoupper($post['turing'])!=$_SESSION['turing'])
        ){
                
$data['Error']='Please enter valid turing number.';
        }elseif(!
is_member_active($post['username'])){
                
$data['Error']='This member was not found in the system. Or is inactive, banned or closed.';
        }elseif(!
is_member_found($post['username'], md5($post['password']))){
           
$data['Error']='Your have entered a wrong username or password.';
        }else{
            unset(
$_SESSION['attempts']);
            
            
$_SESSION['uid']=get_member_id($post['username'], md5($post['password']));
            
$_SESSION['login']=true;
            
set_last_access($post['username']);
            
save_remote_ip((int)$_SESSION['uid'], $_SERVER["REMOTE_ADDR"]);
            if(
$data['UseTuringNumber'])unset($_SESSION['turing']);
            
header("Location:{$data['Host']}/members/index.php");
            echo(
'ACCESS DENIED.');
            exit;
        }
        (int)
$_SESSION['attempts']++;
   }else{
      if(
$data['UseTuringNumber'])unset($_SESSION['turing']);
      unset(
$_SESSION['attempts']);
      
$data['CantLogin']=true;
   }
}
$data['attempts']=$_SESSION['attempts'];

if(
$data['UseTuringNumber'])$_SESSION['turing']=gencode();

display('members');

?> 

He intentado copiar la función de estos dos últimos para enviar los datos de la tarjeta cifrados, pero no he tenido éxito.

Bueno, gracias por su atención y espero que me puedan ayudar.

Etiquetas: registro
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:43.