We moved our repositories to BitBucket!

If you can't login or you can't register to the forums do not rise an issue, instead please write to support (at) l2jserver.com

Check our wiki!

Report server issues here

Forum has been updated to phpBB 3.2, let's see if this fixes some minor bugs we had.

Thank you for visiting http://www.l2jserver.com/

Select A Ranking to home page

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Sat Sep 17, 2016 4:57 pm

I tried to load the xml file trough php but i cannot get the right name based on id out of it.

So now i have imported the xml files into the database edited a bit and it should be working.

The edited verion

Code: Select all

<!DOCTYPE html>
<section class="content-wrap">

<div class="title-page">SELECT A RANKING</div>

<style type="text/css">
table td { width:340px; height:40px; background:#FFF; border:2px solid #cbcbcb; font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif; text-align:center; font-size:18px; color:#545454; margin-top:15px; border-radius:5px;
}


</style>

<form method="post">

<select class="input-default-pages" style="width:691px;" name="rankselect">
<option value="0"> SELECT A RANKING... </option>
<option value="1"> TOP PVP </option>
<option value="2"> TOP PK </option>
<option value="3"> HEROES </option>
<option value="4"> CASTLE SIEGE </option>
<option value="5"> RAID BOSSES </option>

</select>
<br><input type="submit" name="search" value="SEARCH" class="btn-default-pages" style="width:691px;" />

</form>




   

<?php

	// Server Database Config
	$db_host		= '1.1.1.1';
	$db_user		= 'dbuser';
	$db_pass		= 'dbname';
	$db_database	= 'l2jgs';

	// Try to make connection.
	$connection = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_user, $db_pass);
	$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// top pvp
if(isset($_POST['search']))
	{
		$rankselect = $_POST['rankselect'];
		$i = 1;
	if($rankselect == 1)
		{
	?>
		<table width="691" cellpadding="10" cellspacing="10" border="0">
			<tr>
				<td>Pos.</td>
				<td>Nickname</td>
				<td>Pvpkills</td>
			</tr>
			<?php
		try {
				$queryselectpvp = 'SELECT * FROM characters ORDER BY pkkills DESC LIMIT 25 ';
				$querypvp = $connection -> prepare($queryselectpvp);
				$querypvp -> execute();

				while ($respvp = $querypvp -> fetch (PDO::FETCH_OBJ))
					{
					   ?>
						  <tr>
						  <td><?php echo $i++ ?>º</td>
						  <td><?php echo $respvp-> char_name; ?></td>
						  <td><?php echo $respvp-> pvpkills; ?></td>
						</tr>
						<?php
					}
				?></table><?php
			}
			catch (PDOException $e)
			{
				echo $e->getMessage();
			}
		}
	}
// top pk
if(isset($_POST['search']))
	{
		$rankselect = $_POST['rankselect'];
		$i = 1;
	if($rankselect == 2)
		{
		?>
			<table width="691" cellpadding="10" cellspacing="10" border="0">
				<tr>
					<td>Pos.</td>
					<td>Nickname</td>
					<td>Pk kills</td>
				</tr>
			<?php
		try {
				$queryselectpk = 'SELECT * FROM characters ORDER BY pkkills DESC LIMIT 25 ';
				$querypk = $connection -> prepare($queryselectpk);
				$querypk -> execute();

				while ($respk = $querypk -> fetch (PDO::FETCH_OBJ))
					{
					?>
					<tr>
						<td><?php echo $i++ ?>º</td>
						<td><?php echo $respk-> char_name; ?></td>
						<td><?php echo $respk-> pvpkills; ?></td>
					</tr>
					<?php
					}
				?></table><?php
			}
		catch (PDOException $e)
		{
			echo $e->getMessage();
		}
	}
}
// heroes
if(isset($_POST['search']))
	{
		$rankselect = $_POST['rankselect'];
		$i = 1;
	if($rankselect == 3)
		{
		   ?>
			<table width="691" cellpadding="10" cellspacing="10" border="0">
			<tr>
				<td>Nickname</td>
				<td>Class</td>
				<td>Count</td>
			</tr>
			<?php
		try {
				$class_name = array(
						'88' => "Duelist",
						'89' => "Dread Nought",
						'90' => "Phoenix Knight",
						'91' => "Hell Knight",
						'92' => "Sagittarius",
						'93' => "Adventurer",
						'94' => "Archmage",
						'95' => "Soul Taker",
						'96' => "Arcane Lord",
						'97' => "Cardinal",
						'98' => "Hierophant",
						'99' => "Evas Templar",
						'100' => "Sword Muse",
						'101' => "Wind Rider",
						'102' => "Moonlight Sentinel",
						'103' => "Mystic Muse",
						'104' => "Elemental Master",
						'105' => "Evas Saint",
						'106' => "Shillien Templar",
						'107' => "Spectral Dancer",
						'108' => "Ghost Hunter",
						'109' => "Ghost Sentinel",
						'110' => "storm Screamer",
						'111' => "Spectral Master",
						'112' => "Shillien Saint",
						'113' => "Titan",
						'114' => "Grand Khauatari",
						'115' => "Dominator",
						'116' => "Doomcryer",
						'117' => "Fortune Seeker",
						'118' => "Maestro",
					);

					// Get data from heroes and character table
					$queryselectheroes = 'SELECT heroes.charId, heroes.class_id, heroes.count, characters.char_name FROM heroes , characters WHERE heroes.charId =  characters.charId ORDER BY heroes.count DESC';
					$queryheroes = $connection -> prepare($queryselectheroes);

					if ($queryheroes->execute())
						{
							while ($row = $queryheroes->fetch(PDO::FETCH_ASSOC))
								{
									echo '<tr><td>', $row['char_name'],'</td><td>', $class_name[$row['class_id']], '</td><td>', $row['count'], '</td></tr>' ;
								}
								?></table><?php
						}
			}
			catch (PDOException $e)
			{
				echo $e->getMessage();
			}
		}
	}
// castle sieges
if(isset($_POST['search']))
	{
		$rankselect = $_POST['rankselect'];
		$i = 1;
	if($rankselect == 4)
		{
		   ?>
			<table width="691" cellpadding="10" cellspacing="10" border="0">
			<tr>
			  <td>Castle Name: </td>
			  <td>Tax:</td>
			  <td>Next Siege:</td>
			</tr>
			<?php
   
		try{
				$queryselectcastle = 'SELECT * FROM castle ORDER BY name ASC';

				$querycastle = $connection -> prepare($queryselectcastle);
				$querycastle -> execute();
				while ($rescastle = $querycastle -> fetch (PDO::FETCH_OBJ))
					{
					   $SiegeDate=date('j/m/Y H\:i',$rescastle-> siegeDate/1000);
					   ?>
						  <tr>
						  <td><?php echo $rescastle-> name; ?></td>
						  <td><?php echo $rescastle-> taxPercent; ?>%</td>
						  <td><?php echo $SiegeDate; ?></td>
						</tr>
						<?php
					}
			}
			catch (PDOException $e)
			{
				echo $e->getMessage();
			}
		}
	}
// Bosses
if(isset($_POST['search']))
	{
			$rankselect = $_POST['rankselect'];
			$i = 1;
		if($rankselect == 5)
			{
			   ?>
			   
					<div class="title-page" style="margin-bottom:15px;">BIG BOSSES</div>
				<table width="691" cellpadding="10" cellspacing="10" border="0">
				<tr>
				  <td>Name</td>
					<td>Level</td>
				  <td>Status</td>
				</tr>
				<?php
		try {
				// Get data from Grandboss_data and npc_data
				$queryselectbossesbig = 'SELECT grandboss_data.boss_id, grandboss_data.respawn_time, npc_data.id, npc_data.level , npc_data.name FROM grandboss_data , npc_data WHERE grandboss_data.boss_id =  npc_data.id ORDER BY npc_data.level DESC';
				$querybossesbig = $connection -> prepare($queryselectbossesbig);
				
				if ($querybossesbig->execute())
				{

							while ($row = $querybossesbig->fetch(PDO::FETCH_ASSOC))
								{
									$convertdatebig = date('d/m/Y H:i:s',($row['respawn_time'] / 1000));
									echo '<tr><td>', $row['name'],'</td><td>', $row['level'], '</td><td>'; if ($row['respawn_time'] == 0) { echo "ALIVE";}else{ echo $convertdatebig;} '</td></tr>' ;
								}
								?></table><?php
				}
				
				
			}
		catch (PDOException $e)
		{
			echo $e->getMessage();
		}
	?>

		<div class="title-page" style="margin-bottom:15px; clear:both; margin-top:15px;">RAID BOSSES</div>
		<table width="691" cellpadding="10" cellspacing="10" border="0">
		<tr>
		  <td>Name</td>
			<td>Level</td>
		  <td>Status</td>
		</tr>
		<?php
	try {
			// Get data from Raidboss_spawnlist and npc_data
			$queryselectbosses = 'SELECT raidboss_spawnlist.boss_id, raidboss_spawnlist.respawn_time, npc_data.id, npc_data.level, npc_data.name FROM raidboss_spawnlist, npc_data WHERE raidboss_spawnlist.boss_id =  npc_data.id ORDER BY npc_data.level DESC';
			$querybosses = $connection -> prepare($queryselectbosses);

			if ($querybosses->execute())
			{
				while ($row = $querybosses->fetch(PDO::FETCH_ASSOC))
						{
							$convertdatebig = date('d/m/Y H:i:s',($row['respawn_time'] / 1000));
							echo '<tr><td>', $row['name'],'</td><td>', $row['level'], '</td><td>'; if ($row['respawn_time'] == 0) { echo "ALIVE";}else{ echo $convertdatebig;} '</td></tr>' ;
						}

			}
		}
		catch (PDOException $e)
		{
			echo $e->getMessage();
		}
	}
}

?>

And also add this sql file into your database.
http://s000.tinyupload.com/index.php?fi ... 5961526022

If someone knows how to load the xml file and get the right name by id, give me a heads up i would like to know this.
The xml file looks like this and its one big file.
Example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<list>
	<npc id="100" level="80" type="L2Npc" name="Thomas D. Turkey"></npc>
	<npc id="101" level="80" type="L2Npc"></npc>
	<npc id="102" level="70" type="L2Npc" name="Santa Trainee"></npc>
	<npc id="103" level="70" type="L2Npc" name="Christmas Santa" title="Merry Christmas~"></npc>
	<npc id="104" level="70" type="L2Npc" name="Christmas Santa" title="Merry Christmas~"></npc>
	<npc id="105" level="70" type="L2Npc" name="Christmas Sled" title="Merry Christmas~"></npc>
	<npc id="106" level="70" type="L2Npc" name="Birthday Cake"></npc>
	<npc id="107" level="1" type="L2Npc" name="Spirit of Fire"></npc>
	<npc id="108" level="1" type="L2Npc" name="Reckless Spirit of Fire"></npc>
	<npc id="109" level="85" type="L2Npc" name="Steve Shyagel" title="Eva's High Priest"></npc>
	<npc id="110" level="70" type="L2Npc" name="Eva's Obelisk"></npc>
	etc.........
	</list>
Last edited by dasoldier on Sun Oct 23, 2016 7:33 pm, edited 3 times in total.

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Thu Sep 29, 2016 2:50 pm

thanks man :+1:

dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Fri Sep 30, 2016 6:11 pm

No problem :)

Post Reply