Location: PHPKode > scripts > qAdmin > jonathan-fielding-qAdmin-04ccc6a/index.php
<?php
	//Need to do some checks on whether it is installed

	session_start();
	
	//Include system variables
	include("includes/variables.php");
	include("config.php");
	
	//Include used classes
	include("classes/opendb.class.php");
	include("classes/user_auth.class.php");
	
	$database_connection = new database_connection();
	$UserAuth = new UserAuth();

	if (isset($_POST['username'])){
		if($UserAuth->validateUser($_POST['username'],$_POST['password'])){
			$_SESSION['username'] = $_POST['username'];
			$_SESSION['password'] = $_POST['password'];
			$_SESSION['authlevel'] = $UserAuth->getAuthLevel($_SESSION['username']);
		}
		else{
		}
	}

	if (isset($_GET['action'])){
		if($_GET['action'] == 'logout'){
			session_destroy();
			header( 'location:index.php' );
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>qAdmin</title>
	<link href="main.css" rel="stylesheet" type="text/css" />
 <script src="includes/cufon-yui.js" type="text/javascript"></script>
    <script src="includes/TheMixBold_400.font.js" type="text/javascript"></script>
 	
    <script type="text/javascript">
		Cufon.replace('h1');
	</script>
</head>
<body>
	<div class="admin">
		<h1>qAdmin</h1>
		
		
			<?php if (isset($_SESSION['username'])){ ?>
				<a href="index.php?action=logout" id="logout">Logout</a>
				
				<div class="table_list">
					<div class="table_name"><a href="index.php">Home</a></div>
				<?php
				
					$result = $database_connection->dataquery("SHOW TABLES");
					while($row = mysql_fetch_array($result))
					{
						if (!in_array($row['Tables_in_'.strtolower($database)], $exclude_tables)) {
							echo '<div class="table_name"><a href="?table='.$row['Tables_in_'.strtolower($database)].'">'.$row['Tables_in_'.strtolower($database)].'</a></div>';
						}
					}

				?>
				</div>
				<div class="contentbox">
					
					<?php
					if(isset($_GET['table'])){
						$columns = $database_connection->dataquery("SHOW COLUMNS FROM ".$_GET['table'].";");
						$data = $database_connection->dataquery("SELECT * FROM ".$_GET['table'].";");
						
						
						echo '<div class="stats">';
						echo '<h2>Table Statistics</h2>';
						echo 'Rows: ' . mysql_num_rows($data);
						echo '<a href="index.php?table='.$_GET['table'].'&action=export">Export</a>';
						echo '</div>';
						
						echo '<table border="1" align="center" cellspacing="0">';
						
						echo '<tr>';
						
						$items = array();
						
						while($row = mysql_fetch_array($columns))
						{
							echo '<th>'.$row['Field'].'</th>';
							$items[] = $row['Field'];
						}
						echo '</tr>';
						
						
						
						while($data_row = mysql_fetch_array($data))
						{
							echo '<tr>';
							
							
							foreach($items as $item) {
							   echo '<td>'.$data_row[$item].'</td>';
							}
							
							echo '</tr>';
						
						}

						echo '</table>';
					}
					else{
						$result = $database_connection->dataquery("SHOW TABLES");
						while($row = mysql_fetch_array($result))
						{
							$data = $database_connection->dataquery("SELECT * FROM ".$row['Tables_in_'.strtolower($database)].";");
							if (!in_array($row['Tables_in_'.strtolower($database)], $exclude_tables)) {
								echo '<div class="table_block">';
									echo '<h3><a href="?table='.$row['Tables_in_'.strtolower($database)].'">'.$row['Tables_in_'.strtolower($database)].'</a></h3>';
									echo 'Number of Rows:' . mysql_num_rows($data);
								echo '</div>';
							}
						}
					}
					?>
				
				</div>
				
				
			<?php }else{?>
				<div class="loginform">
				<form action="" method="post">
					<input type="text" name="username" id="username" placeholder="Username"/><br/>
					<input type="text" name="password" id="password" placeholder="Password" /><br />
					<input type="submit" name="login" id="login" value="Login" />
				</form>
				</div>
			<?php } ?>
	</div>
</body>
</html>
Return current item: qAdmin