Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 KB | None | 0 0
  1. <?php
  2.  
  3. class Database {
  4.  
  5. public $user;
  6. public $password;
  7. public $database;
  8. public $host;
  9.  
  10. public function __construct() {
  11. $this->user = "username";
  12. $this->password = "pass";
  13. $this->database = "tables";
  14. $this->host = "localhost";
  15.  
  16. }
  17.  
  18. protected function connect() {
  19.  
  20. return new mysqli($this->host, $this->user, $this->password, $this->database);
  21. }
  22.  
  23. public function GetUserColor($rank) {
  24. switch ($rank) {
  25. case 1: //donator
  26. return '#FF3333';
  27. case 2: //super donator
  28. return '#CC33FF';
  29. case 3: //mega donator
  30. return '#3366CC';
  31. case 4: //extreme donator
  32. return 'green';
  33. case 5: //respected donator
  34. return 'orange';
  35. case 6: //server support
  36. return '#3366CC';
  37. case 7: //respected member
  38. return 'red';
  39. case 8: //veteran
  40. return 'grey';
  41. case 9: //moderator
  42. return 'grey';
  43. case 10: //head moderator
  44. return 'grey';
  45. case 14: //legendary donator
  46. return 'yellow';
  47. case 15: //forum moderator
  48. return 'green';
  49. case 17: //youtuber
  50. return 'red';
  51. }
  52. return 'white';
  53. }
  54.  
  55. public function GetOverall($page, $rank) {
  56.  
  57. $database = $this->connect();
  58. $per_page = 25;
  59. $var = $per_page-1;
  60. $start = $page*$per_page-$var-1;
  61. $result = $database->query("SELECT * FROM skillsoverall WHERE iron='".$rank."' ORDER BY lvl DESC, xp DESC LIMIT $start,$per_page");
  62. return $result;
  63.  
  64. }
  65. public function GetTop() {
  66.  
  67. $database = $this->connect();
  68. $result = $database->query("SELECT * FROM skillsoverall ORDER BY lvl DESC, xp DESC LIMIT 0,1");
  69. return $result;
  70.  
  71. }
  72. public function GetTopMode($id) {
  73.  
  74. $database = $this->connect();
  75. $result = $database->query("SELECT * FROM skillsoverall WHERE iron='".$id."' ORDER BY lvl DESC, xp DESC LIMIT 0,1");
  76. return $result;
  77. }
  78.  
  79. public function GetSkill($skill,$page,$rank) {
  80.  
  81. $skill = strtolower($skill);
  82. $skillxp = $skill."xp";
  83. $skilllvl = $skill."lvl";
  84.  
  85. $database = $this->connect();
  86. $per_page = 25;
  87. $var = $per_page-1;
  88. $start = $page*$per_page-$var-1;
  89. $result = $database->query("SELECT * FROM skills WHERE iron='".$rank."' ORDER BY $skilllvl DESC, $skillxp DESC LIMIT $start,$per_page");
  90. return $result;
  91.  
  92. }
  93. public function SkillPages($page, $skill,$rank) {
  94.  
  95. $per_page = 25;
  96. $database = $this->connect();
  97. $result = $database->query("SELECT * FROM skills WHERE iron='".$rank."'");
  98. $num_rows = $result->num_rows;
  99. $num_pages = $num_rows / $per_page;
  100. $max_pages = ceil($num_pages);
  101. $page = preg_replace('/\D/', '', $page);
  102. $next = $page+1;
  103. $prev = $page-1;
  104. $max_pages;
  105. if($rank == 0) {
  106.  
  107. if($page == $max_pages && $num_rows > 25) {
  108. echo '<a href="?skill='.$skill.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  109. } else if($page == 1 && $num_rows > 25) {
  110. echo '<a href="?skill='.$skill.'&page=2" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  111. } else if($page == 1 && $num_rows < 25) {
  112.  
  113. } else {
  114. echo '<a href="?skill='.$skill.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  115. echo '<a href="?skill='.$skill.'&page='.$next.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  116. }
  117.  
  118. } else {
  119.  
  120. if($page == $max_pages && $num_rows > 25) {
  121. echo '<a href="?id='.$rank.'&skill='.$skill.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  122. } else if($page == 1 && $num_rows > 25) {
  123. echo '<a href="?id='.$rank.'&skill='.$skill.'&page=2" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  124. } else if($page == 1 && $num_rows < 25) {
  125.  
  126. } else {
  127. echo '<a href="?id='.$rank.'&skill='.$skill.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  128. echo '<a href="?id='.$rank.'&skill='.$skill.'&page='.$next.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  129. }
  130.  
  131. }
  132.  
  133. }
  134. public function OverallPages($page,$rank) {
  135.  
  136. $per_page = 25;
  137. $database = $this->connect();
  138. $result = $database->query("SELECT * FROM skillsoverall WHERE iron='".$rank."'");
  139. $num_rows = $result->num_rows;
  140. $num_pages = $num_rows / $per_page;
  141. $max_pages = ceil($num_pages);
  142. $page = preg_replace('/\D/', '', $page);
  143. $next = $page+1;
  144. $prev = $page-1;
  145. if($rank == 0) {
  146.  
  147. if($page == $max_pages && $num_rows > 25) {
  148. echo '<a href="?page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  149. } else if($page == 1 && $num_rows > 25) {
  150. echo '<a href="?page=2" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  151. } else if($page == 1 && $num_rows < 25) {
  152.  
  153. } else {
  154. echo '<a href="?page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  155. echo '<a href="?page='.$next.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  156. }
  157.  
  158. } else {
  159.  
  160. if($page == $max_pages && $num_rows > 25) {
  161. echo '<a href="?id='.$rank.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  162. } else if($page == 1 && $num_rows > 25) {
  163. echo '<a href="?id='.$rank.'&page=2" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  164. } else if($page == 1 && $num_rows < 25) {
  165.  
  166. } else {
  167. echo '<a href="?id='.$rank.'&page='.$prev.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Prev</a>';
  168. echo '<a href="?id='.$rank.'&page='.$next.'" style="display:block; height:100px; height:40px; line-height:40px; background:#1C1C1C; color:#F2F2F2; text-align:center;margin:auto;margin-left:5px; margin-right:5px;">Next</a>';
  169. }
  170.  
  171. }
  172.  
  173. }
  174.  
  175. public function Profile($username) {
  176. $database = $this->connect();
  177. $username = htmlspecialchars(stripcslashes(trim($username)));
  178. $result = $database->prepare("SELECT * FROM skills WHERE playerName = ?");
  179. $result->bind_param("s", $username);
  180. $result->execute();
  181. return $result;
  182.  
  183. }
  184.  
  185. public function PlayerExists($username) {
  186.  
  187. $database = $this->connect();
  188. $username = htmlspecialchars(stripcslashes(trim($username)));
  189. $result = $database->prepare("SELECT * FROM skills WHERE playerName = ?");
  190. $result->bind_param("s", $username);
  191. $result->execute();
  192. $num_rows = $result->num_rows;
  193.  
  194. if($num_rows > 0) {
  195.  
  196. $return = 1;
  197.  
  198. } else {
  199.  
  200. $return = 0;
  201.  
  202. }
  203.  
  204. return $return;
  205.  
  206. }
  207.  
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement