blob: a4b9e84805cec3bcf68b935046fba3d0af815b8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<?php
function print_browser($content){
// require_once("include.php");
if($_SERVER['REQUEST_METHOD'] == 'POST'){
//echo "created_folder : ". $_POST["foldername"] . " in ". $_GET["folder"];
if($_POST["task"]=="new-folder"){
create_folder($_POST["path"], $_POST["foldername"], /*$_POST["public"]?*/"PUBLIC"/*:"PRIVATE"*/);
}elseif($_POST["task"]=="upload"){
upload($_POST["path"]);
}
browse(collect_content($GLOBALS["db"], $_SESSION["username"] , $_POST["path"]));
}else{
browse(collect_content($GLOBALS["db"], $_GET["name"] , $_GET["folder"]));
}
}
function browse($content){
include("static/header.html");
if($_SESSION["login"] && $_SESSION["username"] == $_GET["name"]){
print_menu();
}
$file_list = "";
if($content != EMPTY_FOLDER){
foreach($content as $file){
$file_list .= get_item($file);
}
}
echo '<link rel="stylesheet" type="text/css" href="/static/browser.css">
<script>
function showNewFolder(){
document.getElementById("new-folder-bg").style.visibility = "visible";
return;
}
function hideNewFolder(){
document.getElementById("new-folder-bg").style.visibility = "hidden";
return;
}
function showUpload(){
document.getElementById("upload-bg").style.visibility = "visible";
return;
}
function hideUpload(){
document.getElementById("upload-bg").style.visibility = "hidden";
return;
}
</script>
<div id="new-folder-bg">
<div id="new-folder-area">
<h1 class="new-folder"> New Folder </h1>
<form id="new-folder-form" method="post" action="/'.$_GET["name"]."/".$_GET["folder"].'">
<input class="new-folder-input" id="new-folder-name" type="text" placeholder="name" name="foldername" required>
<input type="hidden" value="'.$_GET["folder"].'" name="path">
<input type="hidden" value="new-folder" name="task">
<label>Public</label><input style="display:inline; margin-left: 5px;" class="new-folder-input" type="checkbox" name="public">
<input onclick="hide-new-folder()" type="submit" id="button-input" class="new-folder-input" value="create">
</form>
</div>
</div>
<div id="upload-bg">
<div id="upload-area">
<h1 class="upload"> Upload </h1>
<form id="upload-form" method="post" action="/'.$_GET["name"]."/".$_GET["folder"].'" enctype="multipart/form-data">
<input class="upload-input" id="upload-file" type="file" placeholder="file" name="userfile" size=" 500000000" maxlength="100000000000000" required>
<input type="hidden" value="'.$_GET["folder"].'" name="path">
<input type="hidden" value="upload" name="task">
<label>Public</label><input class="upload-input" type="checkbox" name="share">
<input onclick="hide-upload()" type="submit" id="button-input" class="upload-input" value="upload">
</form>
</div>
</div>
<table>'.$file_list.'</table>';
include("static/footer.html");
}
function get_icon($file){
if($file[4]=="DIRECTORY"){
return '<td id="icon">'.get_link($file).'<img src="/static/img/icon_folder.svg" width="30px"></a></td>';
}else{
return '<td id="icon">'.get_link($file).'<img src="/static/img/icon_file.svg" width="30px"></a></td>';
}
}
function get_link($file){
$slash = (($_GET["folder"]!="" && substr($_GET["folder"], -1) != "/"))? "/" : "";
return '<a href="/'.$_GET["name"]."/".$_GET["folder"].$slash.$file[3].'/">';
}
function get_item($file){
return '<tr>'.get_icon($file).'<td>'.get_link($file).$file[3].'</a></td></tr>';
}
function print_menu(){
echo '<div id="menu">
<div class="menu-item" id="new-item" onclick="showNewFolder()" ><img src="/static/img/icon_new.svg" width="45px" onclick="showNewFolder()"></div>
<div class="menu-item" id="upload-item" onclick="showUpload()" ><img src="/static/img/icon_upload.svg" width="45px" onclick="showUpload()" ></div>
</div><!-- div menu-->';
}
|