Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- _____ _____
- / ___/___ ______ _____ _____/ ___/_________ _____ ___
- \__ \/ _ \/ ___/ | / / _ \/ ___/\__ \/ ___/ __ `/ __ \/ _ \
- ___/ / __/ / | |/ / __/ / ___/ / /__/ /_/ / /_/ / __/
- /____/\___/_/ |___/\___/_/ /____/\___/\__,_/ .___/\___/
- /_/ */
- /////////////////////////////////////////////////////////////////////////////////
- /*
- ServerScape
- ServerScape Version: 0.5
- E-mail: brandon@dankscape.com
- File/Project: Player Card Generator
- Author(s): Brandon, Kemi
- [DO NOT COPY WITHOUT PERMISSION]
- */
- ////////////////////////////////////////////////////////////////////////////////
- ?>
- <?php
- $username = $_REQUEST["player"];
- $username2 = $_REQUEST["user"];
- if($username==null)
- echo '
- <title>ServerScape - Forum Signature Generator</title>
- <body>
- <center>
- <header>
- <span>Forum Signature Generator</span>
- </header>
- <div class="content">
- <form id="search-form">
- <div class="form-group">
- <br>
- <input class="form-control" id="search-input" name="player" placeholder="Username here">
- </div>
- <br>
- <button type="submit" class="button">Create</button>
- </form>
- </section>
- </body>
- </div>
- </center>
- ';
- ?>
- <?php
- if($username!=null)
- {
- $username = $_REQUEST["player"];
- $quests = $_REQUEST["quests"];
- $image = $_REQUEST["img"];
- if(!$image) //no custom image given, use default instead.
- $image = ('img/backgrounds/style0.png');
- /*
- //this seems to be broken when using it with mysqli_connect()
- $host="localhost"; // Host name
- $usr=""; // Mysql username
- $password=""; // Mysql password
- $db_name="serverscape_highscores"; // Database name
- $tbl_name="hs_users"; // Table name
- */
- function getUser($var) {
- //edit the variables here.
- $mysqli = mysqli_connect('localhost', 'mysql_username', 'mysql_password', 'serverscape_highscores');
- //edit the table name here if yours is different.
- $query="SELECT * FROM hs_users WHERE username='".$_REQUEST["player"]."'";
- $result = mysqli_query($mysqli, $query);
- if(mysqli_num_rows($result) > 0) {
- $row = mysqli_fetch_assoc($result);
- return $row[$var.'_xp'];
- }
- }
- function getCombatLevel() {
- $attack = getLevelForSkill("attack");
- $defence = getLevelForSkill("defence");
- $strength = getLevelForSkill("strength");
- $hp = getLevelForSkill("constitution");
- $prayer = getLevelForSkill("prayer");
- $ranged = getLevelForSkill("ranged");
- $magic = getLevelForSkill("magic");
- $combatLevel = (int) (($defence + $hp + floor($prayer / 2)) * 0.25) + 1;
- $melee = ($attack + $strength) * 0.325;
- $ranger = floor($ranged * 1.5) * 0.325;
- $mage = floor($magic * 1.5) * 0.325;
- if ($melee >= $ranger && $melee >= $mage) {
- $combatLevel += $melee;
- } else if ($ranger >= $melee && $ranger >= $mage) {
- $combatLevel += $ranger;
- } else if ($mage >= $melee && $mage >= $ranger) {
- $combatLevel += $mage;
- }
- return (int)$combatLevel;
- }
- function getLevel() {
- return (int)(getCombatLevel() + getSummoningCombatLevel());
- }
- function getSummoningCombatLevel() {
- return getLevelForSkill("summoning") / 8;
- }
- function getTotalLevel()
- {
- 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");
- $skills = explode(',', skills);
- $total = 0;
- foreach ($skills as $skill) {
- if($skill!="dungeoneering")
- $total += getLevelForSkill($skill);
- else if($skill=="dungeoneering")
- $total += getLevelForSkill($skill);
- }
- return $total;
- }
- function getLevelForSkill ($var)
- {
- $lvl = getLevelForXp(getUser($var), $var);
- if($lvl <= 0 || $lvl >= 121)
- return "?";
- else
- return $lvl;
- }
- function getLevelForXp($exp, $skill) {
- $points = 0;
- $output = 0;
- for ($lvl = 1; $lvl <= (strtolower($skill) == 'dungeoneering' ? 120 : 99); $lvl++) {
- $points += floor($lvl + 300.0 * pow(2.0, $lvl / 7.0));
- $output = (int) floor($points / 4);
- if (($output - 1) >= $exp) {
- return $lvl;
- }
- }
- return (strtolower($skill) == 'dungeoneering' ? 120 : 99);
- }
- function dbgetvar() {
- $args = func_get_args();
- $query = array_shift($args);
- foreach ($args as $key => $val) {
- $args[$key] = "'".mysql_real_escape_string($val)."'";
- }
- $query = vsprintf($query, $args);
- $res = mysql_query($query);
- if (!$res) {
- trigger_error("dbgetarr: ".mysql_error()." in ".$query);
- return FALSE;
- } else {
- $row = mysql_fetch_row($res);
- if (!$row) return NULL;
- return $row[0];
- }
- }
- $im = imagecreatefrompng($image);
- $black = imagecolorallocate($im, 255, 255, 255);
- $width = imagesx($im);
- $height = imagesy($im);
- $font = 8; // store the int ID of the system font we're using in $font
- if($image=="img/backgrounds/style5.png")
- $black = imagecolorallocate($im, 1, 1, 1);
- else
- $black = imagecolorallocate($im, 255, 255, 255);
- //username
- $user = ("Statistics for ".$username);
- $middle = ( $width - imagefontwidth($font)*strlen($user) )/2;
- imagestring($im, $font, $middle, $height-140, $user, $black);
- //rank (havent gotten this to work yet)
- //$rank = ("Rank: ".getRank());
- //imagestring($im, 2, $width-60, $height-145, $rank, $black);
- //total lvl
- $totallvl = getTotalLevel();
- imagestring($im, $font, $width-75, $height-50, $totallvl, $black);
- //achievements
- $achievements = ("17");
- imagestring($im, $font, $width-75, $height-77, $achievements, $black);
- //quest points
- $quests = ("2");
- imagestring($im, $font, $width-75, $height-102, $quests, $black);
- //combat level
- imagestring($im, $font, $width-75, $height-127, getLevel(), $black);
- //attack
- $attack = (getLevelForSkill("attack"));
- imagestring($im, $font, 73, 42, $attack, $black);
- //strength
- $str = (getLevelForSkill("strength"));
- imagestring($im, $font, 73, 62, $str, $black);
- //defence
- $def = (getLevelForSkill("defence"));
- imagestring($im, $font, 73, 82, $def, $black);
- //hp
- $hp = (getLevelForSkill("constitution"));
- imagestring($im, $font, 73, 102, $hp, $black);
- //prayer
- $prayer = (getLevelForSkill("prayer"));
- imagestring($im, $font, 73, 125, $prayer, $black);
- //range
- $range = (getLevelForSkill("ranged"));
- imagestring($im, $font, 135, 40, $range, $black);
- //mage
- $mage = (getLevelForSkill("magic"));
- imagestring($im, $font, 135, 60, $mage, $black);
- //cooking
- $cook = (getLevelForSkill("cooking"));
- imagestring($im, $font, 135, 80, $cook, $black);
- //wc
- $wc = (getLevelForSkill("woodcutting"));
- imagestring($im, $font, 135, 100, $wc, $black);
- //fletching
- $fletch = (getLevelForSkill("fletching"));
- imagestring($im, $font, 135, 125, $fletch, $black);
- //fishing
- $fish = (getLevelForSkill("fishing"));
- imagestring($im, $font, 205, 40, $fish, $black);
- //firemaking
- $fire = (getLevelForSkill("firemaking"));
- imagestring($im, $font, 205, 62, $fire, $black);
- //crafting
- $craft = (getLevelForSkill("crafting"));
- imagestring($im, $font, 205, 82, $craft, $black);
- //smithing
- $smith = (getLevelForSkill("smithing"));
- imagestring($im, $font, 205, 102, $smith, $black);
- //mining
- $mining = (getLevelForSkill("mining"));
- imagestring($im, $font, 205, 125, $mining, $black);
- //herblore
- $herb = (getLevelForSkill("herblore"));
- imagestring($im, $font, 275, 40, $herb, $black);
- //agility
- $agility = (getLevelForSkill("agility"));
- imagestring($im, $font, 275, 62, $agility, $black);
- //theive
- $thieve = (getLevelForSkill("thieving"));
- imagestring($im, $font, 275, 82, $thieve, $black);
- //slayer
- $slayer = (getLevelForSkill("slayer"));
- imagestring($im, $font, 275, 102, $slayer, $black);
- //farming
- $farm = (getLevelForSkill("farming"));
- imagestring($im, $font, 275, 125, $farm, $black);
- //runecraft
- $rune = (getLevelForSkill("runecrafting"));
- imagestring($im, $font, 335, 40, $rune, $black);
- //hunter
- $hunt = (getLevelForSkill("hunter"));
- imagestring($im, $font, 335, 62, $hunt, $black);
- //construction
- $con = (getLevelForSkill("construction"));
- imagestring($im, $font, 335, 82, $con, $black);
- //summon
- $summon = (getLevelForSkill("summoning"));
- imagestring($im, $font, 335, 102, $summon, $black);
- //dungeoneering
- $dung = ("".getLevelForSkill("dungeoneering"));
- imagestring($im, $font, 335, 125, $dung, $black);
- //misc
- //servers url or something
- //may require some editing.
- if($image!="img/backgrounds/style0.png")
- $url = ("www.DankScape.com");
- else
- $url = ("");
- imagestring($im, 3, $width-125, $height-25, $url, $black);
- Header('Content-type: image/png');
- imagepng($im);
- imagedestroy($im);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement