This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfileupload2.php
executable file
·118 lines (93 loc) · 3.04 KB
/
fileupload2.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
<?php
session_start();
require("include/functions.php");
$config_file = 'config.php';
if (file_exists($config_file)) {
require("config.php");
} else {
header("Location: error.php?e=config");
die();
}
require("include/apply_config.php");
$force_loggedin = TRUE;
require("include/check_login.php");
$random_cookie=mt_rand();
setcookie("random_cookie", $random_cookie, 0);
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>$app_custom_name - Upload file</title>";
require("include/get_css.php");
require("include/get_jqueryui.php");
if ($use_googleanalytics) {
echo $googleanalytics_code;
}
#Execute custom code for head, if set
if (is_file("$absolute_dir/customhead.php")) {
include("customhead.php");
}
?>
</head>
<body>
<!--Blueprint container-->
<div class="container">
<?php
require("include/topbar.php");
?>
<div class="span-24 last">
<hr noshade>
</div>
<div class="span-24 last">
<?php
mkdir("tmp/$random_cookie", 0777);
$target_path = "tmp/$random_cookie/";
$target_path = $target_path . basename( $_FILES['userfile']['name']);
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
$filename=basename( $_FILES['userfile']['name']);
exec('python include/soundcheck.py tmp/' . $random_cookie . '/' . $filename, $lastline, $retval);
if ($retval==0) {
echo "<div class=\"success\"><img src=\"images/accept.png\"> The file has been uploaded successfully.<br>";
$file_info=$lastline[0];
$file_info=explode(",",$file_info);
$sampling_rate=$file_info[0];
$no_channels=$file_info[1];
$file_format=$file_info[2];
$file_duration=$file_info[3];
$file_bits=$file_info[4];
#Get the size of the file
$soundfile_size=formatsize(filesize("tmp/$random_cookie/$filename"));
$fileID=$_POST["fileID"];
echo "File name: $filename<br>
File format: $file_format<br>
File size: $soundfile_size<br>
Number of channels: $no_channels<br>
Duration: $file_duration seconds<br>
Sampling Rate: $sampling_rate Hz<br>
Bits: $file_bits<br>
File ID: $fileID
</div>";
echo "<p><a href=\"openfile.php?filename=$filename&format=$file_format&duration=$file_duration&samprate=$sampling_rate&fileID=$fileID&no_channels=$no_channels\"><img src=\"images/drive_magnify.png\"> Open file</a>";
}
else {
#delete the folder and destroy cookie
delTree('tmp/' . $random_cookie . '/');
#setcookie("random_cookie", "", time()-3600);
$max=ini_get("upload_max_filesize");
echo "<div class=\"error\">The file is not a recognized sound file.</div><p>The accepted file formats are:<br>";
include("include/sox_formats.php");
}
}
else {
$max=ini_get("upload_max_filesize");
echo "<div class=\"error\">There was a problem with the upload or the file is too big. The maximum file size is $max. Please try again.</div>";
}
?>
</div>
<div class="span-24 last">
<?php
require("include/bottom.php");
?>
</div>
</div>
</body>
</html>