Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.11 KB | None | 0 0
  1. <?php
  2. /*
  3. _____ _____
  4. / ___/___ ______ _____ _____/ ___/_________ _____ ___
  5. \__ \/ _ \/ ___/ | / / _ \/ ___/\__ \/ ___/ __ `/ __ \/ _ \
  6. ___/ / __/ / | |/ / __/ / ___/ / /__/ /_/ / /_/ / __/
  7. /____/\___/_/ |___/\___/_/ /____/\___/\__,_/ .___/\___/
  8. /_/ */
  9. /////////////////////////////////////////////////////////////////////////////////
  10. /*
  11. ServerScape
  12.  
  13. ServerScape Version: 0.5
  14. E-mail: brandon@dankscape.com
  15. File/Project: Player Card Generator
  16. Author(s): Brandon, Kemi
  17.  
  18. [DO NOT COPY WITHOUT PERMISSION]
  19. */
  20. ////////////////////////////////////////////////////////////////////////////////
  21. ?>
  22.  
  23. <?php
  24. $username = $_REQUEST["player"];
  25. $username2 = $_REQUEST["user"];
  26. if($username==null)
  27. echo '
  28. <title>ServerScape - Forum Signature Generator</title>
  29. <body>
  30.  
  31.  
  32. <center>
  33.  
  34.  
  35.  
  36. <header>
  37. <span>Forum Signature Generator</span>
  38. </header>
  39. <div class="content">
  40. <form id="search-form">
  41. <div class="form-group">
  42. <br>
  43. <input class="form-control" id="search-input" name="player" placeholder="Username here">
  44. </div>
  45. <br>
  46. <button type="submit" class="button">Create</button>
  47. </form>
  48. </section>
  49. </body>
  50. </div>
  51. </center>
  52. ';
  53. ?>
  54. <?php
  55. if($username!=null)
  56. {
  57. $username = $_REQUEST["player"];
  58. $quests = $_REQUEST["quests"];
  59. $image = $_REQUEST["img"];
  60. if(!$image) //no custom image given, use default instead.
  61. $image = ('img/backgrounds/style0.png');
  62.  
  63. /*
  64. //this seems to be broken when using it with mysqli_connect()
  65. $host="localhost"; // Host name
  66. $usr=""; // Mysql username
  67. $password=""; // Mysql password
  68. $db_name="serverscape_highscores"; // Database name
  69. $tbl_name="hs_users"; // Table name
  70. */
  71.  
  72. function getUser($var) {
  73. //edit the variables here.
  74. $mysqli = mysqli_connect('localhost', 'mysql_username', 'mysql_password', 'serverscape_highscores');
  75. //edit the table name here if yours is different.
  76. $query="SELECT * FROM hs_users WHERE username='".$_REQUEST["player"]."'";
  77. $result = mysqli_query($mysqli, $query);
  78. if(mysqli_num_rows($result) > 0) {
  79. $row = mysqli_fetch_assoc($result);
  80. return $row[$var.'_xp'];
  81. }
  82. }
  83.  
  84. function getCombatLevel() {
  85. $attack = getLevelForSkill("attack");
  86. $defence = getLevelForSkill("defence");
  87. $strength = getLevelForSkill("strength");
  88. $hp = getLevelForSkill("constitution");
  89. $prayer = getLevelForSkill("prayer");
  90. $ranged = getLevelForSkill("ranged");
  91. $magic = getLevelForSkill("magic");
  92. $combatLevel = (int) (($defence + $hp + floor($prayer / 2)) * 0.25) + 1;
  93. $melee = ($attack + $strength) * 0.325;
  94. $ranger = floor($ranged * 1.5) * 0.325;
  95. $mage = floor($magic * 1.5) * 0.325;
  96.  
  97. if ($melee >= $ranger && $melee >= $mage) {
  98. $combatLevel += $melee;
  99. } else if ($ranger >= $melee && $ranger >= $mage) {
  100. $combatLevel += $ranger;
  101. } else if ($mage >= $melee && $mage >= $ranger) {
  102. $combatLevel += $mage;
  103. }
  104. return (int)$combatLevel;
  105. }
  106.  
  107. function getLevel() {
  108. return (int)(getCombatLevel() + getSummoningCombatLevel());
  109. }
  110.  
  111. function getSummoningCombatLevel() {
  112. return getLevelForSkill("summoning") / 8;
  113. }
  114. function getTotalLevel()
  115. {
  116. define("skills", "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");
  117. $skills = explode(',', skills);
  118. $total = 0;
  119. foreach ($skills as $skill) {
  120. if($skill!="dungeoneering")
  121. $total += getLevelForSkill($skill);
  122. else if($skill=="dungeoneering")
  123. $total += getLevelForSkill($skill);
  124. }
  125. return $total;
  126. }
  127. function getLevelForSkill ($var)
  128. {
  129. $lvl = getLevelForXp(getUser($var), $var);
  130. if($lvl <= 0 || $lvl >= 121)
  131. return "?";
  132. else
  133. return $lvl;
  134. }
  135. function getLevelForXp($exp, $skill) {
  136. $points = 0;
  137. $output = 0;
  138. for ($lvl = 1; $lvl <= (strtolower($skill) == 'dungeoneering' ? 120 : 99); $lvl++) {
  139. $points += floor($lvl + 300.0 * pow(2.0, $lvl / 7.0));
  140. $output = (int) floor($points / 4);
  141. if (($output - 1) >= $exp) {
  142. return $lvl;
  143. }
  144. }
  145. return (strtolower($skill) == 'dungeoneering' ? 120 : 99);
  146. }
  147.  
  148. function dbgetvar() {
  149. $args = func_get_args();
  150. $query = array_shift($args);
  151. foreach ($args as $key => $val) {
  152. $args[$key] = "'".mysql_real_escape_string($val)."'";
  153. }
  154. $query = vsprintf($query, $args);
  155.  
  156. $res = mysql_query($query);
  157. if (!$res) {
  158. trigger_error("dbgetarr: ".mysql_error()." in ".$query);
  159. return FALSE;
  160. } else {
  161. $row = mysql_fetch_row($res);
  162. if (!$row) return NULL;
  163. return $row[0];
  164. }
  165. }
  166.  
  167.  
  168.  
  169. $im = imagecreatefrompng($image);
  170. $black = imagecolorallocate($im, 255, 255, 255);
  171. $width = imagesx($im);
  172. $height = imagesy($im);
  173. $font = 8; // store the int ID of the system font we're using in $font
  174.  
  175. if($image=="img/backgrounds/style5.png")
  176. $black = imagecolorallocate($im, 1, 1, 1);
  177. else
  178. $black = imagecolorallocate($im, 255, 255, 255);
  179.  
  180. //username
  181. $user = ("Statistics for ".$username);
  182. $middle = ( $width - imagefontwidth($font)*strlen($user) )/2;
  183. imagestring($im, $font, $middle, $height-140, $user, $black);
  184. //rank (havent gotten this to work yet)
  185. //$rank = ("Rank: ".getRank());
  186. //imagestring($im, 2, $width-60, $height-145, $rank, $black);
  187. //total lvl
  188. $totallvl = getTotalLevel();
  189. imagestring($im, $font, $width-75, $height-50, $totallvl, $black);
  190. //achievements
  191. $achievements = ("17");
  192. imagestring($im, $font, $width-75, $height-77, $achievements, $black);
  193. //quest points
  194. $quests = ("2");
  195. imagestring($im, $font, $width-75, $height-102, $quests, $black);
  196. //combat level
  197. imagestring($im, $font, $width-75, $height-127, getLevel(), $black);
  198. //attack
  199. $attack = (getLevelForSkill("attack"));
  200. imagestring($im, $font, 73, 42, $attack, $black);
  201. //strength
  202. $str = (getLevelForSkill("strength"));
  203. imagestring($im, $font, 73, 62, $str, $black);
  204. //defence
  205. $def = (getLevelForSkill("defence"));
  206. imagestring($im, $font, 73, 82, $def, $black);
  207. //hp
  208. $hp = (getLevelForSkill("constitution"));
  209. imagestring($im, $font, 73, 102, $hp, $black);
  210. //prayer
  211. $prayer = (getLevelForSkill("prayer"));
  212. imagestring($im, $font, 73, 125, $prayer, $black);
  213. //range
  214. $range = (getLevelForSkill("ranged"));
  215. imagestring($im, $font, 135, 40, $range, $black);
  216. //mage
  217. $mage = (getLevelForSkill("magic"));
  218. imagestring($im, $font, 135, 60, $mage, $black);
  219. //cooking
  220. $cook = (getLevelForSkill("cooking"));
  221. imagestring($im, $font, 135, 80, $cook, $black);
  222. //wc
  223. $wc = (getLevelForSkill("woodcutting"));
  224. imagestring($im, $font, 135, 100, $wc, $black);
  225. //fletching
  226. $fletch = (getLevelForSkill("fletching"));
  227. imagestring($im, $font, 135, 125, $fletch, $black);
  228. //fishing
  229. $fish = (getLevelForSkill("fishing"));
  230. imagestring($im, $font, 205, 40, $fish, $black);
  231. //firemaking
  232. $fire = (getLevelForSkill("firemaking"));
  233. imagestring($im, $font, 205, 62, $fire, $black);
  234. //crafting
  235. $craft = (getLevelForSkill("crafting"));
  236. imagestring($im, $font, 205, 82, $craft, $black);
  237. //smithing
  238. $smith = (getLevelForSkill("smithing"));
  239. imagestring($im, $font, 205, 102, $smith, $black);
  240. //mining
  241. $mining = (getLevelForSkill("mining"));
  242. imagestring($im, $font, 205, 125, $mining, $black);
  243. //herblore
  244. $herb = (getLevelForSkill("herblore"));
  245. imagestring($im, $font, 275, 40, $herb, $black);
  246. //agility
  247. $agility = (getLevelForSkill("agility"));
  248. imagestring($im, $font, 275, 62, $agility, $black);
  249. //theive
  250. $thieve = (getLevelForSkill("thieving"));
  251. imagestring($im, $font, 275, 82, $thieve, $black);
  252. //slayer
  253. $slayer = (getLevelForSkill("slayer"));
  254. imagestring($im, $font, 275, 102, $slayer, $black);
  255. //farming
  256. $farm = (getLevelForSkill("farming"));
  257. imagestring($im, $font, 275, 125, $farm, $black);
  258. //runecraft
  259. $rune = (getLevelForSkill("runecrafting"));
  260. imagestring($im, $font, 335, 40, $rune, $black);
  261. //hunter
  262. $hunt = (getLevelForSkill("hunter"));
  263. imagestring($im, $font, 335, 62, $hunt, $black);
  264. //construction
  265. $con = (getLevelForSkill("construction"));
  266. imagestring($im, $font, 335, 82, $con, $black);
  267. //summon
  268. $summon = (getLevelForSkill("summoning"));
  269. imagestring($im, $font, 335, 102, $summon, $black);
  270. //dungeoneering
  271. $dung = ("".getLevelForSkill("dungeoneering"));
  272. imagestring($im, $font, 335, 125, $dung, $black);
  273. //misc
  274.  
  275. //servers url or something
  276. //may require some editing.
  277. if($image!="img/backgrounds/style0.png")
  278. $url = ("www.DankScape.com");
  279. else
  280. $url = ("");
  281. imagestring($im, 3, $width-125, $height-25, $url, $black);
  282.  
  283.  
  284. Header('Content-type: image/png');
  285. imagepng($im);
  286. imagedestroy($im);
  287. }
  288. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement