This commit is contained in:
Michael Zhang 2023-01-14 07:40:41 -06:00
parent df33b79437
commit 17d49821f5
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
98 changed files with 3114 additions and 7359 deletions

Binary file not shown.

314
about.php
View file

@ -1,157 +1,157 @@
<?php
function getDirectorySize($directory)
{
$dirSize=0;
if(!$dh=opendir($directory))
{
return false;
}
while($file = readdir($dh))
{
if($file == "." || $file == "..")
{
continue;
}
if(is_file($directory."/".$file))
{
$dirSize += filesize($directory."/".$file);
}
if(is_dir($directory."/".$file))
{
$dirSize += getDirectorySize($directory."/".$file);
}
}
closedir($dh);
return $dirSize;
}
function filesize_format($size, $sizes = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'))
{
if ($size == 0) return('n/a');
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
}
function daysAgo($str) { $now=time();
$your_date=strtotime($str); $datediff=$now - $your_date; return floor($datediff/(60*60*24)); }
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<title>About LEXIS</title>
<style>
body {
overflow-x:hidden;
}
#features {
width:100%;
}
#features tr td {
width:50%;
}
#features tr td img {
width:100%;
}
#features tr {
box-shadow:inset 0px 2px 2px #AAA;
}
#features tr td .title {
font-size:28pt;
display:inline-block;
width:70%;
}
#features tr td .text {
display:block;
font-size:15pt;
}
#goToLEXISNow {
position:fixed;
bottom:10px;
right:-250px;
padding:20px;
z-index:1000;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
}
#goToLEXISNow .button {
box-shadow:0px 5px 5px #000;
}
#bottombar {
width:100%;
margin:none;
background-color:#118821;
padding:10px 10px 10px 10px;
text-align:center;
color:#FFF;
position:relative;
left:-10px;
margin-top:17px;
}
</style>
</head>
<body>
<div id="container">
<?php include ("../header.php"); ?>
<center><span style="font-size:32pt;display:block;">LEXIS Cloud Office</span>
<span style="display:block;">A new dimension of cloud computing.</span></center>
<table id="features">
<tr>
<td>
<span class="title">Take your files with you ... everywhere.<br /><br /></span>
<span class="text">With the new cloud computing technology of now, you can carry your files from one place to another with great ease. With a click of a button, your files will be saved not only on your work computer, but also your home computer, your phone, your tablet, or whatever other device you use. All your files are saved on our servers safely, you can access them whenever you want... wherever you want.</span>
</td>
<td><img src="images/about/take_your_files_with_you.png" /></td>
</tr><tr>
<td><img src="images/about/accidents_happen.png" /></td>
<td>
<span class="title">Accidents happen, and you lose your files ... or not?<br /><br /></span>
<span class="text">Your files are always safe. Don't ever worry about losing your files again when you have an accident. When you get a new device, simply install the new LEXIS app, and then all your files are back! </span>
</td>
</tr><tr>
<td>
<span class="title">Easy-to-use, intuitive, built-in apps!<br /><br /></span>
<span class="text">At this point, you must be thinking "Office apps? In your browser? You must be kidding!" Nope, we're not. We're totally serious about this. You get the full features of apps like Microsoft Word, PowerPoint, Excel, etc. all in the convenience of your browser. Never have to worry about buying office apps again!</span>
</td>
<td><img src="images/about/easy_to_use_intuitive.png" /></td>
</tr><tr>
<td><img src="images/about/free.png" /></td>
<td>
<span class="title">Free ... ? It can't be!<br /><br /></span>
<span class="text">It's true. Once you sign up for an ANIXO account, you get 10 gigabytes of free storage. You can use this storage however you want, and you can also expand this space! Simply buy another LEXIS Office Floorplan and you'll have more space in no time!</span>
</td>
</tr><tr>
<td>
<span class="title">Stats? Just for curious people.<br /><br /></span>
<span class="text">So far, we are storing a total of <?php $total = getDirectorySize("files/"); echo filesize_format ($total); ?>. We started this project close to the start of ANIXO Specifications, estimated to be around August 28, 2012 (<?php echo daysAgo ("2012-8-28"); ?> days ago).</span>
</td>
<td><img src="images/about/stats.png" /></td>
</tr>
</table>
<div id="bottombar">
LEXIS &copy; 2012-<?php echo date("Y"); ?> by Michael Zhang, ANIXO Specifications.
</div>
<div style="position:fixed;top:5px;left:15px;" id="disp"></div>
<div id="goToLEXISNow">
<a class="button color2" href="index.php">Go to your LEXIS cloud now! &raquo;</a>
</div>
<script type="text/javascript">
$("#container").scroll(function() {
if(Math.abs($("#container").scrollTop())>40) {
$("#goToLEXISNow").css("right","0px");
}
});
</script>
</div>
</body>
</html>
<?php
function getDirectorySize($directory)
{
$dirSize=0;
if(!$dh=opendir($directory))
{
return false;
}
while($file = readdir($dh))
{
if($file == "." || $file == "..")
{
continue;
}
if(is_file($directory."/".$file))
{
$dirSize += filesize($directory."/".$file);
}
if(is_dir($directory."/".$file))
{
$dirSize += getDirectorySize($directory."/".$file);
}
}
closedir($dh);
return $dirSize;
}
function filesize_format($size, $sizes = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'))
{
if ($size == 0) return('n/a');
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
}
function daysAgo($str) { $now=time();
$your_date=strtotime($str); $datediff=$now - $your_date; return floor($datediff/(60*60*24)); }
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<title>About Keepit</title>
<style>
body {
overflow-x:hidden;
}
#features {
width:100%;
}
#features tr td {
width:50%;
}
#features tr td img {
width:100%;
}
#features tr {
box-shadow:inset 0px 2px 2px #AAA;
}
#features tr td .title {
font-size:28pt;
display:inline-block;
width:70%;
}
#features tr td .text {
display:block;
font-size:15pt;
}
#goToKeepitNow {
position:fixed;
bottom:10px;
right:-250px;
padding:20px;
z-index:1000;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
}
#goToKeepitNow .button {
box-shadow:0px 5px 5px #000;
}
#bottombar {
width:100%;
margin:none;
background-color:#118821;
padding:10px 10px 10px 10px;
text-align:center;
color:#FFF;
position:relative;
left:-10px;
margin-top:17px;
}
</style>
</head>
<body>
<div id="container">
<?php include ("../header.php"); ?>
<center><span style="font-size:32pt;display:block;">Keepit Cloud Office</span>
<span style="display:block;">A new dimension of cloud computing.</span></center>
<table id="features">
<tr>
<td>
<span class="title">Take your files with you ... everywhere.<br /><br /></span>
<span class="text">With the new cloud computing technology of now, you can carry your files from one place to another with great ease. With a click of a button, your files will be saved not only on your work computer, but also your home computer, your phone, your tablet, or whatever other device you use. All your files are saved on our servers safely, you can access them whenever you want... wherever you want.</span>
</td>
<td><img src="images/about/take_your_files_with_you.png" /></td>
</tr><tr>
<td><img src="images/about/accidents_happen.png" /></td>
<td>
<span class="title">Accidents happen, and you lose your files ... or not?<br /><br /></span>
<span class="text">Your files are always safe. Don't ever worry about losing your files again when you have an accident. When you get a new device, simply install the new Keepit app, and then all your files are back! </span>
</td>
</tr><tr>
<td>
<span class="title">Easy-to-use, intuitive, built-in apps!<br /><br /></span>
<span class="text">At this point, you must be thinking "Office apps? In your browser? You must be kidding!" Nope, we're not. We're totally serious about this. You get the full features of apps like Microsoft Word, PowerPoint, Excel, etc. all in the convenience of your browser. Never have to worry about buying office apps again!</span>
</td>
<td><img src="images/about/easy_to_use_intuitive.png" /></td>
</tr><tr>
<td><img src="images/about/free.png" /></td>
<td>
<span class="title">Free ... ? It can't be!<br /><br /></span>
<span class="text">It's true. Once you sign up for a Keepit account, you get 10 gigabytes of free storage. You can use this storage however you want, and you can also expand this space! Simply buy another Keepit Office Floorplan and you'll have more space in no time!</span>
</td>
</tr><tr>
<td>
<span class="title">Stats? Just for curious people.<br /><br /></span>
<span class="text">So far, we are storing a total of <?php $total = getDirectorySize("files/"); echo filesize_format ($total); ?>. We started this project close to the start of Keepit, estimated to be around August 28, 2012 (<?php echo daysAgo ("2012-8-28"); ?> days ago).</span>
</td>
<td><img src="images/about/stats.png" /></td>
</tr>
</table>
<div id="bottombar">
Keepit &copy; 2012-<?php echo date("Y"); ?> by Michael Zhang, Keepit.
</div>
<div style="position:fixed;top:5px;left:15px;" id="disp"></div>
<div id="goToKeepitNow">
<a class="button color2" href="index.php">Go to your Keepit cloud now! &raquo;</a>
</div>
<script type="text/javascript">
$("#container").scroll(function() {
if(Math.abs($("#container").scrollTop())>40) {
$("#goToKeepitNow").css("right","0px");
}
});
</script>
</div>
</body>
</html>

View file

@ -1,9 +1,9 @@
<?php
include ("../../auth.inc.php");
$id = $_POST['ID'] or die ("Error: no variable given.");
mysql_query("delete from `lexis_docbank` where id='".$id."'") or die ("Error: couldn't delete ");
?>
<?php
include ("../../auth.inc.php");
$id = $_POST['ID'] or die ("Error: no variable given.");
mysql_query("delete from `keepit_docbank` where id='".$id."'") or die ("Error: couldn't delete ");
?>
hai

View file

@ -1,13 +1,13 @@
<?php
error_reporting(0);
include ("../../auth.inc.php");
$id = $_POST['ID'] or die ("Error: No variable given.");
$query = mysql_query("select * from `lexis_docbank` where id='" . $id . "'") or die ("Error: File not found.");
$row = mysql_fetch_array($query);
echo $row['title'];
<?php
error_reporting(0);
include ("../../auth.inc.php");
$id = $_POST['ID'] or die ("Error: No variable given.");
$query = mysql_query("select * from `keepit_docbank` where id='" . $id . "'") or die ("Error: File not found.");
$row = mysql_fetch_array($query);
echo $row['title'];
?>

View file

@ -1,200 +1,200 @@
<?php
error_reporting(0);
function slash () {
$dir = substr(getcwd(),strlen("/homepages/21/d438744504/htdocs/wsb7089376101/v3"));
for ($i=0;$i<substr_count($dir,"/");$i++) {
echo "../";
}
}
include ("../../auth.inc.php");
$id = $_POST['id'] or die ("No variable given.");
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../page.css" />
<img src="images/closeIcon.png" id="closeBtn" onclick="javascript:closePreviewPane();" />
<?php
$query = mysql_query("select * from users where username='".$_SESSION['username']."'");
$row = mysql_fetch_array($query);
$lexis_dir = $row['lexis_dir'];
$query = mysql_query("select * from `lexis_docbank` where id='" . $id . "'");
$row = mysql_fetch_array($query);
function filesize_of_folder($id) {
$filesize = 0;
$fquery = mysql_query("select * from lexis_docbank where container='" . $id . "'");
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['type']=="lexis_directory") {
$filesize += filesize_of_folder($frow['id']);
} else {
$filesize += filesize("../files/".$frow['id'].".".$frow['type']);
}
}
return $filesize;
}
if (isset($row['id']) && strlen($row['id'])>1) {
if ($row['type'] != "lexis_directory") {
$filesize = filesize("../files/".$id.".".$row['type']);
} else {
$filesize = filesize_of_folder($row['id']);
}
function getLink($id, $ext) {
if ($ext == "scribe") {
return "apps/scribe.php?doc=open&id=".$id;
} else if ($ext == "cascade") {
return "apps/cascade.php?doc=open&id=".$id;
} else {
return "files/".$id.".".$ext;
}
return "";
}
function getIconURL($ext) {
if ($ext=="lexis_directory") {
return "images/folder.png";
} else {
$x = scandir("../icons/");
if (in_array($ext.".png",$x)) {
return "icons/".$ext.".png";
} else {
return "images/file.png";
}
}
}
function filesize_format($size) {
$i = -1;
$byteUnits = array(' KB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB');
do {
$size = $size / 1024;
$i++;
} while ($size > 1024);
return round(max($size, 0.1),1) ." ". $byteUnits[$i];
};
?>
<table id="toptable" style="border:none; width:100%;">
<tr>
<td id="icon"><img src="<?php echo getIconURL($row['type']); ?>" width="1" height="1" /></td>
<td id="desc">
<?php if ($row['type']=="lexis_directory") { ?>
<a href="index.php?switchDir=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a>
<?php } else { ?>
<form action="downloadFile.php" id="downloadForm" method="POST">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="type" value="<?php echo $row['type']; ?>" />
<input type="hidden" name="title" value="<?php echo $row['title']; ?>" />
<a href="javascript:$('#downloadForm').submit();"><?php echo $row['title'].".<span style='color:#999;'>".$row['type']."</span>"; ?></a>
</form>
<?php } ?>
<!--<h3><?php echo "<a ".(($row['type']!="lexis_directory")?"target='_blank'":"")." href='" . (($row['type']=="lexis_directory")?"index.php?switchDir=".$row['id']:"") . "'>" . $row['title']; ?><?php if ($row['type']!="lexis_directory") echo "<span style='color:#999;'>.".strtolower($row['type'])."</span>"; ?></a></h3>-->
<small style="display:block;">Type: <?php echo $row['type']=="lexis_directory"?"Folder":strtoupper($row['type'])." file"; ?></small>
<small style="display:block;">Size: <?php if ($row['type']!="lexis_directory") { echo filesize_format($filesize); } else { echo filesize_format(filesize_of_folder($row['id'])); } ?></small>
</td>
</table>
<p>&nbsp;</p>
<div>
<a href="javascript:renameBtn('<?php echo $row['id']; ?>');" class="button color1">Rename</a><?php if ($row['type']!="lexis_directory") { ?><form style="display:inline;" action="downloadFile.php" id="downloadForm" method="POST"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" /><input type="hidden" name="type" value="<?php echo $row['type']; ?>" /><input type="hidden" name="title" value="<?php echo $row['title']; ?>" /><a class="button color2" href="javascript:$('#downloadForm').submit();">Download</a></form><?php } ?><a href="javascript:void(0);" id="deleteBtn" class="button color7">Delete</a>
</div>
<p>&nbsp;</p>
<div id="preview">
<?php if ($row['type']=="lexis_directory") { ?>
Folder contents:
<ul style="list-style-type:none;">
<?php
$fquery = mysql_query("select * from lexis_docbank where container='".$row['id']."'");
while($frow = mysql_fetch_array($fquery)) {
echo "<li><img style='vertical-align:middle;' src='".getIconURL($frow['type'])."' width='30' height='30' />&nbsp;<a href='javascript:showPreviewPane(\"".$frow['id']."\");'>".$frow['title']."</a></li>";
}
?>
</ul>
<?php } else if (in_array($row['type'],array("zip","7z","gz"))) { ?>
Zipped folder contents:
<div>
<ul style="list-style-type:none;">
<?php $zip = new ZipArchive;
if (file_exists("../temp/".$row['id']."/")){
unlink("../temp/".$row['id']."/");
}
$res = $zip->open("../files/".$row['id'].".zip");
if ($res == TRUE) {
$zip->extractTo('../temp/'.$row['id'].'/');
$zip->close();
$contents = scandir("../temp/".$row['id']."/",0);
foreach ($contents as $item) {
echo "<li><img src='images/file.png' width='30' height='30' style='vertical-align:middle;'>&nbsp;".$item."</li>";
}
} else {
echo 'Failed to open contents.';
} ?>
</ul>
</div>
<?php } else { ?>
No preview available.
<?php } ?>
</div>
<script>
$("#toptable #icon img").height($("#toptable #desc").height());
$("#toptable #icon img").width($("#toptable #icon img").height());
$("#toptable #icon").width($("#toptable #icon img").width()+10);
var confirmOn = false;
var deleted = false;
$("#deleteBtn").click(function() {
if (deleted) {
if (confirmOn) {
confirmOn = false;
location.reload(true);
} else {
confirmOn = true;
$(this).html("Click here to refresh");
}
} else {
if (confirmOn) {
$.ajax({
type:"POST",
url:"ajax/deleteFile.php",
data: {ID:"<?php echo $row['id']; ?>"},
dataType: "html",
success: function (msg) {
/// alert (msg);
$("#deleteBtn").removeClass("color7");
$("#deleteBtn").addClass("color6");
$("#deleteBtn").html("Deleted");
confirmOn = false;
deleted = true;
},
error: function(msg) {
confirmOn = false;
$(this).html(msg+" Delete");
}
});
} else {
confirmOn = true;
$(this).html("Confirm Delete");
}
}
});
</script>
<?php } else { ?>
Something went wrong... sorry!]
<?php
error_reporting(0);
function slash () {
$dir = substr(getcwd(),strlen("/homepages/21/d438744504/htdocs/wsb7089376101/v3"));
for ($i=0;$i<substr_count($dir,"/");$i++) {
echo "../";
}
}
include ("../../auth.inc.php");
$id = $_POST['id'] or die ("No variable given.");
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../page.css" />
<img src="images/closeIcon.png" id="closeBtn" onclick="javascript:closePreviewPane();" />
<?php
$query = mysql_query("select * from users where username='".$_SESSION['username']."'");
$row = mysql_fetch_array($query);
$keepit_dir = $row['keepit_dir'];
$query = mysql_query("select * from `keepit_docbank` where id='" . $id . "'");
$row = mysql_fetch_array($query);
function filesize_of_folder($id) {
$filesize = 0;
$fquery = mysql_query("select * from keepit_docbank where container='" . $id . "'");
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['type']=="keepit_directory") {
$filesize += filesize_of_folder($frow['id']);
} else {
$filesize += filesize("../files/".$frow['id'].".".$frow['type']);
}
}
return $filesize;
}
if (isset($row['id']) && strlen($row['id'])>1) {
if ($row['type'] != "keepit_directory") {
$filesize = filesize("../files/".$id.".".$row['type']);
} else {
$filesize = filesize_of_folder($row['id']);
}
function getLink($id, $ext) {
if ($ext == "scribe") {
return "apps/scribe.php?doc=open&id=".$id;
} else if ($ext == "cascade") {
return "apps/cascade.php?doc=open&id=".$id;
} else {
return "files/".$id.".".$ext;
}
return "";
}
function getIconURL($ext) {
if ($ext=="keepit_directory") {
return "images/folder.png";
} else {
$x = scandir("../icons/");
if (in_array($ext.".png",$x)) {
return "icons/".$ext.".png";
} else {
return "images/file.png";
}
}
}
function filesize_format($size) {
$i = -1;
$byteUnits = array(' KB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB');
do {
$size = $size / 1024;
$i++;
} while ($size > 1024);
return round(max($size, 0.1),1) ." ". $byteUnits[$i];
};
?>
<table id="toptable" style="border:none; width:100%;">
<tr>
<td id="icon"><img src="<?php echo getIconURL($row['type']); ?>" width="1" height="1" /></td>
<td id="desc">
<?php if ($row['type']=="keepit_directory") { ?>
<a href="index.php?switchDir=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a>
<?php } else { ?>
<form action="downloadFile.php" id="downloadForm" method="POST">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="type" value="<?php echo $row['type']; ?>" />
<input type="hidden" name="title" value="<?php echo $row['title']; ?>" />
<a href="javascript:$('#downloadForm').submit();"><?php echo $row['title'].".<span style='color:#999;'>".$row['type']."</span>"; ?></a>
</form>
<?php } ?>
<!--<h3><?php echo "<a ".(($row['type']!="keepit_directory")?"target='_blank'":"")." href='" . (($row['type']=="keepit_directory")?"index.php?switchDir=".$row['id']:"") . "'>" . $row['title']; ?><?php if ($row['type']!="keepit_directory") echo "<span style='color:#999;'>.".strtolower($row['type'])."</span>"; ?></a></h3>-->
<small style="display:block;">Type: <?php echo $row['type']=="keepit_directory"?"Folder":strtoupper($row['type'])." file"; ?></small>
<small style="display:block;">Size: <?php if ($row['type']!="keepit_directory") { echo filesize_format($filesize); } else { echo filesize_format(filesize_of_folder($row['id'])); } ?></small>
</td>
</table>
<p>&nbsp;</p>
<div>
<a href="javascript:renameBtn('<?php echo $row['id']; ?>');" class="button color1">Rename</a><?php if ($row['type']!="keepit_directory") { ?><form style="display:inline;" action="downloadFile.php" id="downloadForm" method="POST"><input type="hidden" name="id" value="<?php echo $row['id']; ?>" /><input type="hidden" name="type" value="<?php echo $row['type']; ?>" /><input type="hidden" name="title" value="<?php echo $row['title']; ?>" /><a class="button color2" href="javascript:$('#downloadForm').submit();">Download</a></form><?php } ?><a href="javascript:void(0);" id="deleteBtn" class="button color7">Delete</a>
</div>
<p>&nbsp;</p>
<div id="preview">
<?php if ($row['type']=="keepit_directory") { ?>
Folder contents:
<ul style="list-style-type:none;">
<?php
$fquery = mysql_query("select * from keepit_docbank where container='".$row['id']."'");
while($frow = mysql_fetch_array($fquery)) {
echo "<li><img style='vertical-align:middle;' src='".getIconURL($frow['type'])."' width='30' height='30' />&nbsp;<a href='javascript:showPreviewPane(\"".$frow['id']."\");'>".$frow['title']."</a></li>";
}
?>
</ul>
<?php } else if (in_array($row['type'],array("zip","7z","gz"))) { ?>
Zipped folder contents:
<div>
<ul style="list-style-type:none;">
<?php $zip = new ZipArchive;
if (file_exists("../temp/".$row['id']."/")){
unlink("../temp/".$row['id']."/");
}
$res = $zip->open("../files/".$row['id'].".zip");
if ($res == TRUE) {
$zip->extractTo('../temp/'.$row['id'].'/');
$zip->close();
$contents = scandir("../temp/".$row['id']."/",0);
foreach ($contents as $item) {
echo "<li><img src='images/file.png' width='30' height='30' style='vertical-align:middle;'>&nbsp;".$item."</li>";
}
} else {
echo 'Failed to open contents.';
} ?>
</ul>
</div>
<?php } else { ?>
No preview available.
<?php } ?>
</div>
<script>
$("#toptable #icon img").height($("#toptable #desc").height());
$("#toptable #icon img").width($("#toptable #icon img").height());
$("#toptable #icon").width($("#toptable #icon img").width()+10);
var confirmOn = false;
var deleted = false;
$("#deleteBtn").click(function() {
if (deleted) {
if (confirmOn) {
confirmOn = false;
location.reload(true);
} else {
confirmOn = true;
$(this).html("Click here to refresh");
}
} else {
if (confirmOn) {
$.ajax({
type:"POST",
url:"ajax/deleteFile.php",
data: {ID:"<?php echo $row['id']; ?>"},
dataType: "html",
success: function (msg) {
/// alert (msg);
$("#deleteBtn").removeClass("color7");
$("#deleteBtn").addClass("color6");
$("#deleteBtn").html("Deleted");
confirmOn = false;
deleted = true;
},
error: function(msg) {
confirmOn = false;
$(this).html(msg+" Delete");
}
});
} else {
confirmOn = true;
$(this).html("Confirm Delete");
}
}
});
</script>
<?php } else { ?>
Something went wrong... sorry!]
<?php } ?>

View file

@ -1,118 +1,118 @@
<style>
.resultsList {
list-style-type: none;
}
.searchResult {
display: block;
position: relative;
left: -20px;
padding: 10px;
transition:all .2s ease-out;
-o-transition:all .2s ease-out;
-ms-transition:all .2s ease-out;
-moz-transition:all .2s ease-out;
-webkit-transition:all .2s ease-out;
}
.searchResult:hover {
background-color: #F3F3F3;
}
a:hover {
text-decoration: none;
}
</style>
<?php
error_reporting(0);
session_start();
function getIconURL($ext) {
$x = scandir("../icons/");
if (in_array($ext.".png",$x)) {
return "icons/".$ext.".png";
} else {
return "images/file.png";
}
}
function getLink($id, $ext) {
if ($ext == "scribe") {
return "apps/scribe.php?doc=open&id=".$id;
} else if ($ext == "cascade") {
return "apps/cascade.php?doc=open&id=".$id;
} else {
return "files/".$id.".".$ext;
}
return "";
}
function lengthFilter ($text) {
if (strlen($text) > 15) {
return substr($text,0,15)."...";
} else {
return $text;
}
}
if ($_SESSION['logged']==1) {
$words = $_POST['words'];
$words = strtolower(trim($words));
if (isset($words) && strlen($words)>0) {
$not_allowed = array("\"","\'","\\",";","(",")","-");
foreach ($not_allowed as $char) {
$words = str_replace($char,"",$words);
}
echo "<p>Your search query: ".$words."</p>";
/*
PROCEDURE:
1. GET ALL THE FILES WITH THE SEARCH QUERY IN FILENAME
2. GET ALL THE FILES WITH THE SEARCH QUERY IN CONTENTS
*/
$locus = array();
$terms = explode(" ",$words);
include ("../../auth.inc.php");
$fquery = mysql_query("select * from `lexis_docbank` where owner='".$_SESSION['username']."'") or die("Error: " . mysql_error());
$allFiles = array();
while($file= mysql_fetch_array($fquery)) {
array_push($allFiles,$file);
}
foreach ($allFiles as $file) {
$title = strtolower($file['title']);
$b = FALSE;
foreach ($terms as $term) {
if (strlen($term)>0) {
if (strpos($title,$term)!==FALSE) {
$b = TRUE;
}
} else {
$b = FALSE;
}
}
if ($b) {
array_push($locus,$file);
}
}
if (count($locus)>0) {
echo "<ul class='resultsList'>";
foreach ($locus as $file) {
$type = $file['type'];
echo "<li>".($type=="lexis_directory"?('<a href="index.php?switchDir='.$file['id'].'" class="searchResult">'):('<a href="'.getLink($file['id'],$type).'" target="_blank" class="searchResult">'))."<img src='".($type=="lexis_directory"?"images/folder.png":getIconURL($type))."' style='width:30px; height:30px; vertical-align:middle;' />&nbsp;&nbsp;".lengthFilter($file['title'])."</a></li>";
}
echo "</ul>";
} else {
echo "No files found. Sorry :(";
}
}
else {
echo "<p>You must enter a search string.</p>";
}
} else {
echo "<p>You must be logged in.</p>";
}
<style>
.resultsList {
list-style-type: none;
}
.searchResult {
display: block;
position: relative;
left: -20px;
padding: 10px;
transition:all .2s ease-out;
-o-transition:all .2s ease-out;
-ms-transition:all .2s ease-out;
-moz-transition:all .2s ease-out;
-webkit-transition:all .2s ease-out;
}
.searchResult:hover {
background-color: #F3F3F3;
}
a:hover {
text-decoration: none;
}
</style>
<?php
error_reporting(0);
session_start();
function getIconURL($ext) {
$x = scandir("../icons/");
if (in_array($ext.".png",$x)) {
return "icons/".$ext.".png";
} else {
return "images/file.png";
}
}
function getLink($id, $ext) {
if ($ext == "scribe") {
return "apps/scribe.php?doc=open&id=".$id;
} else if ($ext == "cascade") {
return "apps/cascade.php?doc=open&id=".$id;
} else {
return "files/".$id.".".$ext;
}
return "";
}
function lengthFilter ($text) {
if (strlen($text) > 15) {
return substr($text,0,15)."...";
} else {
return $text;
}
}
if ($_SESSION['logged']==1) {
$words = $_POST['words'];
$words = strtolower(trim($words));
if (isset($words) && strlen($words)>0) {
$not_allowed = array("\"","\'","\\",";","(",")","-");
foreach ($not_allowed as $char) {
$words = str_replace($char,"",$words);
}
echo "<p>Your search query: ".$words."</p>";
/*
PROCEDURE:
1. GET ALL THE FILES WITH THE SEARCH QUERY IN FILENAME
2. GET ALL THE FILES WITH THE SEARCH QUERY IN CONTENTS
*/
$locus = array();
$terms = explode(" ",$words);
include ("../../auth.inc.php");
$fquery = mysql_query("select * from `keepit_docbank` where owner='".$_SESSION['username']."'") or die("Error: " . mysql_error());
$allFiles = array();
while($file= mysql_fetch_array($fquery)) {
array_push($allFiles,$file);
}
foreach ($allFiles as $file) {
$title = strtolower($file['title']);
$b = FALSE;
foreach ($terms as $term) {
if (strlen($term)>0) {
if (strpos($title,$term)!==FALSE) {
$b = TRUE;
}
} else {
$b = FALSE;
}
}
if ($b) {
array_push($locus,$file);
}
}
if (count($locus)>0) {
echo "<ul class='resultsList'>";
foreach ($locus as $file) {
$type = $file['type'];
echo "<li>".($type=="keepit_directory"?('<a href="index.php?switchDir='.$file['id'].'" class="searchResult">'):('<a href="'.getLink($file['id'],$type).'" target="_blank" class="searchResult">'))."<img src='".($type=="keepit_directory"?"images/folder.png":getIconURL($type))."' style='width:30px; height:30px; vertical-align:middle;' />&nbsp;&nbsp;".lengthFilter($file['title'])."</a></li>";
}
echo "</ul>";
} else {
echo "No files found. Sorry :(";
}
}
else {
echo "<p>You must enter a search string.</p>";
}
} else {
echo "<p>You must be logged in.</p>";
}
?>

View file

@ -1,9 +1,9 @@
<?php
session_start();
$nv = $_POST['new_view'] or die ("No variable given.");
$_SESSION['lexis_view'] = $nv;
echo "Done.";
<?php
session_start();
$nv = $_POST['new_view'] or die ("No variable given.");
$_SESSION['keepit_view'] = $nv;
echo "Done.";
?>

View file

@ -1,487 +1,487 @@
<?php
// DEFINE FUNCTIONS
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
include ("../../auth.inc.php");
$username = $_SESSION['username'];
$query = mysql_query("select * from `users` where username = '$owner'") or die("Error: ".mysql_error());
$row = mysql_fetch_array($query);
$doc = $_GET['doc'];
$val = true;
$dir = isset($_SESSION['current_dir'])?$_SESSION['current_dir']:$row['lexis_dir'];
if ($doc == "new") {
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789",50);
} else {
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query2 = mysql_query("select * from `lexis_docbank` where id='$id'") or die ("Error: ".mysql_error());
$row2 = mysql_fetch_array($query2);
$contents = nl2br(file_get_contents("../files/".$id.".cascade")) or die ("Can't find file");
if ($username == $row2['owner']) {
$val = true;
}
} else {
$val = false;
}
}
$cDir = "";
if ($_SESSION['current_dir'] == $row['lexis_dir']) {
$cDir = "My Cloud";
} else {
$nowdir = "[unknown directory]";
$upperDirectory = "";
$upperName = "";
$fquery = mysql_query("select * from `lexis_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $_SESSION['current_dir']) {
$nowdir = $frow['title'];
$upperDirectory = $frow['container'];
}
}
if ($upperDirectory == $row['lexis_dir']) {
$upperName = "My Cloud";
} else {
$fquery = mysql_query("select * from `lexis_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $upperDirectory) {
$upperName = $frow['title'];
}
}
}
$cDir = (($upperDirectory != $row['lexis_dir'])?"... ":"") . $upperName . " &raquo; " . $nowdir;
// echo "Current directory: <b>" . $nowdir . "</b> (<a href='index.php?switchDir=" . $upperDirectory . "'>Back to " . $upperName . "</a>)";
}
?>
<!--
CASCADE Spreadsheet Editor
LEXIS CLOUD OFFICE
(c) 2012-2013 by ANIXO Specifications
The code you found here is written by Michael Zhang. If you have found the PHP inside it we ask that you don't read any sensitive information. Otherwise, feel free to use some of the scripts here as examples as you create your own website or other such project.
If we didn't write the code for any specific portion, we'll tell you about that.
-->
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(c) 2012-<?php echo date("Y"); ?> by ANIXO Specifications." />
<title>Cascade Spreadsheet</title>
<link rel="stylesheet" href="../../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="shortcut.js"></script>
<style type="text/css">
@media screen {
#topbar {
width:100%;
position:fixed;
top:0px;
left:0px;
background-color:#DDDDDD;
height:40px;
padding:25px;
z-index:20;
}
#toolbar {
width:100%;
position:fixed;
top:90px;
left:0px;
background-color:#CCCCCC;
height:25px;
padding:20px;
border-top:1px solid #999;
box-shadow:0px 1px 2px #555;
z-index:19;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
#toolbar:before {
border-radius:10px / 100px;
-o-border-radius:10px / 100px;
-ms-border-radius:10px / 100px;
-moz-border-radius:10px / 100px;
-webkit-border-radius:10px / 100px;
}
#topbar #title {
font-size:30px;
display:inline;
cursor:pointer;
padding-left:30px;
}
#topbar #cascadeTab {
position:absolute;
background-color:#33AA43;
padding:5px 50px 5px 50px;
right:360px;
color:#FFF;
top:0px;
}
.menu {
border-radius:5px;
padding:5px 15px 5px 15px;
margin:0px 15px 0px 15px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
.menu:hover {
background-color:#CDCDCD;
text-decoration:none;
box-shadow:0px 2px 5px #999;
}
.menu:active, .selected {
background-color:#ABABAB;
text-decoration:none;
box-shadow:inset 0px 2px 5px #999;
}
#slideMenu {
position:fixed;
top:150px;
left:0px;
width:100%;
background-color:#DEDEDE;
/* border:1px solid #F00; */
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
z-index:18;
padding:10px;
height:100px;
}
.slideMenuUp {
top:30px;
opacity:0;
}
.slideMenuDown {
top:150px;
opacity:1;
}
#editor {
font-family:Arial,Helvetica;
width:624px;
padding:96px;
background-color:#FFF;
margin:auto;
position:relative;
top:170px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
box-shadow:0px 5px 6px #999;
z-index:5;
outline:none;
}
#editor:focus {
box-shadow:0px 6px 10px #666;
}
.dialog {
position:fixed;
top:0px;
left:0px;
display:none;
z-index:240;
}
.dialog .mask {
width:100%;
height:100%;
background-color:#FFF;
opacity:0.5;
position:fixed;
top:0px;
left:0px;
z-index:249;
}
.dialog .window {
z-index:251;
position:absolute;
top:0px;
left:0px;
background-color:#EEE;
border:1px solid #000;
padding:15px;
box-shadow:0px 5px 5px #999;
}
<?php
for ($i = 1; $i <= 30; $i++) {
echo ".shadowBottom".$i." {
position:relative;
-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.3);
box-shadow:0 1px 4px rgba(0,0,0,0.3);
}
.shadowBottom".$i.":after{
content:'';
z-index:-1;
position:absolute;
top:100%;
left:0px;
right:0px;
bottom:0px;
width:100%;
height:".$i."px;
background:-webkit-radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.7), rgba(97, 97, 97, 0.0) 50%);
background: radial-gradient(ellipse at 50% -3%, rgba(00, 00, 00, 0.7), rgba(97, 97, 97, 0.0) 50%);
}";
}
?>
}
@media print {
#sidebarLeft, #sidebarRight {
display:none;
}
#topbar {
display:none;
}
#toolbar {
display:none;
}
#slideMenu {
display:none;
}
.dialog {
display:none;
}
}
</style>
<script type="text/javascript">
var unsaved = false;
<?php $fonts = "Roboto,Arial,Comic Sans MS,Courier New,Georgia,Impact,Tahoma,Times New Roman,Trebuchet MS,Verdana"; echo "var fonts = '".$fonts."'.split(',');"; ?>
</script>
</head>
<body>
<?php include ("../../sidebars.php"); ?>
<?php
if ($_SESSION['logged']==1) {
?>
<div id="topbar">
<div id="cascadeTab">CASCADE</div>
<div id="title"><span id="unsaved"></span><span id="actualTitle">Untitled Spreadsheet</a></div>&nbsp;&nbsp;&nbsp;<span id="saveResults" style="color:#444; vertical-align:middle;"></span>
<br />
<span id="message">Ready.</span>
</div>
<div id="toolbar">
<a class="menu" id="home" href="#">Home</a>
<a class="menu" id="insert" href="#">Insert</a>
<a class="menu" id="view" href="#">View</a>
<a class="menu" id="design" href="#">Design</a>
<a class="menu" id="page_layout" href="#">Page Layout</a>
<a class="menu" id="review" href="#">Review</a>
</div>
<div id="slideMenu" class="slideMenuUp">
</div>
<!-- MODALS -->
<div id="retitleDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Retitle Spreadsheet</b><a style="position:absolute; top:5px; right:5px;" href="#" class="close"><img src="../images/closeIcon.png" style="width:32px;height:32px;" alt="Close" /></a></p>
<input type="text" class="tf" name="newTitle" id="newTitle" />
<p><a class="button color2" href="#" id="retitleBtn">Rename</a></p>
<script type="text/javascript">
$("#newTitle").val($("#topbar #title #actualTitle").html());
$("#retitleBtn").click(function() {
var q = $("#newTitle").val();
if (q.length > 1) {
$("#topbar #title #actualTitle").html(q);
$("#retitleDialog").fadeOut("fast");
}
});
</script>
</div>
</div>
<script>
$("#retitleDialog .window").css("left",(window.innerWidth/2-150)+"px");
$("#retitleDialog .window").css("top",(window.innerHeight/2-125)+"px");
$(".dialog .mask").click(function() {
$(".dialog .window").css("border","1px solid #F00");
$(".dialog .window").css("box-shadow","0px 5px 5px #F00");
setTimeout(function() {
$(".dialog .window").css("border","1px solid #000");
$(".dialog .window").css("box-shadow","0px 5px 5px #999");
},1000);
});
$(".dialog .close").click(function() {
$(".dialog").fadeOut("fast");
});
$("#topbar #title #actualTitle").click (function() {
$("#retitleDialog").fadeIn("fast");
$("#newTitle").focus();
});
$("#toolbar .menu").click(function() {
if ($(this).hasClass("selected")) {
$(this).removeClass("selected");
$("#slideMenu").removeClass("slideMenuDown");
$("#slideMenu").addClass("slideMenuUp");
isMenuDown = false;
scrollShadow();
$("#editor").css("top","170px");
} else {
$("#toolbar .menu").each(function() {
$(this).removeClass("selected");
});
$(this).addClass("selected");
$.ajax({
type:"POST",
url:"cascadeSlideMenuAjax.php",
data:{view:$(this).attr("id")},
dataType:"html",
success:function(msg) {
$("#slideMenu").html(msg);
}
});
$("#slideMenu").addClass("slideMenuDown");
$("#slideMenu").removeClass("slideMenuUp");
$("#toolbar").css("box-shadow","none");
$("#editor").css("top","290px");
}
});
$("#editor").keyup (function(e) {
if ((e.keyCode>=48 && e.keyCode<=57) || (e.keyCode>=65 && e.keyCode<=90) || (e.keyCode>=112 && e.keyCode<=123) || (e.keyCode==188 || e.keyCode==190 || e.keyCode==19 || e.keyCode==192 || e.keyCode==219 || e.keyCode==220 || e.keyCode==221 || e.keyCode==222 || e.keyCode==32)) {
unsaved = true;
}
});
function save() {
$("#results").html("Saving... ");
$.ajax({
type:"POST",
url:"cascadeSave.php",
data:{id:"<?php echo $id;?>",
title:$("#title #actualTitle").html(),
contents:"wrong format!",
owner:"<?php echo $_SESSION['username'];?>",
dir:"<?php echo $dir; ?>"},
dataType:"html",
success:function(msg) {
$("#message").html(msg);
document.title = $("#title #actualTitle").html()+" - Cascade Spreadsheet";
unsaved = false;
}
});
}
// KEYBOARD SHORTCUTS
shortcut.add("Ctrl+S",function() {
save();
},{'propagate':false});
shortcut.add("Esc",function() {
$(".dialog").fadeOut("fast");
},{'propagate':false});
setInterval(function() {
scrollShadow();
if (unsaved) $("#title #unsaved").html("*");
else $("#title #unsaved").html("");
},30);
function scrollShadow() {
if ($("#slideMenu").hasClass("slideMenuUp")===true) {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k/6)>10) k=60;
if (k>10) {
$("#toolbar").removeClass();
$("#toolbar").addClass("shadowBottom"+Math.floor(k/2));
} else {
$("#toolbar").removeClass();
$("#toolbar").addClass("shadowBottom3");
}
$("#toolbar").addClass("shadowBottom");
} else {
$("#toolbar").removeClass("shadowBottom");
}
} else {
$("#toolbar").removeClass();
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k/6)>10) k=60;
if (k>10) {
$("#slideMenu").removeClass();
$("#slideMenu").addClass("shadowBottom"+Math.floor(k/2));
} else {
$("#slideMenu").removeClass();
$("#slideMenu").addClass("shadowBottom3");
}
$("#slideMenu").addClass("shadowBottom");
} else {
$("#slideMenu").removeClass("shadowBottom");
}
}
// background:radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.5), rgba(97, 97, 97, 0.0) 50%);
/* if ($("#slideMenu").hasClass("slideMenuUp")===true) {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k / 6) > 10) {
k = 10 * 6;
}
if (k > 10) {
$("#toolbar").css("box-shadow","0px "+(k/12)+"px "+(k/6)+"px #555");
} else {
$("#toolbar").css("box-shadow","0px 1px 2px #555");
}
} else {
$("#toolbar").css("box-shadow","0px 1px 2px #555");
}
} else {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k / 6) > 10) {
k = 10 * 6;
}
if (k > 10) {
$("#slideMenu").css("box-shadow","0px "+(k/12)+"px "+(k/6)+"px #555");
} else {
$("#slideMenu").css("box-shadow","0px 1px 2px #555");
}
} else {
$("#slideMenu").css("box-shadow","0px 1px 2px #555");
}
} */
}
$("#title #actualTitle").html("<?php echo ($row2['title'])?$row2['title']:"Untitled Spreadsheet"; ?>");
$("#editor").html("<?php echo $contents; ?>");
$("#editor").focus();
</script>
<?php } else { ?>
<h2>You must be signed in to use the LEXIS Cloud Office.</h2>
<p>Hover over to the right to reveal the sign in page!</p>
<?php } ?>
</body>
<?php
// DEFINE FUNCTIONS
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
include ("../../auth.inc.php");
$username = $_SESSION['username'];
$query = mysql_query("select * from `users` where username = '$owner'") or die("Error: ".mysql_error());
$row = mysql_fetch_array($query);
$doc = $_GET['doc'];
$val = true;
$dir = isset($_SESSION['current_dir'])?$_SESSION['current_dir']:$row['keepit_dir'];
if ($doc == "new") {
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789",50);
} else {
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query2 = mysql_query("select * from `keepit_docbank` where id='$id'") or die ("Error: ".mysql_error());
$row2 = mysql_fetch_array($query2);
$contents = nl2br(file_get_contents("../files/".$id.".cascade")) or die ("Can't find file");
if ($username == $row2['owner']) {
$val = true;
}
} else {
$val = false;
}
}
$cDir = "";
if ($_SESSION['current_dir'] == $row['keepit_dir']) {
$cDir = "My Cloud";
} else {
$nowdir = "[unknown directory]";
$upperDirectory = "";
$upperName = "";
$fquery = mysql_query("select * from `keepit_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $_SESSION['current_dir']) {
$nowdir = $frow['title'];
$upperDirectory = $frow['container'];
}
}
if ($upperDirectory == $row['keepit_dir']) {
$upperName = "My Cloud";
} else {
$fquery = mysql_query("select * from `keepit_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $upperDirectory) {
$upperName = $frow['title'];
}
}
}
$cDir = (($upperDirectory != $row['keepit_dir'])?"... ":"") . $upperName . " &raquo; " . $nowdir;
// echo "Current directory: <b>" . $nowdir . "</b> (<a href='index.php?switchDir=" . $upperDirectory . "'>Back to " . $upperName . "</a>)";
}
?>
<!--
CASCADE Spreadsheet Editor
Keepit CLOUD OFFICE
(c) 2012-2013 by Keepit
The code you found here is written by Michael Zhang. If you have found the PHP inside it we ask that you don't read any sensitive information. Otherwise, feel free to use some of the scripts here as examples as you create your own website or other such project.
If we didn't write the code for any specific portion, we'll tell you about that.
-->
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(c) 2012-<?php echo date("Y"); ?> by Keepit." />
<title>Cascade Spreadsheet</title>
<link rel="stylesheet" href="../../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="shortcut.js"></script>
<style type="text/css">
@media screen {
#topbar {
width:100%;
position:fixed;
top:0px;
left:0px;
background-color:#DDDDDD;
height:40px;
padding:25px;
z-index:20;
}
#toolbar {
width:100%;
position:fixed;
top:90px;
left:0px;
background-color:#CCCCCC;
height:25px;
padding:20px;
border-top:1px solid #999;
box-shadow:0px 1px 2px #555;
z-index:19;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
#toolbar:before {
border-radius:10px / 100px;
-o-border-radius:10px / 100px;
-ms-border-radius:10px / 100px;
-moz-border-radius:10px / 100px;
-webkit-border-radius:10px / 100px;
}
#topbar #title {
font-size:30px;
display:inline;
cursor:pointer;
padding-left:30px;
}
#topbar #cascadeTab {
position:absolute;
background-color:#33AA43;
padding:5px 50px 5px 50px;
right:360px;
color:#FFF;
top:0px;
}
.menu {
border-radius:5px;
padding:5px 15px 5px 15px;
margin:0px 15px 0px 15px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
.menu:hover {
background-color:#CDCDCD;
text-decoration:none;
box-shadow:0px 2px 5px #999;
}
.menu:active, .selected {
background-color:#ABABAB;
text-decoration:none;
box-shadow:inset 0px 2px 5px #999;
}
#slideMenu {
position:fixed;
top:150px;
left:0px;
width:100%;
background-color:#DEDEDE;
/* border:1px solid #F00; */
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
z-index:18;
padding:10px;
height:100px;
}
.slideMenuUp {
top:30px;
opacity:0;
}
.slideMenuDown {
top:150px;
opacity:1;
}
#editor {
font-family:Arial,Helvetica;
width:624px;
padding:96px;
background-color:#FFF;
margin:auto;
position:relative;
top:170px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
box-shadow:0px 5px 6px #999;
z-index:5;
outline:none;
}
#editor:focus {
box-shadow:0px 6px 10px #666;
}
.dialog {
position:fixed;
top:0px;
left:0px;
display:none;
z-index:240;
}
.dialog .mask {
width:100%;
height:100%;
background-color:#FFF;
opacity:0.5;
position:fixed;
top:0px;
left:0px;
z-index:249;
}
.dialog .window {
z-index:251;
position:absolute;
top:0px;
left:0px;
background-color:#EEE;
border:1px solid #000;
padding:15px;
box-shadow:0px 5px 5px #999;
}
<?php
for ($i = 1; $i <= 30; $i++) {
echo ".shadowBottom".$i." {
position:relative;
-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.3);
box-shadow:0 1px 4px rgba(0,0,0,0.3);
}
.shadowBottom".$i.":after{
content:'';
z-index:-1;
position:absolute;
top:100%;
left:0px;
right:0px;
bottom:0px;
width:100%;
height:".$i."px;
background:-webkit-radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.7), rgba(97, 97, 97, 0.0) 50%);
background: radial-gradient(ellipse at 50% -3%, rgba(00, 00, 00, 0.7), rgba(97, 97, 97, 0.0) 50%);
}";
}
?>
}
@media print {
#sidebarLeft, #sidebarRight {
display:none;
}
#topbar {
display:none;
}
#toolbar {
display:none;
}
#slideMenu {
display:none;
}
.dialog {
display:none;
}
}
</style>
<script type="text/javascript">
var unsaved = false;
<?php $fonts = "Roboto,Arial,Comic Sans MS,Courier New,Georgia,Impact,Tahoma,Times New Roman,Trebuchet MS,Verdana"; echo "var fonts = '".$fonts."'.split(',');"; ?>
</script>
</head>
<body>
<?php include ("../../sidebars.php"); ?>
<?php
if ($_SESSION['logged']==1) {
?>
<div id="topbar">
<div id="cascadeTab">CASCADE</div>
<div id="title"><span id="unsaved"></span><span id="actualTitle">Untitled Spreadsheet</a></div>&nbsp;&nbsp;&nbsp;<span id="saveResults" style="color:#444; vertical-align:middle;"></span>
<br />
<span id="message">Ready.</span>
</div>
<div id="toolbar">
<a class="menu" id="home" href="#">Home</a>
<a class="menu" id="insert" href="#">Insert</a>
<a class="menu" id="view" href="#">View</a>
<a class="menu" id="design" href="#">Design</a>
<a class="menu" id="page_layout" href="#">Page Layout</a>
<a class="menu" id="review" href="#">Review</a>
</div>
<div id="slideMenu" class="slideMenuUp">
</div>
<!-- MODALS -->
<div id="retitleDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Retitle Spreadsheet</b><a style="position:absolute; top:5px; right:5px;" href="#" class="close"><img src="../images/closeIcon.png" style="width:32px;height:32px;" alt="Close" /></a></p>
<input type="text" class="tf" name="newTitle" id="newTitle" />
<p><a class="button color2" href="#" id="retitleBtn">Rename</a></p>
<script type="text/javascript">
$("#newTitle").val($("#topbar #title #actualTitle").html());
$("#retitleBtn").click(function() {
var q = $("#newTitle").val();
if (q.length > 1) {
$("#topbar #title #actualTitle").html(q);
$("#retitleDialog").fadeOut("fast");
}
});
</script>
</div>
</div>
<script>
$("#retitleDialog .window").css("left",(window.innerWidth/2-150)+"px");
$("#retitleDialog .window").css("top",(window.innerHeight/2-125)+"px");
$(".dialog .mask").click(function() {
$(".dialog .window").css("border","1px solid #F00");
$(".dialog .window").css("box-shadow","0px 5px 5px #F00");
setTimeout(function() {
$(".dialog .window").css("border","1px solid #000");
$(".dialog .window").css("box-shadow","0px 5px 5px #999");
},1000);
});
$(".dialog .close").click(function() {
$(".dialog").fadeOut("fast");
});
$("#topbar #title #actualTitle").click (function() {
$("#retitleDialog").fadeIn("fast");
$("#newTitle").focus();
});
$("#toolbar .menu").click(function() {
if ($(this).hasClass("selected")) {
$(this).removeClass("selected");
$("#slideMenu").removeClass("slideMenuDown");
$("#slideMenu").addClass("slideMenuUp");
isMenuDown = false;
scrollShadow();
$("#editor").css("top","170px");
} else {
$("#toolbar .menu").each(function() {
$(this).removeClass("selected");
});
$(this).addClass("selected");
$.ajax({
type:"POST",
url:"cascadeSlideMenuAjax.php",
data:{view:$(this).attr("id")},
dataType:"html",
success:function(msg) {
$("#slideMenu").html(msg);
}
});
$("#slideMenu").addClass("slideMenuDown");
$("#slideMenu").removeClass("slideMenuUp");
$("#toolbar").css("box-shadow","none");
$("#editor").css("top","290px");
}
});
$("#editor").keyup (function(e) {
if ((e.keyCode>=48 && e.keyCode<=57) || (e.keyCode>=65 && e.keyCode<=90) || (e.keyCode>=112 && e.keyCode<=123) || (e.keyCode==188 || e.keyCode==190 || e.keyCode==19 || e.keyCode==192 || e.keyCode==219 || e.keyCode==220 || e.keyCode==221 || e.keyCode==222 || e.keyCode==32)) {
unsaved = true;
}
});
function save() {
$("#results").html("Saving... ");
$.ajax({
type:"POST",
url:"cascadeSave.php",
data:{id:"<?php echo $id;?>",
title:$("#title #actualTitle").html(),
contents:"wrong format!",
owner:"<?php echo $_SESSION['username'];?>",
dir:"<?php echo $dir; ?>"},
dataType:"html",
success:function(msg) {
$("#message").html(msg);
document.title = $("#title #actualTitle").html()+" - Cascade Spreadsheet";
unsaved = false;
}
});
}
// KEYBOARD SHORTCUTS
shortcut.add("Ctrl+S",function() {
save();
},{'propagate':false});
shortcut.add("Esc",function() {
$(".dialog").fadeOut("fast");
},{'propagate':false});
setInterval(function() {
scrollShadow();
if (unsaved) $("#title #unsaved").html("*");
else $("#title #unsaved").html("");
},30);
function scrollShadow() {
if ($("#slideMenu").hasClass("slideMenuUp")===true) {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k/6)>10) k=60;
if (k>10) {
$("#toolbar").removeClass();
$("#toolbar").addClass("shadowBottom"+Math.floor(k/2));
} else {
$("#toolbar").removeClass();
$("#toolbar").addClass("shadowBottom3");
}
$("#toolbar").addClass("shadowBottom");
} else {
$("#toolbar").removeClass("shadowBottom");
}
} else {
$("#toolbar").removeClass();
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k/6)>10) k=60;
if (k>10) {
$("#slideMenu").removeClass();
$("#slideMenu").addClass("shadowBottom"+Math.floor(k/2));
} else {
$("#slideMenu").removeClass();
$("#slideMenu").addClass("shadowBottom3");
}
$("#slideMenu").addClass("shadowBottom");
} else {
$("#slideMenu").removeClass("shadowBottom");
}
}
// background:radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.5), rgba(97, 97, 97, 0.0) 50%);
/* if ($("#slideMenu").hasClass("slideMenuUp")===true) {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k / 6) > 10) {
k = 10 * 6;
}
if (k > 10) {
$("#toolbar").css("box-shadow","0px "+(k/12)+"px "+(k/6)+"px #555");
} else {
$("#toolbar").css("box-shadow","0px 1px 2px #555");
}
} else {
$("#toolbar").css("box-shadow","0px 1px 2px #555");
}
} else {
if ($("#topbar").offset().top!==0) {
var k = $("#topbar").offset().top;
if ((k / 6) > 10) {
k = 10 * 6;
}
if (k > 10) {
$("#slideMenu").css("box-shadow","0px "+(k/12)+"px "+(k/6)+"px #555");
} else {
$("#slideMenu").css("box-shadow","0px 1px 2px #555");
}
} else {
$("#slideMenu").css("box-shadow","0px 1px 2px #555");
}
} */
}
$("#title #actualTitle").html("<?php echo ($row2['title'])?$row2['title']:"Untitled Spreadsheet"; ?>");
$("#editor").html("<?php echo $contents; ?>");
$("#editor").focus();
</script>
<?php } else { ?>
<h2>You must be signed in to use the Keepit Cloud Office.</h2>
<p>Hover over to the right to reveal the sign in page!</p>
<?php } ?>
</body>
</html>

View file

@ -1,41 +1,41 @@
<?php
session_start();
include ("../../auth.inc.php");
if(!$_POST['id']) die("no id");
$id = $_POST['id'];
if(!$_POST['title']) die("no title");
$title = $_POST['title'];
if(!$_POST['contents']) die("no contents");
$contents = $_POST['contents'];
if(!$_POST['owner']) die("no owner");
$owner = $_POST['owner'];
if(!$_POST['dir']) die("no dir");
$dir = $_POST['dir'];
$query = mysql_query ("select * from `users` where username = '$owner'") or die ("Error: ".mysql_error());
$row = mysql_fetch_array ($query);
$password = $row['password'];
$file = "../files/".$id.".cascade";
// echo "<script>alert('".$file."');</script>";
if (file_exists($file)) {
unlink($file);
file_put_contents($file, $contents) or die ("Error");
mysql_query("update lexis_docbank set title='$title' where id='$id' and owner='$owner'") or die(mysql_error());
} else {
$query = mysql_query("insert into lexis_docbank (id,title,container,owner,type) values('$id','$title','$dir','$owner','cascade')") or die("Can't connect: ".mysql_error());
file_put_contents($file, $contents) or die ("Error");
}
/*$fh = fopen($file, 'w');
fwrite($fh, $contents);
fclose($fh);*/
echo "All changes saved!";
<?php
session_start();
include ("../../auth.inc.php");
if(!$_POST['id']) die("no id");
$id = $_POST['id'];
if(!$_POST['title']) die("no title");
$title = $_POST['title'];
if(!$_POST['contents']) die("no contents");
$contents = $_POST['contents'];
if(!$_POST['owner']) die("no owner");
$owner = $_POST['owner'];
if(!$_POST['dir']) die("no dir");
$dir = $_POST['dir'];
$query = mysql_query ("select * from `users` where username = '$owner'") or die ("Error: ".mysql_error());
$row = mysql_fetch_array ($query);
$password = $row['password'];
$file = "../files/".$id.".cascade";
// echo "<script>alert('".$file."');</script>";
if (file_exists($file)) {
unlink($file);
file_put_contents($file, $contents) or die ("Error");
mysql_query("update keepit_docbank set title='$title' where id='$id' and owner='$owner'") or die(mysql_error());
} else {
$query = mysql_query("insert into keepit_docbank (id,title,container,owner,type) values('$id','$title','$dir','$owner','cascade')") or die("Can't connect: ".mysql_error());
file_put_contents($file, $contents) or die ("Error");
}
/*$fh = fopen($file, 'w');
fwrite($fh, $contents);
fclose($fh);*/
echo "All changes saved!";
?>

File diff suppressed because it is too large Load diff

View file

@ -1,41 +1,41 @@
<?php
session_start();
include ("../../auth.inc.php");
if(!$_POST['id']) die("no id");
$id = $_POST['id'];
if(!$_POST['title']) die("no title");
$title = $_POST['title'];
if(!$_POST['contents']) die("no contents");
$contents = $_POST['contents'];
if(!$_POST['owner']) die("no owner");
$owner = $_POST['owner'];
if(!$_POST['dir']) die("no dir");
$dir = $_POST['dir'];
$query = mysql_query ("select * from `users` where username = '$owner'") or die ("Error: ".mysql_error());
$row = mysql_fetch_array ($query);
$password = $row['password'];
$file = "../files/".$id.".scribe";
// echo "<script>alert('".$file."');</script>";
if (file_exists($file)) {
unlink($file);
file_put_contents($file, $contents) or die ("Error");
mysql_query("update lexis_docbank set title='$title' and dateMod=NOW() where id='$id' and owner='$owner'") or die(mysql_error());
} else {
$query = mysql_query("insert into lexis_docbank (id,title,container,owner,type,dateMod) values('$id','$title','$dir','$owner','scribe',NOW())") or die("Can't connect: ".mysql_error());
file_put_contents($file, $contents) or die ("Error");
}
/*$fh = fopen($file, 'w');
fwrite($fh, $contents);
fclose($fh);*/
echo "All changes saved!";
<?php
session_start();
include ("../../auth.inc.php");
if(!$_POST['id']) die("no id");
$id = $_POST['id'];
if(!$_POST['title']) die("no title");
$title = $_POST['title'];
if(!$_POST['contents']) die("no contents");
$contents = $_POST['contents'];
if(!$_POST['owner']) die("no owner");
$owner = $_POST['owner'];
if(!$_POST['dir']) die("no dir");
$dir = $_POST['dir'];
$query = mysql_query ("select * from `users` where username = '$owner'") or die ("Error: ".mysql_error());
$row = mysql_fetch_array ($query);
$password = $row['password'];
$file = "../files/".$id.".scribe";
// echo "<script>alert('".$file."');</script>";
if (file_exists($file)) {
unlink($file);
file_put_contents($file, $contents) or die ("Error");
mysql_query("update keepit_docbank set title='$title' and dateMod=NOW() where id='$id' and owner='$owner'") or die(mysql_error());
} else {
$query = mysql_query("insert into keepit_docbank (id,title,container,owner,type,dateMod) values('$id','$title','$dir','$owner','scribe',NOW())") or die("Can't connect: ".mysql_error());
file_put_contents($file, $contents) or die ("Error");
}
/*$fh = fopen($file, 'w');
fwrite($fh, $contents);
fclose($fh);*/
echo "All changes saved!";
?>

View file

@ -1,92 +1,92 @@
<?php
$view = $_POST['view'] or die ("No variable.");
if ($view == "home") {?>
<style>
div.hStack {
display:inline-block;
height:100%;
}
.item {
display:inline-block;
text-align:center;
vertical-align:middle;
border-radius:5px;
padding:5px 15px 5px 15px;
margin:0px 15px 0px 15px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
.item:hover {
background-color:#CDCDCD;
text-decoration:none;
box-shadow:0px 2px 5px #999;
}
.item:active {
background-color:#ABABAB;
text-decoration:none;
box-shadow:inset 0px 2px 5px #999;
}
.smallImg img {
width:32px;
height:32px;
vertical-align:middle;
padding-right:5px;
}
</style>
<div class="hStack">
<table style="height:100%;" class="smallImg">
<tr>
<td><a href="scribe.php?doc=new" target="_blank" class="item"><img src="images/new.png" alt="New SCRIBE Document" />New</a></td>
<td><a href="javascript:save();" class="item"><img src="images/save.png" alt="Save this Document" />Save</a></td>
<td><a href="javascript:window.close();" class="item"><img src="images/close.png" alt="Close this Document" />Close</a></td>
</tr><tr>
<td><a href="javascript:document.execCommand('cut',false,null);" class="item"><img src="images/cut.png" alt="Cut Selected Text" />Cut</a></td>
<td><a href="javascript:document.execCommand('copy',false,null);" class="item"><img src="images/copy.png" alt="Copy Selected Text" />Copy</a></td>
<td><a href="javascript:document.execCommand('paste',false,null);" class="item"><img src="images/paste.png" alt="Paste Clipboard Text" />Paste</a></td>
</tr>
</table>
</div>
<div class="hStack">
<table><tr><td>
<select style="width:200px;" id="fontChooser" onChange="javascript:document.execCommand('fontName',false,this.value);">
<option value="Arial">Arial</option>
<option value="Comic Sans MS">Comic Sans MS</option>
<option value="Courier New">Courier New</option>
<option value="Droid Sans">Droid Sans</option>
<option value="Georgia">Georgia</option>
<option value="HelveticaNeue">Helvetica Neue</option>
<option value="Impact">Impact</option>
<option value="Open Sans">Open Sans</option>
<option value="Roboto">Roboto</option>
<option value="Tahoma">Tahoma</option>
<option value="Times">Times New Roman</option>
<option value="Trebuchet MS">Trebuchet MS</option>
<option value="Verdana">Verdana</option>
</select>
<script type="text/javascript">
</script>
</td></tr><tr><td>
</td></tr></table>
</div>
<?php } else if ($view == "review") { ?>
<div id="wordCount"></div>
<script type="text/javascript">
setInterval (function() {
$("#wordCount").html("Word count: "+$("#editor").text().split(" ").length);
},300);
</script>
</script>
<?php } else {
echo $view;
}
<?php
$view = $_POST['view'] or die ("No variable.");
if ($view == "home") {?>
<style>
div.hStack {
display:inline-block;
height:100%;
}
.item {
display:inline-block;
text-align:center;
vertical-align:middle;
border-radius:5px;
padding:5px 15px 5px 15px;
margin:0px 15px 0px 15px;
transition:.2s all ease-out;
-o-transition:.2s all ease-out;
-ms-transition:.2s all ease-out;
-moz-transition:.2s all ease-out;
-webkit-transition:.2s all ease-out;
}
.item:hover {
background-color:#CDCDCD;
text-decoration:none;
box-shadow:0px 2px 5px #999;
}
.item:active {
background-color:#ABABAB;
text-decoration:none;
box-shadow:inset 0px 2px 5px #999;
}
.smallImg img {
width:32px;
height:32px;
vertical-align:middle;
padding-right:5px;
}
</style>
<div class="hStack">
<table style="height:100%;" class="smallImg">
<tr>
<td><a href="scribe.php?doc=new" target="_blank" class="item"><img src="images/new.png" alt="New SCRIBE Document" />New</a></td>
<td><a href="javascript:save();" class="item"><img src="images/save.png" alt="Save this Document" />Save</a></td>
<td><a href="javascript:window.close();" class="item"><img src="images/close.png" alt="Close this Document" />Close</a></td>
</tr><tr>
<td><a href="javascript:document.execCommand('cut',false,null);" class="item"><img src="images/cut.png" alt="Cut Selected Text" />Cut</a></td>
<td><a href="javascript:document.execCommand('copy',false,null);" class="item"><img src="images/copy.png" alt="Copy Selected Text" />Copy</a></td>
<td><a href="javascript:document.execCommand('paste',false,null);" class="item"><img src="images/paste.png" alt="Paste Clipboard Text" />Paste</a></td>
</tr>
</table>
</div>
<div class="hStack">
<table><tr><td>
<select style="width:200px;" id="fontChooser" onChange="javascript:document.execCommand('fontName',false,this.value);">
<option value="Arial">Arial</option>
<option value="Comic Sans MS">Comic Sans MS</option>
<option value="Courier New">Courier New</option>
<option value="Droid Sans">Droid Sans</option>
<option value="Georgia">Georgia</option>
<option value="HelveticaNeue">Helvetica Neue</option>
<option value="Impact">Impact</option>
<option value="Open Sans">Open Sans</option>
<option value="Roboto">Roboto</option>
<option value="Tahoma">Tahoma</option>
<option value="Times">Times New Roman</option>
<option value="Trebuchet MS">Trebuchet MS</option>
<option value="Verdana">Verdana</option>
</select>
<script type="text/javascript">
</script>
</td></tr><tr><td>
</td></tr></table>
</div>
<?php } else if ($view == "review") { ?>
<div id="wordCount"></div>
<script type="text/javascript">
setInterval (function() {
$("#wordCount").html("Word count: "+$("#editor").text().split(" ").length);
},300);
</script>
</script>
<?php } else {
echo $view;
}
?>

View file

@ -1,16 +1,16 @@
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(c) 2012-<?php echo date("Y"); ?> by ANIXO Specifications." />
<title></title>
<link rel="stylesheet" href="../../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<?php include ("../../sidebars.php"); ?>
</body>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(c) 2012-<?php echo date("Y"); ?> by Keepit." />
<title></title>
<link rel="stylesheet" href="../../page.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<?php include ("../../sidebars.php"); ?>
</body>
</html>

View file

@ -1,31 +1,31 @@
<?php
$id=$_POST['id'] or die("No id");
$type=$_POST['type'] or die("No type");
$title=$_POST['title'] or die("No title");
copy("files/".$id.".".$type,"temp/".$title.".".$type) or die("NONONONONONONONOO DON'T TOUCH THE FILES");
$file = "temp/".$title.".".$type;
switch(strtolower(substr(strrchr($file, '.'), 1))) {
case 'pdf': $mime = 'application/pdf'; break;
case 'zip': $mime = 'application/zip'; break;
case 'jpeg':
case 'jpg': $mime = 'image/jpg'; break;
default: $mime = 'application/force-download';
}
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: '.gmdate ('D, d M Y H:i:s', filemtime ($file)).' GMT');
header('Cache-Control: private',false);
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file)); // provide file size
header('Connection: close');
readfile($file); // push it out
exit();
<?php
$id=$_POST['id'] or die("No id");
$type=$_POST['type'] or die("No type");
$title=$_POST['title'] or die("No title");
copy("files/".$id.".".$type,"temp/".$title.".".$type) or die("NONONONONONONONOO DON'T TOUCH THE FILES");
$file = "temp/".$title.".".$type;
switch(strtolower(substr(strrchr($file, '.'), 1))) {
case 'pdf': $mime = 'application/pdf'; break;
case 'zip': $mime = 'application/zip'; break;
case 'jpeg':
case 'jpg': $mime = 'image/jpg'; break;
default: $mime = 'application/force-download';
}
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: '.gmdate ('D, d M Y H:i:s', filemtime ($file)).' GMT');
header('Cache-Control: private',false);
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file)); // provide file size
header('Connection: close');
readfile($file); // push it out
exit();
?>

View file

@ -1,31 +1,31 @@
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö |
|--------------------------------------------------*/
.dtree {
white-space: nowrap;
}
.dtree img {
border: 0px;
vertical-align: middle;
}
.dtree a {
color: #333;
text-decoration: none;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
}
.dtree a.nodeSel {
background-color: #c0d2ec;
}
.dtree .clip {
overflow: hidden;
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö |
|--------------------------------------------------*/
.dtree {
white-space: nowrap;
}
.dtree img {
border: 0px;
vertical-align: middle;
}
.dtree a {
color: #333;
text-decoration: none;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
}
.dtree a.nodeSel {
background-color: #c0d2ec;
}
.dtree .clip {
overflow: hidden;
}

696
dtree.js
View file

@ -1,349 +1,349 @@
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : 'images/dTree/base.png',
folder : 'images/dTree/folder.png',
folderOpen : 'images/dTree/folderopen.png',
node : 'images/dTree/page.png',
empty : 'images/dTree/empty.png',
line : 'images/dTree/line.png',
join : 'images/dTree/join.png',
joinBottom : 'images/dTree/joinbottom.png',
plus : 'images/dTree/plus.png',
plusBottom : 'images/dTree/plusbottom.png',
minus : 'images/dTree/minus.png',
minusBottom : 'images/dTree/minusbottom.png',
nlPlus : 'images/dTree/nolines_plus.png',
nlMinus : 'images/dTree/nolines_minus.png'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" style="width:30px; height:30px; margin-right:10px;" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" style="width:30px; height:30px;" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" style="width:30px; height:30px;" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" style="width:30px; height:30px;" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
/* if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
*/
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landrö |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : 'images/dTree/base.png',
folder : 'images/dTree/folder.png',
folderOpen : 'images/dTree/folderopen.png',
node : 'images/dTree/page.png',
empty : 'images/dTree/empty.png',
line : 'images/dTree/line.png',
join : 'images/dTree/join.png',
joinBottom : 'images/dTree/joinbottom.png',
plus : 'images/dTree/plus.png',
plusBottom : 'images/dTree/plusbottom.png',
minus : 'images/dTree/minus.png',
minusBottom : 'images/dTree/minusbottom.png',
nlPlus : 'images/dTree/nolines_plus.png',
nlMinus : 'images/dTree/nolines_minus.png'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" style="width:30px; height:30px; margin-right:10px;" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" style="width:30px; height:30px;" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" style="width:30px; height:30px;" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" style="width:30px; height:30px;" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
/* if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
*/
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};

1735
index.php

File diff suppressed because it is too large Load diff

View file

@ -1,808 +0,0 @@
<?php
// error_reporting (0);
include ("../auth.inc.php");
if ($_GET['switchDir']) {
$_SESSION['current_dir'] = $_GET['switchDir'];
echo "<script type='text/javascript'>location.href='index.php';</script>";
}
// DEFINE FUNCTIONS
function get_random_string($valid_chars, $length)
{
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick - 1];
$random_string .= $random_char;
}
return $random_string;
}
function filesize_format($size, $sizes = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'))
{
if ($size == 0)
return ('');
return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
}
$username = $_SESSION['username'];
$query = mysql_query("select * from `users` where username = '$username'") or die("Error: " . mysql_error());
$row = mysql_fetch_array($query);
if (!isset($row['lexis_dir']) || strlen($row['lexis_dir']) < 51) {
$k = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789", 51);
mysql_query("update `users` set lexis_dir = '" . $k . "' where username = '$username'") or die("Error: " . mysql_error());
}
if (!isset($_SESSION['lexis_view'])) {
$_SESSION['lexis_view'] = "icon";
}
?>
<html>
<head>
<title>LEXIS Cloud Office</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="../images/lexis.png" />
<link rel="stylesheet" href="../page.css" />
<link rel="stylesheet" href="dtree.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="dtree.js" type="text/javascript"></script>
<style type="text/css">
#container {
overflow:hidden;
}
#topbar {
width:100%;
position:absolute;
left:0px;
margin:none;
padding:none;
z-index:104;
}
#topbar a.btn {
display:inline-block;
padding:15px 30px 15px 30px;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
}
#topbar a.btn:hover {
text-decoration:none;
}
#searchBar {
width:100%;
position:absolute;
left:0px;
}
#searchBar #search {
width:100%;
height:100%;
font-family:'Roboto', Arial, Helvetica;
font-weight:300;
font-size:15pt;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
border:none;
outline:none;
}
#searchBar #search:focus {
box-shadow:none;
}
#navTree {
position:absolute;
left:0px;
width:30%;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
overflow:auto;
margin:0px;
}
#mainContent {
position:absolute;
right:0px;
width:70%;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
overflow:auto;
margin:0px;
}
.fileNode {
display:inline-block;
cursor:pointer;
width:35%;
height:60px;
padding-top:10px;
padding-bottom:15px;
padding-left:80px;
border:1px solid #999;
/* box-shadow:0px 3px 5px #999; */
margin:5px;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
overflow:hidden;
float:left;
}
.fileNode:hover {
background-color:#FDFDFD;
/* box-shadow:0px 3px 5px #666; */
}
.fileNode:active {
background-color:#DFDFDF;
/* box-shadow:0px 3px 5px #333; */
}
.nodeDirectory {
background-image:url(images/folder.png);
background-repeat:no-repeat;
background-size:80px;
}
.nodeFile {
background-image:url(images/files.png);
background-repeat:no-repeat;
background-size:80px;
}
.fileNode span {
font-size:16pt;
display:block;
}
#menu {
width:450px;
position:absolute;
left:0px;
background-color:#EEE;
z-index:100;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
box-shadow:0px 5px 10px #666;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
}
#menu a.btn {
width:100%;
display:block;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:10px;
background-color:#E0E0E0;
margin-bottom:10px;
box-shadow:inset 0px 3px 5px #999;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
}
#menu a.btn:hover {
box-shadow:inset 0px 3px 5px #666;
background-color:#FAFAFA;
text-decoration:none;
}
#menu a.btn:active {
background-color:#C2C2C2;
}
.dialog {
position:fixed;
top:0px;
left:0px;
display:none;
z-index:240;
}
.dialog .mask {
width:100%;
height:100%;
background-color:#FFF;
opacity:0.5;
position:fixed;
top:0px;
left:0px;
z-index:249;
}
.dialog .window {
z-index:251;
position:absolute;
top:0px;
left:0px;
background-color:#EEE;
border:1px solid #000;
padding:15px;
box-shadow:0px 5px 5px #999;
}
.newDialogInnerBtn {
display:block;
text-align:center;
}
.newDialogInnerBtn:hover {
text-decoration:none;
}
#searchResults {
position:absolute;
left:30px;
z-index:105;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
box-shadow:0px 5px 10px #666;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
background-color:#EEE;
}
#searchResults #results {
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
width:100%;
height:100%;
overflow:auto;
z-index:67;
}
#searchResults #closeBtn {
z-index:68;
position:absolute;
right:50px;
top:10px;
width:30px;
height:30px;
cursor:pointer;
}
#previewPane {
z-index:110;
position:absolute;
left:-30%;
width:30%;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
overflow:auto;
margin:0px;
display:block;
background-color:#EEE;
transition:all .3s ease-out;
-o-transition:all .3s ease-out;
-ms-transition:all .3s ease-out;
-moz-transition:all .3s ease-out;
-webkit-transition:all .3s ease-out;
border-right:3px solid #999;
}
#previewPane #closeBtn {
z-index:111;
position:absolute;
width:25px;
height:25px;
cursor:pointer;
right:10px;
top:10px;
}
</style>
</head>
<body>
<div id="container">
<?php include ("../header.php"); if ($_SESSION['logged']==1) { ?>
<?php
/*
PROCEDURE:
1. CHECK WHICH DIRECTORY WE ARE CURRENTLY VIEWING
2. GO THROUGH THE ENTIRE CLOUD SERVER
3a. CHECK FOR PERMISSIONS
3b. RETURN THE FILES THAT ARE IN THE CONTAINING FOLDER
4. ARRANGE THE FILES IN A CERTAIN ORDER
5. DISPLAY TO THE USER IN A NEAT, ORGANIZED METHOD.
*/
// STEP 1
$current_dir = (isset($_SESSION['current_dir'])) ? $_SESSION['current_dir'] : $row['lexis_dir'];
$_SESSION['current_dir'] = $current_dir;
// STEP 2
$fquery = mysql_query("select * from `lexis_docbank` where container = '$current_dir'") or die("Error: " . mysql_error());
$files = array();
$totalfiles = array();
while ($frow = mysql_fetch_array($fquery)) {
array_push($totalfiles, $frow);
/*
CONDITIONS:
1. IT MUST BE IN THE CONTAINING FOLDER
2. ITS OWNER IS THE USER || THE USER IS AN EDITOR || THE USER IS A VIEWER
*/
$val = false;
if ($frow['owner'] == $username) {
$val = true;
}
if ($frow['container'] != $current_dir) {
$val = false;
}
if ($val) {
array_push($files, $frow);
}
}
// STEP 3a
$cDir = "";
if ($_SESSION['current_dir'] == $row['lexis_dir']) {
$cDir = "<a href='index.php'>My Cloud</a>";
} else {
/* $nowdir = "[unknown directory]";
$upperDirectory = "";
$upperName = "";
$fquery = mysql_query("select * from `lexis_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $_SESSION['current_dir']) {
$nowdir = $frow['title'];
$upperDirectory = $frow['container'];
}
}
if ($upperDirectory == $row['lexis_dir']) {
$upperName = "My Cloud";
} else {
$fquery = mysql_query("select * from `lexis_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
if ($frow['id'] == $upperDirectory) {
$upperName = $frow['title'];
}
}
}
$cDir = (($upperDirectory != $row['lexis_dir'])?"... ":"") . "<a href='index.php?switchDir=" . $upperDirectory . "'>" . $upperName . "</a> &raquo; <a href='index.php'>" . $nowdir . "</a>"; */
$nowdir = "[unknown directory]";
$fquery = mysql_query("select * from `lexis_docbank` where id='".$_SESSION['current_dir']."'") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
$nowdir = $frow['title'];
}
if ($_SESSION['current_dir']==$row['lexis_dir']) {
$cDir = "<a href='index.php?switchDir=" . $row['lexis_dir'] . "'>My Cloud</a>";
} else {
$cur = $_SESSION['current_dir'];
$cDir = "<a href='index.php?switchDir=" . $cur . "'>" . $nowdir . "</a>";
$upperDirectory = "";
$upperName = "";
$cName = "";
while ($cur != $row['lexis_dir']) {
$fquery = mysql_query("select * from `lexis_docbank` where id='".$cur."'") or die("Error: " . mysql_error());
$frow = mysql_fetch_array($fquery);
$cName = $frow['title'];
$upperDirectory = $frow['container'];
$fquery = mysql_query("select * from `lexis_docbank` where id='".$upperDirectory."'") or die("Error: " . mysql_error());
$frow = mysql_fetch_array($fquery);
$upperName = $frow['title'];
$cDir = "<a href='index.php?switchDir=" . $upperDirectory . "'>" . $upperName . "</a> &raquo; " . $cDir;
$cur = $upperDirectory;
}
$cDir = "<a href='index.php?switchDir=" . $row['lexis_dir'] . "'>My Cloud</a> " . $cDir;
}
// echo "Current directory: <b>" . $nowdir . "</b> (<a href='index.php?switchDir=" . $upperDirectory . "'>Back to " . $upperName . "</a>)";
}
echo "<br />";
function getLink($id, $ext) {
if ($ext == "scribe") {
return "apps/scribe.php?doc=open&id=".$id;
} else if ($ext == "cascade") {
return "apps/cascade.php?doc=open&id=".$id;
} else {
return "files/".$id.".".$ext;
}
return "";
}
?>
<div id="searchBar">
<input type="text" id="search" autofocus autocomplete="off" placeholder="Search your cloud..." />
</div>
<div id="topbar">
<a href="javascript:void(0);" id="fileBtn" class="btn color1">File</a>
<a href="javascript:void(0);" id="actionsBtn" class="btn color6">Actions</a>
<a href="javascript:void(0);" id="viewBtn" class="btn color6">View</a>
&nbsp;&nbsp;&nbsp;
<div id="navigation" style="display:inline-block;">
<?php echo $cDir; ?>
</div>
</div>
<div id="navTree">
<script type="text/javascript">
d = new dTree ('d');
<?php
$c = 1;
$t = array();
$all = array();
$root = array(
"id" => $row['lexis_dir'],
"type" => "lexis_directory",
"owner" => $_SESSION['username'],
"container" => "n/a",
"title" => "My Cloud",
);
array_push($t,$root);
$fquery = mysql_query("select * from `lexis_docbank`") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
array_push ($all,$frow);
}
foreach ($all as $one) {
if ($one['owner']==$_SESSION['username']) {
if ($one['type']=='lexis_directory') {
array_push($t,$one);
}
}
}
for ($i=0;$i<count($t);$i++) {
$one = $t[$i];
$k = -1;
for ($j=0;$j<count($t);$j++) {
$two = $t[$j];
if ($two['id']==$one['container']) {
$k = $j;
}
}
echo "d.add(".$i.",".$k.",\"".$one['title']."\",'index.php?switchDir=".$one['id']."','','','images/dTree/folder.png','images/dTree/folderOpen.png');\r\n";
}
?>
document.write (d);
</script>
</div>
<div id="mainContent">
<?php
function getIconURL($ext) {
$x = scandir("icons/");
if (in_array($ext.".png",$x)) {
return "icons/".$ext.".png";
} else {
return "images/file.png";
}
}
// ORGANIZE THE FILES
$ids = array();
$titles = array();
$sizes = array();
$types = array();
foreach ($files as $file) {
if ($file['type'] != "lexis_directory") {
$thissize = filesize("files/" . $file['id'] . "." . $file['type']);
array_push($ids, $file['id']);
array_push($titles, $file['title']);
array_push($sizes, $thissize);
array_push($types, $file['type']);
} else {
array_push($ids, $file['id']);
array_push($titles, $file['title']);
array_push($sizes, "");
array_push($types, $file['type']);
}
}
if (isset($_SESSION['sort']))
$meth = $_SESSION['sort'];
else
$meth = "title";
switch ($meth) {
case "title":
array_multisort($titles, SORT_STRING, $ids, SORT_STRING, $types, SORT_STRING, $sizes, SORT_NUMERIC);
break;
case "type":
array_multisort($types, SORT_STRING, $ids, SORT_STRING, $titles, SORT_STRING, $sizes, SORT_NUMERIC);
break;
case "size":
array_multisort($sizes, SORT_NUMERIC, $ids, SORT_STRING, $types, SORT_STRING, $titles, SORT_STRING);
break;
default:
array_multisort($titles, SORT_STRING, $ids, SORT_STRING, $types, SORT_STRING, $sizes, SORT_NUMERIC);
break;
}
?>
<?php if ($_SESSION['lexis_view']=='icon') { ?>
<script type="text/javascript">
function filesize_format(size) {
var i = -1;
var byteUnits = [' KB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
do {
size = size / 1024;
i++;
} while (size > 1024);
return Math.max(size, 0.1).toFixed(1) +" "+ byteUnits[i];
};
function fileNode (id, title, type, size) {
this.id = id;
this.title = title;
this.type = type;
this.size = size;
function str() {
var t = "";
if (this.type=="lexis_directory") { t+="<a href='index.php?switchDir="+this.id+"'>"; }
else { t+="<a href='files/"+this.id+"."+this.type+"' target='_blank'>"; }
t += "<div class='node'><h3>"+this.title+"</h3>"+filesize_format(this.size)+"</div>";
t += "</a>";
return t;
}
}
</script>
<?php
$count = 0;
echo "<!-- WRITING THE NODES -->";
for ($i = 0; $i < count($files); $i++) {
if ($types[$i] == "lexis_directory") {
// echo "var node".$count." = new node('".$ids[$i]."','".$titles[$i]."','".$types[$i]."','".$sizes[$i]."');";
$t = "";
$t .= "<a href='javascript:showPreviewPane(\"".$ids[$i]."\");'>"; //href='index.php?switchDir=".$ids[$i]."'>";
$t .= "<div class='fileNode nodeDirectory' contextmenu='menu".$i."'><span>".$titles[$i]."</span>Directory</div>";
$t .= "</a>\n";
echo $t;
$count++;
}
echo "\r\n";
}
for ($i = 0; $i < count($files); $i++) {
if ($types[$i] != "lexis_directory") {
// echo "var node".$count." = new node('".$ids[$i]."','".$titles[$i]."','".$types[$i]."','".$sizes[$i]."');";
$t = "";
$t .= "<a href='javascript:showPreviewPane(\"".$ids[$i]."\");'>"; //href='".getLink($ids[$i],$types[$i])."' target='_blank'>";
$t .= "<div class='fileNode nodeFile' style='background-image:url(".getIconURL($types[$i]).");'><span>".$titles[$i]."</span>" . strtoupper($types[$i]) . " file<br />".filesize_format($sizes[$i])."</div>";
$t .= "</a>\n";
echo $t;
$count++;
}
echo "\r\n";
}
?>
<?php } else { ?>
<div id="dblClickHint"></div>
<table id="mainTable" style="width:80%; border-collapse:collapse;font-weight:300;">
<tr style="background-color:#DDD;">
<th style="width:30px;"></th>
<th>Name</th>
<th>Size</th>
<th>Type</th>
</tr>
<?php
for ($i = 0; $i < count($files); $i++) {
if ($types[$i] == "lexis_directory") {
echo "<tr class='row'>";
echo "<td><img src='images/folder.png' alt='Folder' width='60' height='60' /></td>";
echo "<td style='cursor:pointer;' onclick='javascript:location.href=\"index.php?switchDir=" . $ids[$i] . "\";'>" . $titles[$i] . "</td>";
echo "<td></td>";
echo "<td>Directory</td>";
echo "</tr>";
}
echo "\r\n";
}
for ($i = 0; $i < count($files); $i++) {
if ($types[$i] != "lexis_directory") {
echo "<tr class='row'>";
echo "<td><img src='".getIconURL($types[$i])."' alt='File' width='60' height='60' /></td>";
echo "<td><a href='".getLink($ids[$i],$types[$i])."' target='_blank'>" . $titles[$i] . "</a></td>";
echo "<td>" . filesize_format($sizes[$i]) . "</td>";
echo "<td>" . strtoupper($types[$i]) . " file</td>";
echo "</tr>";
}
echo "\r\n";
}
?>
</table>
<?php } ?>
</div>
<div id="menu" style="opacity:0;"></div>
<div id="searchResults">
<img src="images/closeIcon.png" id="closeBtn" />
<div id="results"></div>
</div>
<div id="previewPane">
&nbsp;
</div>
<div id="uploadDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Upload File</b><a style="position:absolute; top:5px; right:5px;" href="#" class="close"><img src="images/closeIcon.png" style="width:32px;height:32px;" alt="Close" /></a></p>
<form action="upload.php" style="display:inline;" enctype="multipart/form-data" method="post" id="uploadForm">
<input type="file" name="uploaded" id="uploaded" />
</form>
<p><a class="button color2" href="javascript:$('#uploadForm').submit();">Upload</a></p>
</div>
</div>
<div id="newDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Create File</b><a style="position:absolute; top:5px; right:5px;" href="#" class="close"><img src="images/closeIcon.png" style="width:32px;height:32px;" alt="Close" /></a></p>
<p>Choose the type of file you want to create.</p>
<p class="buttonGroup">
<a class="newDialogInnerBtn button color5" href="#" id="newDirBtn">Directory (folder)</a>
<a class="newDialogInnerBtn button color1" target="_blank" href="apps/scribe.php?doc=new" id="newScribeBtn">Scribe Document</a>
<a class="newDialogInnerBtn button color2" target="_blank" href="apps/cascade.php?doc=new" id="newCascadeBtn">Cascade Spreadsheet (EXPERIMENTAL)</a>
</p>
</div>
</div>
<div id="newDirDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Create Directory</b><a style="position:absolute; top:5px; right:5px;" href="#" class="close"><img src="images/closeIcon.png" style="width:32px;height:32px;" alt="Close" /></a></p>
<p>Give your new folder a name.</p>
<p>
<form action="newdir.php" method="POST">
<input type="text" name="name" class="tf" autocomplete="off" />
<input type="submit" class="button color2" value="Create Folder!" />
</form>
</p>
</div>
</div>
<script type="text/javascript">
var currentMenu = "fileBtn";
function showPreviewPane(id) {
$.ajax({
type:"POST",
url:"ajax/previewPane.php",
data: {id:id},
dataType: "html",
success: function (msg) {
$("#previewPane").html(msg);
$("#previewPane").css("left","0px");
}
});
}
function closePreviewPane() {
$("#previewPane").css("left","-30%");
}
setInterval(function() {
$("#searchResults").width(window.innerWidth*4/5);
$("#searchBar").css("top",$("#bars").position().top + $("#bars").height());
$("#searchBar").css("width",window.innerWidth);
$("#topbar").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height());
$("#searchResults").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height());
$("#menu").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height() + $("#topbar").height());
$("#menu").height(window.innerHeight - $("#bars").position().top - $("#bars").height() - $("#searchBar").height() - $("#topbar").height() - 50);
$("#navTree").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height() + $("#topbar").height());
$("#navTree").height(window.innerHeight - $("#bars").position().top - $("#bars").height() - $("#searchBar").height() - $("#topbar").height() - 30);
$("#previewPane").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height() + $("#topbar").height());
$("#previewPane").height(window.innerHeight - $("#bars").position().top - $("#bars").height() - $("#searchBar").height() - $("#topbar").height() - 30);
$("#mainContent").css("top",$("#bars").position().top + $("#bars").height() + $("#searchBar").height() + $("#topbar").height());
$("#mainContent").height(window.innerHeight - $("#bars").position().top - $("#bars").height() - $("#searchBar").height() - $("#topbar").height() - 30);
$("#uploadDialog .window").css("left",(window.innerWidth/2-150)+"px");
$("#uploadDialog .window").css("top",(window.innerHeight/2-125)+"px");
$("#newDialog .window").css("left",(window.innerWidth/2-200)+"px");
$("#newDialog .window").css("top",(window.innerHeight/2-150)+"px");
$("#newDirDialog .window").css("left",(window.innerWidth/2-150)+"px");
$("#newDirDialog .window").css("top",(window.innerHeight/2-125)+"px");
$("#uploadDialog .window").css("width",300);
$("#uploadDialog .window").css("height",250);
$("#newDialog .window").css("width",400);
$("#newDialog .window").css("height",300);
$("#newDirDialog .window").css("width",300);
$("#newDirDialog .window").css("height",250);
});
$("#search").keypress(function(e) {
if ($("#search").val().length>0) {
var searchTerm = $("#search").val();
$.ajax({
type:"POST",
url:"ajax/searchAjax.php",
data: {words:searchTerm},
dataType: "html",
success: function (msg) {
$("#searchResults #results").html(msg);
showResults();
}
});
} else {
hideResults();
}
});
$("#searchResults #closeBtn").click(function() {
hideResults();
});
function showResults() {
$("#searchResults").height(window.innerHeight - $("#bars").position().top - $("#bars").height() - $("#searchBar").height() - 50);
$("#searchResults").css("opacity",1);
$("#searchResults").css("padding",15);
}
function hideResults() {
$("#searchResults").height(0);
$("#searchResults").css("opacity",0);
$("#searchResults").css("padding",0);
}
hideResults();
$("#topbar .btn").click(function () {
if ($("#menu").css("opacity")==1 && currentMenu==$(this).attr("id")) {
hideMenu()
} else {
if ($("#menu").css("opacity")==1) {
hideMenu();
}
$("#menu").css("left",($(this).position().left==0)?15:$(this).position().left);
var content = "";
if ($(this).attr("id")=="fileBtn") {
content = "<h2>File</h2><a href='javascript:newBtn();' class='btn'>Create File</a><a href='javascript:uploadBtn();' class='btn'>Upload File</a><a href='javascript:newDirBtn();' class='btn'>Create Folder</a><a href='javascript:location.href=\"about.php\"' class='btn'>About LEXIS</a>";
} else if ($(this).attr("id")=="actionsBtn") {
content = "<h2>Actions</h2><a href='javascript:deleteBtn();' class='btn'>Delete</a>";
} else if ($(this).attr("id")=="viewBtn") {
content = "<h2>View</h2><a href='javascript:switchViewBtn();' class='btn'>Switch to <?php echo $_SESSION['lexis_view']=="icon"?"list":"icon"; ?> view</a>";
}
currentMenu = $(this).attr("id");
$("#menu").html(content);
$("#menu").css("opacity",1);
}
closePreviewPane();
});
$(".dialog .mask").click(function() {
$(".dialog .window").css("border","1px solid #F00");
$(".dialog .window").css("box-shadow","0px 5px 5px #F00");
setTimeout(function() {
$(".dialog .window").css("border","1px solid #000");
$(".dialog .window").css("box-shadow","0px 5px 5px #999");
},1000);
});
$(".dialog .close").click(function() {
$(".dialog").fadeOut("fast");
});
function hideMenu() {
$("#menu").css("opacity",0);
$("#menu").css("left",-1*$("#menu").width());
}
hideMenu();
function uploadBtn() {
$("#uploadDialog").fadeIn("fast");
hideMenu();
};
function newBtn() {
$("#newDialog").fadeIn("fast");
hideMenu();
};
$("#newScribeBtn").click (function() {
$(".dialog").fadeOut("fast");
});
$("#newCascadeBtn").click (function() {
$(".dialog").fadeOut("fast");
});
function newDirBtn() {
$(".dialog").fadeOut("fast");
$("#newDirDialog").fadeIn("fast");
hideMenu();
};
function switchViewBtn() {
$.ajax({
type:"POST",
url:"ajax/switchView.php",
data: {new_view:"<?php if ($_SESSION['lexis_view']=="icon") { echo "list"; } else { echo "icon"; } ?>"},
dataType: "html",
success: function (msg) {
location.reload(true);
}
});
}
document.title = "<?php echo ($current_dir == $row['lexis_dir']) ? "My Cloud" : $nowdir; ?>";
</script>
<?php } else { ?>
You have to be signed in to use LEXIS!
<?php } ?>
</div>
</body>
</html>

View file

@ -1,32 +1,32 @@
<?php
session_start();
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
if (isset($_POST['name'])) {
if ($_SESSION['logged']==1) {
include ("../auth.inc.php");
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789", 50);
$newdir = $_POST['name'] or die ("No name");
$use_dir = $_SESSION['current_dir'];
$username = $_SESSION['username'];
mysql_query("insert into lexis_docbank (id,title,container,owner,type,dateMod) values('$id','$newdir','$use_dir','$username','lexis_directory',NOW())") or die("Error: " . mysql_error());?>
<script type="text/javascript">
location.href='index.php';
</script>
<?php
}
}
<?php
session_start();
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
if (isset($_POST['name'])) {
if ($_SESSION['logged']==1) {
include ("../auth.inc.php");
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789", 50);
$newdir = $_POST['name'] or die ("No name");
$use_dir = $_SESSION['current_dir'];
$username = $_SESSION['username'];
mysql_query("insert into keepit_docbank (id,title,container,owner,type,dateMod) values('$id','$newdir','$use_dir','$username','keepit_directory',NOW())") or die("Error: " . mysql_error());?>
<script type="text/javascript">
location.href='index.php';
</script>
<?php
}
}
?>

View file

@ -1,13 +1,13 @@
<?php
include ("../auth.inc.php");
$id = $_POST['renameFormItem'] or die ("Error: no variable given.");
$nName = $_POST['name'] or die ("Error: no variable given.");
mysql_query("update `lexis_docbank` set title='".$nName."' where id='".$id."'") or die ("Error: couldn't rename ");
?>
<script>
location.href="index.php";
<?php
include ("../auth.inc.php");
$id = $_POST['renameFormItem'] or die ("Error: no variable given.");
$nName = $_POST['name'] or die ("Error: no variable given.");
mysql_query("update `keepit_docbank` set title='".$nName."' where id='".$id."'") or die ("Error: couldn't rename ");
?>
<script>
location.href="index.php";
</script>

View file

@ -1,70 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* CONSTANTS *********************
const double PI = 3.141592653589793238462643383279502884197;
// ********************* PROBLEM 1 *********************
double L = 6;
double r = 5;
double TA = PI*r*L + PI*r*r;
cout << "Total Area = " << TA << " Units squared" << endl;
// ********************* PROBLEM 2 *********************
double a = 7;
double b = 8.4;
double c = sqrt(a*a + b*b);
cout << "c = " << c << endl;
// ********************* PROBLEM 3 *********************
double h = 0.6;
double b1 = 1.3;
double b2 = 3.5;
double A = 0.5 * h * (b1 + b2);
cout << "Area = " << A << " Units squared" << endl;
// ********************* PROBLEM 4 *********************
h = 12;
r = 3;
double volume = PI * r * r * h;
cout << "Volume = " << volume << " Units cubed" << endl;
// ********************* PROBLEM 5 *********************
double d1 = 3;
double d2 = 5;
double d3 = 7;
double s = (d1 + d2 + d3) /2;
A = sqrt(s*(s-d1)*(s-d2)*(s-d3));
cout << "Area = " << A << " Units squared" << endl;
// ********************* PROBLEM 6 *********************
double diameter = 10;
double SA = pow(diameter,2) - PI*pow(diameter/2,2);
cout << "Shaded Area = " << SA << " Units squared" << endl;
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,72 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
double a[5];
for (int i=0;i<5;i++) {
cout << "Please enter a number: ";
cin >> a[i];
}
cout << endl << "The average of your numbers is " << (a[0]+a[1]+a[2]+a[3]+a[4])/5 << "." << endl;
cout << endl;
// ********************* PROBLEM 2 *********************
for (int i=0;i<5;i++) {
cout << "Please enter a number: ";
cin >> a[i];
}
double product = a[0]*a[1]*a[2]*a[3]*a[4];
cout << endl << "The product of your numbers is " << product << "." << endl;
// ********************* PROBLEM 3 *********************
double sum = 0;
for (int i=25;i<=50;i++) {
sum += i;
}
cout << endl << "The sum of the consecutive integers from 25 to 50 is " << sum << "." << endl;
// ********************* PROBLEM 3 *********************
product = 1;
for (int i=3;i<=11;i+=2) {
product *= i;
}
cout << endl << "The product of the odd integers from 3 to 11 is " << product << "." << endl;
// ********************* PROBLEM 4 *********************
double frac = 1, decimal = 1;
for (int i=2;i<=6;i++) {
frac *= i;
decimal /= i;
}
cout << endl << "The product of 1/2, 1/3, 1/4, 1/5, and 1/6 is 1/" << frac << ", or " << decimal << "." << endl;
return 0;
}

View file

@ -1,96 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
for (int i=0;i<4;i++) {
for (int j=7;j<=10;j++) {
cout << j << " ";
}
cout << endl;
}
cout << endl;
for (int i=0;i<4;i++) {
cout << "* ";
for (int j=2;j<=10;j+=2) {
cout << j << " ";
}
cout << endl;
}
cout << endl;
for (int i=0;i<4;i++) {
for (int j=1;j<=4;j++) {
cout << j << " ";
}
cout << "0 ";
for (int j=6;j<=9;j++) {
cout << j << " ";
}
cout << endl;
}
cout << endl;
// ********************* PROBLEM 2 *********************
for (int i=0;i<3;i++) {
for (int j=0;j<3;j++) {
cout << "A " << (j+1) << " ";
}
cout << endl;
}
cout << endl;
for (int i=0;i<4;i++) {
cout << "<";
for (int j=0;j<10;j++) {
cout << "*";
}
cout << ">" << endl;
}
cout << endl;
for (int i=0;i<6;i++) {
for (int j=1;j<=4;j++) {
if (i%2==0)
cout << j << " ";
else
cout << 5-j << " ";
}
cout << endl;
}
cout << endl;
// ********************* PROBLEM 3 *********************
for (int i=0;i<3;i++) {
cout << "$ ";
for (int j=0;j<3;j++) {
if (j > 0) cout << "# ";
for (int k=1;k<=5;k++) {
cout << k << " ";
}
}
cout << "$" << endl;
}
return 0;
}

View file

@ -1,61 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
ifstream f1;
f1.open("nbrs1.dat");
double data;
while (f1 >> data) {
if (data > 25) {
cout << data << endl;
}
}
cout << endl;
// ********************* PROBLEM 2 *********************
double S = 25, R, D, T;
cout << fixed;
cout << "Speed (MPH)\tReaction Dist\tBraking Dist\tTotal Dist" << endl;
do {
R = S*5200/7200;
D = 0.06*S*S;
T = R+D;
cout << setprecision(1) << S << "\t\t" << R << "\t\t" << D << "\t\t" << T << endl;
S += 5;
} while (S <= 90);
// ********************* PROBLEM 3 *********************
int Y = 1;
double amount = 500;
cout << "Year\tAmount" << endl;
do {
amount *= 1.05;
cout << setprecision(2) << Y << "\t$" << amount << endl;
Y += 1;
} while (Y <= 10);
return 0;
}

View file

@ -1,67 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
double population = 1700;
for (int i=0;i<8;i++) {
population *= 1.04;
}
cout << "At Malcolm Community College, there will be " << (int) population << " students in 8 years." << endl;
cout << endl;
// ********************* PROBLEM 2 *********************
ifstream f1;
f1.open("jobs.dat");
cout << fixed;
double a,b;
while (f1 >> a >> b) {
cout << "When Ann Sparks worked " << setprecision(0) << a << " hours at $" << setprecision(2) << b << " per hour she earned $" << a*b << "." << endl;
}
cout << endl;
// ********************* PROBLEM 3 *********************
ifstream f2;
f2.open("rooms.dat");
double sum;
while (f2 >> a >> b) {
sum += a*b;
}
cout << "Mr. Thomas' building has " << setprecision(0) << sum << " square feet of floor space." << endl;
cout << endl;
// ********************* PROBLEM 5 *********************
double value = 37000;
for (int i=0;i<5;i++) {
value *= 0.75;
}
cout << "Hook-U's truck is worth $" << setprecision(2) << value << " in 5 years." << endl;
return 0;
}

View file

@ -1,79 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
double a,b;
ifstream f1;
f1.open("p14_1.dat");
while (f1 >> a >> b) {
if (a<0) {
cout << a*b << endl;
} else {
cout << a+b << endl;
}
}
cout << endl;
// ********************* PROBLEM 2 *********************
ifstream f2;
f2.open("p14_2.dat");
while (f2 >> a >> b) {
if (a>0) {
if (b<0) {
cout << a << endl;
} else {
cout << b << endl;
}
} else {
cout << a+b << endl;
}
}
cout << endl;
// ********************* PROBLEM 3 *********************
string c;
ifstream f3;
f3.open("p14_3.dat");
cout << fixed;
cout << "EMPLOYEE\tREGULAR HOURLY RATE\tNUMBER OF HOURS WORKED\tPAY" << endl;
while (f3 >> c >> a >> b) {
string q = "";
if (c.length() < 8) q = "\t\t"; else q = "\t";
double pay = 0;
if (b<=40) {
pay = a*b;
} else {
pay = a*40;
b -= 40;
pay += 1.5*a*b;
}
cout << setprecision(2) << c << q << a << "\t\t\t" << b << "\t\t\t" << pay << endl;
}
return 0;
}

View file

@ -1,51 +0,0 @@
//
// main.cpp
// Program 2
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
double C = 30;
double F = 9*C/5 + 32;
cout << "CELSIUS\tFAHRENHEIT" << endl << C << "\t\t" << F << endl << endl;
// ********************* PROBLEM 2 *********************
double A = 78000;
double R = 6.45;
double T = A * R / 100;
cout << "The tax on a house with an assessed value of $" << A << " and a tax rate of $" << R << "per $100 is $" << T << "." << endl << endl;
// ********************* PROBLEM 3 *********************
double T1 = 89;
double T2 = 72;
double T3 = 86;
double average = (T1 + T2 + T3) / 3;
cout << "test1\ttest2\ttest3\taverage" << endl << T1 << "\t\t" << T2 << "\t\t" << T3 << "\t\t" << average << endl << endl;
// ********************* PROBLEM 4 *********************
double H = 38;
R = 4.75;
double P = H * R;
cout << "Todd worked " << H << " hours at a rate of $" << R << " and earned $" << P << "." << endl;
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,56 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
cout << std::scientific;
// ********************* PROBLEM 3 *********************
double a = 1.922e+14;
int b = 75;
cout << "The product of " << a << " and " << b << " is " << (a*b) << "." << endl;
// ********************* PROBLEM 4 *********************
a = 6.22e-8;
double c = 3.511e-7;
cout << "The sum of " << a << " and " << c << " is " << (a+c) << "." << endl;
// ********************* PROBLEM 5 *********************
double LS = 186000;
double YS = 365 * 24 * 60 * 60;
cout << "The distance light can travel in one year is " << (LS * YS) << " miles." << endl;
// ********************* PROBLEM 6 *********************
double MILE = 5280;
double W = 62.4;
cout << "The weight of 1000 cubic miles is " << 1000*pow(MILE,3)*W << " pounds." << endl;
// ********************* PROBLEM 7 *********************
double L = 5000, H = 9140, R = 516;
W = 199;
cout << "The total number of sheets of paper in a warehouse that have been stacked " << L << " reams long by " << W << " reams wide by " << H << " reams high is " << (L*W*H*R) << " sheets." << endl;
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,58 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
cout << std::scientific;
cout << "This program will determine the appropriate letter grade and message for a certain percentage.\n\nInput the percentage of the grade here and press <enter>\n > ";
int percent;
cin >> percent;
string letter, message;
if (percent > 100) {
letter = "A+";
message = "Excellent";
} else if (percent <= 100 && percent >= 90) {
letter = "A";
message = "Solid work";
} else if (percent < 90 && percent >= 80) {
letter = "B";
message = "Doing fine";
} else if (percent < 80 && percent >= 70) {
letter = "C";
message = "Need to work harder";
} else if (percent < 70 && percent >= 60) {
letter = "D";
message = "On probation";
} else if (percent < 60 && percent >= 0) {
letter = "F";
message = "You are failing";
} else {
letter = "N/A";
message = "Can't have negative score";
}
cout << "\tGrade\t\tLetter Grade\t\tMessage" << endl << "\t" << percent << "\t\t" << letter << "\t\t\t" << message << endl;
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,88 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
cout << "Input the mortgage amount requested and press <enter>:\n > ";
double mortgage;
cin >> mortgage;
double DP;
if (mortgage < 0 || mortgage >100000) {
cout << "Please input a reasonable mortgage amount (less than 100000)";
return 0;
} else {
if (mortgage <= 50000) {
DP += 0.02 * mortgage;
} else {
DP += 0.02 * 50000;
mortgage -= 50000;
if (mortgage <= 25000) {
DP += 0.2 * mortgage;
}else {
DP += 0.2 * 25000;
mortgage -= 25000;
DP += 0.25 * mortgage;
}
}
}
cout << "Your mortgage of $" << mortgage << " requires a down payment of $" << DP << "." << endl;
// ********************* PROBLEM 2 *********************
double T1, T2, T3, T4;
cout << "Enter T1: ";
cin >> T1;
cout << "Enter T2: ";
cin >> T2;
cout << "Enter T3: ";
cin >> T3;
cout << "Enter T4: ";
cin >> T4;
double sum = T1 + T2 + T3 + T4;
string pass = "pass";
if (sum <= 260) {
pass = "fail";
}
cout << "\tT1\tT2\tT3\tT4\tSum\tFinal Grade" << endl;
cout << "\t" << T1 << "\t" << T2 << "\t" << T3 << "\t" << T4 << "\t" << sum << "\t" << pass << endl;
// ********************* PROBLEM 3 *********************
double sales, commission;
cout << "Enter the sales\n > ";
cin >> sales;
if (sales >= 15000)
commission = 0.15 * sales;
else
commission = 0.0725 * sales;
cout << "\tSales\tCommission" << endl;
cout << "\t" << sales << "\t" << commission << endl;
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,52 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* CONSTANTS *********************
const double PI = 3.1415926535897932384626433832795028841971693993;
// ********************* PROBLEM 1 *********************
double F = -35;
double C;
cout << "C\tF" << endl;
do {
C = 5*(F-32)/9;
cout << F << "^F\t" << C << "^C" << endl;
F += 5;
} while (F <= 125);
cout << endl;
// ********************* PROBLEM 2 *********************
double radius = 2;
double area, circumference;
cout << "Radius\tCircumference\tArea" << endl;
do {
circumference = 2 * radius * PI;
area = radius * radius * PI;
cout << radius << "\t" << circumference << "\t\t" << area << endl;
radius += 5;
} while (radius <= 47);
cout << endl << endl << "done" << endl;
return 0;
}

View file

@ -1,79 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 3 *********************
int i = 1;
double s = 1, c = 1;
cout << "Integer\tSquare Root\tCube Root" << endl;
do {
cout << i << "\t" << s << "\t\t" << c << endl;
i += 1;
s = pow(i,0.5);
c = pow(i,1./3);
} while (c < 2.5);
cout << endl;
// ********************* PROBLEM 4 *********************
double cost = 1.95;
int year = 2013;
cout << "Year\tCost" << endl;
cout << fixed;
do {
cout << year << "\t" << setprecision(2) << cost << endl;
year += 1;
cost *= 1.05;
} while (cost <= 10);
cout << year << "\t" << cost << endl;
// ********************* PROBLEM 5 *********************
int x;
int x1;
cout << "What is the value of x?\n > ";
cin >> x1;
if (abs(x1) != x1) {
cout << "Can't be negative." << endl;
return 0;
} else {
x = x1;
int c = 0;
do {
if (x % 2 == 0) {
x /= 2;
} else {
x = 3*x+1;
}
c += 1;
cout << x << " ";
} while (x != 1);
cout << "It took " << c << " replacements." << endl;
}
return 0;
}

View file

@ -1,47 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
cout << fixed;
double amount, rate, payment;
cout << "Amount? ";
cin >> amount;
cout << "Rate? ";
cin >> rate;
cout << "Payment? ";
cin >> payment;
int month = 1;
double interest, principal;
cout << "MONTH\tAMOUNT\tINTEREST\tTO PRINCIPAL" << endl;
do {
interest = rate*amount/1200;
principal = payment - interest;
if (principal > amount) principal = amount;
cout << month << "\t" << setprecision(2) << amount << "\t" << interest << "\t\t" << principal << endl;
amount -= principal;
month++;
} while (amount > 0);
return 0;
}

View file

@ -1,55 +0,0 @@
//
// main.cpp
// Program 1
//
// Created by Liyang Zhang 2016 on 6/10/13.
// Copyright (c) 2013 Liyang Zhang 2016. All rights reserved.
//
//precompiler directives:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
int main( )
{
// ********************* PROBLEM 1 *********************
int num, counter = 1;
while (counter <= 5) {
num = counter * 2;
cout << counter << " doubled is " << num << endl;
counter ++;
}
// ********************* PROBLEM 2 *********************
cout << "You will input two numbers. This program will determine if the numbers are equal, or if one is larger than the other." << endl;
cout << endl;
double A, B;
cout << "A = ";
cin >> A;
cout << "B = ";
cin >> B;
cout << endl;
if (A>B) {
cout << A << " > " << B << endl;
cout << "Larger";
} else if (A<B) {
cout << A << " < " << B << endl;
cout << "Smaller";
} else {
cout << A << " = " << B << endl;
cout << "Equal";
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
<font face=\"HelveticaNeue\">hiadsfihqpweiohtasdifhqpoiewtpqiehwptiqhewpotihqpweithpqioewtpqijwerpoqewjfpjasdo;fkja;dslkfja;lsdkfj;askdjf</font>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 KiB

1177
temp/jquery-ui.css vendored

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PlanarTowerDefense</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,6 +0,0 @@
5x5
2,1,1,1,0
0,0,0,1,0
0,1,1,1,0
0,1,0,0,0
0,1,1,1,3

View file

@ -1,6 +0,0 @@
5x5
2,1,1,0,0
0,0,1,0,0
0,0,1,0,0
0,0,1,0,0
0,0,1,1,3

View file

@ -1,6 +0,0 @@
5x5
2,1,0,0,0
0,1,1,0,0
0,0,1,0,0
0,0,1,1,0
0,0,0,1,3

View file

@ -1,158 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class Camera {
BufferedImage back;
static Tile[][][] maps;
static Enemy[] enemies = new Enemy[3];
int map = 0;
int w = 5, h = 5;
int money = 1000;
FontMetrics metrics;
int R = (int) (Math.random() * 255), G = (int) (Math.random() * 255),
B = (int) (Math.random() * 255);
boolean R1 = (Math.random() > 0.5) ? false : true,
G1 = (Math.random() > 0.5) ? false : true,
B1 = (Math.random() > 0.5) ? false : true;
public Camera() throws Exception {
back = ImageIO.read(Camera.class.getResource("Back1.jpg"));
loadMap();
}
public void nextMap() {
map += 1;
if (map > 2)
map = 0;
}
public void prevMap() {
map -= 1;
if (map < 0)
map = 2;
}
public void loadMap() throws Exception {
maps = new Tile[3][w][h];
for (int i = 0; i < 3; i++) {
BufferedReader in = new BufferedReader(
new InputStreamReader(
Camera.class.getResourceAsStream("defaultMap" + i
+ ".dat")));
String t = in.readLine();
for (int j = 0; j < w; j++) {
t = in.readLine();
for (int k = 0; k < h; k++) {
maps[i][j][k] = new Tile(j, k, Integer.parseInt(t
.split(",")[k]));
}
}
}
for (int i = 0; i < enemies.length; i++) {
enemies[i] = new Enemy();
enemies[i].setMap(i);
enemies[i].setX(0);
enemies[i].setY(0);
}
}
public void update(long time) {
for (int i = 0; i < enemies.length; i++) {
enemies[i].update(time);
}
}
public void draw(Graphics2D g) {
String t = "";
g.drawImage(back, 0, 0, PDefense.width, PDefense.height, null);
g.setColor(new Color(R, G, B, 50));
g.fillRect(0, 0, PDefense.width, PDefense.height);
if (!PDefense.paused) {
if (R1)
R += 1;
else
R -= 1;
if (G1)
G += 1;
else
G -= 1;
if (B1)
B += 1;
else
B -= 1;
if (R >= 255) {
R = 255;
R1 = false;
}
if (R <= 0) {
R = 0;
R1 = true;
}
if (G >= 255) {
G = 255;
G1 = false;
}
if (G <= 0) {
G = 0;
G1 = true;
}
if (B >= 255) {
B = 255;
B1 = false;
}
if (B <= 0) {
B = 0;
B1 = true;
}
}
g.setFont(PFont.getFont(15));
g.setColor(new Color(255, 255, 255));
metrics = new JFrame().getFontMetrics(g.getFont());
// t = "[Current map: Map " + (map + 1) +
// "] Keyboard shortcuts: Escape to pause, Tab for next map, Shift+Tab for previous map";
t = "[Current map: Map " + (map + 1) + "]";
g.drawString(t, 20, 20);
for (int i = 0; i < maps[map].length; i++) {
for (int j = 0; j < maps[map][0].length; j++) {
int l = 150 + (100 * i), q = 50 + (100 * j);
if (maps[map][i][j].getC() == 0 && !PDefense.paused) {
if (PDefense.location.x >= l
&& PDefense.location.x <= (l + 100)
&& PDefense.location.y >= q
&& PDefense.location.y <= q + 100) {
if (PDefense.leftMouse) {
g.setColor(maps[map][i][j].getPressColor(map % 3));
} else {
g.setColor(maps[map][i][j].getHoverColor(map % 3));
}
} else {
g.setColor(maps[map][i][j].getColor(map % 3));
}
} else {
g.setColor(maps[map][i][j].getColor(map % 3));
}
g.fillRect(l, q, 100, 100);
}
}
for (int i = 0; i < enemies.length; i++) {
if (enemies[i].map == map) {
enemies[i].draw(g, 150, 50, 100, 100);
}
}
}
}

View file

@ -1,78 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
public class Enemy extends Entity {
ArrayList<Point> travelled;
int moveCountdown = 50;
int health = 100;
public Enemy() {
travelled = new ArrayList<Point>();
travelled.add(new Point(0, 0));
color = new Color(200, 50, 50);
}
public void update(long time) {
Set<Point> setItems = new LinkedHashSet<Point>(travelled);
travelled.clear();
travelled.addAll(setItems);
moveCountdown -= 1;
if (moveCountdown == 0) {
moveCountdown = 50;
move();
}
}
public void move() {
boolean moved = false;
for (int i = 0; i < Camera.maps[map].length; i++) {
for (int j = 0; j < Camera.maps[map][0].length; j++) {
if (!moved) {
Tile tmpTile = Camera.maps[map][i][j];
if (tmpTile.getC() == 1) {
int dx = (int) (Math.abs(x - tmpTile.getX())), dy = (int) (Math
.abs(y - tmpTile.getY()));
if ((dx == 0 && dy == 1) || (dy == 0 && dx == 1)) {
boolean b = true;
for (Point p : travelled) {
if (tmpTile.getX() == p.x
&& tmpTile.getY() == p.y) {
b = false;
}
}
if (b) {
for (Enemy e : Camera.enemies) {
if (map == e.map && tmpTile.getX() == e.x
&& tmpTile.getY() == e.y) {
b = false;
}
}
}
if (b) {
travelled.add(new Point(x, y));
x = tmpTile.getX();
y = tmpTile.getY();
moved = true;
}
}
}
}
}
}
}
public void draw(Graphics2D g, int sx, int sy, int bw, int bh) {
int eX = sx + (x * bw) + (bw - (bw / 4 * 3)) / 2, eY = sy + (y * bh)
+ (bh - (bh / 4 * 3)) / 2;
g.setColor(new Color(200, 50, 50, 100));
g.fillOval(eX, eY, bw / 4 * 3, bh / 4 * 3);
g.setColor(color);
g.fillArc(eX, eY, bw / 4 * 3, bh / 4 * 3, 90, 90 + (health * 360 / 100));
}
}

View file

@ -1,48 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
public class Entity {
int x, y;
int map;
Color color;
public Entity() {
x = -1;
y = -1;
map = 0;
color = Color.black;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setMap(int map) {
this.map = map;
}
public void setColor(Color color) {
this.color = color;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getMap() {
return map;
}
public Color getColor() {
return color;
}
}

View file

@ -1,125 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.swing.JFrame;
public class MenuOptions {
FontMetrics metrics;
JFrame frame;
int countdown = 6;
private int button1W = 300, button1H = 60, button1X = 20, button1Y = 520;
private boolean button1O = false;
private int button2W = 300, button2H, button2X, button2Y = 180;
private boolean button2O = false;
public MenuOptions() {
frame = new JFrame();
}
public void draw(Graphics2D g) {
String t = "";
g.setColor(new Color(102, 204, 204));
g.fillRect(0, 0, PDefense.width, PDefense.height);
g.setColor(new Color(0, 0, 0));
g.setFont(PFont.getFont(35));
metrics = frame.getFontMetrics(g.getFont());
t = "Options";
g.drawString(t, PDefense.width / 2 - metrics.stringWidth(t) / 2, 100);
// AUTO-PAUSE
g.setFont(PFont.getFont(16));
metrics = frame.getFontMetrics(g.getFont());
t = "Auto-Pause (focusLost)";
g.drawString(t, 40, 180);
button2X = 55 + metrics.stringWidth(t);
button2H = metrics.getHeight() + 10;
g.setFont(PFont.getFont(15));
metrics = frame.getFontMetrics(g.getFont());
t = String.valueOf(PDefense.autopause);
g.setColor(button2O ? new Color(140, 70, 140) : new Color(102, 51, 102));
g.fillRect(button2X, button2Y + metrics.getHeight() / 2 - button2H / 2,
button2W, button2H);
g.setColor(new Color(255, 255, 255));
g.drawString(t, button2X + button2W / 2 - metrics.stringWidth(t) / 2,
button2Y);
// BACK BUTTON
g.setColor(button1O ? new Color(70, 140, 140) : new Color(51, 102, 102));
g.fillRect(button1X, button1Y, button1W, button1H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = frame.getFontMetrics(g.getFont());
t = "Back";
g.drawString(t, button1X + button1W / 2 - metrics.stringWidth(t) / 2,
button1Y + button1H / 2);
// MOUSE LOCATION ETC.
button1O = PDefense.location.x >= button1X
&& PDefense.location.x <= button1X + button1W
&& PDefense.location.y >= button1Y
&& PDefense.location.y <= button1Y + button1H;
button2O = PDefense.location.x >= button2X
&& PDefense.location.x <= button2X + button2W
&& PDefense.location.y >= button2Y
&& PDefense.location.y <= button2Y + button2H;
if (PDefense.leftMouse && button1O) {
writeOptions();
PDefense.PState = PDefense.state.MENU;
PDefense.leftMouse = false;
}
if (PDefense.leftMouse && button2O) {
PDefense.autopause = !PDefense.autopause;
ArrayList<String> oTmp = new ArrayList<String>();
for (String option : PDefense.options) {
if (option.split("=")[0].equals("autopause")) {
oTmp.add("autopause=" + !PDefense.autopause);
} else {
oTmp.add(option);
}
}
PDefense.leftMouse = false;
}
if (countdown > 0) {
countdown -= 1;
} else {
countdown = 6;
writeOptions();
}
}
public void writeOptions() {
try {
PrintWriter out = new PrintWriter(new File(PDefense.appdata
+ File.separator + ".planar" + File.separator
+ "options.dat"));
for (String option : PDefense.options) {
out.println(option);
}
out.flush();
out.close();
} catch (Exception e) {
System.err
.println("***** AN ERROR OCCURRED AT MenuOptions.java *****");
e.printStackTrace();
System.exit(0);
}
}
}

View file

@ -1,77 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
public class MenuPause {
FontMetrics metrics;
int button1W = 400, button1H = 60, button1X = 200, button1Y = 320;
private boolean button1O = false;
int button3W = 400, button3H = 60, button3X = 200, button3Y = 390;
private boolean button3O = false;
public MenuPause() {
}
public void draw(Graphics2D g) {
String t = "";
g.setFont(PFont.getFont(100));
g.setColor(new Color(0, 0, 0, 50));
g.fillRect(0, 0, PDefense.width, PDefense.height);
g.setColor(new Color(255, 255, 255));
metrics = new JFrame().getFontMetrics(g.getFont());
t = "PAUSED";
g.drawString(t, PDefense.width / 2 - metrics.stringWidth(t) / 2,
PDefense.height / 2 - metrics.getHeight() / 2);
// RESUME BUTTON
g.setColor(button1O ? new Color(140, 70, 140) : new Color(102, 51, 102));
g.fillRect(button1X, button1Y, button1W, button1H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = new JFrame().getFontMetrics(g.getFont());
t = "Resume";
g.drawString(t, PDefense.width / 2 - metrics.stringWidth(t) / 2,
button1Y + button1H / 2);
// MENU BUTTON
g.setColor(button3O ? new Color(140, 70, 140) : new Color(102, 51, 102));
g.fillRect(button3X, button3Y, button3W, button3H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = new JFrame().getFontMetrics(g.getFont());
t = "Menu";
g.drawString(t, PDefense.width / 2 - metrics.stringWidth(t) / 2,
button3Y + button3H / 2);
// MOUSE LOCATION ETC.
button1O = PDefense.location.x >= button1X
&& PDefense.location.x <= button1X + button1W
&& PDefense.location.y >= button1Y
&& PDefense.location.y <= button1Y + button1H;
button3O = PDefense.location.x >= button3X
&& PDefense.location.x <= button3X + button3W
&& PDefense.location.y >= button3Y
&& PDefense.location.y <= button3Y + button3H;
if (PDefense.leftMouse && button1O) {
PDefense.paused = false;
PDefense.leftMouse = false;
}
if (PDefense.leftMouse && button3O) {
PDefense.PState = PDefense.state.MENU;
PDefense.leftMouse = false;
}
}
}

View file

@ -1,522 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class PDefense extends JFrame implements MouseMotionListener,
MouseListener, KeyListener, FocusListener {
public static final long serialVersionUID = 1L;
public static boolean leftMouse = false;
private FontMetrics metrics;
public static Point location;
private int button1W = 400, button1H = 60, button1X = 200, button1Y = 260;
private boolean button1O = false;
private int button2W = 400, button2H = 60, button2X = 200, button2Y = 330;
private boolean button2O = false;
private int button3W = 400, button3H = 60, button3X = 200, button3Y = 400;
private boolean button3O = false;
private int logowait = 80;
BufferedImage splash;
public static int optionsReferrer = 0;
private String version = "0.2.1";
Camera c;
MenuPause mp;
MenuOptions mo;
static int xmouse, ymouse;
static int width, height;
long oldTime, time;
static boolean paused = false;
boolean shiftPressed = false, tabPressed = false;
public static String appdata = System.getenv("APPDATA");
public static ArrayList<String> options;
static boolean autopause;
boolean ee = false;
JFrame eeTmp;
int switchMapDelay = 8;
/**
*
* @author Michael Zhang Copyright 2013 by pFusion
*
*/
public static enum state {
NULL, MENU, OPTIONS, GAME
}
public static state PState = state.NULL;
public static enum gstate {
PLAYING, PAUSED
}
public static gstate GState = gstate.PLAYING;
public PDefense() {
try {
// SEE IF DIRECTORY EXISTS
File mainDir = new File(appdata + File.separator + ".planar");
if (!(mainDir.exists() && mainDir.isDirectory())) {
mainDir.mkdir();
}
// SEE IF OPTIONS FILE EXISTS
boolean updated = false;
File optionsFile = new File(appdata + File.separator + ".planar"
+ File.separator + "options.dat");
if (!optionsFile.exists()) {
copyOptionsFile();
} else {
ArrayList<String> optionsTmp = new ArrayList<String>();
BufferedReader in = new BufferedReader(new FileReader(appdata
+ File.separator + ".planar" + File.separator
+ "options.dat"));
String line;
while ((line = in.readLine()) != null) {
optionsTmp.add(line);
}
in.close();
for (String option : optionsTmp) {
if (option.split("=")[0] == "version"
&& option.split("=")[1] == version) {
updated = true;
}
}
}
if (!updated) {
copyOptionsFile();
}
// LOAD OPTIONS
options = new ArrayList<String>();
BufferedReader in = new BufferedReader(new FileReader(appdata
+ File.separator + ".planar" + File.separator
+ "options.dat"));
String line;
while ((line = in.readLine()) != null) {
options.add(line);
}
in.close();
for (String option : options) {
if (option.split("=")[0].equals("autopause")) {
autopause = option.split("=")[1].toLowerCase().trim() == "true";
}
}
splash = ImageIO.read(PDefense.class.getResource("Splash.png"));
c = new Camera();
mp = new MenuPause();
mo = new MenuOptions();
setSize(800, 600);
setTitle("Planar Tower Defense");
setFont(PFont.getFont(30f));
setResizable(false);
setIconImage(ImageIO.read(PDefense.class.getResource("Icon.png")));
setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2
- getWidth() / 2, Toolkit.getDefaultToolkit()
.getScreenSize().height / 2 - getHeight() / 2);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setFocusable(true);
requestFocus();
addMouseMotionListener(this);
addMouseListener(this);
addKeyListener(this);
addFocusListener(this);
setFocusTraversalKeysEnabled(false);
width = getWidth();
height = getHeight();
addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
leftMouse = true;
}
public void mouseReleased(MouseEvent e) {
leftMouse = false;
}
});
Thread th = new Thread() {
public void run() {
try {
while (true) {
location = MouseInfo.getPointerInfo().getLocation();
location.setLocation(location.x - getLocation().x,
location.y - getLocation().y);
if (PState == state.MENU) {
button1O = location.x >= button1X
&& location.x <= button1X + button1W
&& location.y >= button1Y
&& location.y <= button1Y + button1H;
button2O = location.x >= button2X
&& location.x <= button2X + button2W
&& location.y >= button2Y
&& location.y <= button2Y + button2H;
button3O = location.x >= button3X
&& location.x <= button3X + button3W
&& location.y >= button3Y
&& location.y <= button3Y + button3H;
}
if (leftMouse && button1O) {
PState = state.GAME;
PDefense.leftMouse = false;
}
if (leftMouse && button2O) {
options(0);
PDefense.leftMouse = false;
}
if (leftMouse && button3O) {
System.out.println("Exiting the application!");
System.exit(0);
}
repaint();
Thread.sleep(50);
}
} catch (Exception e) {
System.err
.println("***** AN ERROR OCCURRED AT PDefense.java *****");
e.printStackTrace();
System.exit(0);
}
}
};
th.start();
} catch (Exception e) {
System.err
.println("***** AN ERROR OCCURRED AT PDefense.java *****");
e.printStackTrace();
System.exit(0);
}
}
public void paint(Graphics g) {
try {
Image buffer = createImage(getWidth(), getHeight());
Graphics2D g2 = (Graphics2D) buffer.getGraphics();
draw(g2);
g.drawImage(buffer, 0, 0, null);
g2.dispose();
} catch (Exception e) {
System.err
.println("***** AN ERROR OCCURRED AT PDefense.java *****");
e.printStackTrace();
System.exit(0);
}
}
public void draw(Graphics2D g) {
g.setRenderingHints(new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP));
if (logowait > 0) {
logowait -= 1;
g.drawImage(splash, 0, 0, null);
g.setColor(Color.black);
g.setFont(PFont.getFont(12));
// g.drawString("Menu in " + logowait + "u", 20, 40);
} else if (logowait == 0) {
logowait = -1;
PState = state.MENU;
} else {
if (PState == state.MENU) {
String t = "";
g.setColor(new Color(204, 102, 204));
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(40));
metrics = getFontMetrics(g.getFont());
t = "Planar Defense";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
180);
// PLAY BUTTON
g.setColor(button1O ? new Color(140, 70, 140) : new Color(102,
51, 102));
g.fillRect(button1X, button1Y, button1W, button1H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = getFontMetrics(g.getFont());
t = "Play";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
button1Y + button1H / 2);
// OPTION BUTTON
g.setColor(button2O ? new Color(140, 70, 140) : new Color(102,
51, 102));
g.fillRect(button2X, button2Y, button2W, button2H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = getFontMetrics(g.getFont());
t = "Options";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
button2Y + button2H / 2);
// QUIT BUTTON
g.setColor(button3O ? new Color(140, 70, 140) : new Color(102,
51, 102));
g.fillRect(button3X, button3Y, button3W, button3H);
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(25));
metrics = getFontMetrics(g.getFont());
t = "Exit";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
button3Y + button3H / 2);
// MADE BY
g.setColor(new Color(255, 255, 255));
g.setFont(PFont.getFont(15));
metrics = getFontMetrics(g.getFont());
t = "Made by Michael Zhang.";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
570);
t = "© 2013 by pFusion";
g.drawString(t, getWidth() / 2 - metrics.stringWidth(t) / 2,
585);
} else if (PState == state.OPTIONS) {
mo.draw(g);
} else if (PState == state.GAME) {
time = System.currentTimeMillis() - oldTime;
oldTime += time;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHints(new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP));
update();
draw2(g);
}
}
}
public void update() {
if (!paused) {
switchMapDelay -= 1;
if (switchMapDelay <= 0)
switchMapDelay = 0;
if (tabPressed && switchMapDelay == 0) {
if (shiftPressed) {
c.prevMap();
} else {
c.nextMap();
}
tabPressed = false;
switchMapDelay = 8;
}
c.update(time);
}
}
public void menuUpdate() {
}
public void draw2(Graphics2D g) {
if (GState == gstate.PLAYING) {
gameDraw(g);
} else if (GState == gstate.PAUSED) {
}
}
public void gameDraw(Graphics2D g) {
c.draw(g);
if (paused) {
menuDraw(g);
}
}
public void menuDraw(Graphics2D g) {
mp.draw(g);
}
public static void options(int referrer) {
// REFERRER ID
//
// 0: MENU
// 1: GAME
optionsReferrer = referrer;
PState = state.OPTIONS;
}
public void copyOptionsFile() throws Exception {
File optionsFile = new File(appdata + File.separator + ".planar"
+ File.separator + "options.dat");
BufferedReader in = new BufferedReader(new InputStreamReader(
PDefense.class.getResourceAsStream("defaultOptions.dat")));
PrintWriter out = new PrintWriter(optionsFile);
String line;
while ((line = in.readLine()) != null) {
out.println(line);
}
in.close();
out.flush();
out.close();
}
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
if (GState == gstate.PLAYING && autopause) {
paused = true;
}
}
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_TAB:
tabPressed = true;
break;
case KeyEvent.VK_SHIFT:
shiftPressed = true;
break;
case KeyEvent.VK_ESCAPE:
if (GState == gstate.PLAYING) {
paused = !paused;
}
break;
// E
case KeyEvent.VK_Q:
eeTmp = new JFrame();
eeTmp.setUndecorated(true);
eeTmp.setSize(Toolkit.getDefaultToolkit().getScreenSize());
eeTmp.setAlwaysOnTop(true);
eeTmp.addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
ee = false;
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
});
ee = true;
eeTmp.setVisible(true);
break;
}
}
public void keyReleased(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_TAB:
tabPressed = false;
break;
case KeyEvent.VK_SHIFT:
shiftPressed = false;
break;
}
}
public void keyTyped(KeyEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
leftMouse = true;
}
public void mouseReleased(MouseEvent e) {
leftMouse = false;
}
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
}
public static void main(String[] args) {
new PDefense();
}
}

View file

@ -1,21 +0,0 @@
package pFusion.tmp;
import java.awt.Font;
public class PFont extends Font {
public static final long serialVersionUID = 1L;
protected PFont(Font f) {
super(f);
}
public static Font getFont(float size) {
try {
return Font.createFont(Font.TRUETYPE_FONT,
PFont.class.getResourceAsStream("Nexa.ttf")).deriveFont(
size);
} catch (Exception e) {
return new Font("sans", Font.PLAIN, (int) size);
}
}
}

View file

@ -1,106 +0,0 @@
package pFusion.tmp;
import java.awt.Color;
public class Tile {
private int x, y, c;
/*
*
* KEY:
*
* 0 = AVAILABLE TILE; 1 = ROAD TILE; 2 = ENTER TILE; 3 = EXIT TILE;
*/
public Tile(int x, int y, int c) {
this.x = x;
this.y = y;
this.c = c;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setC(int c) {
this.c = c;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getC() {
return this.c;
}
public Color getHoverColor(int theme) {
Color tmp = getColor(theme);
int k = 30;
int r = tmp.getRed() + k, b = tmp.getBlue() + k, g = tmp.getGreen() + k;
if (r > 255)
r = 255;
if (g > 255)
g = 255;
if (b > 255)
b = 255;
return new Color(r, g, b, tmp.getAlpha());
}
public Color getPressColor(int theme) {
Color tmp = getColor(theme);
int k = 30;
int r = tmp.getRed() - k, b = tmp.getBlue() - k, g = tmp.getGreen() - k;
if (r < 0)
r = 0;
if (g < 0)
g = 0;
if (b < 0)
b = 0;
return new Color(r, g, b, tmp.getAlpha());
}
public Color getColor(int theme) {
switch (c) {
case 0:
return new Color(225, 225, 225, 85);
case 1:
switch (theme) {
case 0:
return new Color(200, 64, 64, 85);
case 1:
return new Color(64, 200, 64, 85);
case 2:
return new Color(64, 64, 200, 85);
}
case 2:
switch (theme) {
case 0:
return new Color(175, 32, 32, 85);
case 1:
return new Color(32, 175, 32, 85);
case 2:
return new Color(32, 32, 175, 85);
}
case 3:
switch (theme) {
case 0:
return new Color(175, 32, 32, 85);
case 1:
return new Color(32, 175, 32, 85);
case 2:
return new Color(32, 32, 175, 85);
}
default:
return new Color(0, 0, 0, 85);
}
}
}

View file

@ -1,6 +0,0 @@
5x5
2,1,1,1,0
0,0,0,1,0
0,1,1,1,0
0,1,0,0,0
0,1,1,1,3

View file

@ -1,6 +0,0 @@
5x5
2,1,1,0,0
0,0,1,0,0
0,0,1,0,0
0,0,1,0,0
0,0,1,1,3

View file

@ -1,6 +0,0 @@
5x5
2,1,0,0,0
0,1,1,0,0
0,0,1,0,0
0,0,1,1,0
0,0,0,1,3

View file

@ -1,109 +1,109 @@
<?php
error_reporting(0);
// DEFINE FUNCTIONS
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
session_start();
include("../auth.inc.php");
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789", 50);
$permitted = array(
'doc','docx','log','msg','odt','pages','rtf','tex','txt','wpd','wps',
'csv','dat','gbr','ged','ibooks','key','keychain','pps','ppt','pptx','sdf','tar','vcf','xml',
'aif','iff','m3u','m4a','mid','midi','mp3','mpa','ra','wav','wma',
'3g2','3gp','asf','asx','avi','flv','mov','mp4','mpg','rm','srt','swf','vob','wmv',
'3dm','3ds','max','obj',
'bmp','dds','gif','jpg','png','psd','pspimage','tga','thm','tif','tiff','yuv',
'ai','eps','ps','svg',
'indd','pct','pdf',
'xlr','xls','xlsx',
'accdb','db','dbf','mdb','pdb','sql',
'apk','app','bat','cgi','com','exe','gadget','jar','pif','vb','wsf',
'dem','gam','nes','rom','sav',
'dwg','dxf',
'gpx','kml',
'asp','aspx','cer','cfm','csr','css','htm','html','js','jsp','php','rss','xhtml',
'crx','plugin',
'fnt','fon','otf','ttf',
'cab','cpl','cur','deskthemepack','dll','dmp','drv','icns','ico','lnk','sys',
'cfg','ini','prf',
'hqx','mim','uue',
'7z','cbr','deb','gz','pkg','rar','rpm','sit','sitx','zip','zipx',
'bin','cue','dmg','iso','mdf','toast','vcd',
'asm','c','class','cpp','cs','dtd','fla','h','java','lua','m','pl','py','sh','sln','vcxproj','xcodeproj',
'bak','tmp',
'crdownload','ics','msi','part','torrent',
'scribe',
);
// print_r ( $permitted);
if ($_SESSION['logged'] == 1 && isset($_FILES['uploaded'])) {
$username = $_SESSION['username'];
$query2 = mysql_query("select * from `lexis_docbank` where owner = '" . $_SESSION['username'] . "'") or die("Error: " . mysql_error());
$usage = 0;
while ($row2 = mysql_fetch_array($query2)) {
$fileLoc = "files/" . $row2['id'] . "." . $row2['type'];
if ($row2['type']!="lexis_directory") {
$fileSize = filesize($fileLoc);
$usage += $fileSize;
}
}
$err = "";
if (!isset($_POST['uploaded'])) {
$err = "No file uploaded.";
}
$use_dir = $_SESSION['current_dir'];
echo "Directory: ".$use_dir."<br />";
define("MAX_FILE_SIZE", 1024 * 1024 * 50);
define("UPLOAD_DIR", "files/");
$type = strtolower(end(explode('.', $_FILES['uploaded']['name'])));
$file = $id . "." . $type;
echo "Destination file: " . $file;
echo "<p>Wow! ".count($permitted)." extensions supported! <a href='mailto:mzhang@anixospecifications.com' target='_blank'>Request more extensions</a></p>";
if (in_array($type,$permitted) && $_FILES['uploaded']['size'] > 0 && $_FILES['uploaded']['size'] <= MAX_FILE_SIZE) {
switch ($_FILES['image']['error']) {
case 0:
if (!file_exists(UPLOAD_DIR . $file)) {
$success = move_uploaded_file($_FILES['uploaded']['tmp_name'], UPLOAD_DIR . $file);
} else {
unlink(UPLOAD_DIR . $file);
$success = move_uploaded_file($_FILES['uploaded']['tmp_name'], UPLOAD_DIR . $file);
}
if ($success) {
$result = "Your file was uploaded.<br /><a href='index.php'>&laquo; Back to LEXIS</a><script type='text/javascript'>location.href='index.php';</script>";
$pieces = explode('.', $_FILES['uploaded']['name']);
$query = mysql_query("insert into lexis_docbank (id,title,container,owner,type,dateMod) values('$id','" . $pieces[0] . "','$use_dir','$username','" . $type . "',NOW())") or die("Can't connect: " . mysql_error());
} else {
$result = "Error uploading your file. Please try again. If this problem persists, contact ANIXO Specifications and we will try to help you.";
}
break;
case 8:
$result = "Error uploading your file. Please try again. If this problem persists, contact ANIXO Specifications and we will try to help you.";
break;
case 4:
$result = "You didn't upload a file.";
break;
default:
break;
}
} else {
$result = "Your file is either too big or is not a file of the specified upload types.";
}
}
if (isset($result)) {
echo "<p><b>$result</b></p>";
}
?>
<?php
error_reporting(0);
// DEFINE FUNCTIONS
function get_random_string($valid_chars, $length) {
$random_string = "";
$num_valid_chars = strlen($valid_chars);
for ($i = 0; $i < $length; $i++) {
$random_pick = mt_rand(1, $num_valid_chars);
$random_char = $valid_chars[$random_pick-1];
$random_string .= $random_char;
}
return $random_string;
}
session_start();
include("../auth.inc.php");
$id = get_random_string("ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwyz0123456789", 50);
$permitted = array(
'doc','docx','log','msg','odt','pages','rtf','tex','txt','wpd','wps',
'csv','dat','gbr','ged','ibooks','key','keychain','pps','ppt','pptx','sdf','tar','vcf','xml',
'aif','iff','m3u','m4a','mid','midi','mp3','mpa','ra','wav','wma',
'3g2','3gp','asf','asx','avi','flv','mov','mp4','mpg','rm','srt','swf','vob','wmv',
'3dm','3ds','max','obj',
'bmp','dds','gif','jpg','png','psd','pspimage','tga','thm','tif','tiff','yuv',
'ai','eps','ps','svg',
'indd','pct','pdf',
'xlr','xls','xlsx',
'accdb','db','dbf','mdb','pdb','sql',
'apk','app','bat','cgi','com','exe','gadget','jar','pif','vb','wsf',
'dem','gam','nes','rom','sav',
'dwg','dxf',
'gpx','kml',
'asp','aspx','cer','cfm','csr','css','htm','html','js','jsp','php','rss','xhtml',
'crx','plugin',
'fnt','fon','otf','ttf',
'cab','cpl','cur','deskthemepack','dll','dmp','drv','icns','ico','lnk','sys',
'cfg','ini','prf',
'hqx','mim','uue',
'7z','cbr','deb','gz','pkg','rar','rpm','sit','sitx','zip','zipx',
'bin','cue','dmg','iso','mdf','toast','vcd',
'asm','c','class','cpp','cs','dtd','fla','h','java','lua','m','pl','py','sh','sln','vcxproj','xcodeproj',
'bak','tmp',
'crdownload','ics','msi','part','torrent',
'scribe',
);
// print_r ( $permitted);
if ($_SESSION['logged'] == 1 && isset($_FILES['uploaded'])) {
$username = $_SESSION['username'];
$query2 = mysql_query("select * from `keepit_docbank` where owner = '" . $_SESSION['username'] . "'") or die("Error: " . mysql_error());
$usage = 0;
while ($row2 = mysql_fetch_array($query2)) {
$fileLoc = "files/" . $row2['id'] . "." . $row2['type'];
if ($row2['type']!="keepit_directory") {
$fileSize = filesize($fileLoc);
$usage += $fileSize;
}
}
$err = "";
if (!isset($_POST['uploaded'])) {
$err = "No file uploaded.";
}
$use_dir = $_SESSION['current_dir'];
echo "Directory: ".$use_dir."<br />";
define("MAX_FILE_SIZE", 1024 * 1024 * 50);
define("UPLOAD_DIR", "files/");
$type = strtolower(end(explode('.', $_FILES['uploaded']['name'])));
$file = $id . "." . $type;
echo "Destination file: " . $file;
echo "<p>Wow! ".count($permitted)." extensions supported! <a href='mailto:mzhang@anixospecifications.com' target='_blank'>Request more extensions</a></p>";
if (in_array($type,$permitted) && $_FILES['uploaded']['size'] > 0 && $_FILES['uploaded']['size'] <= MAX_FILE_SIZE) {
switch ($_FILES['image']['error']) {
case 0:
if (!file_exists(UPLOAD_DIR . $file)) {
$success = move_uploaded_file($_FILES['uploaded']['tmp_name'], UPLOAD_DIR . $file);
} else {
unlink(UPLOAD_DIR . $file);
$success = move_uploaded_file($_FILES['uploaded']['tmp_name'], UPLOAD_DIR . $file);
}
if ($success) {
$result = "Your file was uploaded.<br /><a href='index.php'>&laquo; Back to Keepit</a><script type='text/javascript'>location.href='index.php';</script>";
$pieces = explode('.', $_FILES['uploaded']['name']);
$query = mysql_query("insert into keepit_docbank (id,title,container,owner,type,dateMod) values('$id','" . $pieces[0] . "','$use_dir','$username','" . $type . "',NOW())") or die("Can't connect: " . mysql_error());
} else {
$result = "Error uploading your file. Please try again. If this problem persists, contact Keepit and we will try to help you.";
}
break;
case 8:
$result = "Error uploading your file. Please try again. If this problem persists, contact Keepit and we will try to help you.";
break;
case 4:
$result = "You didn't upload a file.";
break;
default:
break;
}
} else {
$result = "Your file is either too big or is not a file of the specified upload types.";
}
}
if (isset($result)) {
echo "<p><b>$result</b></p>";
}
?>
<link rel="stylesheet" href="../page.css" />