-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist_datafiles.php
More file actions
87 lines (76 loc) · 2.98 KB
/
list_datafiles.php
File metadata and controls
87 lines (76 loc) · 2.98 KB
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
<?php
/*
* list_files.php
*/
include('common_functions.php');
echo(html_header());
echo('<div class="datacontainer">');
$output_mode = isset($_GET['mode']) ? $_GET['mode'] : 'all';
//initialization of array variables
$txtdir = 'ClearanceResults';
$txtfiles = array();
$csvdir = 'ClearanceRaw';
$csvfiles = array();
$match_dates = array();
//loop over the directory and find .txt files
if ($handle = opendir($txtdir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && strtolower(substr($entry, strrpos($entry, '.') + 1)) == 'txt') {
array_push($txtfiles, $entry);
}
}
closedir($handle);
}
//loop over the directory and find .csv files
if ($handle = opendir($csvdir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && strtolower(substr($entry, strrpos($entry, '.') + 1)) == 'csv') {
$csv = array_map('str_getcsv',file('ClearanceRaw/'.$entry));
if(trim($csv[1][1]) == 'VOXCLEAR 5000sec' || trim($csv[1][1]) == 'VOXCLEAR 1200sec'){
array_push($csvfiles, $entry);
//if($output_mode == 'matching'){
for($i=0;$i<sizeof($txtfiles);$i++){
if(abs(filemtime('ClearanceRaw/' . $entry) - filemtime('ClearanceResults/' . $txtfiles[$i])) < 100){
array_push($match_dates, array("csvfile"=>$entry,"txtfile"=>$txtfiles[$i]));
}
}
//}
}
}
}
closedir($handle);
}
?>
<input type="button" class="button" value="Vis alle datafiler" onclick="window.location.href='list_datafiles.php?mode=all'">
<input type="button" class="button" value="Vis tidsmatchede datafiler" onclick="window.location.href='list_datafiles.php?mode=matching'"><br/>
Totalt antal .csv-filer: <?php echo sizeof($csvfiles);?><br/>
Totalt antal .txt-filer: <?php echo sizeof($txtfiles);?><br/>
Antal tidsmatchede .csv- og .txt-filer: <?php echo sizeof($match_dates);?><br/>
<table class="sub_worksheet">
<th>#</th><th>Output fra WorkOut</th><th>Output fra Wizard</th>
<?php
//iterate over all the files in the directory
if($output_mode == 'matching'){
$file_list = sizeof($match_dates);
} else {
$file_list = max(sizeof($txtfiles),sizeof($csvfiles));
}
for($k=0; $k<$file_list; $k++){
echo '<tr>';
echo ' <td width="10%" align="center">'. $k .'</td>';
if($output_mode == 'matching'){
echo ' <td width="40%" align="center"><a href="' . $txtdir . '/' . $match_dates[$k]['txtfile'] . '"> ' . $match_dates[$k]['txtfile'] . '</a></td>';
echo ' <td width="40%" align="center"><a href="' . $csvdir . '/' . $match_dates[$k]['csvfile'] . '"> ' . $match_dates[$k]['csvfile'] . '</a></td>';
} else {
echo ' <td width="40%" align="center"><a href="' . $txtdir . '/' . $txtfiles[$k] . '"> ' . $txtfiles[$k] . '</a></td>';
echo ' <td width="40%" align="center"><a href="' . $csvdir . '/' . $csvfiles[$k] . '"> ' . $csvfiles[$k] . '</a></td>';
}
echo '</tr>';
}
?>
</table>
<?php
echo('<input type="button" class="button" value="Tilbage" onclick="javascript:history.back()">');
echo('</div>');
echo(html_footer());
?>