-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_page.php
64 lines (60 loc) · 2.57 KB
/
main_page.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
<?php
echo "<link rel='stylesheet' href='main_page.css'>";
echo "<link rel='stylesheet' href='form.css'>";
if($_COOKIE['auth'] == false){
echo'<div class ="error">Please login
<a href="/" class="back-btn">Exit to main menu</a></div>';
}else{
function deleteFile($file){
unlink("upload/".$file."");
header('Location: delete.php');
}
if (isset($_GET['delete'])) {
deleteFile($_GET['delete']);
}
echo "
<div class='wrap'>
<div class='welcome'>
<a href='logout.php'><div class='logout'><img src='logout.png'><a href='logout.php'>Logout</div></a></a>
<a href='download.php'><div class='download'><img src='icon_downl.png'><a href='download.php'>Upload new file</div></a></a>
<div class='enter'>You are logged in as: <div class='name'> ". $_COOKIE['name_ldap'].' '. $_COOKIE['surname_ldap'] ."</div><br></div></div>
<div class='access'>Available files:</div>
</div>";
function get_file_extension($file_path) {
$basename = basename($file_path);
if ( strrpos($basename, '.')!==false ) {
$file_extension = substr($basename, strrpos($basename, '.') + 1);
} else {
$file_extension = false;
}
return $file_extension;
}
$dir = '/upload';
$f = scandir($_SERVER['DOCUMENT_ROOT'].$dir);
foreach ($f as $file) {
if ($file != '.' and $file != '..') {
$name = $file;
$name = str_replace(' ','',$name);
$name = mb_strimwidth($name = wordwrap($name,30,'<br>',true),0,60,"...");
if (get_file_extension($dir.$file) == 'doc' or get_file_extension($dir.$file) == 'docx') {
echo '<div class="item"><img src="icon.png" alt="icon">
' . $name . '
<div class="btns"><a href="http://docs.google.com/viewer?url=http://your_domen' . $dir . '/' . $file . '" class="down_btn">Открыть</a>
<a class="del_btn" href="main_page.php?delete=' . $file . '">Удалить</a><br></div>
</div>';
} else {
echo '<div class="item"><img src="icon.png" alt="icon">
' . $name . '
<div class="btns"><a href="' . $dir . '/' . $file . '" class="down_btn">Opend</a>
<a class="del_btn" href="main_page.php?delete=' . $file . '">Delete</a><br></div>
</div>';
}
}
}
echo '
<title>Documents</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@300&display=swap" rel="stylesheet">'; }
?>