<?php
	if(!isset($_SESSION)) session_start();
	include("loginCheckPoint.php");
	if($_SESSION["username"] != "kfirbar"){
		echo "only for admin users";
		die();
	}
	require_once("demosettings.php");
	
	$mysqli = new mysqli($databaseHost, $databaseUser, $databasePass, $databaseName);
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IntuScan - Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<!-- CuFon: Enables smooth pretty custom font rendering. 100% SEO friendly. To disable, remove this section -->
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/arial.js"></script>
<script type="text/javascript" src="js/cuf_run.js"></script>

 <script src="jquery/jquery.js" type="text/javascript"></script>
  <script src="jquery/jquery-ui.custom.js" type="text/javascript"></script>
  <script src="jquery/jquery.cookie.js" type="text/javascript"></script>
  <script src="jquery-ui/development-bundle/ui/jquery.ui.tabs.js"></script>

<link type="text/css" href="jquery-ui/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
<script type="text/javascript" src="jquery-ui/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jquery-ui/js/jquery-ui-1.8.17.custom.min.js"></script>
		
  <link href="src/skin/ui.dynatree.css" rel="stylesheet" type="text/css" id="skinSheet">
  <script src="src/jquery.dynatree.js" type="text/javascript"></script>
 

<script type="text/javascript">
var ajax_load = "<p align=center><img src='images/loader.gif' alt='loading...' /></p>";
function showText(text){
	document.getElementById("dialogText").innerHTML = text;
	$( "#dialogModal" ).dialog({
		height: 300,
		modal: true
	});
};

 $(function(){
  	$( "#tabs" ).tabs({
			ajaxOptions: {
				error: function( xhr, status, index, anchor ) {
					$( anchor.hash ).html(
						"Couldn't load this tab. We'll try to fix this as soon as possible.");
				}
			}
		});
  });
 
</script>
</head>
<body>

 <div id="dialogModal" title="Text">
	<div id="dialogText"></div>
 </div>


 <div class="top-banner">
	 <a href="senddoc.php"><img src="images/intuscan-img.png" /></a>
	 <p style="padding:0 10px 10px 10px; float:right;"><b>1.2.0.1 (demo version)</b></p>
	 <p style="padding:0 10px 10px 10px; float:right;">Hi, <?=$_SESSION["username"] ?></p>
	 <p style="padding:0 10px 10px 10px; float:right;"><a style="color:red;" href="logoff.php">logoff</a></p>
 </div>
<div class="main">
  <div class="header">
    <div class="header_block">

      <div class="clr"></div>
    </div>
    <div class="clr"></div>
  </div>
  <div class="content">
      <div class="mainbar">
        <div class="article">
        	<div class="ann1">
					<div id="tabs">
						<ul>
							<li><a href="#tabs-1" style="font-size:12px;">Transactions</a></li>
						</ul>
						<div class="article">
							<div id="tabs-1">
								<table>
									<tr>
										<th>Username</th>
										<th>Type</th>
										<th>Date</th>
										<th>ID</th>
										<th>Content</th>
										<th>Results</th>
									</tr>
								<?php
									
									$res = $mysqli->query("SELECT * FROM files order by id DESC");
									while ($row = $res->fetch_object()) {
										echo "<tr>";
										$username = $row->username;
										$type = $row->type;
										$data = $row->data;
										$datetime = $row->date;
										$id = $row->id;
										echo "<td>" . $username . "</td>";
										echo "<td>" . $type . "</td>";
										echo "<td>" . $datetime . "</td>";
										echo "<td>" . $id . "</td>";
										if($type == "catalogfile"){
											echo "<td>" . $data . "</td>";
										}else if($type == "newfile"){
											echo "<td><a href=\"download.php?filename=" . $data . "\">" . basename($data) . "</a></td>"; 
										}else if($type == "text"){
											echo "<td><a href=\"javascript:showText('" . $data . "');\">Show Text</a></td>";
										}else if($type == "url"){
											echo "<td><a href=\"" . $data . "\">" . $data . "</a></td>";
										}
										echo "<td><a href=\"document.php?dcid=" . $id . "\">Results</a></td>";
										echo "</tr>";
									}
								?>
								</table>
							</div>
						</div>
					</div>
			</div>	
        </div>
      </div>
      <div class="clr"></div>
  </div>
</div>
<div class="footer">
    <div class="footer_resize">
    	<p>
    	<div class="logo">
    		<img src="images/logo.jpg" width="100"/>  
    	</div>
    	</p>
    	<p class="lf">© Copyright <a href="#">www.intuview.com</a></p>
      <div class="clr"></div>
    </div>
  </div>
</body>
</html>