-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.php
157 lines (139 loc) · 4.69 KB
/
home.php
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<style>
.custom-menu {
z-index: 1000;
position: absolute;
background-color: #ffffff;
border: 1px solid #0000001c;
border-radius: 5px;
padding: 8px;
min-width: 13vw;
}
a.custom-menu-list {
width: 100%;
display: flex;
color: #4c4b4b;
font-weight: 600;
font-size: 1em;
padding: 1px 11px;
}
span.card-icon {
position: absolute;
font-size: 3em;
bottom: .2em;
color: #ffffff80;
}
.file-item{
cursor: pointer;
}
a.custom-menu-list:hover,.file-item:hover,.file-item.active {
background: #80808024;
}
a.custom-menu-list span.icon{
width:1em;
margin-right: 5px
}
</style>
<div class="container-fluid">
<?php include('db_connect.php') ;
$files = $conn->query("SELECT f.*,u.name as uname FROM files f inner join users u on u.id = f.user_id where f.is_public = 1 order by date(f.date_updated) desc");
?>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="card col-md-4 bg-info float-left mb-3">
<div class="card-body text-white">
<h4><b>Available Users</b></h4>
<hr>
<span class="card-icon"><i class="fa fa-users"></i></span>
<h3 class="text-right"><b><?php echo $conn->query('SELECT * FROM users')->num_rows ?></b></h3>
</div>
</div>
<div class="card col-md-4 bg-primary ml-4 float-left">
<div class="card-body text-white">
<h4><b>Uploaded Files</b></h4>
<hr>
<span class="card-icon"><i class="fa fa-file"></i></span>
<h3 class="text-right"><b><?php echo $conn->query('SELECT * FROM files')->num_rows ?></b></h3>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row mt-3 ml-3 mr-3">
<div class="card col-md-12">
<div class="card-body">
<h5 class="card-title" style="font-weight: bold;">All Uploaded Files</h5>
<table width="100%" class="table table-responsive">
<tr>
<th width="20%" class="">Uploader</th>
<th width="30%" class="">Filename</th>
<th width="20%" class="">Date</th>
<th width="30%" class="">Description</th>
</tr>
<?php
while($row=$files->fetch_assoc()):
$name = explode(' ||',$row['name']);
$name = isset($name[1]) ? $name[0] ." (".$name[1].").".$row['file_type'] : $name[0] .".".$row['file_type'];
$img_arr = array('png','jpg','jpeg','gif','psd','tif');
$doc_arr =array('doc','docx');
$pdf_arr =array('pdf','ps','eps','prn');
$icon ='fa-file';
if(in_array(strtolower($row['file_type']),$img_arr))
$icon ='fa-image';
if(in_array(strtolower($row['file_type']),$doc_arr))
$icon ='fa-file-word';
if(in_array(strtolower($row['file_type']),$pdf_arr))
$icon ='fa-file-pdf';
if(in_array(strtolower($row['file_type']),['xlsx','xls','xlsm','xlsb','xltm','xlt','xla','xlr']))
$icon ='fa-file-excel';
if(in_array(strtolower($row['file_type']),['zip','rar','tar']))
$icon ='fa-file-archive';
?>
<tr class='file-item' data-id="<?php echo $row['id'] ?>" data-name="<?php echo $name ?>">
<td><i><?php echo ucwords($row['uname']) ?></i></td>
<td><large><span><i class="fa <?php echo $icon ?>"></i></span><b> <?php echo $name ?></b></large>
<input type="text" class="rename_file" value="<?php echo $row['name'] ?>" data-id="<?php echo $row['id'] ?>" data-type="<?php echo $row['file_type'] ?>" style="display: none">
</td>
<td><i><?php echo date('Y/m/d h:i A',strtotime($row['date_updated'])) ?></i></td>
<td><i><?php echo $row['description'] ?></i></td>
</tr>
<?php endwhile; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="menu-file-clone" style="display: none;">
<a href="javascript:void(0)" class="custom-menu-list file-option download"><span><i class="fa fa-download"></i> </span>Download</a>
</div>
<script>
//FILE
$('.file-item').bind("contextmenu", function(event) {
event.preventDefault();
$('.file-item').removeClass('active')
$(this).addClass('active')
$("div.custom-menu").hide();
var custom =$("<div class='custom-menu file'></div>")
custom.append($('#menu-file-clone').html())
custom.find('.download').attr('data-id',$(this).attr('data-id'))
custom.appendTo("body")
custom.css({top: event.pageY + "px", left: event.pageX + "px"});
$("div.file.custom-menu .download").click(function(e){
e.preventDefault()
window.open('download.php?id='+$(this).attr('data-id'))
})
})
$(document).bind("click", function(event) {
$("div.custom-menu").hide();
$('#file-item').removeClass('active')
});
$(document).keyup(function(e){
if(e.keyCode === 27){
$("div.custom-menu").hide();
$('#file-item').removeClass('active')
}
})
</script>