Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* WBB Connect by Hauke Marquardt alias |-|auke - 08.05.2012
- * Other credits:
- * MySQL Plugin: G-sTyLeZzZ
- * Encryption Plugin: Fro1sha
- */
- /*
- 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´re not allowed to copy any code from this, into your code without
- naming authors name in credits!
- */
- #include <a_samp>
- #include <a_http>
- native sha1 ( const text[ ] , hesh[ ] );
- native mysql_fetch_int ( connectionHandle = 1 );
- native md5 ( const text[ ] , hesh[ ] );
- native mysql_debug ( enable = 1 );
- native mysql_num_rows ( connectionHandle = 1 );
- native mysql_close ( connectionHandle = 1 );
- native mysql_connect ( const host[ ] , const user[ ] , const database[ ] , const password[ ] );
- native mysql_ping ( connectionHandle = 1 );
- native mysql_fetch_row_format ( string[ ] , const delimiter[ ] = "|" , connectionHandle = 1 );
- native mysql_format ( connectionHandle , output[ ] , format[ ] , {Float,_}:... );
- native mysql_free_result ( connectionHandle = 1 );
- native mysql_query ( query[ ] , resultid = ( -1 ) , extraid = ( -1 ) , connectionHandle = 1 );
- native mysql_real_escape_string ( const source[ ] , destination[ ] , connectionHandle = 1 );
- native mysql_store_result ( connectionHandle = 1 );
- forward HTTPResponse ( index , response_code , data[ ] );
- #define STORE_AND_FREE_RESULT mysql_query ( Query , -1 , -1 , MySQL[ Handle ] ); mysql_store_result ( MySQL[ Handle ] ); mysql_fetch_row_format ( Row , " " , MySQL[ Handle ] );mysql_free_result ( MySQL[ Handle ] );
- #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_USER_POSTS 0x0008
- #define WBB_USER_LAST_VISIT 0x0016
- #define WBB_USER_ACTIVATIO_CODE 0x0032
- #define WBB_USER_ACTIVITY_POINTS 0x0064
- #define WBB_USER_PROFILE_HITS 0x0128
- #define WBB_USER_UNREAD_PM 0x0256
- forward _WBB_SetMySQLData ( _Server[ ] , _User[ ] , _Password[ ] , _Database[ ] , _InstallationCount );
- forward _WBB_IsValidUser ( wbbUsername[ ] );
- forward _WBB_CheckPassword ( wbbUsername[ ] , Password[ ] );
- forward _WBB_AddNewUser ( Username[ ] , Password[ ] , Email[ ] , ActivationState );
- forward _WBB_ActivateUser ( Username[ ] );
- forward _WBB_BanUser ( Username[ ] , Reason[ ] );
- forward _WBB_UnBanUser ( Username[ ] );
- forward _WBB_NewPrivateMessage ( Username[ ] , RecipientName[ ] , Subject[ ] , Message[ ] );
- forward _WBB_GetUserActivationState ( Username[ ] );
- forward _WBB_SetUserPassword ( Username[ ] , Password[ ] );
- forward _WBB_SetProfileField ( Username[ ] , Field[ ] , Value[ ] , Type );
- forward _WBB_GetProfileField ( Username[ ] , Field[ ] );
- forward _WBB_SendUserActivationMail ( Username[ ] , Sendername[ ] , Servername[ ] , ForumIndexURL[ ] );
- forward _WBB_AddPost ( Thread , Subject[ ] , Message[ ] , Username[ ] , BBCodes , HTML );
- forward _WBB_IsUserInGroup ( Username[ ] , GroupID );
- forward _WBB_SetUserToGroup ( Username[ ] , GroupID );
- forward _WBB_RemoveUserFromGroup ( Username[ ] , GroupID );
- forward _WBB_UpdateUserMail ( Username[ ] , Mail[ ] );
- forward _WBB_GetUserStats ( Username[ ] , Data );
- forward _WBB_CreateThread ( Board , Topic[ ] , Username[ ] , Disabled , Closed , Subject[ ] , Message[ ] , BBCodes , HTML );
- enum MySQLData {
- Handle,
- Installation
- }
- new MySQL[ MySQLData ];
- public _WBB_SetMySQLData ( _Server[ ] , _User[ ] , _Password[ ] , _Database[ ] , _InstallationCount ) {
- mysql_debug ( 1 );
- MySQL[ Installation ] = _InstallationCount;
- MySQL[ Handle ] = mysql_connect ( _Server , _User , _Database , _Password );
- return mysql_ping ( MySQL[ Handle ] ) == -1 ? false : true;
- }
- public _WBB_IsValidUser ( wbbUsername[ ] )
- return IsValidUser ( wbbUsername );
- public _WBB_CheckPassword ( wbbUsername[ ] , Password[ ] )
- return strcmp ( GetDoubleSaltedHash ( Password , GetUserData ( wbbUsername , "salt" ) ) , GetUserData ( wbbUsername , "Password" ) ) ? false : true;
- public _WBB_AddNewUser ( Username[ ] , Password[ ] , Email[ ] , ActivationState ) {
- if ( IsValidEmail ( Email ) )
- return -1;
- if ( IsValidUser ( Username ) )
- return 0;
- new Query[ 256 ] , Salt[ 64 ];
- strcat ( Salt , CreateSalt ( ) );
- mysql_format ( MySQL[ Handle ] , Query ,
- "INSERT INTO `wcf%d_user` (username,email,password,salt,languageID,registrationDate,activationCode) VALUES ('%s','%s','%s','%s',1,%i,%i)" , MySQL[ Installation ] , Username , Email , GetDoubleSaltedHash ( Password , Salt ) , Salt , TimestampNow ( ) , ActivationState ? 0 : GenerateRandomValue ( ) );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- AddUserToGroup ( Username , 1 );
- if ( ActivationState )
- AddUserToGroup ( Username , 3 );
- return true;
- }
- public _WBB_ActivateUser ( Username[ ] ) {
- if ( !IsValidUser ( Username ) )
- return 0;
- if ( IsUserInGroup ( Username , 3 ) )
- return -1;
- else
- return AddUserToGroup ( Username , 3 ) ? 1 : 0;
- }
- public _WBB_BanUser ( Username[ ] , Reason[ ] ) {
- if ( !IsValidUser ( Username ) )
- return false;
- SetUserData ( Username , "banned" , "1" , PAWN_TYPE_INT );
- SetUserData ( Username , "banReason" , Reason );
- return true;
- }
- public _WBB_UnBanUser ( Username[ ] ) {
- if ( !IsValidUser ( Username ) )
- return false;
- SetUserData ( Username , "banned" , "0" , PAWN_TYPE_INT );
- new Query[ 128 ];
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET banReason = null WHERE username = '%s'" , MySQL[ Installation ] , Username );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return true;
- }
- public _WBB_NewPrivateMessage ( Username[ ] , RecipientName[ ] , Subject[ ] , Message[ ] ) {
- if ( !IsValidUser ( Username ) )
- return -1;
- if ( !IsValidUser ( RecipientName ) )
- return 20;
- new Query[ 512 ] , PMID[ 8 ] , Time = TimestampNow ( );
- mysql_format ( MySQL[ Handle ] , Query ,
- "INSERT INTO `wcf%d_pm` (userID,username,subject,message,time,saveInOutbox) VALUES (%i,'%s','%s','%s',%i,1)" , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) , Username , Subject , Message , Time );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT pmID FROM `wcf%d_pm` WHERE time = %d AND username = '%s'" , MySQL[ Installation ] , Time , Username );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_store_result ( MySQL[ Handle ] );
- mysql_fetch_row_format ( PMID , " " , MySQL[ Handle ] );
- mysql_free_result ( MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_pm` SET parentPmID = pmID WHERE pmID = %d" , MySQL[ Installation ] , strval ( PMID ) );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query ,
- "INSERT IGNORE INTO `wcf%d_pm_to_user` (pmID,recipientID,recipient,userWasNotified) VALUES (%i,%i,'%s',0)" , MySQL[ Installation ] , strval ( PMID ) , strval ( GetUserData ( RecipientName , "userID" ) ) , RecipientName );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET pmTotalCount = pmTotalCount + 1 WHERE username = '%s'" , MySQL[ Installation ] , RecipientName );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET pmUnreadCount = pmUnreadCount + 1 WHERE username = '%s'" , MySQL[ Installation ] , RecipientName );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET pmOutstandingNotification = pmOutstandingNotification + 1 WHERE username = '%s'" , MySQL[ Installation ] , RecipientName );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET pmTotalCount = pmTotalCount + 1 WHERE username = '%s'" , MySQL[ Installation ] , Username );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query ,
- "INSERT INTO `wcf%d_pm_hash` (pmID,time,messageHash) VALUES (%i,%i,'%s')" , MySQL[ Installation ] , strval ( PMID ) , Time , GetHash ( Message , GetWBBConfig ( "encryption_method" ) ) );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return 1;
- }
- public _WBB_GetUserActivationState ( Username[ ] )
- return IsUserInGroup ( Username , 3 );
- public _WBB_SetUserPassword ( Username[ ] , Password[ ] ) {
- if ( !IsValidUser ( Username ) )
- return false;
- new Salt[ 64 ];
- strcat ( Salt , CreateSalt ( ) );
- SetUserData ( Username , "password" , GetDoubleSaltedHash ( Password , Salt ) );
- return SetUserData ( Username , "salt" , Salt );
- }
- public _WBB_SetProfileField ( Username[ ] , Field[ ] , Value[ ] , Type ) {
- if ( !IsValidUser ( Username ) )
- return -1;
- if ( !GetWBBOptionID ( Field ) )
- return 0;
- SetUserOption ( Username , GetWBBOptionID ( Field ) , Value , Type );
- return 1;
- }
- public _WBB_GetProfileField ( Username[ ] , Field[ ] ) {
- if ( !IsValidUser ( Username ) )
- return -1;
- if ( !GetWBBOptionID ( Field ) )
- return 0;
- return GetUserOption ( Username , GetWBBOptionID ( Field ) );
- }
- public _WBB_SendUserActivationMail ( Username[ ] , Sendername[ ] , Servername[ ] , ForumIndexURL[ ] ) {
- if ( !IsValidUser ( Username ) )
- return false;
- return SendMail ( Username , Sendername , Servername , ForumIndexURL );
- }
- public _WBB_AddPost ( Thread , Subject[ ] , Message[ ] , Username[ ] , BBCodes , HTML ) {
- if ( !IsValidUser ( Username ) )
- return false;
- return AddPostToThread ( Thread , Subject , Message , Username , BBCodes , HTML , TimestampNow ( ) );
- }
- public _WBB_IsUserInGroup ( Username[ ] , GroupID )
- return IsValidUser ( Username ) ? IsUserInGroup ( Username , GroupID ) : -1;
- public _WBB_SetUserToGroup ( Username[ ] , GroupID ) {
- if ( !IsValidUser ( Username ) )
- return false;
- return AddUserToGroup ( Username , GroupID );
- }
- public _WBB_RemoveUserFromGroup ( Username[ ] , GroupID ) {
- if ( !IsValidUser ( Username ) )
- return -1;
- if ( !IsUserInGroup ( Username , GroupID ) )
- return -2;
- return RemoveUserFromGroup ( Username , GroupID ) ? 1 : 0;
- }
- public _WBB_UpdateUserMail ( Username[ ] , Mail[ ] ) {
- if ( !IsValidUser ( Username ) )
- return false;
- return SetUserData ( Username , "email" , Mail , PAWN_TYPE_ARRAY );
- }
- public _WBB_GetUserStats ( Username[ ] , Data ) {
- switch ( Data ) {
- case WBB_USER_POSTS:
- return strval ( GetUserWBBData ( Username , "posts" ) );
- case WBB_USER_LAST_VISIT:
- return strval ( GetUserWBBData ( Username , "boardLastVisitTime" ) );
- case WBB_USER_ACTIVATIO_CODE:
- return strval ( GetUserData ( Username , "activationCode" ) );
- case WBB_USER_ACTIVITY_POINTS:
- return strval ( GetUserData ( Username , "activityPoints" ) );
- case WBB_USER_PROFILE_HITS:
- return strval ( GetUserData ( Username , "profileHits" ) );
- case WBB_USER_UNREAD_PM:
- return strval ( GetUserData ( Username , "pmUnreadCount" ) );
- }
- return false;
- }
- public _WBB_CreateThread ( Board , Topic[ ] , Username[ ] , Disabled , Closed , Subject[ ] , Message[ ] , BBCodes , HTML ) {
- if ( !IsValidUser ( Username ) )
- return false;
- new Query[ 1536 ] , Keys[ 512 ] , Values[ 1024 ] , UserID = strval ( GetUserData ( Username , "userID" ) ) , Time = TimestampNow ( ) , Row[ 16 ] , ThreadID , PostID;
- strcat ( Keys , "boardID,topic,languageID,userID,username,prefix,time,lastPostTime,lastPosterID,lastPoster,attachments,polls,isSticky,isAnnouncement,isClosed,isDisabled,everEnabled" );
- format ( Values , sizeof Values , "%d,'%s',0,%d,'%s','',%d,%d,%d,'%s',0,0,0,0,%d,%d,0" , Board , Topic , UserID , Username , Time , Time , UserID , Username , Closed > 0 ? 1 : 0 , Disabled > 0 ? 1 : 0 );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_thread` (%s) VALUES (%s)" , MySQL[ Installation ] , Keys , Values );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT threadID FROM `wbb1_%d_thread` WHERE boardID = %d AND time = %d" , MySQL[ Installation ] , Board , Time );
- STORE_AND_FREE_RESULT
- ThreadID = strval ( Row );
- format ( Keys , sizeof Keys , "%s" , "threadID,subject,message,userID,username,time,attachments,enableSmilies,enableHtml,enableBBCodes,showSignature,pollID,ipAddress,isDisabled,everEnabled" );
- format ( Values , sizeof Values , "%d,'%s','%s',%d,'%s',%d,0,0,%d,%d,0,0,'127.0.0.1',0,0" , ThreadID , Subject , Message , UserID , Username , Time , HTML > 0 ? 1 : 0 , BBCodes > 0 ? 1 : 0 );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_post` (%s) VALUES (%s)" , MySQL[ Installation ] , Keys , Values );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT postID FROM `wbb1_%d_post` WHERE userID = %d AND time = %d" , MySQL[ Installation ] , UserID , Time );
- STORE_AND_FREE_RESULT
- PostID = strval ( Row );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_user_last_post` (userID,postID,time) VALUES (%d,%d,%d)" , MySQL[ Installation ] , UserID , PostID , Time );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_post_hash` (postID,messageHash,time) VALUES (%d,'%s',%d)" , MySQL[ Installation ] , PostID , GetHash ( Message , "md5" ) , Time );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT boardID FROM `wbb1_%d_thread` WHERE threadID = %d" , MySQL[ Installation ] , ThreadID );
- STORE_AND_FREE_RESULT
- mysql_format ( MySQL[ Handle ] , Query , "REPLACE INTO `wbb1_%d_board_last_post` (boardID,languageID,threadID) VALUES (%d,0,%d)" , MySQL[ Installation ] , strval ( Row ) , ThreadID );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wbb1_%d_thread` SET firstPostID = %d, firstPostPreview = 'WBB_Connect Message | © WBB_Connect by Hauke Marquardt' WHERE threadID = %d" , MySQL[ Installation ] , PostID , ThreadID );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return true;
- }
- AddPostToThread ( Thread , Subject[ ] , Message[ ] , Username[ ] , BBCodes , HTML , Time ) {
- new Query[ 1536 ] , Keys[ 512 ] , Values[ 1024 ] , Row[ 16 ] , UserID = strval ( GetUserData ( Username , "userID" ) );
- strcat ( Keys , "threadID,subject,message,userID,username,time,attachments,enableSmilies,enableHtml,enableBBCodes,showSignature,pollID,ipAddress,isDisabled,everEnabled" );
- format ( Values , sizeof Values , "%d,'%s','%s',%d,'%s',%d,0,0,%d,%d,0,0,'127.0.0.1',0,0" , Thread , Subject , Message , strval ( GetUserData ( Username , "userID" ) ) , Username , Time , HTML > 0 ? 1 : 0 , BBCodes > 0 ? 1 : 0 );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_post` (%s) VALUES (%s)" , MySQL[ Installation ] , Keys , Values );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT postID FROM `wbb1_%d_post` WHERE userID = %d AND time = %d" , MySQL[ Installation ] , UserID , Time );
- STORE_AND_FREE_RESULT
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_user_last_post` (userID,postID,time) VALUES (%d,%d,%d)" , MySQL[ Installation ] , UserID , strval ( Row ) , Time );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wbb1_%d_post_hash` (postID,messageHash,time) VALUES (%d,'%s',%d)" , MySQL[ Installation ] , strval ( Row ) , GetHash ( Message , "md5" ) , Time );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "SELECT boardID FROM `wbb1_%d_thread` WHERE threadID = %d" , MySQL[ Installation ] , Thread );
- STORE_AND_FREE_RESULT
- mysql_format ( MySQL[ Handle ] , Query , "REPLACE INTO `wbb1_%d_board_last_post` (boardID,languageID,threadID) VALUES (%d,0,%d)" , MySQL[ Installation ] , strval ( Row ) , Thread );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wbb1_%d_thread` SET replies = replies + 1, lastPostTime = %d, lastPosterID = %d, lastPoster = '%s' WHERE threadID = %d" , MySQL[ Installation ] , Time , UserID , Username , Thread );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return true;
- }
- AddUserToGroup ( Username[ ] , GroupID ) {
- new Query[ 256 ];
- mysql_format ( MySQL[ Handle ] , Query , "INSERT INTO `wcf%d_user_to_groups` (userID,groupID) VALUES (%d,%d)" , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) , GroupID );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return 1;
- }
- RemoveUserFromGroup ( Username[ ] , GroupID ) {
- new Query[ 256 ];
- mysql_format ( MySQL[ Handle ] , Query , "DELETE from `wcf%d_user_to_groups` WHERE userID = %d AND groupID = %d" , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) , GroupID );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return IsUserInGroup ( Username , GroupID ) ? false : true;
- }
- SetUserData ( Username[ ] , Data[ ] , Value[ ] , Type = PAWN_TYPE_ARRAY ) {
- new Query[ 128 ];
- if ( Type == PAWN_TYPE_INT )
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET %s = %i WHERE username = '%s'" , MySQL[ Installation ] , Data , strval ( Value ) , Username );
- else
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user` SET %s = '%s' WHERE username = '%s'" , MySQL[ Installation ] , Data , Value , Username );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- return true;
- }
- IsUserInGroup ( Username[ ] , GroupID ) {
- new Groups[ 16 ] , I , bool:InGroupState;
- GetUserGroups ( Username , Groups );
- while ( Groups[ I ] > 0 && !InGroupState ) {
- if ( Groups[ I ] == GroupID )
- InGroupState = true;
- I++;
- }
- return InGroupState;
- }
- GetUserGroups ( Username[ ] , Groups[ ] ) {
- new Query[ 64 ] , Row[ 16 ] , I;
- mysql_format ( MySQL[ Handle ] , Query , "SELECT groupID FROM `wcf%d_user_to_groups` WHERE userID = %d" , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- mysql_store_result ( MySQL[ Handle ] );
- while ( I < mysql_num_rows( MySQL[ Handle ] ) ) {
- mysql_fetch_row_format ( Row , " " , MySQL[ Handle ] );
- Groups[ I ] = strval ( Row );
- I++;
- }
- mysql_free_result ( MySQL[ Handle ] );
- }
- GetUserData ( Username[ ] , Data[ ] ) {
- new Query[ 64 ] , Row[ 64 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT %s FROM `wcf%d_user` WHERE username = '%s'" , Data , MySQL[ Installation ] , Username );
- STORE_AND_FREE_RESULT
- return Row;
- }
- GetUserWBBData ( Username[ ] , Data[ ] ) {
- new Query[ 64 ] , Row[ 64 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT %s FROM `wbb1_%d_user` WHERE userID = %d" , Data , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) );
- STORE_AND_FREE_RESULT
- return Row;
- }
- IsValidUser ( Username[ ] ) {
- new Query[ 128 ] , Row[ 6 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT userID FROM `wcf%d_user` WHERE username = '%s'" , MySQL[ Installation ] , Username );
- STORE_AND_FREE_RESULT
- return strval ( Row ) > 0 ? true : false;
- }
- IsValidEmail ( Email[ ] ) {
- new Query[ 128 ] , Row[ 6 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT userID FROM `wcf%d_user` WHERE email = '%s'" , MySQL[ Installation ] , Email );
- STORE_AND_FREE_RESULT
- return strval ( Row ) > 0 ? true : false;
- }
- SetUserOption ( Username[ ] , OptionID , Value[ ] , Type ) {
- new Query[ 128 ];
- if ( Type == PAWN_TYPE_ARRAY )
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user_option_value` SET userOption%d = '%s' WHERE userID = %d" , MySQL[ Installation ] , OptionID , Value , strval ( GetUserData ( Username , "userID" ) ) );
- else
- mysql_format ( MySQL[ Handle ] , Query , "UPDATE `wcf%d_user_option_value` SET userOption%d = %d WHERE userID = %d" , MySQL[ Installation ] , OptionID , strval( Value ) , strval ( GetUserData ( Username , "userID" ) ) );
- mysql_query ( Query , -1 , -1 , MySQL[ Handle ] );
- }
- GetUserOption ( Username[ ] , OptionID ) {
- new Row[ 64 ] , Query[ 64 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT userOption%d FROM `wcf%d_user_option_value` WHERE userID = %d" , OptionID , MySQL[ Installation ] , strval ( GetUserData ( Username , "userID" ) ) );
- STORE_AND_FREE_RESULT
- return strval ( Row );
- }
- GetWBBOptionID ( Data[ ] ) {
- new Row[ 64 ] , Query[ 64 ];
- mysql_format ( MySQL[ Handle ] , Query , "SELECT optionID FROM `wcf%d_user_option` WHERE optionName = '%s'" , MySQL[ Installation ] , Data );
- STORE_AND_FREE_RESULT
- return strval ( Row );
- }
- GetWBBConfig ( Data[ ] ) {
- new Row[ 64 ] , Query[ 64 ];
- if ( !strcmp ( "encrypt_before_salting" , Data ) )
- mysql_format ( MySQL[ Handle ] , Query , "SELECT optionValue FROM `wcf%d_option` WHERE optionName = 'encryption_encrypt_before_salting'" , MySQL[ Installation ] );
- else
- mysql_format ( MySQL[ Handle ] , Query , "SELECT optionValue FROM `wcf%d_option` WHERE optionName = '%s'" , MySQL[ Installation ] , Data );
- STORE_AND_FREE_RESULT
- return Row;
- }
- TimestampNow ( ) {
- new String[ 16 ];
- mysql_query ( "SELECT UNIX_TIMESTAMP(NOW())" , -1 , -1 , MySQL[ Handle ] );
- mysql_store_result ( MySQL[ Handle ] );
- mysql_fetch_row_format ( String , "|" , MySQL[ Handle ] );
- mysql_free_result ( MySQL[ Handle ] );
- return strval ( String );
- }
- GenerateRandomValue ( ) {
- new RandomValue;
- while ( RandomValue < 100000000 )
- RandomValue = random ( 999999999 );
- return RandomValue;
- }
- CreateSalt ( ) {
- new Salt[ 64 ] , Code[ 10 ];
- format ( Code , 10 , "%i" , GenerateRandomValue ( ) );
- strcat ( Salt , GetHash ( Code , GetWBBConfig ( "encryption_method" ) ) );
- return Salt;
- }
- GetDoubleSaltedHash ( String[ ] , Salt[ ] ) {
- new TempString[ 128 ] , HashedString[ 64 ];
- strcat ( TempString , Salt );
- strcat ( TempString , GetSaltedHash ( String , Salt ) );
- format ( HashedString , 64 , GetHash ( TempString , GetWBBConfig ( "encryption_method" ) ) );
- return HashedString;
- }
- GetSaltedHash ( String[ ] , Salt[ ] ) {
- new HashedString[ 128 ] , TempString[ 128 ];
- if ( strval ( GetWBBConfig ( "encryption_enable_salting" ) ) > 0 ) {
- if ( !strcmp ( GetWBBConfig ( "encryption_salt_position" ) , "before" ) )
- strcat ( TempString , Salt );
- if ( strval ( GetWBBConfig ( "encrypt_before_salting" ) ) > 0 )
- strcat ( TempString , GetHash ( String , GetWBBConfig ( "encryption_method" ) ) );
- else
- strcat ( TempString , String );
- if ( !strcmp ( GetWBBConfig ( "encryption_salt_position" ) , "after" ) )
- strcat ( TempString , Salt );
- strcat ( HashedString , GetHash ( TempString , GetWBBConfig ( "encryption_method" ) ) );
- }
- else
- strcat ( HashedString , GetHash ( String , GetWBBConfig ( "encryption_method" ) ) );
- return HashedString;
- }
- GetHash ( Value[ ] , Method[ ] )
- {
- new Hashed[ 128 ];
- if ( !strcmp ( Method , "sha1" ) )
- sha1 ( Value , Hashed );
- if ( !strcmp ( Method , "md5" ) )
- md5 ( Value , Hashed );
- return Hashed;
- }
- stock SendMail ( Username[ ] , Sendername[ ] , Servername[ ] , ForumIndexURL[ ] )
- {
- new Post[ 2000 ] , Subject[ 128 ] , Message[ 1024 ] , DataAndLink[ 512 ] , Key[ 9 ];
- format ( Key , 9 , "%d" , GenerateRandomValue ( ) );
- SetUserData ( Username , "activationCode" , Key , PAWN_TYPE_INT );
- format ( Subject , 128 , "Deine Aktivierung: %s" , Username );
- format ( DataAndLink , 512 , "|t|tr|td Benutzernummer |/td|tdb: %s|/td|/tr|tr|td Aktivierungscode|/td|tdb: %s|/td|tr|/t" , GetUserData ( Username , "userID" ) , Key )/* ,"16873246" )*/;
- format ( Message , 1000 , "Hallo %s,|nVielen Dank f|uer deine Registrierung bei %s.|n|nBitte klicke auf |l%s|quepage=Register|andaction=enable|diesen Link|/l, und aktiviere deinen Account mit folgenden Daten:%s|n|nMit freundlichen Gr|ue|ssen|nDein %s Team" , Username , Sendername , ForumIndexURL , DataAndLink , Sendername );
- format ( Post , 2000 , "absender=%s&server=%s&adresse=%s&betreff=%s&nachricht=%s&html_allow=%i" , Sendername , Servername , GetUserData ( Username , "email" ) , Subject , Message , 1 );
- HTTP ( 1234 , HTTP_POST , "www.1000zet.net/wbb_connect/mailsender.php" , Post , "HTTPResponse" );
- return true;
- }
- public HTTPResponse ( index , response_code , data[ ] )
- if ( response_code == 200 )
- if ( !strcmp ( data , "true" ) )
- printf ( "Mail wurde erfolgreich gesendet!" );
- else
- printf ( "Schnittstellen Antwort: %s" , data );
- else
- print ( "Schnittstelle nicht gefunden" );
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" WBB Connect Filterscript by Hauke");
- print("--------------------------------------\n");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement