[Off] SMF REGISTRO
#8

Sй que es un poco tarde para responder aquн, pero bueno. Te recomiendo usar las funciones de SMF y HTTP, te ahorras mucho trabajo. Tambiйn arreglarнa tu problema.

Te dejo un cуdigo que hice bastante tiempo. Para que funcione debes ponerlo en la carpeta dуnde tienes el index.php.

PHP код:
<?php
// API key - usada para evitar que gente no autorizada haga cuentas usando este script
$api_key 'af97f036f9dbfb76830f46b5266e78569566270c'
// Extraemos los datos requeridos de la URL
$passed_api_key $_GET['key'];
$username $_GET['user'];
$password $_GET['pass'];
$email $_GET['email'];
// Verificamos si la API Key que pasaron es vбlida
if(strcmp($api_key$passed_api_key) === 0)
{
    
// Es vбlida - continuar
}
else
{
    
// API Key invбlida - no molestar a las demбs funciones
    
die("ERROR: Invalid API key");
}
// Verificamos si no hace falta ningъn parбmetro
if(empty($username) || empty($password) || empty($email))
{
    die(
"ERROR: Missing parameters");
}
// Incluimos los archivos necesarios
require_once('SSI.php');
require_once(
$sourcedir.'/Subs-Members.php');
function 
CreateForumAccount($user$pass$email_add)
{
    
    
$regOptions = array('interface' => 'admin',
                        
'auth_method' => 'password',
                        
'username' => $user,
                        
'password' => $pass,
                        
'password_check' => $pass,
                        
'email' => $email_add,
                        
'require' => 'nothing');
    
// Registramos la cuenta
    
$id registerMember($regOptions);
    
/*
// Crear un post informando que la cuenta fue creada
    $bot_name = 'Bot';
    $title = $user.' ('.$id.')';
    $body = 'Cuenta creada para '.$user.'';
    $msgOptions = array('body' => $body, 'subject' => $title);
    $topicOptions = array('board' => '1', 'mark_as_read' => '1','id' => '2');
    $posterOptions = array('email' => 'support@taco.com', 'name' => $bot_name);
    createPost($msgOptions, $topicOptions, $posterOptions);
*/
    
return $id;
}
// Llamamos la funciуn con los datos que extraнmos previamente de la URL
$id CreateForumAccount($username$password$email);
echo 
$id;
?>
Para llamar la funciуn:

pawn Код:
#include <sscanf2>

#define API_KEY "af97f036f9dbfb76830f46b5266e78569566270c"

CreateForumAccountForPlayer(playerid, password[], email[])
{
    new tmp@str[128], tmp@username[MAX_PLAYER_NAME];

    GetPlayerName(playerid, tmp@username, sizeof(tmp@username));

    format(tmp@str, sizeof(tmp@str), "url/foro/script.php?key="API_KEY"\
    &user=%s\
    &pass=%s\
    &email=%s"
, tmp@username, password, email);

    HTTP(playerid, HTTP_GET, tmp@str, "", "CheckAccount");
    return true;
}

forward CheckAccount(playerid, response_code, data[]);
public CheckAccount(playerid, response_code, data[])
{
    if(response_code == 200)
    {
         new tmp@user_id;
         if(sscanf(data, "i", tmp@user_id)) return SendClientMessage(playerid, -1, "error");
         
         CallLocalFunction("OnPlayerForumAccCreated", "ii", playerid, tmp@user_id);
    }
    else
    {
         printf("Ha ocurrido un error! \n response_code: %d \n data: %s", response_code, data);
         SendClientMessage(playerid, -1, "error");
    }
    return true;
}


forward OnPlayerForumAccCreated(playerid, user_id);
public OnPlayerForumAccCreated(playerid, user_id);
{
    new tmp@str[128], tmp@name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, tmp@name, sizeof(tmp@name));
    format(tmp@str, sizeof(tmp@str), "%s ha creado una cuenta en el foro. Ahora hay un total de %d cuentas registradas en el foro.", tmp@name, user_id);
 
    SendClientMessageToAll(-1, tmp@str);

    // otras cosas
   
   
    return true;
}
Reply


Messages In This Thread
SMF REGISTRO - by Juand - 07.06.2015, 16:22
Respuesta: SMF REGISTRO - by Goncho28 - 07.06.2015, 17:58
Respuesta: SMF REGISTRO - by Juand - 07.06.2015, 20:30
Respuesta: SMF REGISTRO - by Goncho28 - 07.06.2015, 23:28
Respuesta: SMF REGISTRO - by Juand - 08.06.2015, 00:04
Respuesta: SMF REGISTRO - by Goncho28 - 08.06.2015, 00:11
Respuesta: SMF REGISTRO - by Goncho28 - 08.06.2015, 17:16
Respuesta: SMF REGISTRO - by hotspicytaco - 12.06.2015, 21:06

Forum Jump:


Users browsing this thread: 2 Guest(s)