1
0

bugreport.pwn 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Bug Report System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. Developers:
  14. (*) Miguel
  15. * Copyright (c) 2016, Next Generation Gaming, LLC
  16. *
  17. * All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms, with or without modification,
  20. * are not permitted in any case.
  21. *
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  27. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  28. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <YSI\y_hooks>
  36. ShowBugReportMainMenu(playerid)
  37. {
  38. new string[256], bug[41], bugdesc[41];
  39. DeletePVar(playerid, "BugStep");
  40. SetPVarInt(playerid, "BugListItem", 1);
  41. if(GetPVarType(playerid, "BugSubject")) GetPVarString(playerid, "BugSubject", bug, 40); else bug = "N/A";
  42. if(GetPVarType(playerid, "BugDetail")) GetPVarString(playerid, "BugDetail", bugdesc, 40); else bugdesc = "N/A";
  43. if(strlen(bugdesc) > 35) strmid(bugdesc, bugdesc, 0, 35, 35), format(bugdesc, 41, "%s [...]", bugdesc);
  44. format(string, sizeof(string), "Subject: %s\nDetails: %s\nSubmit Anonymously?: %s\nSubmit", bug, bugdesc, GetPVarInt(playerid, "BugAnonymous") == 1 ? ("Yes"):("No"));
  45. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_LIST, "Bug Report", string, "Select", "Close");
  46. }
  47. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  48. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  49. szMiscArray[0] = 0;
  50. switch(dialogid)
  51. {
  52. case DIALOG_BUGREPORT:
  53. {
  54. if(!response && GetPVarType(playerid, "BugStep")) return ShowBugReportMainMenu(playerid);
  55. if(response)
  56. {
  57. new bug[41], bugdesc[129];
  58. GetPVarString(playerid, "BugSubject", bug, 40);
  59. GetPVarString(playerid, "BugDetail", bugdesc, 128);
  60. if(GetPVarInt(playerid, "BugListItem") == 1)
  61. {
  62. if(listitem == 0) //Subject
  63. {
  64. SetPVarInt(playerid, "BugStep", 1);
  65. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_INPUT, "Bug Report - Subject", "Please enter a short description of the bug:\n * 15 characters min\n * 40 characters max", "Continue", "Close");
  66. }
  67. if(listitem == 1) //Bug Details
  68. {
  69. SetPVarInt(playerid, "BugStep", 2);
  70. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_INPUT, "Bug Report - Bug Details", "Please explain the bug in as much detail you can:\n * 50 characters minimum", "Continue", "Close");
  71. }
  72. if(listitem == 2) //Submit Anonymously?
  73. {
  74. SetPVarInt(playerid, "BugStep", 3);
  75. SetPVarInt(playerid, "BugListItem", 2);
  76. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_LIST, "Bug Report - Submit Anonymously?", "No\nYes", "Continue", "Close");
  77. }
  78. if(listitem == 3) //Submit
  79. {
  80. new stringg[256];
  81. if(strlen(bug) == 0 || strlen(bugdesc) == 0)
  82. return ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX , "Bug Report - {FF0000}Error", "Please fill in all the available text fields.", "Close", "");
  83. if(strlen(bugdesc) > 64)
  84. {
  85. new firstl[65], secondl[65];
  86. strmid(firstl, bugdesc, 0, 65);
  87. strmid(secondl, bugdesc, 64, 128);
  88. format(bugdesc, sizeof(bugdesc),"%s\n%s", firstl, secondl);
  89. }
  90. format(stringg, sizeof(stringg), "{4A8BC2}Subject: {BFC0C2}%s\n{4A8BC2}Details:\n{BFC0C2}%s\n{4A8BC2}Anonymous: {BFC0C2}%s", bug, bugdesc, GetPVarInt(playerid, "BugAnonymous") == 1 ? ("Yes"):("No"));
  91. SetPVarInt(playerid, "BugStep", 4);
  92. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_MSGBOX , "Bug Report - Submit", stringg, "Submit", "Cancel");
  93. }
  94. }
  95. if(GetPVarInt(playerid, "BugStep") == 1) //Subject
  96. {
  97. new bugsub[41];
  98. if(sscanf(inputtext, "s[41]", bugsub) || strlen(inputtext) < 15 || strlen(inputtext) > 40)
  99. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_INPUT, "Bug Report - Subject", "Please enter a short description of the bug:\n * 15 characters min\n * 40 characters max", "Continue", "Close");
  100. SetPVarString(playerid, "BugSubject", bugsub);
  101. ShowBugReportMainMenu(playerid);
  102. }
  103. if(GetPVarInt(playerid, "BugStep") == 2) //Bug Details
  104. {
  105. new bugdetails[128];
  106. if(sscanf(inputtext, "s[128]", bugdetails) || strlen(inputtext) < 50)
  107. return ShowPlayerDialogEx(playerid, DIALOG_BUGREPORT, DIALOG_STYLE_INPUT, "Bug Report - Bug Details", "Please explain the bug in as much detail you can:\n * 50 characters minimum", "Continue", "Close");
  108. SetPVarString(playerid, "BugDetail", bugdetails);
  109. ShowBugReportMainMenu(playerid);
  110. }
  111. if(GetPVarInt(playerid, "BugStep") == 3) //Submit Anonymously?
  112. {
  113. if(GetPVarInt(playerid, "BugListItem") == 2)
  114. {
  115. SetPVarInt(playerid, "BugAnonymous", listitem);
  116. ShowBugReportMainMenu(playerid);
  117. }
  118. }
  119. if(GetPVarInt(playerid, "BugStep") == 4) //Submit
  120. {
  121. new szResult[512];
  122. mysql_format(MainPipeline, szResult, sizeof(szResult), "INSERT INTO `bugs` (`Userid`, `Anoy`, `Type`, `Subject`, `Created`, `LastDate`) \
  123. VALUES(%d, %d, 0, '%e', UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", GetPVarInt(playerid, "pSQLID"), GetPVarInt(playerid, "BugAnonymous"), bug);
  124. mysql_tquery(MainPipeline, szResult, "OnBugReport", "i", playerid);
  125. }
  126. }
  127. }
  128. }
  129. return 0;
  130. }
  131. CMD:bugreport(playerid, params[]) {
  132. if(GetPVarType(playerid, "PlayerCuffed") || GetPVarInt(playerid, "pBagged") >= 1 || GetPVarInt(playerid, "pDoingPJob") >= 1 || GetPVarType(playerid, "Injured") || GetPVarType(playerid, "IsFrozen") || PlayerInfo[playerid][pHospital]) {
  133. return SendClientMessage(playerid, COLOR_GRAD2, "You can't do that at this time!");
  134. }
  135. else if(GetPVarType(playerid, "FixVehicleTimer")) {
  136. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are fixing a vehicle!");
  137. }
  138. if(gettime() - PlayerInfo[playerid][pBugReportTimeout] < 3600)
  139. return ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX , "Bug Report - {FF0000}Error", "You can only submit a bug report once every hour!\nAlternatively, you can visit http://cp.ng-gaming.net and post a bug report there.", "Close", "");
  140. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `devcpbans` WHERE `Userid` = %d LIMIT 1", GetPlayerSQLId(playerid));
  141. return mysql_tquery(MainPipeline, szMiscArray, "CheckBugReportBans", "ii", playerid, 1);
  142. }
  143. CMD:changes(playerid, params[])
  144. {
  145. new rev[16], string[64];
  146. format(rev, sizeof(rev), "%s", str_replace("NG:RP ", "", SERVER_GM_TEXT));
  147. format(string, sizeof(string), "dev.ng-gaming.net/server.php?revision=%s", rev);
  148. HTTP(playerid, HTTP_GET, string, "", "RevisionListHTTP");
  149. return 1;
  150. }
  151. forward OnBugReport(playerid);
  152. public OnBugReport(playerid)
  153. {
  154. new string[128], bug[41], szResult[512], bugdesc[129];
  155. GetPVarString(playerid, "BugSubject", bug, 40);
  156. GetPVarString(playerid, "BugDetail", bugdesc, 128);
  157. mysql_format(MainPipeline, szResult, sizeof(szResult), "INSERT INTO `bugcomments` (`Bugid`, `Postid`, `UserId`, `Message`, `Created`) \
  158. VALUES(%d, 1, %d, '%e', UNIX_TIMESTAMP())", cache_insert_id(), GetPVarInt(playerid, "pSQLID"), bugdesc);
  159. mysql_tquery(MainPipeline, szResult, "OnQueryFinish", "i", SENDDATA_THREAD);
  160. format(string, sizeof(string), "[BugID: %d] %s(%d) submitted a%sbug (%s)", cache_insert_id(), GetPlayerNameEx(playerid), GetPVarInt(playerid, "pSQLID"), GetPVarInt(playerid, "BugAnonymous") == 1 ? (" anonymous "):(" "), bug);
  161. Log("logs/bugreport.log", string);
  162. ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX , "Bug Report Submitted",
  163. "{FFFFFF}Your bug report has been successfully submitted.\n\
  164. We highly suggest adding more information regarding the bug by visiting: http://cp.ng-gaming.net\n\
  165. {FF8000}Note:{FFFFFF} If you are found abusing this system you will be restricted from submitting future bug reports.", "Close", "");
  166. PlayerInfo[playerid][pBugReportTimeout] = gettime();
  167. DeletePVar(playerid, "BugStep");
  168. DeletePVar(playerid, "BugSubject");
  169. DeletePVar(playerid, "BugDetail");
  170. DeletePVar(playerid, "BugAnonymous");
  171. DeletePVar(playerid, "BugListItem");
  172. return 1;
  173. }
  174. forward CheckBugReportBans(playerid, check);
  175. public CheckBugReportBans(playerid, check)
  176. {
  177. new rows;
  178. cache_get_row_count(rows);
  179. if(rows == 0)
  180. {
  181. ShowBugReportMainMenu(playerid);
  182. }
  183. else
  184. {
  185. ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Bug Report - {FF0000}Error", "You are restricted from submitting bug reports.\n\nPlease visit http://cp.ng-gaming.net and select anything from the Bug Report menu\nand your unban date/reason will be displayed.", "Close", "");
  186. }
  187. return 1;
  188. }
  189. forward CheckPendingBugReports(playerid);
  190. public CheckPendingBugReports(playerid)
  191. {
  192. new rows;
  193. cache_get_row_count(rows);
  194. if(rows == 0) return 1;
  195. new string[256], szResult[41];
  196. format(string, sizeof(string), "{BFC0C2}You have {4A8BC2}%d{BFC0C2} bug report(s) pending your response.", rows);
  197. strcat(string, "\nPlease follow up with the bug reports listed below and provide as many details as you can.\n{4A8BC2}BugID\tBug{BFC0C2}");
  198. for(new i = 0; i < rows; i++)
  199. {
  200. cache_get_value_name(i, "id", szResult);
  201. format(string, sizeof(string), "%s\n%s\t", string, szResult);
  202. cache_get_value_name(i, "Subject", szResult);
  203. format(string, sizeof(string), "%s%s", string, szResult);
  204. }
  205. return ShowPlayerDialogEx(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Bug Reports Pending Response - {4A8BC2}http://cp.ng-gaming.net", string, "Close", "");
  206. }