Hilfe pWBB4

  • Hilfe pWBB4

    Hallo ich komme nicht mehr weiter

    ich will mit pWBB4 einen user erstellen


    pWBB-4-WSF

    Spoiler anzeigen

    /*
    wbb4 natives:
    native WBB_AddUser(Username[], Password[], Email[], playerid = -1, index = 0)
    native WBB_CheckPassword(UserID, Password[], playerid = -1, index = 0)

    native WBB_AddToGroups(UserID, GroupIDs[], playerid = -1, index = 0)
    native WBB_RemoveFromGroups(UserID, GroupIDs[], playerid = -1, index = 0)

    native WBB_BanUsername(Username[], Reason[] = "", BanTime = 0, playerid = -1, index = 0)
    native WBB_BanUserID(UserID, Reason[] = "", BanTime = 0, playerid = -1, index = 0)
    native WBB_UnbanUsername(Username[], playerid = -1, index = 0)
    native WBB_UnbanUserID(UserID, playerid = -1, index = 0)

    native WBB_EnableUsername(Username[], playerid = -1, index = 0)
    native WBB_EnableUserID(UserID, playerid = -1, index = 0)
    native WBB_DisableUsername(Username[], playerid = -1, index = 0)
    native WBB_DisableUserID(UserID, playerid = -1, index = 0)

    native WBB_AddPost(Username[], ThreadID, Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0)
    native WBB_AddPostUserID(UserID, ThreadID, Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0)

    WBB_AddThread(Username[], BoardID, Subject[], Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0)
    WBB_AddThreadUserID(UserID, BoardID, Subject[], Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0)

    native WBB_GetUserID(Username[], playerid = -1, index = 0)
    native WBB_IsForbiddenUsername(Username[], playerid = -1, index = 0)
    native WBB_IsBannedUserID(UserID, playerid = -1, index = 0)
    native WBB_IsBannedUsername(Username[], playerid = -1, index = 0)
    other natives:
    native pWBB4_CheckUpdate();
    php natives:
    native PHP_Hash(String[], Algo[], playerid = -1, index = 0)
    native PHP_CheckEmail(Email[], playerid = -1, index = 0);

    callbacks:
    native pWBB4_Callback(action, index, playerid, status, response[]);
    */
    // pWBB4 allready loaded?
    #if defined _pWBB4_included
    #endinput
    #endif
    #define _pWBB4_included
    // all includes loaded?
    #if !defined _samp_included
    #include <a_samp>
    #endif
    #if !defined HTTP_GET
    #include <a_http>
    #endif
    #if !defined sscanf
    #error sscanf wurde anscheinend nicht gefunden.
    #endif

    // check wbb key
    #if !defined pWBB_CONNECT_KEY "Zensiert"

    #endif
    #if !defined pWBB_URL "german-lagshot.de/forum"

    #endif
    // Settings
    #define pWBB_URL_LENGTH 512
    // Actions
    #define pWBB4_ACTION_PHPHASH 1
    #define pWBB4_ACTION_PHPCHECKEMAIL 2
    #define pWBB4_ACTION_WBBADDUSER 3
    #define pWBB4_ACTION_WBBCHECKPASSWORD 4
    #define pWBB4_ACTION_WBBADDTOGROUPS 5
    #define pWBB4_ACTION_WBBREMOVEFROMGROUPS 6
    #define pWBB4_ACTION_WBBBANUSERNAME 7
    #define pWBB4_ACTION_WBBBANUSERID 8
    #define pWBB4_ACTION_WBBUNBANUSERNAME 9
    #define pWBB4_ACTION_WBBUNBANUSERID 10
    #define pWBB4_ACTION_WBBENABLEUSERNAME 11
    #define pWBB4_ACTION_WBBENABLEUSERID 12
    #define pWBB4_ACTION_WBBDISABLEUSERNAME 13
    #define pWBB4_ACTION_WBBDISABLEUSERID 14
    #define pWBB4_ACTION_WBBADDPOST 15
    #define pWBB4_ACTION_WBBADDPOSTUSERID 16
    #define pWBB4_ACTION_WBBGETUSERID 17
    #define pWBB4_ACTION_WBBISFORBIDDENUSERNAME 18
    #define pWBB4_ACTION_CHECKUPDATE 19
    #define pWBB4_ACTION_WBBISBANNED 20
    #define pWBB4_ACTION_WBBADDTHREAD 21
    // OTHER Functions
    stock pWBB4_CheckUpdate() {
    return pWBB4_SendRequest(pWBB4_ACTION_CHECKUPDATE, "", -1, 0);
    }
    // PHP Functions
    stock PHP_Hash(string[], algo[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s&b=%s", algo, pWBB4_urlencode(string));
    return pWBB4_SendRequest(pWBB4_ACTION_PHPHASH, str, playerid, index);
    }
    stock PHP_CheckEmail(Email[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s", pWBB4_urlencode(Email));
    return pWBB4_SendRequest(pWBB4_ACTION_PHPCHECKEMAIL, str, playerid, index);
    }
    // WBB4 Functions
    stock WBB_AddUser(Username[], Password[], Email[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s&b=%s&c=%s", pWBB4_urlencode(Username), pWBB4_urlencode(Password), pWBB4_urlencode(Email));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDUSER, str, playerid, index);
    }
    stock WBB_CheckPassword(UserID, Password[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%d&b=%s", UserID, pWBB4_urlencode(Password));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBCHECKPASSWORD, str, playerid, index);
    }
    // and WBB_CheckPasswordByUsername?
    stock WBB_AddToGroups(UserID, GroupIDs[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%d&b=%s", UserID, pWBB4_urlencode(GroupIDs));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDTOGROUPS, str, playerid, index);
    }
    stock WBB_RemoveFromGroups(UserID, GroupIDs[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%d&b=%s", UserID, pWBB4_urlencode(GroupIDs));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBREMOVEFROMGROUPS, str, playerid, index);
    }
    stock WBB_BanUsername(Username[], Reason[] = "", BanTime = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=1&b=%s&c=%s&d=%d", pWBB4_urlencode(Username), pWBB4_urlencode(Reason), BanTime);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBBANUSERNAME, str, playerid, index);
    }
    stock WBB_BanUserID(UserID, Reason[] = "", BanTime = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=2&b=%d&c=%s&d=%d", UserID, pWBB4_urlencode(Reason), BanTime);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBBANUSERID, str, playerid, index);
    }
    stock WBB_UnbanUsername(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=1&b=%s", Username);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBUNBANUSERNAME, str, playerid, index);
    }
    stock WBB_UnbanUserID(UserID, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=2&b=%d", UserID);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBUNBANUSERID, str, playerid, index);
    }
    stock WBB_EnableUsername(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=1&b=1&c=%s", Username);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBENABLEUSERNAME, str, playerid, index);
    }
    stock WBB_EnableUserID(UserID, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=2&b=1&c=%d", UserID);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBENABLEUSERID, str, playerid, index);
    }
    stock WBB_DisableUsername(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=1&b=2&c=%s", Username);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBDISABLEUSERNAME, str, playerid, index);
    }
    stock WBB_DisableUserID(UserID, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=2&b=2&c=%d", UserID);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBDISABLEUSERID, str, playerid, index);
    }
    stock WBB_AddPost(Username[], ThreadID, Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s&b=%d&d=%s&i=1&j=%d&k=%d", pWBB4_urlencode(Username), ThreadID, pWBB4_urlencode(Message), isDisabled, isGuest);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDPOST, str, playerid, index);
    }
    stock WBB_AddPostUserID(UserID, ThreadID, Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%d&b=%d&d=%s&i=2&j=%d&k=%d", UserID, ThreadID, pWBB4_urlencode(Message), isDisabled, isGuest);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDPOSTUSERID, str, playerid, index);
    }
    stock WBB_GetUserID(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s", pWBB4_urlencode(Username));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBGETUSERID, str, playerid, index);
    }
    stock WBB_IsForbiddenUsername(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s", pWBB4_urlencode(Username));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBISFORBIDDENUSERNAME, str, playerid, index);
    }
    stock WBB_IsBannedUserID(UserID, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%d&b=0", UserID);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBISBANNED, str, playerid, index);
    }
    stock WBB_IsBannedUsername(Username[], playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=%s&b=1", pWBB4_urlencode(Username));
    return pWBB4_SendRequest(pWBB4_ACTION_WBBISBANNED, str, playerid, index);
    }
    /*stock WBB_AddThread(Username[], BoardID, Subject[], Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=1&b=%s&c=%d&d=%s&e=%s&f=%d&g=%d", pWBB4_urlencode(Username), BoardID, pWBB4_urlencode(Subject), pWBB4_urlencode(Message), isDisabled, isGuest);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDTHREAD, str, playerid, index);
    }
    stock WBB_AddThreadUserID(UserID, BoardID, Subject[], Message[], isDisabled = 0, isGuest = 0, playerid = -1, index = 0) {
    new str[pWBB_URL_LENGTH];
    format(str,sizeof str, "a=0&b=%d&c=%d&d=%s&e=%s&f=%d&g=%d", UserID, BoardID, pWBB4_urlencode(Subject), pWBB4_urlencode(Message), isDisabled, isGuest);
    return pWBB4_SendRequest(pWBB4_ACTION_WBBADDTHREAD, str, playerid, index);
    }*/
    // include functions + callbacks
    stock pWBB4_SendRequest(action, postData[], playerid = 0, index = 0) {
    new url[pWBB_URL_LENGTH];
    format(url, pWBB_URL_LENGTH, #pWBB_URL"/samp.php?action=%d&playerid=%d&index=%d&key="#pWBB_CONNECT_KEY, action, playerid, index);
    #if defined pWBB_DEBUG
    printf("[pWBB4/HTTP Debug] URL: %s / Post: %s",url, postData);
    #endif
    return HTTP(action, HTTP_POST, url, postData, "pWBB4_Response");
    }
    forward pWBB4_Response(action, response, data[]);
    public pWBB4_Response(action, response, data[]) {
    #if defined pWBB_DEBUG
    printf("[pWBB4/Debug] Response (%d): %d / %s", response, action, data);
    #endif
    if ( response == 200 ) {
    new index, playerid, status, res[256];
    if ( !sscanf(data, "ddds[256]", index, playerid, status, res) ) {
    CallRemoteFunction("pWBB4_Callback", "dddds", action, index, playerid, status, res);
    } else {
    CallRemoteFunction("pWBB4_Callback", "dddds", action, -1, -1, -1, "null");
    }
    } else {
    CallRemoteFunction("pWBB4_Callback", "dddds", action, -1, -1, -1, "null");
    }
    }
    /**
    * Url encodes a specific string (by DracoBlue)
    */
    stock pWBB4_urlencode(string[]) {
    new ret[128];
    ret[0] = 0;
    new i,p,s;
    while (string != 0) {
    if ( string[i] >= 128 ) {
    i++;
    continue;
    }
    if ( (string[i] >= 'A' && string[i] <='Z') || (string[i] >= 'a' && string[i] <='z') || (string[i] >= '0' && string[i] <='9') || (string[i] == '-') || (string[i] == '_') || (string[i] == '.') ) { ret[p] = string[i]; }
    else {
    ret[p] = '%';
    p++;
    s = (string[i] % 16);
    ret[p+1] = (s>9) ? (55+s) : (48+s);
    s = floatround((string[i] - s)/16);
    ret[p] = (s>9) ? (55+s) : (48+s);
    p++;
    }
    p++;
    i++;
    }
    return ret;
    }



    Pawncode

    PAWN-Quellcode

    1. #define pWBB_DEBUG 1;#include <pWBB4-WSF>unter onplayerconnectWBB_AddUser("derpierre65", "1337", "info@tesohahsa.de", playerid, 1);forward pWBB4_Callback(action, index, playerid, status, response[]);public pWBB4_Callback(action, index, playerid, status, response[]) { if ( action == pWBB4_ACTION_WBBADDUSER ) { if ( status == 1 ) { printf("Der User wurde erfolgreich erstellt! UserID = %d", strval(response)); } else if ( status == -1 ) { printf("Der Benutzername '%s' ist ungültig.", response); SendClientMessage(playerid, ROT, "Der Benutzername ist ungültig."); } else if ( status == -2 ) { printf("Der Benutzername '%s' ist bereits vergeben.", response); } else if ( status == -3 ) { printf("Das Passwort '%s' ist nicht sicher genug.", response); } else if ( status == -4 ) { printf("Die E-Mail Adresse '%s' ist ungültig.", response); } else if ( status == -5 ) { printf("Die E-Mail Adresse '%s' ist bereits vergeben.", response); } } return 1;}[b][/b]


    Serverlog

    Spoiler anzeigen

    [15:14:32] [pWBB4/HTTP Debug] URL: pWBB_URL/samp.php?action=3&playerid=0&index=1&key=pWBB_CONNECT_KEY / Post: a=derpierre65&b=1337&c=admin%40derpierre65.de
    [15:14:32] [pWBB4/Debug] Response (1): 3 /
    [15:14:32] Der Benutzername 'null' ist ungültig.


    bei der Installation wurde die rechte der beien Dateien auf 777 gestellt und dem user WWW-date zugewiesen.


    @theTV
    @Kaliber

    @seegras

    bitte hilft mi
    cooler Roleplay server :server.lyd-roleplay.de:7777

    cooler Dm server: German-lagshot.de:7777

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von Lukas_freiman ()

  • wiki.sa-mp.com/wiki/HTTP

    -> wie im Debug zu sehen ist der Response Code 1, wäre also folgender: HTTP_ERROR_BAD_HOST
    also scheint deine URL falsch zu sein, auch an der Request URL zu sehen (außer diese wurde zensiert)...

    bevor pWBB4 eingebunden wird muss folgendes definiert werden:

    PAWN-Quellcode

    1. #define pWBB_CONNECT_KEY "hier dein key von der installation"
    2. #define pWBB_URL "localhost/path/to/wbb"
    Mit freundlichen Grüßen derpierre65

    Ps: Rechtschreibfehler dürfen behalten werden.

    Alle meine Projekte (auch alte) können auf meiner Webseite nachgelesen werden.
    Mein öffentlicher Code kann bei GitHub runtergeladen werden.