added shit

This commit is contained in:
Michael Zhang 2014-11-09 12:30:55 -06:00
commit df33b79437
155 changed files with 7604 additions and 0 deletions

BIN
LexisSync.exe Normal file

Binary file not shown.

BIN
LexisSync.jar Normal file

Binary file not shown.

157
about.php Normal file
View file

@ -0,0 +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>

9
ajax/deleteFile.php Normal file
View file

@ -0,0 +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 ");
?>
hai

13
ajax/getTitleForID.php Normal file
View file

@ -0,0 +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'];
?>

200
ajax/previewPane.php Normal file
View file

@ -0,0 +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 } ?>

118
ajax/searchAjax.php Normal file
View file

@ -0,0 +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>";
}
?>

9
ajax/switchView.php Normal file
View file

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

487
apps/cascade.php Normal file
View file

@ -0,0 +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>
</html>

41
apps/cascadeSave.php Normal file
View file

@ -0,0 +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!";
?>

BIN
apps/images/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
apps/images/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
apps/images/cut.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
apps/images/new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
apps/images/paste.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
apps/images/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

575
apps/scribe.php Normal file
View file

@ -0,0 +1,575 @@
<?php
$title = isset($_GET['title'])?$_GET['title']:"Untitled Document";
$not_allowed = array("\"","\'","\\",";","(",")","-");
foreach ($not_allowed as $char) {
$words = str_replace($char,"",$title);
}
// 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.".scribe")) 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>)";
}
?>
<!--
SCRIBE Word 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>Scribe Word Editor</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 #scribeTab {
position:absolute;
background-color:#06C;
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>
<div id="container">
<?php
if ($_SESSION['logged']==1) {
?>
<div id="topbar">
<div id="scribeTab">SCRIBE</div>
<div id="title"><span id="unsaved"></span><span id="actualTitle"><?php echo $title; ?></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>
<div id="editor" contenteditable></div>
<script>
function getSelectionHtml() {
var t = "";
if (window.getSelection) {
t = window.getSelection();
} else if (document.getSelection) {
t = document.getSelection();
} else if (document.selection) {
t = document.selection.createRange().text;
}
if (t.length > 0) {
return t;
}
return "";
}
$("#editor").mouseup(function (e) {
var font_family = $(e.srcElement).css("fontFamily").split(",")[0].trim().replace(/['"]/g,'');
document.getElementById("fontChooser").value = font_family;
});
</script>
<!-- MODALS -->
<div id="retitleDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Retitle Document</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:"scribeSlideMenuAjax.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:"scribeSave.php",
data:{id:"<?php echo $id;?>",
title:$("#title #actualTitle").html(),
contents:$("#editor").html(),
owner:"<?php echo $_SESSION['username'];?>",
dir:"<?php echo $dir; ?>"},
dataType:"html",
success:function(msg) {
$("#message").html(msg);
document.title = $("#title #actualTitle").html()+" - Scribe Document";
unsaved = false;
}
});
}
// KEYBOARD SHORTCUTS
shortcut.add("Ctrl+S",function() {
save();
},{'propagate':false});
shortcut.add("Tab",function() {
document.execCommand("indent",false,null);
},{'propagate':false});
shortcut.add("Shift+Tab",function() {
document.execCommand("outdent",false,null);
},{'propagate':false});
shortcut.add("Ctrl+B",function() {
document.execCommand("bold",false,null);
},{'propagate':false});
shortcut.add("Ctrl+I",function() {
document.execCommand("italic",false,null);
},{'propagate':false});
shortcut.add("Ctrl+U",function() {
document.execCommand("underline",false,null);
},{'propagate':false});
shortcut.add("Ctrl+.",function() {
document.execCommand("superscript",false,null);
},{'propagate':false});
shortcut.add("Ctrl+,",function() {
document.execCommand("subscript",false,null);
},{'propagate':false});
shortcut.add("Ctrl+Alt+1",function() {
document.execCommand("fontSize",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Alt+2",function() {
document.execCommand("fontSize",false,2);
},{'propagate':false});
shortcut.add("Ctrl+Alt+3",function() {
document.execCommand("fontSize",false,3);
},{'propagate':false});
shortcut.add("Ctrl+Alt+4",function() {
document.execCommand("fontSize",false,4);
},{'propagate':false});
shortcut.add("Ctrl+Alt+5",function() {
document.execCommand("fontSize",false,5);
},{'propagate':false});
shortcut.add("Ctrl+Alt+6",function() {
document.execCommand("fontSize",false,6);
},{'propagate':false});
shortcut.add("Ctrl+Alt+7",function() {
document.execCommand("fontSize",false,7);
},{'propagate':false});
shortcut.add("Ctrl+Shift+L",function() {
document.execCommand("justifyLeft",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Shift+E",function() {
document.execCommand("justifyCenter",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Shift+R",function() {
document.execCommand("justifyRight",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Shift+J",function() {
document.execCommand("justifyFull",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Shift+7",function() {
document.execCommand("insertOrderedList",false,1);
},{'propagate':false});
shortcut.add("Ctrl+Shift+8",function() {
document.execCommand("insertUnorderedList",false,1);
},{'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 Document"; ?>");
$("#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 } ?>
</span>
</body>
</html>

41
apps/scribeSave.php Normal file
View file

@ -0,0 +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!";
?>

View file

@ -0,0 +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;
}
?>

223
apps/shortcut.js Normal file
View file

@ -0,0 +1,223 @@
/**
* http://www.openjs.com/scripts/events/keyboard_shortcuts/
* Version : 2.01.B
* By Binny V A
* License : BSD
*/
shortcut = {
'all_shortcuts':{},//All the shortcuts are stored in this array
'add': function(shortcut_combination,callback,opt) {
//Provide a set of default options
var default_options = {
'type':'keydown',
'propagate':false,
'disable_in_input':false,
'target':document,
'keycode':false
}
if(!opt) opt = default_options;
else {
for(var dfo in default_options) {
if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
}
}
var ele = opt.target;
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
var ths = this;
shortcut_combination = shortcut_combination.toLowerCase();
//The function to be called at keypress
var func = function(e) {
e = e || window.event;
if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
var element;
if(e.target) element=e.target;
else if(e.srcElement) element=e.srcElement;
if(element.nodeType==3) element=element.parentNode;
if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
}
//Find Which key is pressed
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code).toLowerCase();
if(code == 188) character=","; //If the user presses , when the type is onkeydown
if(code == 190) character="."; //If the user presses , when the type is onkeydown
var keys = shortcut_combination.split("+");
//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
var kp = 0;
//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
var shift_nums = {
"`":"~",
"1":"!",
"2":"@",
"3":"#",
"4":"$",
"5":"%",
"6":"^",
"7":"&",
"8":"*",
"9":"(",
"0":")",
"-":"_",
"=":"+",
";":":",
"'":"\"",
",":"<",
".":">",
"/":"?",
"\\":"|"
}
//Special Keys - and their codes
var special_keys = {
'esc':27,
'escape':27,
'tab':9,
'space':32,
'return':13,
'enter':13,
'backspace':8,
'scrolllock':145,
'scroll_lock':145,
'scroll':145,
'capslock':20,
'caps_lock':20,
'caps':20,
'numlock':144,
'num_lock':144,
'num':144,
'pause':19,
'break':19,
'insert':45,
'home':36,
'delete':46,
'end':35,
'pageup':33,
'page_up':33,
'pu':33,
'pagedown':34,
'page_down':34,
'pd':34,
'left':37,
'up':38,
'right':39,
'down':40,
'f1':112,
'f2':113,
'f3':114,
'f4':115,
'f5':116,
'f6':117,
'f7':118,
'f8':119,
'f9':120,
'f10':121,
'f11':122,
'f12':123
}
var modifiers = {
shift: { wanted:false, pressed:false},
ctrl : { wanted:false, pressed:false},
alt : { wanted:false, pressed:false},
meta : { wanted:false, pressed:false} //Meta is Mac specific
};
if(e.ctrlKey) modifiers.ctrl.pressed = true;
if(e.shiftKey) modifiers.shift.pressed = true;
if(e.altKey) modifiers.alt.pressed = true;
if(e.metaKey) modifiers.meta.pressed = true;
for(var i=0; k=keys[i],i<keys.length; i++) {
//Modifiers
if(k == 'ctrl' || k == 'control') {
kp++;
modifiers.ctrl.wanted = true;
} else if(k == 'shift') {
kp++;
modifiers.shift.wanted = true;
} else if(k == 'alt') {
kp++;
modifiers.alt.wanted = true;
} else if(k == 'meta') {
kp++;
modifiers.meta.wanted = true;
} else if(k.length > 1) { //If it is a special key
if(special_keys[k] == code) kp++;
} else if(opt['keycode']) {
if(opt['keycode'] == code) kp++;
} else { //The special keys did not match
if(character == k) kp++;
else {
if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
character = shift_nums[character];
if(character == k) kp++;
}
}
}
}
if(kp == keys.length &&
modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
modifiers.shift.pressed == modifiers.shift.wanted &&
modifiers.alt.pressed == modifiers.alt.wanted &&
modifiers.meta.pressed == modifiers.meta.wanted) {
callback(e);
if(!opt['propagate']) { //Stop the event
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = false;
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
}
}
}
this.all_shortcuts[shortcut_combination] = {
'callback':func,
'target':ele,
'event': opt['type']
};
//Attach the function with the event
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
else ele['on'+opt['type']] = func;
},
//Remove the shortcut - just specify the shortcut and I will remove the binding
'remove':function(shortcut_combination) {
shortcut_combination = shortcut_combination.toLowerCase();
var binding = this.all_shortcuts[shortcut_combination];
delete(this.all_shortcuts[shortcut_combination])
if(!binding) return;
var type = binding['event'];
var ele = binding['target'];
var callback = binding['callback'];
if(ele.detachEvent) ele.detachEvent('on'+type, callback);
else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
else ele['on'+type] = false;
}
}

16
apps/template.php Normal file
View file

@ -0,0 +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>
</html>

31
downloadFile.php Normal file
View file

@ -0,0 +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();
?>

31
dtree.css Normal file
View file

@ -0,0 +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;
}

349
dtree.js Normal file
View file

@ -0,0 +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;
}
};

BIN
icons/bmp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
icons/cascade.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
icons/crdownload.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
icons/crx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
icons/csv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

5
icons/desktop.ini Normal file
View file

@ -0,0 +1,5 @@
[.ShellClassInfo]
InfoTip=This folder is shared online.
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
IconIndex=12

BIN
icons/doc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
icons/docx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
icons/gif.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
icons/jar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
icons/jpg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/log.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
icons/mp3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
icons/msg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
icons/odt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
icons/pages.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
icons/pdf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
icons/png.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/rar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

BIN
icons/rtf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
icons/scribe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
icons/tex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
icons/txt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
icons/xls.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/xlsx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
icons/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
images/about/free.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
images/about/stats.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 KiB

BIN
images/closeIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
images/dTree/base.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

BIN
images/dTree/cd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
images/dTree/empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
images/dTree/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
images/dTree/folderopen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
images/dTree/globe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
images/dTree/join.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
images/dTree/joinbottom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
images/dTree/line.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
images/dTree/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
images/dTree/page.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
images/dTree/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
images/dTree/plusbottom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
images/file.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
images/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

927
index.php Normal file
View file

@ -0,0 +1,927 @@
<?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_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;
}
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">
body {
overflow:hidden;
}
#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;
z-index:106;
}
#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;
margin:0px;
box-shadow: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;
border-right:4px solid #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;
}
#mainContent {
position:absolute;
right:0px;
width:70%;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
overflow:auto;
margin:0px;
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;
}
.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:#E2E2E2;
margin-bottom:10px;
/* box-shadow:inset 0px 3px 5px #999; */
border:1px solid #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:#EAEAEA;
text-decoration:none;
}
#menu a.btn:active {
background-color:#D7D7D7;
}
.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;
height:0px;
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;
}
/* * {border:1px solid #F00;} */
#previewPane {
z-index:110;
position:absolute;
right:0px;
width:30%;
box-sizing:border-box; -moz-box-sizing:border-box;
padding:15px;
overflow:auto;
margin:0px;
border-left:4px solid #999;
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;
}
#previewPane #closeBtn {
z-index:111;
position:absolute;
width:25px;
height:25px;
cursor:pointer;
right:10px;
top:10px;
}
</style>
<script>
function preventOverScroll(scrollPane) {
var CAPTURE_PHASE = true;
var BUBBLE_PHASE = false;
var allowScrollUp = true, allowScrollDown = true, lastY = 0;
scrollPane.addEventListener
('touchstart',
function(e) {
allowScrollUp = (this.scrollTop > 0);
allowScrollDown = (this.scrollTop < this.scrollHeight - this.clientHeight);
lastY = e.pageY;
},
CAPTURE_PHASE);
scrollPane.addEventListener
('touchmove',
function (e) {
var up = (e.pageY > lastY);
var down = ! up;
lastY = event.pageY;
if ((up && allowScrollUp) || (down && allowScrollDown)) {
e.stopPropagation();
} else {
e.preventDefault();
}
},
CAPTURE_PHASE);
};
document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
preventOverScroll(document.getElementById("mainContent"));
preventOverScroll(document.getElementById("navTree"));
preventOverScroll(document.getElementById("previewPane"));
</script>
</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
$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` where owner='".$_SESSION['username']."' and type='lexis_directory'") or die("Error: " . mysql_error());
while ($frow = mysql_fetch_array($fquery)) {
array_push ($t,$frow);
}
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>
<p style="width:100%; text-align:center;">
<a href="LexisSync.exe" class="button color2" style="width:50%; box-sizing:border-box; -moz-box-sizing:border-box; display:inline-block; text-align:center;" target="_blank">LEXIS Sync Tool<br /><small>Windows Executable</small></a><a href="LexisSync.jar" class="button color3" style="width:50%; box-sizing:border-box; -moz-box-sizing:border-box; display:inline-block; text-align:center;" target="_blank">LEXIS Sync Tool<br /><small>Universal JAR</small></a>
</p>
</div>
<div id="mainContent">
<?php if (count($totalfiles)<1 && $current_dir==$row['lexis_dir']) { ?>
<div id="welcomeSign" style="width:70%; background-color:#FAFAFA; padding:15px; border:1px solid #999; position:relative;">
<h2>Welcome to LEXIS!</h2>
<p>LEXIS is a convenient place to store your files, where you can access them from different devices. To get started, head over to the top left and click the File button. There you can create or upload a file. You have 10 GB of available online storage space.</p>
<p>Thanks for using LEXIS!</p>
<a href="javascript:$('#welcomeSign').slideUp();" style="position:absolute; top:10px; right:10px;"><img src="images/closeIcon.png" /></a>
</div>
<?php } else { ?>
<?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, filesize_of_folder($file['id']));
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="text-align:left; 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><a href='javascript:showPreviewPane(\"".$ids[$i]."\");'>" . $titles[$i] . "</a></td>";
echo "<td>" . filesize_format($sizes[$i]) . "</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='javascript:showPreviewPane(\"".$ids[$i]."\");'>" . $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" id="name" class="tf" autocomplete="off" />
<input type="submit" class="button color2" value="Create Folder!" />
</form>
</p>
</div>
</div>
<div id="renameDialog" class="dialog">
<div class="mask"></div>
<div class="window">
<p><b>Rename Item</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>Rename "<span id="renameSource"></span>" to:</p>
<p>
<form action="rename.php" method="POST">
<input type="hidden" name="renameFormItem" id="renameFormItem" value="" />
<input type="text" name="name" class="tf" autocomplete="off" />
<input type="submit" class="button color2" value="Rename" />
</form>
</p>
</div>
</div>
<script type="text/javascript">
var currentMenu = "fileBtn";
$("#previewPane").css("right","-30%");
function showPreviewPane(id) {
$("#previewPane").css("right","0px");
$("#mainContent").css("right","30%");
$("#navTree").css("left","-30%");
$("#previewPane").html("Loading file information...");
$.ajax({
type:"POST",
url:"ajax/previewPane.php",
data: {id:id},
dataType: "html",
success: function (msg) {
$("#previewPane").html(msg);
}
});
hideMenu();
}
function closePreviewPane() {
$("#previewPane").css("right","-30%");
$("#mainContent").css("right","0px");
$("#navTree").css("left","0px");
}
$("#searchResults").css("top",$("#bars").position().top + $("#bars").height());
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());
$("#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");
$("#renameDialog .window").css("left",(window.innerWidth/2-150)+"px");
$("#renameDialog .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);
$("#renameDialog .window").css("width",300);
$("#renameDialog .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("top",$("#bars").position().top+$("#bars").height()+$("#searchBar").height());
$("#searchResults").css("opacity",1);
$("#searchResults").css("padding",15);
}
function hideResults() {
$("#searchResults").css("top",$("#bars").position().top+$("#bars").height());
$("#searchResults").height("0px");
$("#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:location.href=\"about.php\"' class='btn'>About LEXIS</a>";
} else if ($(this).attr("id")=="actionsBtn") {
content = "<h2>Actions</h2><a href='javascript:newDirBtn();' class='btn'>Create Folder</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 renameBtn(id) {
$(".dialog").fadeOut("fast");
$("#renameDialog #renameFormItem").val(id);
$.ajax({
type:"POST",
url:"ajax/getTitleForID.php",
data: {ID:id},
dataType: "html",
success: function (msg) {
$("#renameDialog #renameSource").html(msg);
$("#renameDialog #renameTo").val("");
$("#renameDialog").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; ?> - LEXIS Cloud Office";
</script>
<?php } else { ?>
<p>You have to be signed in to use LEXIS!</p>
<p>&nbsp;</p>
<?php } ?>
</div>
</body>
</html>

808
index_1.php Normal file
View file

@ -0,0 +1,808 @@
<?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>

32
newdir.php Normal file
View file

@ -0,0 +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
}
}
?>

13
rename.php Normal file
View file

@ -0,0 +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";
</script>

View file

@ -0,0 +1,70 @@
//
// 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

@ -0,0 +1,72 @@
//
// 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

@ -0,0 +1,96 @@
//
// 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

@ -0,0 +1,61 @@
//
// 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

@ -0,0 +1,67 @@
//
// 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

@ -0,0 +1,79 @@
//
// 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

@ -0,0 +1,51 @@
//
// 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

@ -0,0 +1,56 @@
//
// 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

@ -0,0 +1,58 @@
//
// 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

@ -0,0 +1,88 @@
//
// 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

@ -0,0 +1,52 @@
//
// 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

@ -0,0 +1,79 @@
//
// 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

@ -0,0 +1,47 @@
//
// 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

@ -0,0 +1,55 @@
//
// 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.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
temp/7232wall.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

BIN
temp/Blocks.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
temp/Bouken Desho Desho.pdf Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more