-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse.php
69 lines (64 loc) · 2.23 KB
/
analyse.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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Analyser</title>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src = "https://d3js.org/d3.v4.min.js"></script>
<?php
//check if file was posted
if (!isset($_FILES['file']) || !file_exists($_FILES['file']['tmp_name']) || !is_uploaded_file($_FILES['file']['tmp_name'])) {
echo '<meta http-equiv="refresh" content="2; url=index.php" />';
} else {
//if file exists
$fileArr = $_FILES['file'];
$fileLoc = "uploads/".str_replace(' ','',$fileArr['name']);
//prevent dir traversal
$basePath = getcwd();
$realBasePath = realpath($basePath);
$realFileLoc = realpath($fileLoc);
$fileData = '';
if ( !TRUE || ($realFileLoc === FALSE || strpos($realFileLoc,$realBasePath) !== 0) ) {
echo '<meta http-equiv="refresh" content="2; url=index.php" />';
} else {
//if no dir traversal
move_uploaded_file($fileArr['tmp_name'], $fileLoc);
$file = fopen($fileLoc, 'r');
$fileData = fread($file, filesize($fileLoc));
$fileData = htmlspecialchars($fileData);
$fileData = nl2br($fileData);
}//if-else dirTraversal
}//if-else fileExists
?>
</head>
<body>
<div id="chatText" style="display:none">'
<?php echo $fileData; ?>
</div>
<div id="loader">uploading to database</div>
<div id="container">
<input type="button" id='drop' value='Drop DB' style='display:none'>
<div class="total">
<svg id='totalMsgPie'></svg>
</div>
</div>
<!-- Script to drop database -->
<script>
$('#drop').click(function() {
$.ajax({
type:'POST',
url: 'php/dropDB.php',
async: false
});
history.go(-1);
});
</script>
<script src="js/Message.js" charset="utf-8"></script>
<script src="js/extract.js" charset="utf-8"></script>
<script src="js/database.js"></script>
<script src="js/draw.js"></script>
</body>
</html>