Guest User

Untitled

a guest
Oct 27th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.70 KB | None | 0 0
  1. if(isset($_COOKIE["Champions_cookielogin"])) {
  2. $email = getCurrentUser();
  3. $username = getUserNameFromName($email);
  4. $registerdate = getRegisterdateFromName($email);
  5. $accountid = getAccountIDFromName($email);
  6. $user_level = getUserLevelFromName($email);
  7. $champions_uniqueid = getUniqueIDFromEmail($email);
  8. $champions_count = getChampionCount($email);
  9. $champions_max = getChampionMax($email);
  10. if(isset($_COOKIE["Champions_cookieselectedchampion"])) {
  11. $selected = getCurrentSelected();
  12. $arr = getCharactervalues($selected);
  13. $Power = $arr[0];
  14. $Speed = $arr[1];
  15. $Ironflesh = $arr[2];
  16. $Power_Strike = $arr[3];
  17. $Power_Throw = $arr[4];
  18. $Power_Draw = $arr[5];
  19. $Shield = $arr[6];
  20. $Athletics = $arr[7];
  21. $Riding = $arr[8];
  22. $Proficiencies = $arr[9];
  23. }
  24. } else {
  25. header('Location: index.php');
  26. }
  27.  
  28. <?php
  29. ini_set('display_errors', 0);
  30.  
  31. // clearHeader()
  32. // Used for the URL-Requests-related scripts. It's mandatory to avoid bugs and problems and has to be executed at the beginning of the scripts.
  33. function clearHeader() {
  34. header_remove();
  35. function set_content_length($output)
  36. {
  37. header("Content-Length: ".strlen($output));
  38. return $output;
  39. }
  40. ob_start("set_content_length");
  41. }
  42.  
  43. // db_login()
  44. // Gets executed every time by accessing the database in any way.
  45. function db_login() {
  46.  
  47. $server = "localhost";
  48. $user = "root";
  49. $password = "-";
  50. $database = "-";
  51.  
  52. return mysqli_connect($server, $user, $password, $database);
  53. }
  54.  
  55. function getCurrentUser() {
  56. return $_COOKIE["Champions_cookielogin"];
  57. }
  58.  
  59. function getCurrentSelected() {
  60. return $_COOKIE["Champions_cookieselectedchampion"];
  61. }
  62.  
  63. function getUserNameFromName($email) {
  64.  
  65. $db = db_login();
  66.  
  67. $abfrage = "SELECT Username FROM account WHERE email = '$email'";
  68. $ergebnis = mysqli_query($db, $abfrage);
  69.  
  70. while($row = mysqli_fetch_object($ergebnis))
  71. {
  72. return $row->Username;
  73. }
  74.  
  75. return "null";
  76.  
  77. }
  78.  
  79. function getRegisterdateFromName($email) {
  80.  
  81. $db = db_login();
  82.  
  83. $abfrage = "SELECT user_registerdate FROM account WHERE email = '$email'";
  84. $ergebnis = mysqli_query($db, $abfrage);
  85.  
  86. while($row = mysqli_fetch_object($ergebnis))
  87. {
  88. return $row->user_registerdate;
  89. }
  90.  
  91. return "Unknown Date";
  92.  
  93. }
  94.  
  95. function getAccountIDFromName($email) {
  96.  
  97. $db = db_login();
  98.  
  99. $abfrage = "SELECT id FROM account WHERE email = '$email'";
  100. $ergebnis = mysqli_query($db, $abfrage);
  101.  
  102. while($row = mysqli_fetch_object($ergebnis))
  103. {
  104. return $row->id;
  105. }
  106.  
  107. return "Unknown ID";
  108.  
  109. }
  110.  
  111. function checkEmail($email) {
  112.  
  113. $db = db_login();
  114.  
  115. $abfrage = "SELECT ID FROM account WHERE Email = '$email'";
  116. $ergebnis = mysqli_query($db, $abfrage);
  117.  
  118. while($row = mysqli_fetch_object($ergebnis))
  119. {
  120. return $row->ID;
  121. }
  122.  
  123. return 0;
  124. }
  125.  
  126. function checkUsername($username) {
  127.  
  128. $db = db_login();
  129.  
  130. $abfrage = "SELECT ID FROM account WHERE Username = '$username'";
  131. $ergebnis = mysqli_query($db, $abfrage);
  132.  
  133. while($row = mysqli_fetch_object($ergebnis))
  134. {
  135. return $row->ID;
  136. }
  137.  
  138. return 0;
  139. }
  140.  
  141. function getPasswordRequestFromEmail($email) {
  142.  
  143. $db = db_login();
  144.  
  145. $abfrage = "SELECT pwrequest FROM account WHERE email = '$email'";
  146. $ergebnis = mysqli_query($db, $abfrage);
  147.  
  148. while($row = mysqli_fetch_object($ergebnis))
  149. {
  150. return $row->pwrequest;
  151. }
  152.  
  153. return 0;
  154.  
  155. $row->close();
  156. $db->close();
  157. }
  158.  
  159.  
  160. function getUserLevelFromName($email) {
  161.  
  162.  
  163. $db = db_login();
  164.  
  165. $abfrage = "SELECT user_level FROM account WHERE email = '$email'";
  166. $ergebnis = mysqli_query($db, $abfrage);
  167.  
  168. while($row = mysqli_fetch_object($ergebnis))
  169. {
  170. return $row->user_level;
  171. }
  172.  
  173. return 0;
  174.  
  175. }
  176.  
  177. function getUniqueIDFromEmail($email) {
  178.  
  179.  
  180. $db = db_login();
  181.  
  182. $abfrage = "SELECT unique_id FROM account WHERE email = '$email'";
  183. $ergebnis = mysqli_query($db, $abfrage);
  184.  
  185. while($row = mysqli_fetch_object($ergebnis))
  186. {
  187. return $row->unique_id;
  188. }
  189.  
  190. return 0;
  191.  
  192. }
  193.  
  194. function getChampionMadeDate($username) {
  195.  
  196.  
  197. $db = db_login();
  198.  
  199. $abfrage = "SELECT champion_createddate FROM champions WHERE Username = '$username'";
  200. $ergebnis = mysqli_query($db, $abfrage);
  201.  
  202. while($row = mysqli_fetch_object($ergebnis))
  203. {
  204. return $row->champion_createddate;
  205. }
  206.  
  207. return "0000-00-00 00:00:00";
  208.  
  209. }
  210.  
  211. function getChampionCount($email) {
  212.  
  213.  
  214. $db = db_login();
  215.  
  216. $abfrage = "SELECT Username FROM champions WHERE ChampionEmail = '$email'";
  217. $ergebnis = mysqli_query($db, $abfrage);
  218. $count = mysqli_num_rows($ergebnis);
  219.  
  220. return $count;
  221.  
  222. }
  223.  
  224. function checkChampionName($championname) {
  225.  
  226. $db = db_login();
  227.  
  228. $abfrage = "SELECT ID FROM champions WHERE Username = '$championname'";
  229. $ergebnis = mysqli_query($db, $abfrage);
  230.  
  231. while($row = mysqli_fetch_object($ergebnis))
  232. {
  233. return $row->ID;
  234. }
  235.  
  236. return 0;
  237. }
  238.  
  239. function getChampionPower($username) {
  240.  
  241. $db = db_login();
  242.  
  243. $abfrage = "SELECT Power FROM champions WHERE Username = '$username'";
  244. $ergebnis = mysqli_query($db, $abfrage);
  245.  
  246. while($row = mysqli_fetch_object($ergebnis))
  247. {
  248. return $row->Power;
  249. }
  250.  
  251. return 0;
  252. }
  253.  
  254. function getChampionSpeed($username) {
  255.  
  256. $db = db_login();
  257.  
  258. $abfrage = "SELECT Speed FROM champions WHERE Username = '$username'";
  259. $ergebnis = mysqli_query($db, $abfrage);
  260.  
  261. while($row = mysqli_fetch_object($ergebnis))
  262. {
  263. return $row->Speed;
  264. }
  265.  
  266. return 0;
  267. }
  268.  
  269. function getChampionMax($email) {
  270.  
  271. $db = db_login();
  272.  
  273. $abfrage = "SELECT maxChampions FROM account WHERE email = '$email'";
  274. $ergebnis = mysqli_query($db, $abfrage);
  275.  
  276. while($row = mysqli_fetch_object($ergebnis))
  277. {
  278. return $row->maxChampions;
  279. }
  280.  
  281. return 0;
  282. }
  283.  
  284. function getChampionID($username) {
  285.  
  286. $db = db_login();
  287.  
  288. $abfrage = "SELECT ID FROM champions WHERE Username = '$username'";
  289. $ergebnis = mysqli_query($db, $abfrage);
  290.  
  291. while($row = mysqli_fetch_object($ergebnis))
  292. {
  293. return $row->ID;
  294. }
  295.  
  296. return 0;
  297. }
  298.  
  299. function checkChampionOwnerByEmail($email, $delete) {
  300. $db = db_login();
  301.  
  302. $query = "SELECT ChampionEmail, Username FROM champions WHERE ChampionEmail = '$email' AND Username = '$delete'";
  303. $ergebnis = mysqli_query($db, $query);
  304. $num_rows = mysqli_num_rows($ergebnis);
  305.  
  306. if ($num_rows > 0) {
  307. return $num_rows;
  308. } else {
  309. return 0;
  310. }
  311. }
  312.  
  313. function RegisterAccount($username, $email, $password, $hash) {
  314. $db = db_login();
  315. $abfrage = "INSERT INTO `account` (`username`, `email`, `password`, `hash`) VALUES ('$username', '$email', '$password', '$hash')";
  316. $ergebnis = mysqli_query($db, $abfrage);
  317. }
  318.  
  319. function RegisterChampion($championname, $email) {
  320. $db = db_login();
  321. $abfrage = "INSERT INTO `champions` (`Username`, `ChampionEmail`) VALUES ('$championname', '$email')";
  322. $ergebnis = mysqli_query($db, $abfrage);
  323.  
  324. }
  325.  
  326. function ResetPW($email, $hash) {
  327. $db = db_login();
  328.  
  329. $query = "UPDATE account SET pwhash = '$hash', pwrequest = '1' WHERE email='$email' AND pwrequest = '0'";
  330. $execute = mysqli_query($db, $query);
  331.  
  332. }
  333.  
  334. function getChampionClassName($championstrength, $championagility) {
  335. if($championstrength == 6 && $championagility == 6) {
  336. return "Peasant";
  337. } else {
  338. return "Unknown";
  339. }
  340. }
  341.  
  342. function getCharactervalues($selected) {
  343.  
  344.  
  345. $db = db_login();
  346.  
  347. $abfrage = "SELECT * FROM champions WHERE Username = '$selected'";
  348. $ergebnis = mysqli_query($db, $abfrage);
  349.  
  350. $arr = array();
  351.  
  352. while($row = mysqli_fetch_object($ergebnis))
  353. {
  354. array_push($arr, $row->Power);
  355. array_push($arr, $row->Speed);
  356. array_push($arr, $row->Ironflesh);
  357. array_push($arr, $row->Power_Strike);
  358. array_push($arr, $row->Power_Throw);
  359. array_push($arr, $row->Power_Draw);
  360. array_push($arr, $row->Shield);
  361. array_push($arr, $row->Athletics);
  362. array_push($arr, $row->Riding);
  363. array_push($arr, $row->Proficiencies);
  364. }
  365.  
  366. return $arr;
  367.  
  368. }
  369.  
  370. function getUserInfo($email) {
  371. $db = db_login();
  372. $abfrage = "SELECT * FROM account WHERE email = $email";
  373. $ergebnis = mysqli_query($db, $abfrage);
  374.  
  375. $arr = array();
  376.  
  377. while($row = mysqli_fetch_object($ergebnis))
  378. {
  379. array_push($arr, $row->Username);
  380. array_push($arr, $row->user_level);
  381. array_push($arr, $row->id);
  382. array_push($arr, $row->unique_id);
  383. array_push($arr, $row->maxChampions);
  384. }
  385.  
  386. return $arr;
  387.  
  388. }
  389.  
  390. function SaveSkillsChampion($selected, $Power, $Speed) {
  391. $db = db_login();
  392.  
  393. $query = "UPDATE champions SET Power = '$Power', Speed = '$Speed' WHERE Username='$selected'";
  394. $execute = mysqli_query($db, $query);
  395.  
  396. }
  397. ?>
Add Comment
Please, Sign In to add comment