1
0

create-character.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/modules/core/header.php");
  3. if(!isset($link))
  4. {
  5. $link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
  6. if($link === false)
  7. {
  8. die("ERROR: Could not connect.");
  9. }
  10. }
  11. $gabim = "";
  12. $user_check_query = "SELECT `answer1`, `answer2`, `answered_questions` FROM `accounts` WHERE `ID` = '$playersqlid' LIMIT 1";
  13. $result = mysqli_query($link, $user_check_query);
  14. $result2 = mysqli_fetch_array($result, MYSQLI_ASSOC);
  15. $answered_questions = $result2['answered_questions'];
  16. $answer1 = $result2['answer1'];
  17. $answer2 = $result2['answer2'];
  18. $answer1clean = $answer1;
  19. $answer2clean = $answer2;
  20. mysqli_free_result($result);
  21. $ApplicationErrors = array();
  22. // Processing form data when form is submitted
  23. if($_SERVER["REQUEST_METHOD"] == "POST")
  24. {
  25. $character = $_POST["character"];
  26. $origin = $_POST["origin"];
  27. $gender = $_POST["gender"];
  28. $age = $_POST["age"];
  29. $story = $_POST["story"];
  30. $skin = $_POST["skin"];
  31. $clean_story = $story;
  32. if(empty($character) || empty($origin) || empty($gender) || empty($age))
  33. {
  34. array_push($ApplicationErrors, "Fill in all the fields.");
  35. }
  36. if(characterCount($character, "_") < 1)
  37. {
  38. array_push($ApplicationErrors, "Your character name format is not valid.");
  39. }
  40. $symbols = array("!", "@", "#", "$", "%", "^", "*", "(", ")", "=", "+", "-", "~", "[", "]", ">", "<", "?", "|", ":", "{", "}", "'");
  41. for($f = 0; $f < sizeof($symbols); $f++)
  42. {
  43. if(characterCount($character, $symbols[$f]))
  44. {
  45. array_push($ApplicationErrors, "Your character name contains invalid symbols.");
  46. break;
  47. }
  48. }
  49. $character = mysqli_escape_string($link, $character);
  50. $origin = mysqli_escape_string($link, $origin);
  51. $gender = mysqli_escape_string($link, $gender);
  52. $story = mysqli_escape_string($link, $story);
  53. $skin = mysqli_escape_string($link, $skin);
  54. if($adminlevel < 1)
  55. {
  56. $answer1 = $_POST["answer1"];
  57. $answer2 = $_POST["answer2"];
  58. $answer1clean = $answer1;
  59. $answer2clean = $answer2;
  60. $answer1 = mysqli_escape_string($link, $answer1);
  61. $answer2 = mysqli_escape_string($link, $answer2);
  62. if(empty($story))
  63. {
  64. array_push($ApplicationErrors, "Your background story is empty.");
  65. }
  66. if($answered_questions == 0 && (empty($answer1) || empty($answer2)))
  67. {
  68. array_push($ApplicationErrors, "OOC fields are empty.");
  69. }
  70. }
  71. if(!is_numeric($age))
  72. {
  73. array_push($ApplicationErrors, "Birthyear must be a number, e.g. 1996.");
  74. }
  75. if(!count($ApplicationErrors))
  76. {
  77. if($adminlevel >= 1 || strlen($story) > 50)
  78. {
  79. $user_check_query = "SELECT `ID` FROM `characters` WHERE `char_name` = '$character' LIMIT 1";
  80. $result = mysqli_query($link, $user_check_query);
  81. $rowcount = $result->num_rows;
  82. if($rowcount == 0)
  83. {
  84. if($adminlevel > 0)
  85. {
  86. $phone_num = rand(100000, 999999);
  87. $user_check_query = "INSERT INTO `characters` (master, char_name, PhoneNumbr, Activated, Model) VALUES ('$playersqlid', '$character', '$phone_num', '1', '$skin')";
  88. $result = mysqli_query($link, $user_check_query);
  89. mysqli_close($link);
  90. echo "<script>document.location.href='./panel/characters'</script>";
  91. exit;
  92. }
  93. else
  94. {
  95. $ip_address = returnIpAddress();
  96. // Gather location data such as country name, code
  97. $json_url = "http://ip-api.com/json/$ip_address";
  98. $json = file_get_contents($json_url);
  99. $data = json_decode($json, TRUE);
  100. $country_name = $data["country"];
  101. $country_code = $data["countryCode"];
  102. $user_check_query = "SELECT `answered_questions` FROM `accounts` WHERE `ID` = '$playersqlid' LIMIT 1";
  103. $result = mysqli_query($link, $user_check_query);
  104. $result2 = mysqli_fetch_array($result, MYSQLI_ASSOC);
  105. $answered_questions = $result2['answered_questions'];
  106. mysqli_free_result($result);
  107. if($answered_questions == 0)
  108. {
  109. $user_check_query = "UPDATE `accounts` SET `answer1` = '$answer1', `answer2` = '$answer2', `answered_questions` = '1' WHERE `ID` = '$playersqlid' LIMIT 1";
  110. $result = mysqli_query($link, $user_check_query);
  111. }
  112. $user_check_query = "INSERT INTO application (master, char_name, story, ip_address, country_name, country_code, origin, gender, age, skin) VALUES ('$playersqlid', '$character', '$story', '$ip_address', '$country_name', '$country_code', '$origin', '$gender', '$age', '$skin')";
  113. $result = mysqli_query($link, $user_check_query);
  114. $app_id = mysqli_insert_id($link);
  115. mysqli_close($link);
  116. Discord_AlertStaff("@here A new character application has just been submitted by **$username**! ./admin/application/$app_id");
  117. echo "<script>document.location.href='./panel/characters'</script>";
  118. exit;
  119. }
  120. }
  121. else
  122. {
  123. array_push($ApplicationErrors, "Character name is already taken.");
  124. }
  125. }
  126. else
  127. {
  128. array_push($ApplicationErrors, "Background story is too short.");
  129. }
  130. }
  131. else
  132. {
  133. $gabim = "Failed to submit your application";
  134. }
  135. }
  136. if(isset($link))
  137. {
  138. mysqli_close($link);
  139. }
  140. ?>
  141. <router-outlet _ngcontent-tnh-c136="" class="router-outlet"></router-outlet>
  142. <app-settings _nghost-tnh-c144="">
  143. <section class="content-header">
  144. <h3>New Character Application</h3>
  145. </section>
  146. <form action="./panel/create-character" method="post" name="forma_char" id="appi_test"></form>
  147. <div class="content">
  148. <?php if(count($ApplicationErrors) > 0) { ?>
  149. <app-info-bar _ngcontent-tnh-c169="" type="warning" class="cs-1" _nghost-tnh-c215="">
  150. <div _ngcontent-tnh-c215="" class="warning infobar">
  151. <div _ngcontent-tnh-c215="" class="icon"><i _ngcontent-tnh-c215="" class="fa fa-exclamation-triangle fa-fw"></i></div>
  152. <div _ngcontent-tnh-c215="" class="message">There were a few errors while processing your application:
  153. <?php for($i = 0; $i < sizeof($ApplicationErrors); $i++)
  154. {
  155. ?>
  156. <br><span style="padding-left: 40px;">- <?php echo $ApplicationErrors[$i]; ?></span>
  157. <?php
  158. }
  159. ?>
  160. </div>
  161. </div>
  162. </app-info-bar>
  163. <?php } ?>
  164. <section class="card cshalf">
  165. <span class="card-title"> In Character Information</span>
  166. <app-input-text _ngcontent-tnh-c189="" placeholder="E-mail account" _nghost-tnh-c217="">
  167. <div _ngcontent-tnh-c217="" class="wrapper" id="characterName">
  168. <!---->
  169. <label _ngcontent-tnh-c217="" for="input">Character name: (Firstname_Lastname - CAUTION: Make sure to put an underscore.)</label><input _ngcontent-tnh-c217="" form="appi_test" value="" id="input" name="character" type="text" class="ng-untouched ng-pristine ng-valid" oninput="onValueChange(this, 'characterName')">
  170. </div>
  171. </app-input-text>
  172. <div _ngcontent-tnh-c189="" class="margin-top-10">
  173. <app-input-text _ngcontent-tnh-c189="" placeholder="Origin: (IC)" _nghost-tnh-c217="">
  174. <div _ngcontent-tnh-c217="" class="wrapper" id="origin">
  175. <!---->
  176. <label _ngcontent-tnh-c217="" for="input">Origin: (IC)</label><input _ngcontent-tnh-c217="" form="appi_test" value="" id="input" name="origin" type="text" class="ng-untouched ng-pristine ng-valid" oninput="onValueChange(this, 'origin')">
  177. </div>
  178. </app-input-text>
  179. </div>
  180. <div _ngcontent-tnh-c189="" class="margin-top-10">
  181. <app-input-text _ngcontent-tnh-c189="" placeholder="Gender: (IC - Male | Female)" _nghost-tnh-c217="">
  182. <div _ngcontent-tnh-c217="" class="wrapper" id="gender">
  183. <!---->
  184. <label _ngcontent-tnh-c217="" for="input">Gender: (IC - Male | Female)</label><input _ngcontent-tnh-c217="" form="appi_test" value="" id="input" name="gender" type="text" class="ng-untouched ng-pristine ng-valid" oninput="onValueChange(this, 'gender')">
  185. </div>
  186. </app-input-text>
  187. </div>
  188. <div _ngcontent-tnh-c189="" class="margin-top-10">
  189. <app-input-text _ngcontent-tnh-c189="" placeholder="Born: (IC - e.g. 1958 [Must be numeric.])" _nghost-tnh-c217="">
  190. <div _ngcontent-tnh-c217="" class="wrapper" id="birthday">
  191. <!---->
  192. <label _ngcontent-tnh-c217="" for="input">Birthyear: (IC - example: 1995 [Must be numeric.])</label><input _ngcontent-tnh-c217="" form="appi_test" value="" id="birthdayinputelement" name="age" type="text" class="ng-untouched ng-pristine ng-valid" oninput="onValueChange(this, 'birthday')">
  193. </div>
  194. </app-input-text>
  195. </div>
  196. <div _ngcontent-tnh-c189="" class="margin-top-10" style="display: none;">
  197. <app-input-text _ngcontent-tnh-c189="" placeholder="Skin" _nghost-tnh-c217="">
  198. <div _ngcontent-tnh-c217="" class="wrapper">
  199. <!---->
  200. <label _ngcontent-tnh-c217="" for="input">Skin</label><input _ngcontent-tnh-c217="" form="appi_test" value="" id="inputSkin" name="skin" type="text" class="ng-untouched ng-pristine ng-valid">
  201. </div>
  202. </app-input-text>
  203. </div>
  204. </section>
  205. <section class="card cshalf">
  206. <span class="card-title"> Select skin</span>
  207. <div class="skin-container">
  208. <?php
  209. for($i = 0; $i < sizeof($serverSkins); ++$i)
  210. {
  211. ?>
  212. <div class="skin-box" id="skin<?php echo $serverSkins[$i]["id"]; ?>" onclick="selectSkinModel(this, <?php echo $serverSkins[$i]["id"]; ?>)" style="background-image: url('/assets/skins_small/<?php echo $serverSkins[$i]["name"]; ?>-240-400.png');"></div>
  213. <?php
  214. }
  215. ?>
  216. </div>
  217. </section>
  218. <?php if($adminlevel < 1) { ?>
  219. <section class="card cs-1"> <span class="card-title"> <i class="fa fa-fw fa-book color-blue"></i> Your character's Background Story <!--<span class="fl-ri" *ngIf="!story || (story && (story.length < requirements.ic.lower || story.length > requirements.ic.upper))"> <i class="fa fa-fw fa-times color-tomato"></i> </span> <span class="fl-ri" *ngIf="story && (story.length >= requirements.ic.lower && story.length <= requirements.ic.upper)"> <i class="fa fa-fw fa-check color-green"></i> </span> <span class="fl-ri color-grey"> requirement of {{ requirements.ic.lower }} characters --></span> </span>
  220. <p> Information within this section relates to the background of your character, prior to your use on the server. This can consist of their origins, backstory in relation to future character development & anything you believe is of note to the character you are portraying on the server. This box is your first opportunity to highlight the type of character you wish to bring to our roleplaying community! <textarea ondrop="return false;" onpaste="return false;" form="appi_test" name="story" id="bgstoryelement" placeholder="Write your story here" [(ngModel)]="story"><?php if(isset($story)) { echo $clean_story; } ?></textarea> </p>
  221. </section>
  222. <?php } if($adminlevel < 1) { ?>
  223. <section class="card cs-1"> <span class="card-title"> <i class="fa fa-fw fa-book color-blue"></i> Something about you <!--<span class="fl-ri" *ngIf="!about || (about && (about.length < requirements.ooc.lower || about.length > requirements.ooc.upper))"> <i class="fa fa-fw fa-times color-tomato"></i> </span> <span class="fl-ri" *ngIf="about && (about.length >= requirements.ooc.lower && about.length <= requirements.ooc.upper)"> <i class="fa fa-fw fa-check color-green"></i> </span> <span class="fl-ri color-grey"> requirement of {{ requirements.ooc.lower }} characters --></span> </span>
  224. <p> Tell us about yourself. Do you have any experience with Verdant Roleplay, roleplay or even roleplay on SA-MP? <textarea <?php if($answered_questions) { ?>disabled<?php } ?> ondrop="return false;" onpaste="return false;" form="appi_test" name="answer1" class="height-100" placeholder="About you" [(ngModel)]="about"><?php echo $answer1clean; ?></textarea> </p>
  225. </section>
  226. <section class="card cs-1"> <span class="card-title"> <i class="fa fa-fw fa-book color-blue"></i> Other <!-- <span class="fl-ri" *ngIf="!about || (about && (about.length < requirements.ooc.lower || about.length > requirements.ooc.upper))"> <i class="fa fa-fw fa-times color-tomato"></i> </span> <span class="fl-ri" *ngIf="about && (about.length >= requirements.ooc.lower && about.length <= requirements.ooc.upper)"> <i class="fa fa-fw fa-check color-green"></i> </span> <span class="fl-ri color-grey"> requirement of {{ requirements.ooc.lower }} characters --></span> </span>
  227. <p> Explain some roleplaying terms, like metagaming and powergaming, and give two examples to each. <textarea <?php if($answered_questions) { ?>disabled<?php } ?> ondrop="return false;" onpaste="return false;" form="appi_test" name="answer2" class="height-100" placeholder="Write here" [(ngModel)]="about"><?php echo $answer2clean; ?></textarea> </p>
  228. </section>
  229. <?php } ?>
  230. </div>
  231. <center>
  232. <!--<div class="notice">Once the application is submitted you MUST log into game in order for your application to be reviewed. If you are resubmitting your application after being denied you must. Failure to do so will result in an application that will not be reviewed and eventually denied for not logging in.</div>-->
  233. </br>
  234. <app-button _ngcontent-tnh-c145="" caption="Freeze" icon="fa-snowflake" class="blue" _nghost-tnh-c216="" onclick="submitApplication()">
  235. <div _ngcontent-tnh-c216="" class="btn-wrapper">
  236. <div _ngcontent-tnh-c216="" class="button">
  237. <div _ngcontent-tnh-c216="" class="icon"><i _ngcontent-tnh-c216="" class="fa fa-save"></i></div>
  238. <!---->
  239. <div _ngcontent-tnh-c216="" class="caption"><?php echo $adminlevel > 0 ? "Create my character!" : "Post my application!"; ?></div>
  240. <!---->
  241. </div>
  242. <!---->
  243. </div>
  244. </app-button>
  245. </center>
  246. </app-settings>
  247. <!---->
  248. <script>
  249. var check = <?php if($adminlevel > 0) { ?>true;<?php } else { ?>false;<?php } ?>
  250. aplicationFormElementID = document.getElementById('appi_test');
  251. var selectedSkinModel = -1;
  252. function selectSkinModel(element, id)
  253. {
  254. if(selectedSkinModel != -1)
  255. {
  256. document.getElementById(`skin${selectedSkinModel}`).classList.remove("skin-active");
  257. }
  258. document.getElementById("inputSkin").value = id;
  259. element.classList.add("skin-active");
  260. selectedSkinModel = id;
  261. }
  262. function submitApplication()
  263. {
  264. if(selectedSkinModel == -1)
  265. {
  266. alert("Select a skin first.");
  267. return;
  268. }
  269. if(check == false)
  270. {
  271. const bgstoryelement = document.getElementById("bgstoryelement").value;
  272. if(bgstoryelement.length < 50)
  273. {
  274. alert("Your background story is too short.");
  275. return;
  276. }
  277. }
  278. /*const birthdayelement = document.getElementById("birthdayinputelement").value;
  279. if(birthdayelement.isInteger == false)
  280. {
  281. alert("Birthday must be a number. (Example: 1996)");
  282. return;
  283. }*/
  284. aplicationFormElementID.submit();
  285. }
  286. </script>