Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # condicionales si sincroniza por alguna razon
- if( si esta haciendo log/in/facebook o log/in/facebook/sync )
- include( "autentificacion/auth_facebook.php" );
- else if( si esta haciendo log/in/twitter o log/in/twitter/sync )
- include( "autentificacion/auth_twitter.php" );
- else if( si esta haciendo log/in/gplus o log/in/gplus/sync )
- include( "autentificacion/auth_gplus.php" );
- # --------------------------------------------------------------
- # ejemplo "auth_facebook.php
- <?php
- if( !strcmp($log, "entrar") && !strcmp( $_GET["social"], "facebook") )
- {
- if( !strcmp($_GET["m"], "sync") ) # sincronizando porque no tiene cuenta o cerro sesion de facebook
- {
- # no esta logeado, entonces tal vez:
- # - es usuario nuevo
- # - es usuario haciendo login por red social
- if( !is_login() )
- {
- $user_id= facebook_conectar();
- if( !$user_id )
- {
- echo '<h1>Error: no se pudo consultar tu informaci'. acento("o"). 'n en Facebook.</h1>';
- unset($user_id);
- }
- else
- {
- # si ya tiene cuenta
- if( consultar_datos_general( "USUARIOS", "ID_FACEBOOK='". proteger_cadena($user_id). "'", "ID") )
- {
- $_SESSION["username"]= consultar_datos_general( "USUARIOS", "ID_FACEBOOK='". proteger_cadena($user_id). "'", "USUARIO");
- $_SESSION["password"]= consultar_datos_general( "USUARIOS", "ID_FACEBOOK='". proteger_cadena($user_id). "'", "CLAVE");
- $_SESSION["iduser"]= consultar_datos_general( "USUARIOS", "ID_FACEBOOK='". proteger_cadena($user_id). "'", "ID");
- bruteforcing_del(); # eliminamos la IP del Bruteforcing (si es que existe)
- header( "Location: /" );
- }
- # no tiene cuenta, crearemos nueva cuenta
- else
- {
- $userface= facebook_get_userid(); # consultamos informacion del usuario a facebook
- # generamos valores aleatorios de clave y ID
- do //generamos numero aleatorio
- {
- $idtrack= generar_idtrack(); //obtenemos digito aleatorio
- }while( !strcmp( $idtrack, consultar_datos_general( "USUARIOS", "ID='". $idtrack. "'", "ID" ) ) );
- # creacion de sesiones
- $_SESSION["username"]= $userface["username"];
- $_SESSION["password"]= $idtrack;
- $_SESSION["iduser"]= $idtrack;
- # Geo Localizacion por IP
- require( "../geoipcity.inc" ); //incluimos cabecera
- include( "../geoipregionvars.php" );
- $geoip_bd= geoip_open( "admin/geoip/GeoIPLiteCity.dat", GEOIP_STANDARD ); //abrimos archivos dat
- $ip= $_SERVER['REMOTE_ADDR']; //obtenemos IP
- $r= geoip_record_by_addr( $geoip_bd, $ip );
- $ubicacion= proteger_cadena(($r->city. '/'. $GEOIP_REGION_NAME[$r->country_code][$r->region]. '/'. $r->country_name));
- geoip_close($geoip_bd); # cerramos stream
- $mundo= explode( "/", $ubicacion ); # ciudad/estado/pais
- $x= explode( "@", $userface["email"] ); # obtenemos dominio del mail
- # creamos cuenta en el sistema
- $trama= array(
- "id"=>"'". $idtrack. "'",
- "usuario"=>"'". proteger_cadena($userface["username"]). "'",
- "clave"=>"'". $idtrack. "'",
- "email"=>"'". proteger_cadena($userface["email"]). "'",
- "fecha"=>"'". time(). "'",
- "ciudad"=>"'". consultar_datos_general( "MUNDO_CIUDAD", "CIUDAD='". proteger_cadena($mundo[0]). "'", "ID"). "'",
- "estado"=>"'". consultar_datos_general( "MUNDO_ESTADO", "ESTADO='". proteger_cadena($mundo[1]). "'", "ID"). "'",
- "pais"=>"'". consultar_datos_general( "MUNDO_PAIS", "PAIS='". proteger_cadena($mundo[2]). "'", "CODIGO" ). "'",
- "id_facebook"=>"'". proteger_cadena($user_id). "'",
- "facebook_token"=>"'". facebook_token( "auto" ). "'" # ver my_facebook.php
- );
- insertar_bdd( "USUARIOS", $trama ); # si inserta con exito al usuario
- inicializar_espacio_personal($idtrack); # si hay error inicializando carpetas
- bruteforcing_del(); # eliminamos la IP del Bruteforcing (si es que existe)
- unset($userface, $ubicacion, $mundo, $trama );
- header( "Location: /" );
- }
- }
- }
- }
- else # sincronizando desde cuenta ya existente
- {
- if( !is_login() ) # si no esta logeado, esta haciendo fuerza bruta
- header( "Location: ". url_amigable( "?log=brute", "log", "login", "dos_prev") );
- else # esta logeado, esta agregando su facebook
- {
- $user_id= facebook_conectar();
- if( !$user_id )
- {
- echo '<h1>Error: no se pudo consultar tu informaci'. acento("o"). 'n en Facebook.</h1>';
- unset($user_id);
- }
- else
- {
- #trama
- $trama= array( "id"=>"'". proteger_cadena($_SESSION["iduser"]). "'",
- "id_facebook"=>"'". proteger_cadena($user_id). "'" );
- # actualizamos
- if( !actualizar_bdd( "USUARIOS", $trama ) ) # error
- {
- unset($trama, $user_id);
- header( "Location: ". url_amigable( "?my=perfil", consultar_datos_general("USUARIOS", "ID='". proteger_cadena($_SESSION["iduser"]). "'", "USUARIO"), "users", 0 ) );
- }
- else # exito
- {
- echo '<div class="exito_izq_nf">Perfil sincronizado con exito...</div>';
- unset($trama, $user_id);
- header( "Location: ". url_amigable( "?my=perfil", consultar_datos_general("USUARIOS", "ID='". proteger_cadena($_SESSION["iduser"]). "'", "USUARIO"), "users", 0 ) );
- }
- }
- }
- }
- }
- ?>
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement