<?
// Copyright 2007, Google Inc.
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions are met:
//
//  1. Redistributions of source code must retain the above copyright notice, 
//     this list of conditions and the following disclaimer.
//  2. Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//  3. Neither the name of Google Inc. nor the names of its contributors may be
//     used to endorse or promote products derived from this software without
//     specific prior written permission.
//
require("_database.php");
require("_functions.php");
require("_layout.php");
?>
<html>
<head>
<script src = "note.js" ></script>
<!-- TREE YUI -->
   <!-- Required CSS -->
  <link type="text/css" rel="stylesheet" href="yui/build/treeview/assets/skins/sam/treeview.css"> 
  <!-- Dependency source files --> 
  <script src = "yui/build/yahoo/yahoo-min.js" ></script>
  <script src = "yui/build/event/event-min.js" ></script>
  <!-- TreeView source file --> 
  <script src = "yui/build/treeview/treeview-min.js" ></script>
  <!--bring in the folder-style CSS for the TreeView Control-->
  <link rel="stylesheet" type="text/css" href="yui/examples/treeview/assets/css/folders/tree.css"> 

<style type="text/css">


.icon-ppt { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 0px no-repeat; }
.icon-dmg { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -36px no-repeat; }
.icon-prv { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -72px no-repeat; }
.icon-gen { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -108px no-repeat; }
.icon-doc { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -144px no-repeat; }
.icon-jar { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -180px no-repeat; }
.icon-zip { padding-left: 20px; background: transparent url(yui/examples/treeview/assets/img/icons.png) 0 -216px no-repeat; }
</style>

<style type="text/css">
<? include("_style_base.php"); ?>

body {
  margin:0;
  overflow:visible;
}

textarea {
  position:absolute; 
  overflow:auto; 
  left:2px; 
  top:1em; 
  right:2px; 
  bottom:1em; 
  margin-top:8px; 
  margin-bottom:2px; 
  border:1px solid #ccc;
}

label {
  position:absolute; 
  overflow:auto; 
  left:2px; 
  top:1em; 
  right:2px; 
  bottom:1em; 
  margin-top:8px; 
  margin-bottom:2px; 
  border:1px solid #ccc;
}

#table {
  position:absolute; 
  overflow:auto; 
  left:2px; 
  top:1em; 
  right:2px; 
  bottom:1em; 
  margin-top:8px; 
  margin-bottom:2px; 
  border:1px solid #ccc;
}


iframe {
  height:200px;
}

#setup-offline a {
  color:red!important;
  font-weight:bold!important;
}


#tempstatus{
  position:relative;
  top:5px;
  left:0px;
}

#status {
  position:relative;
  top:0px;
  left:0px;
  bottom: 0px;
}

#contact {
  position:relative;
  top:5px;
  left:0px;
  bottom: 5px;
}

.tree{
  position:relative;
  top:5px;
  left:0px;
  right:15px;
  bottom: 0px
}

.info{
  font-size: 120%;
  position:relative;
  top: 5px;
  left: 0px;
  right:0px;
  bottom:5px;
  padding: 10px;
}
</style>

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
	  die('Could not connect: ' . mysql_error());
  }
$id = validateUserCookie();
validateUserCookie(true );
$id = db_escape($id);
if($id)
{
	$result = db_query_get("SELECT * FROM users where id=$id" );
	$data = $result[0]['content'];
	$path = $result[0]['path'];
	$email = $result[0]['email'];
	$email = db_escape($email);
	$mcname = $result[0]['mcname'];
	$mcname = db_escape($mcname);
	$row = db_query_get("SELECT * FROM users where email='$email'");
//	$count = count($row);
}
else
{
	header('Location: login.php');
}
?>
<title>File System View</title>
<script src = "note.js" ></script>
</head>

<? masthead("Home"); ?>
<!-- Display db-->

<?php
	//echo phpversion() . "<br/>" ;
if(!($data))
	echo"Error in DB or file path undefined";
	//redirect to settings -- file path undefined
	
else	
	{
		echo "<body onload=\"init()\" class=\"folder\">";
		echo "<script type=\"text/javascript\" src=\"wz_tooltip.js\"></script>";
//		echo "<script src = \"note.js\" ></script>";
		echo "<div id=\"status\" class=\"green\">Ready.</div>";
		echo "<input type=hidden  id = \"identity\" name = \"identity\" value=\"$id\" />";
		echo "<input type=hidden  id = \"test\" name = \"test\" value=\"$data\" />";
		echo "<input type=hidden  id = \"path\" name = \"path\" value=\"$path\" />";
		echo "<input type=hidden  id = \"mcname\" name = \"mcname\" value=\"$mcname\" />";
//		print "Path". $path . "<br/>";
//		print "Data". $data . "<br/>";
//		print "Email". $email . "<br/>";
//		echo "<div id=\"divTree\" name=\"divTree\"> TREE OLD</div>";
//		echo "<div id=\"report\" class=\"info\"></div>";
		echo "<b>$mcname</b>";
		echo "<div id=\"treeDiv1\" name=\"treeDiv1\" class=\"tree\"> TREE YUI</div>";		
		echo "<br/>";
		foreach($row as $o)
		{
			$i=db_escape($o['id']);
			$c=db_escape($o['content']);
			$mcname = db_escape($o['mcname']);
			if($id!=$i)
			{
				echo "<b>$mcname</b>";
				$tagname='treeDiv'.$i;
				echo "<input type=\"hidden\" name=\"id\"  value=\"$i\"/>";
				echo "<input type=\"hidden\" id=\"$i\"  value=\"$c\"/>";
				echo "<input type=\"hidden\" name=\"$tagname\"  value=\"$mcname\"/>";
				echo "<div id=$tagname class=\"tree\">TREE YUI: $tagname</div><br/>";	
				echo "<script  type=\"text/javascript\">";
				echo "disp_it(\"$c\", \"$tagname\", \"$mcname\" );";
				echo "</script>";
			}
		}
		echo "<script  type=\"text/javascript\">";
		echo "print_it();";
//		echo "print_it();";
//		echo "disp_all();";
		echo "</script>";
	}
?>

<!--
<a onclick="listFiles()"> + Click to List Files and Directories (Change the path above first!) </a>
<div id="list"> List Comes Here </div>
-->

<script type="text/javascript" src="base.js"></script>
<script type="text/javascript" src="cookies.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="datastore.js"></script>
<script src = "note.js" ></script>
</body>
</html>

