y_users.inc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /**--------------------------------------------------------------------------**\
  2. ===================================
  3. y_users - Registration functions.
  4. ===================================
  5. Description:
  6. Provides access to a user system for registering and saving users.
  7. Legal:
  8. Version: MPL 1.1
  9. The contents of this file are subject to the Mozilla Public License Version
  10. 1.1 (the "License"); you may not use this file except in compliance with
  11. the License. You may obtain a copy of the License at
  12. http://www.mozilla.org/MPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. for the specific language governing rights and limitations under the
  16. License.
  17. The Original Code is the YSI malloc include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2011
  20. the Initial Developer. All Rights Reserved.
  21. Contributors:
  22. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  23. Thanks:
  24. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  25. ZeeX - Very productive conversations.
  26. koolk - IsPlayerinAreaEx code.
  27. TheAlpha - Danish translation.
  28. breadfish - German translation.
  29. Fireburn - Dutch translation.
  30. yom - French translation.
  31. 50p - Polish translation.
  32. Zamaroht - Spanish translation.
  33. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  34. for me to strive to better.
  35. Pixels^ - Running XScripters where the idea was born.
  36. Matite - Pestering me to release it and using it.
  37. Very special thanks to:
  38. Thiadmer - PAWN, whose limits continue to amaze me!
  39. Kye/Kalcor - SA:MP.
  40. SA:MP Team past, present and future - SA:MP.
  41. Version:
  42. 2.2
  43. Changelog:
  44. 02/02/13:
  45. Added bits and join timestamp to preload data.
  46. Added backwards compatible salting to the hash.
  47. 15/11/11:
  48. Added comments.
  49. Added language to the top-level player data (needed for login).
  50. 11/11/11:
  51. First version.
  52. Functions:
  53. Public
  54. -
  55. Core:
  56. -
  57. Stock:
  58. -
  59. Static:
  60. -
  61. Inline:
  62. -
  63. API:
  64. -
  65. Callbacks:
  66. -
  67. Definitions:
  68. -
  69. Enums:
  70. -
  71. Macros:
  72. -
  73. Tags:
  74. -
  75. Variables:
  76. Global:
  77. -
  78. Static:
  79. -
  80. Commands:
  81. -
  82. Compile options:
  83. -
  84. Operators:
  85. -
  86. \**--------------------------------------------------------------------------**/
  87. #if defined _INC_y_users
  88. #endinput
  89. #endif
  90. #define _INC_y_users
  91. #if !defined MODE_NAME
  92. #error Please define "MODE_NAME" before including y_users.
  93. #endif
  94. #include <a_samp>
  95. forward OnPlayerLogin(playerid, uid);
  96. forward OnPlayerLogout(playerid, uid);
  97. forward OnPlayerSaved(playerid, uid);
  98. //#if !defined HAS_USER_CALLBACKS
  99. // #define HAS_USER_CALLBACKS
  100. //#endif
  101. #include "..\YSI_Internal\y_version"
  102. #include "..\YSI_Players\y_text"
  103. #include "..\YSI_Coding\y_remote"
  104. #include "..\YSI_Core\y_debug"
  105. #include "..\YSI_Storage\y_ini"
  106. #include "..\YSI_Core\y_utils"
  107. #include "..\YSI_Coding\y_timers"
  108. #define YSIM_U_DISABLE
  109. #define MASTER 55
  110. #include "..\YSI_Core\y_master"
  111. #define MAX_INDEX_LENGTH 8
  112. #include "..\YSI_Internal\y_plugins"
  113. #include "..\YSI_Internal\y_natives"
  114. #include "..\YSI_Coding\y_hooks"
  115. #if defined PP_ADLER32
  116. //#define MAX_PASSWORD_LENGTH 11
  117. #error Adler32 sucks!
  118. #elseif defined PP_MD5
  119. #if defined MD5_Hash
  120. #define MAX_PASSWORD_LENGTH 32
  121. #else
  122. #error Could not find MD5_Hash.
  123. #endif
  124. #elseif defined PP_SHA1
  125. #error SHA1 unsupported.
  126. #elseif defined PP_YSI
  127. #define MAX_PASSWORD_LENGTH 16
  128. #elseif defined PP_WP || defined PP_WHIRLPOOL
  129. #if defined _YSI_PLUGINS_WHIRLPOOL
  130. #define MAX_PASSWORD_LENGTH 128
  131. #else
  132. #error Could not find WP_Hash.
  133. #endif
  134. #else
  135. #error Default hash removed: See YSI topic for details.
  136. //#define PP_YSI
  137. //#define MAX_PASSWORD_LENGTH 16
  138. #endif
  139. //#define INDEX_DATA_LINE_LENGTH (MAX_INDEX_LENGTH + 1 + MAX_PLAYER_NAME + 1 + MAX_PASSWORD_LENGTH + 3 + 3 + 9 + 9)
  140. // MAX_INDEX_LENGTH - The player's ID.
  141. // 1 - Space.
  142. // MAX_PLAYER_NAME - The player's name.
  143. // 1 - Space.
  144. // MAX_PASSWORD_LENGTH - The password hash.
  145. // 1 - Space.
  146. // 2 - Language.
  147. // 1 - Space.
  148. // 8 - Free HEX bits.
  149. // 1 - Space.
  150. // 8 - Join timestamp.
  151. // 3 - Newline + Null.
  152. const
  153. INDEX_DATA_LINE_LENGTH = MAX_INDEX_LENGTH + 1 + MAX_PLAYER_NAME + 1 + MAX_PASSWORD_LENGTH + 1 + 2 + 1 + 8 + 1 + 8 + 3;
  154. #if !defined USER_FILE_PATH
  155. #if defined YSI_TESTS
  156. // Create a separate path for any test data so that we don't ruin any
  157. // live user data.
  158. #define USER_FILE_PATH "YSI/test_users/"
  159. #define USER_FILE_LENGTH 15
  160. #else
  161. #define USER_FILE_PATH "YSI/users/"
  162. #define USER_FILE_LENGTH 10
  163. #endif
  164. #endif
  165. #define OnUserData[%0](%1) @yU_%0(%1)
  166. #define PINI:%0(%1) forward OnUserData[%0](%1);public OnUserData[%0](%1)
  167. foreign Player_TryRegister(playerid, string:password[]);
  168. foreign Player_TryLogin(playerid, string:password[]);
  169. foreign Player_TryGroup(playerid, string:other[], string:password[]);
  170. foreign Player_ChangePassword(playerid, string:password[]);
  171. foreign Player_ForceGroup(playerid, string:other[]);
  172. foreign Player_ForceLogin(playerid);
  173. foreign Player_ChangeLanguage(playerid, string:code[]);
  174. #if defined USERS_USE_MYSQL
  175. /*
  176. #if _YSI_PLUGINS_MYSQL == 7
  177. #include "y_users/blueg7"
  178. #elseif _YSI_PLUGINS_MYSQL == 6
  179. #include "y_users/blueg6"
  180. #elseif _YSI_PLUGINS_MYSQL == 7
  181. #include "y_users/stricken"
  182. #else
  183. #error No MySQL plugin found.
  184. #endif
  185. */
  186. // I know it is a bit odd that this should need y_ini for database access, but
  187. // there is a very good reason (loading passwords).
  188. #include "..\YSI_Storage\y_ini"
  189. #include "..\YSI_Data\y_iterate"
  190. #include "y_users/dan10"
  191. #elseif defined USERS_USE_SQLITE
  192. #include "y_users/sqlite"
  193. #else
  194. #include "y_users/ini"
  195. #endif
  196. #if defined YSI_TESTS
  197. #include "..\YSI_Core\y_testing"
  198. #include "y_users/tests"
  199. #endif
  200. #include "..\YSI_Core\y_master"