Location: PHPKode > projects > Dominant Creature RPG > class/home_class.php
<?php



require_once ("data_class.php");



class Home extends Data {





	function Init() {



		$this->GetUserData();



	}



	

	function Link() {

		

		if (isset($_GET["rr"])) {

			

			$t = time();

			$q = mysql_query("UPDATE users SET ref_time = '$t' WHERE id = '".$this->creature[user_id]."'");

			

		}

		

		$q = mysql_query("SELECT * FROM users WHERE id = '".$this->creature[user_id]."'");

		

		$user = mysql_fetch_assoc($q);

		

		echo "<table width='280' align='right' border='0'>";

		echo "<tr><td align='center' style='margin-bottom: 2px; border-bottom: 1px solid #ccc;'>Player info:</td></tr>";

		echo "<tr><td>Your link:<br /> $this->gameurl/ref.php?pid=".$user[id]."</td></tr>";

		echo "<tr><td>Referrals today: ".$user[ref_count]."</td></tr>";



		if (time() > ($user[ref_time] + 86400)) {$link = "<a href='?p=home&rr'>Reset referrals</a>";}

		else {$link = "<font color='cccccc'>Reset not possible yet.</font>";}

		

		$lref = date("F j, Y, g:i a", $user[ref_time]);  

		

		echo "<tr><td>Referal round start: $lref</td></tr>";

		echo "<tr><td>$link</td></tr>";

		echo "</table>";

	

		

	}

	

	

	function Overview() {

		

		$this->Init();

		

		// Top players

			

		

	if (preg_match("/[^0-9]+/", $_GET["pg"]))

		{

		echo "<table align='center'><tr><td>Invalid action or no creatures exist</td></tr></table>";	 

		exit;

		}

		

		//level or exp?

		

		if (isset($_GET["c"]) && $_GET["c"] == 'l') {$field = 'level'; $ul = 'l';}

		else if (isset($_GET["c"]) && $_GET["c"] == 'e') {$field = 'exp'; $ul = 'e';}

		else {$field = 'level'; $ul = 'l';}

		

		//some security check

		

		if (isset($_GET["pg"]))

		{

			

		$pg = $_GET["pg"];

		if ($pg == 1) {$start = 0;} else {$start = ($pg - 1)  * 10;}

		$end = $start + 10;

		}

		else {

			$pg = 1;

			$start = 0;

			$end = $start + 10;

		}

		

		

		$back = $pg - 1;

		$next = $pg + 1;

		

		if ($back < 1) {$back = 1;}

		

		$qry = "

		SELECT id, name, level, exp, type

			FROM

		player_creatures

		ORDER BY $field DESC

		LIMIT $start, $end

		";

		

		//echo $qry;

		

		$q = mysql_query($qry);

		

		echo "<table width='280' align='left' border='0'>";

		echo "<tr><td colspan='3' align='center' style='margin-bottom: 2px; border-bottom: 1px solid #ccc;'>

		Top players by <a href='?p=home&c=l'>Level</a> | <a href='?p=home&c=e'>Exp</a>:</td></tr>";

		echo "<tr><td><b>Name</b></td><td><b>$field</b></td><td><b>Class</b></td></tr>";

		$i = 1;

		$m = mysql_num_rows($q);

		

		while ($i <= $m) {



			$p[$i] = mysql_fetch_assoc($q);



			if ($p[$i][id] == $this->creature[user_id]) {$name[$i] = "<font color='blue'>".$p[$i][name]."</font>";}

			else {$name[$i] = $p[$i][name];}

			

		echo "<tr><td><b>".$name[$i]."</b></td><td>".$p[$i][$field]."</td><td>".$p[$i][type]."</td></tr>";

			

			$i++;

		}

		

		

		echo "<tr><td colspan='3' align='center' style='margin-bottom: 2px; border-top: 1px solid #ccc;'> ...<a href='?p=home&c=$ul&pg=$back'>prev</a> | <a href='?p=home&c=$ul&pg=$next'>next</a>... </td></tr>";

		echo "</table>";

		

		$this->Link();

		

	}

	

}

	

?>

Return current item: Dominant Creature RPG