Advertisement
Johurt

[GM] jSOS

Oct 4th, 2015
1,546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.06 KB | None | 0 0
  1. /*
  2.     jSOS by Johurt
  3.     2015/10/04
  4. */
  5. #include <a_samp>
  6. #include <a_mysql>  // MySQL R39-3 - https://github.com/pBlueG/SA-MP-MySQL/releases
  7. #include <md5>      // MD5 - https://github.com/GRGServer/SAMP/blob/master/includes/MD5.inc
  8.  
  9. #define MySQL_HOST                  "******"
  10. #define MySQL_USER                  "******"
  11. #define MySQL_DATA                  "******"
  12. #define MySQL_PASS                  "******"
  13. #define MYSQL_PLAYERS_TABLE_NAME    "`players`"
  14. #define MYSQL_NAME_FIELD_NAME       "`Vardas`"
  15. #define MYSQL_PASSWORD_FIELD_NAME   "`Slaptazodis`"
  16. #define USE_MYSQL                   false
  17.  
  18. #define DATABASE_FILE_NAME          "vLRG.txt"
  19. #define MAX_LINE_LENGTH             128
  20. #define QUOTE_1                     1
  21. #define QUOTE_2                     3
  22. #define USE_FILE                    false
  23.  
  24. #define USE_MD5                     false
  25. #define PRINT_CHECK_STEPS           false
  26.  
  27. enum eACC
  28. {
  29.     Nick[21],
  30.     Pass[129],
  31.     PassH[33]
  32. }
  33. new ACC[][eACC] =
  34. {
  35.     {"Define_Php", "qweasdzxc", "315EB115D98FCBAD39FFC5EDEBD669C9"},
  36.     {"Tomas_Salala", "barsukas", "C9B0D7906055A1FEC153A284CA0A46A0"},
  37.     {"Arnelis_Sumus", "whitesd78fsa", "6776660DAA76EBB7C446DD172C239CD4"}
  38. };
  39. new MYSQL_ARG, MAX = sizeof(ACC), st;
  40.  
  41. main() print("\n\n\n\n\n\n\n\n\n\n");
  42.  
  43. public OnGameModeInit()
  44. {
  45.     #if USE_FILE
  46.         ExportDatabaseDataViaTXT();
  47.     #endif
  48.     #if USE_MYSQL
  49.         MYSQL_ARG = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_DATA, MySQL_PASS);
  50.         new stats[100];
  51.         mysql_stat(stats);
  52.         print(stats);
  53.         mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_TEXT);
  54.         StartCheckInfo();
  55.     #endif
  56.     #if !USE_FILE && !USE_MYSQL
  57.         print("SERVERIS: Tai kam tu mane pajungei?");
  58.         SendRconCommand("exit");
  59.     #endif
  60.     #if USE_FILE && USE_MYSQL
  61.         print("SERVERIS: Nedaryk taip!");
  62.         SendRconCommand("exit");
  63.     #endif
  64.     return 1;
  65. }
  66.  
  67. public OnGameModeExit()
  68. {
  69.     #if USE_MYSQL
  70.         mysql_close();
  71.     #endif
  72.     return 1;
  73. }
  74.  
  75. public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
  76. {
  77.     printf("Error: %s | callback: %s", error, callback);
  78.     if(errorid == 2006)
  79.     {
  80.         print("MySQL: Nepavyko prisijugti prie duomenu bazes.");
  81.         SendRconCommand("exit");
  82.     }
  83.     return 1;
  84. }
  85.  
  86. forward CheckResult(id);
  87. public CheckResult(id)
  88. {
  89.     new rows, fields;
  90.     cache_get_data(rows, fields);
  91.     if(rows) printf("[+] %s slaptazodis sutampa!", ACC[id][Nick]);
  92.     #if PRINT_CHECK_STEPS
  93.         printf("Step... %d/%d", id + 1, MAX);
  94.     #endif
  95.     if(id + 1 == MAX) printf("Done... After %dMS", GetTickCount() - st);
  96.     return 1;
  97. }
  98.  
  99. stock StartCheckInfo()
  100. {
  101.     st = GetTickCount();
  102.     #if USE_MD5
  103.         new str[168];
  104.         for(new c; c < MAX; c++)
  105.         {
  106.             format(str, 168, "SELECT null FROM "MYSQL_PLAYERS_TABLE_NAME" WHERE "MYSQL_NAME_FIELD_NAME" = '%s' AND "MYSQL_PASSWORD_FIELD_NAME" = '%s'", ACC[c][Nick], ACC[c][PassH]);
  107.             mysql_function_query(MYSQL_ARG, str, true, "CheckResult", "d", c);
  108.         }
  109.     #else
  110.         new str[264];
  111.         for(new c; c < MAX; c++)
  112.         {
  113.             format(str, 264, "SELECT null FROM "MYSQL_PLAYERS_TABLE_NAME" WHERE "MYSQL_NAME_FIELD_NAME" = '%s' AND "MYSQL_PASSWORD_FIELD_NAME" = '%s'", ACC[c][Nick], ACC[c][Pass]);
  114.             mysql_function_query(MYSQL_ARG, str, true, "CheckResult", "d", c);
  115.         }
  116.     #endif
  117.     return 1;
  118. }
  119.  
  120. stock ExportDatabaseDataViaTXT()
  121. {
  122.     new buf[2048], File:handle = fopen(DATABASE_FILE_NAME, io_read), c, kelintas, kur[4], i, vardas[21], slaptazodis[129];
  123.     if(handle)
  124.     {
  125.         while(fread(handle, buf))
  126.         {
  127.             i = 0;
  128.             kelintas = 0;
  129.             for(c = 0; c < MAX_LINE_LENGTH; c++)
  130.             {
  131.                 if(buf[c] == 0x27)
  132.                 {
  133.                     kelintas ++;
  134.                     if(!(kelintas == QUOTE_1 || kelintas == QUOTE_1 + 1 || kelintas == QUOTE_2 || kelintas == QUOTE_2 + 1)) continue;
  135.                     i++;
  136.                     switch(kelintas)
  137.                     {
  138.                         case QUOTE_1: kur[0] = c;
  139.                         case QUOTE_1 + 1: kur[1] = c;
  140.                         case QUOTE_2: kur[2] = c;
  141.                         case QUOTE_2 + 1: kur[3] = c;
  142.                     }
  143.                     if(i > 3) break;
  144.                 }
  145.             }
  146.             strmid(vardas, buf, kur[0] + 1, kur[1]);
  147.             strmid(slaptazodis, buf, kur[2] + 1, kur[3]);
  148.             #if USE_MD5
  149.                 printf("{%c%s%c, %c%s%c, %c%s%c},", 0x22, vardas, 0x22, 0x22, slaptazodis, 0x22, 0x22, MD5_Hash(slaptazodis), 0x22);
  150.             #else
  151.                 printf("{%c%s%c, %c%s%c, %c-%c},", 0x22, vardas, 0x22, 0x22, slaptazodis, 0x22, 0x22, 0x22);
  152.             #endif
  153.         }
  154.         fclose(handle);
  155.     }
  156.     return 1;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement