Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // WBB_Connect 3.0 include by Hauke Marquardt alias |-|auke - 11.08.2013
- // Developed with the awesome pawn IDE: PAWNit 0.8.9 Beta
- // Used plugins: - SyncHTTP by Hauke Marquardt
- /*
- License:
- This code is free: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- You are not allowed to copy any code from this, into your code without
- naming authors name in credits!
- */
- #if defined _wbb_connect_included
- #endinput
- #endif
- #if !defined SYNC_HTTP_INCLUDED
- #if !defined HTTP_GET
- #define HTTP_GET 1
- #endif
- #if !defined HTTP_POST
- #define HTTP_POST 2
- #endif
- native SynchronizedHTTP ( URL[ ] , Data[ ] , const Result[] , Length , Method = HTTP_POST , Timeout = 5 , EnableDebug = false );
- #define SYNC_HTTP_INCLUDED
- #endif
- #define _wbb_connect_included
- #if !defined _samp_included
- #include <a_samp>
- #endif
- #if !defined _h_library_norm_included
- #define PAWN_TYPE_INT 1
- #define PAWN_TYPE_FLOAT 2
- #define PAWN_TYPE_ARRAY 3
- #define _h_library_norm_included
- #endif
- #define WBB_Connect::%0->%1( WBB_%0_%1(
- #define Var::%0-> Val_%0_
- #define PublicMethod:%1(%2) stock %1(%2)
- #define PrivateMethod:%1(%2) %1(%2)
- #if !defined LOD_CORE_HEADER_INCLUDED
- #define _:%0,) _:%0)
- #endif
- #pragma unused SplitResult
- #define ConsoleWriteLine(%1) printf ( "\n=== WBB_Connect ===\n%s\n===================%s\n" , %1 )
- #if !defined WBB_CONNECT_URL_LENGTH
- #define WBB_CONNECT_URL_LENGTH 128
- #endif
- #if !defined WBB_CONNECT_URL_SUFFIX
- #define WBB_CONNECT_URL_SUFFIX "?page=WBB_ConnectAPI"
- #endif
- #if !defined WBB_CONNECT_POST_SIZE
- #define WBB_CONNECT_POST_SIZE 2048
- #endif
- #if !defined WBB_CONNECT_MAX_POST_SIZE
- #define WBB_CONNECT_MAX_POST_SIZE 1536
- #endif
- #if !defined WBB_CONNECT_MAX_RESULT_BUFFER
- #define WBB_CONNECT_MAX_RESULT_BUFFER 768
- #endif
- #if !defined WBB_CONNECT_TIMEOUT
- #define WBB_CONNECT_TIMEOUT 5
- #endif
- #if defined WBB_CONNECT_ENABLE_DEBUG
- #define WBB_CONNECT_DEBUG_MODE 1
- #else
- #define WBB_CONNECT_DEBUG_MODE 0
- #endif
- #define USER_GENDER_MALE 1
- #define USER_GENDER_FEMALE 2
- #define USER_GENDER_NONE 0
- #define USER_ALREADY_EXISTS -1
- #define EMAIL_ALREADY_EXISTS 0
- enum WBB_Data {
- bool:Initialized = false,
- _:ApiURL[ WBB_CONNECT_URL_LENGTH ],
- _:AuthKey[ 32 ]
- }
- stock Var::Global->System[ WBB_Data ];
- PublicMethod:WBB_Initialize ( _:_ApiURL[ WBB_CONNECT_URL_LENGTH ] , _:_AuthKey[ ] ) {
- new subStr[ 8 ];
- strmid ( subStr , _ApiURL , 0 , 7 , sizeof subStr );
- if ( !strcmp ( "http://" , subStr ) )
- strmid ( _ApiURL , _ApiURL , 7 , strlen ( _ApiURL ) , WBB_CONNECT_URL_LENGTH );
- format ( Var::Global->System[ ApiURL ] , sizeof Var::Global->System[ ApiURL ] , "%s"WBB_CONNECT_URL_SUFFIX , _ApiURL );
- format ( Var::Global->System[ AuthKey ] , sizeof Var::Global->System[ AuthKey ] , _AuthKey );
- new buffer[ 128 ];
- if ( SendAPIRequest ( "function=None" , buffer , sizeof buffer ) ) {
- Var::Global->System[ Initialized ] = true;
- ConsoleWriteLine ( "Successfully initialized!" );
- return true;
- }
- return false;
- }
- PublicMethod:WBB_GetUserName ( _:UserID ) {
- new buffer[ 128 ], postData[ 32 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserName&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserID ( _:UserName[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return 0;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserID&name=%s" , UserName );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval(buffer);
- }
- PublicMethod:WBB_AddUserActivityPoints ( _:UserID , _:ActivityPoints ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=AddUserActivityPoints&id=%d&activityPoints=%d" , UserID , ActivityPoints );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_AddUserToGroup ( _:UserID , _:GroupID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=AddUserToGroup&id=%d&group=%d" , UserID , GroupID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_BanUser ( _:UserID , _:Reason[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=BanUser&id=%d&reason=%s" , UserID , Reason );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_UnbanUser ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=UnbanUser&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_CheckUserPassword ( _:UserID , _:Password[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=CheckUserPassword&id=%d&password=%s" , UserID , Password );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_CloseThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=CloseThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_OpenThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=OpenThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_StickThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=StickThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_UnstickThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=UnstickThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DisableThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DisableThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_EnableThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=EnableThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_TrashThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=TrashThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_RestoreThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=RestoreThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DeleteThread ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DeleteThread&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DisablePost ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DisablePost&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_EnablePost ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=EnablePost&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_TrashPost ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=TrashPost&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_RestorePost ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=RestorePost&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DeletePost ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DeletePost&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_SetUserBirthday ( _:UserID , _:Day , _:Month , _:Year ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=SetUserBirthday&id=%d&day=%d&month=%d&year=%d" , UserID , Day , Month , Year );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_SetUserGender ( _:UserID , _:Gender ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=SetUserGender&id=%d&gender=%d" , UserID , Gender );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_SetUserEmail ( _:UserID , _:Email[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=SetUserEmail&id=%d&email=%s" , UserID , Email );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- if ( buffer[ 0 ] = '1' )
- return true;
- return EMAIL_ALREADY_EXISTS;
- }
- PublicMethod:WBB_SetUserName ( _:UserID , _:Name[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=SetUserName&id=%d&name=%s" , UserID , Name );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- if ( buffer[ 0 ] == '1' )
- return true;
- return USER_ALREADY_EXISTS;
- }
- PublicMethod:WBB_SetUserPassword ( _:UserID , _:Password[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=SetUserPassword&id=%d&password=%s" , UserID , Password );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- if ( buffer[ 0 ] == '1' )
- return true;
- return false;
- }
- PublicMethod:WBB_SetUserTitle ( _:UserID , _:Title[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=SetUserTitle&id=%d&title=%s" , UserID , Title );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_SetUserCustomOption ( _:UserID , _:Option[ ] , _:Value[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=SetUserCustomOption&id=%d&option=%s&value=%s" , UserID , Option , Value );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_RemoveUserFromGroup ( _:UserID , _:Group ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=RemoveUserFromGroup&id=%d&group=%d" , UserID , Group );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- if ( buffer[ 0 ] == '1' )
- return true;
- return false;
- }
- PublicMethod:WBB_SendPM ( _:UserID , _:RecipientID , _:Subject[ ] , _:Text[ ] , bool:EnableSmilies = false , bool:EnableHTML = false , bool:EnableBBCodes = false , bool:ShowSignature = false ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ WBB_CONNECT_MAX_POST_SIZE ];
- format ( postData , sizeof postData , "function=SendPM&id=%d&recipient=%d&subject=%s&text=%s&enableSmilies=%d&enableHtml=%d&enableBBCodes=%d&showSignature=%d" , UserID , RecipientID , Subject , Text , EnableSmilies , EnableHTML , EnableBBCodes , ShowSignature );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_CreatePost ( _:UserID , _:ThreadID , _:Subject[ ] , _:Text[ ] , bool:Disabled = false , bool:CloseThread = false , bool:MarkAsDone = false , bool:EnableSmilies = false , bool:EnableHTML = false , bool:EnableBBCodes = false , bool:ShowSignature = false ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ WBB_CONNECT_MAX_POST_SIZE ];
- format ( postData , sizeof postData , "function=CreatePost&id=%d&threadID=%d&subject=%s&text=%s&disabled=%d&markAsDone=%d&closeThread=%d&enableSmilies=%d&enableHtml=%d&enableBBCodes=%d&showSignature=%d" ,
- UserID , ThreadID , Subject , Text , Disabled , MarkAsDone , CloseThread , EnableSmilies , EnableHTML , EnableBBCodes , ShowSignature );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval(buffer);
- }
- PublicMethod:WBB_CreateThread ( _:UserID , _:BoardID , _:Prefix[ ] , _:Subject[ ] , _:Text[ ] , bool:IsImportant = false , bool:Closed = false , bool:Disabled = false , bool:CloseThread = false , bool:EnableSmilies = false , bool:EnableHTML = false , bool:EnableBBCodes = false , bool:ShowSignature = false ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ WBB_CONNECT_MAX_POST_SIZE ];
- format ( postData , sizeof postData , "function=CreateThread&id=%d&boardID=%d&prefix=%s&subject=%s&text=%s&isImportant=%d&closed=%d&disabled=%d&closeThread=%d&enableSmilies=%d&enableHtml=%d&enableBBCodes=%d&showSignature=%d" ,
- UserID , BoardID , Prefix , Subject , Text , IsImportant , Closed , Disabled , CloseThread , EnableSmilies , EnableHTML , EnableBBCodes , ShowSignature );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval(buffer);
- }
- PublicMethod:WBB_CreateUser ( _:Name[ ] , _:Email[ ] , _:Password[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 128 ];
- format ( postData , sizeof postData , "function=CreateUser&name=%s&email=%s&password=%s" , Name , Email , Password );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_DeleteUser ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DeleteUser&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DisableUserAvatar ( _:UserID , _:Reason[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DisableUserAvatar&id=%d&reason=%s" , UserID , Reason );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_EnableUserAvatar ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=EnableUserAvatar&id=%d&reason=%s" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_DisableUserSignature ( _:UserID , _:Reason[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=DisableUserSignature&id=%d&reason=%s" , UserID , Reason );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_EnableUserSignature ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=EnableUserSignature&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_GetNewestUser ( ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ];
- SendAPIRequest ( "function=GetNewestUser" , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetOldUsername ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetOldUserName&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetPostCreator ( _:PostID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetPostCreator&id=%d" , PostID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetThreadCreator ( _:ThreadID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetThreadCreator&id=%d" , ThreadID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetProfileAge ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetProfileAge&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserAge ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 128 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserAge&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserAboutMe ( _:UserID ) {
- new buffer[ WBB_CONNECT_MAX_RESULT_BUFFER ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserAboutMe&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserActivityPoints ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserActivityPoints&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserActivationCode ( _:UserID ) {
- new buffer[ 96 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserActivationCode&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserAvatarDisableReason ( _:UserID ) {
- new buffer[ 256 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserAvatarDisableReason&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserSigDisableReason ( _:UserID ) {
- new buffer[ 256 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserSignatureDisableReason&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserBanReason ( _:UserID ) {
- new buffer[ 256 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserBanReason&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserBirthday ( _:UserID ) {
- new buffer[ 64 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserBirthday&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserCustomOption ( _:UserID , _:Option[ ] ) {
- new buffer[ 64 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserCustomOption&id=%d&option=%s" , UserID , Option );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserEmail ( _:UserID ) {
- new buffer[ 96 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserEmail&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserGender ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserGender&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserHobbies ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserHobbies&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserHomepage ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserHomepage&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserLocation ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserLocation&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserLostPasswordKey ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserLostPasswordKey&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserOccupation ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserOccupation&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_SetUserOccupation ( _:UserID , _:Occupation[ ] ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 96 ];
- format ( postData , sizeof postData , "function=SetUserOccupation&id=%d&occupation=%s" , UserID , Occupation );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return true;
- }
- PublicMethod:WBB_GetUserReactivationCode ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserReactivationCode&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserTitle ( _:UserID ) {
- new buffer[ 128 ], postData[ 64 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return buffer;
- }
- format ( postData , sizeof postData , "function=GetUserTitle&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer;
- }
- PublicMethod:WBB_GetUserUnreadPMQuantity ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserUnreadPMQuantity&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserOutstandingPMs ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserOutstandingPMs&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserProfileHits ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserProfileHits&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserRankID ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=GetUserRankID&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return strval ( buffer );
- }
- PublicMethod:WBB_GetUserGroups ( _:UserID , _:GroupIDs[ ] , const _:ArraySize ) {
- new buffer[ 96 ], postData[ 64 ], tmpGroupBuffer[ 32 ][ 8 ];
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- format ( postData , sizeof postData , "function=GetUserGroups&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- SplitResult ( buffer , tmpGroupBuffer , ',' );
- for ( new i; i < ArraySize; i++ )
- GroupIDs[ i ] = strval ( tmpGroupBuffer[ i ] );
- return true;
- }
- PublicMethod:WBB_IsUserActivated ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserActivated&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_IsUserAvatarDisabled ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserAvatarDisabled&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_IsUserBanned ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserBanned&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_IsUserInGroup ( _:UserID , _:GroupID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserInGroup&id=%d&group=%d" , UserID , GroupID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_IsUserOnline ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserOnline&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PublicMethod:WBB_IsUserSignatureDisabled ( _:UserID ) {
- if ( !Var::Global->System[ Initialized ] ) {
- ConsoleWriteLine ( "Error: Not initialized" );
- return false;
- }
- new buffer[ 64 ], postData[ 64 ];
- format ( postData , sizeof postData , "function=IsUserSignatureDisabled&id=%d" , UserID );
- SendAPIRequest ( postData , buffer , sizeof buffer );
- return buffer[ 0 ] == '1' ? true : false;
- }
- PrivateMethod:SendAPIRequest ( PostData[ ] , Result[ ] , Length ) {
- new postString[ WBB_CONNECT_POST_SIZE ];
- format ( postString , WBB_CONNECT_POST_SIZE , "auth_key=%s&%s" , Var::Global->System[ AuthKey ] , PostData );
- new httpStatus = SynchronizedHTTP ( Var::Global->System[ ApiURL ] , postString , Result , Length , HTTP_POST , WBB_CONNECT_TIMEOUT , WBB_CONNECT_DEBUG_MODE );
- #if WBB_CONNECT_DEBUG_MODE == 1
- new tmpString[ 256 ];
- format ( tmpString , sizeof tmpString , "DEBUG:\nDestination: %s\nData: %s\nHTTP status: %d\nResponse: %s", Var::Global->System[ ApiURL ] , postString , httpStatus , Result );
- ConsoleWriteLine ( tmpString );
- #endif
- if ( httpStatus == 200 ) {
- if ( Result[ 0 ] == '0' ) { // check connection bytes
- ConsoleWriteLine ( "Error: Connection rejected. IP restriction is enabled." );
- return false;
- }
- else if ( Result[ 0 ] == '1' ) {
- ConsoleWriteLine ( "Error: Connection rejected. Wrong authentication key." );
- return false;
- }
- else if ( Result[ 0 ] == '2' ) {
- if ( Result[ 1 ] == '0' ) { // check execution bytes
- strdel ( Result , 0 , 3 );
- new tmpStr[ 256 ];
- format ( tmpStr , sizeof tmpStr , "Error: API request could not be executed.\nReason: %s", Result );
- ConsoleWriteLine ( tmpStr );
- return false;
- }
- else if ( Result[ 1 ] == '1' ) {
- strdel ( Result , 0 , 3 );
- return true;
- }
- }
- new tmpStr[ 256 ];
- format ( tmpStr , sizeof tmpStr , "Error: Internal error. Connection bytes: %s", Result[ 0 ] );
- ConsoleWriteLine ( tmpStr );
- return false;
- }
- else {
- new tmpStr[ 256 ];
- format ( tmpStr , sizeof tmpStr , "Error: Bad response from server: %d", httpStatus );
- ConsoleWriteLine ( tmpStr );
- return false;
- }
- }
- PrivateMethod:SplitResult ( String[ ] , Result[ ][ ] , Delimiter = ';' ) {
- new currentSplit = 0, offset = 0;
- for ( new i; i < strlen ( String ); i++ ) {
- if ( String[ i ] == Delimiter ) {
- Result[ currentSplit ][ offset ] = EOS;
- currentSplit++;
- offset = 0;
- continue;
- }
- else {
- Result[ currentSplit ][ offset ] = String[ i ];
- }
- offset++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement