Advertisement
Guest User

Constants.php website

a guest
Mar 31st, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. <?php
  2. $sql_host = "162.253.224.12";
  3. $sql_user = "oshighsc_hs";
  4. $sql_pass = "killerkiller";
  5. $sql_data = "oshighsc_hs";
  6.  
  7. $table = "hs_users";
  8.  
  9. define("skills", "Overall,Attack,Defence,Strength,Constitution,Ranged,Prayer,Magic,Cooking,Woodcutting,Fletching,Fishing,Firemaking,Crafting,Smithing,Mining,Herblore,Agility,Thieving,Slayer,Farming,Runecrafting,Hunter,Construction,Summoning,Dungeoneering");
  10.  
  11. # playercard
  12. define("font", "assets/fonts/Oswald-Regular.ttf");
  13. define("cache_time", 300); #seconds - 300 = 5 minutes
  14.  
  15. function formatName($string) {
  16. return ucwords(str_replace("_", " ", $string));
  17. }
  18.  
  19. function cleanString($string) {
  20. return preg_replace("/[^A-Za-z0-9_ ]/", '_', $string);
  21. }
  22.  
  23. function cleanInt($string) {
  24. return preg_replace("/[^0-9]/", ' ', $string);
  25. }
  26.  
  27. function isValidEmail($email) {
  28. return filter_var($email, FILTER_VALIDATE_EMAIL);
  29. }
  30.  
  31. function getSkills() {
  32. return explode(",", skills);
  33. }
  34.  
  35. function isValidSkill($skill) {
  36. foreach (getSkills() as $skillName) {
  37. if (strtolower($skill) == strtolower($skillName)) {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43.  
  44. function getTotalLevel($user) {
  45. $total = 0;
  46. foreach (getSkills() as $skill) {
  47. if (strtolower($skill) == "overall")
  48. continue;
  49. $skillName = strtolower($skill).'_xp';
  50. $total += getLevelForXp($user[$skillName], $skill);
  51. }
  52. return $total;
  53. }
  54.  
  55. function getLevelForXp($exp, $skill) {
  56. $points = 0;
  57. $output = 0;
  58. for ($lvl = 1; $lvl <= (strtolower($skill) == 'dungeoneering' ? 120 : 99); $lvl++) {
  59. $points += floor($lvl + 300.0 * pow(2.0, $lvl / 7.0));
  60. $output = (int) floor($points / 4);
  61. if (($output - 1) >= $exp) {
  62. return $lvl;
  63. }
  64. }
  65. return (strtolower($skill) == 'dungeoneering' ? 120 : 99);
  66. }
  67.  
  68. function getXPForLevel($level) {
  69. $points = 0;
  70. $output = 0;
  71. for ($lvl = 1; $lvl <= $level; $lvl++) {
  72. $points += floor($lvl + 300.0 * pow(2.0, $lvl / 7.0));
  73. if ($lvl >= $level) {
  74. return $output;
  75. }
  76. $output = (int) floor($points / 4);
  77. }
  78. return 0;
  79. }
  80.  
  81. function getCombatLevel($row) {
  82. $attack = getLevelForXp($row['attack_xp'], "");
  83. $defence = getLevelForXp($row['defence_xp'], "");
  84. $strength = getLevelForXp($row['strength_xp'], "");
  85. $hp = getLevelForXp($row['constitution_xp'], "");
  86. $prayer = getLevelForXp($row['prayer_xp'], "");
  87. $ranged = getLevelForXp($row['ranged_xp'], "");
  88. $magic = getLevelForXp($row['magic_xp'], "");
  89. $combatLevel = (int) (($defence + $hp + floor($prayer / 2)) * 0.25) + 1;
  90. $melee = ($attack + $strength) * 0.325;
  91. $ranger = floor($ranged * 1.5) * 0.325;
  92. $mage = floor($magic * 1.5) * 0.325;
  93.  
  94. if ($melee >= $ranger && $melee >= $mage) {
  95. $combatLevel += $melee;
  96. } else if ($ranger >= $melee && $ranger >= $mage) {
  97. $combatLevel += $ranger;
  98. } else if ($mage >= $melee && $mage >= $ranger) {
  99. $combatLevel += $mage;
  100. }
  101. return (int)$combatLevel;
  102. }
  103.  
  104. function getLevel($row) {
  105. return (int)(getCombatLevel($row) + getSummoningCombatLevel($row));
  106. }
  107.  
  108. function getSummoningCombatLevel($row) {
  109. return getLevelForXp($row['summoning_xp'], "") / 8;
  110. }
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement