-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathusb.php
More file actions
executable file
·143 lines (124 loc) · 4.21 KB
/
usb.php
File metadata and controls
executable file
·143 lines (124 loc) · 4.21 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
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
<script>
var n;
$('table').tablesorter();
current_path = ["media","usb0"];
function get_subdir_files(dirname)
{
current_path.push(dirname);
get_files(current_path);
}
function print_cws_file(cws_filename)
{
var file_path = "/"+current_path.join("/")+"/"+cws_filename;
// alert(file_path);
$("#confirm_print_modal_dialogue").html("Are you sure you want to upload "+cws_filename+"?");
$("#confirm_print_modal_yes").click(function(){
$(".modal").modal("hide");
$("#processing").show();
$.post("allthefunctions.php",
{
'funct': "usb_upload",
'param': file_path
},
function(data, status){
if(data == "1")
alert("File uploaded successfully");
load_page("recent.php");
});
});
}
function get_files(path)
{
$("#table_body").html("");
$.ajax({
type: 'POST',
url: 'read_usb.php',
data: {'path': path},
dataType: 'json',
success: function (ret_obj)
{
current_path = ret_obj["path"];
files = ret_obj["contents"];
$.each(files, function(name,type)
{
table_row="<tr>";
if(type == "directory")
{
var glyphicon = ""
if(name == "..")
glyphicon = "fa-reply"
else
glyphicon = "fa-folder-open"
table_row += "<td onclick=\"get_subdir_files('"+name+"')\"><i class='fa "+glyphicon+" ' aria-hidden='true'></i> <strong><a href='#' onclick='return false;'>"+name+"</a></strong></td><td></td>";
}
if(type == "cws_file")
{
print_button = '<button type="button" data-toggle="modal" data-target=".confirm_print_modal" class="btn btn-success btn-sm" onclick="print_cws_file(\''+name+'\')"><i class="fa fa-upload"></i> Upload </button>';
table_row += "<td><i class='fa fa-arrow-right' aria-hidden='true'></i> <strong><i>"+name+"</i></strong></td>";
table_row += "<td>" + print_button + "</td>";
}
table_row += "</tr>";
$("#table_body").append(table_row);
});
}
});
}
$(document).ready(function()
{
$("#hidden_stuff").hide();
$("#processing").hide();
get_files(current_path);
});
</script>
<?php
$usb_port = shell_exec("ls /dev/sd*1");
if($usb_port == "")
echo "<h3>No USB device found.</h3>";
else
{
?>
<div id="processing">
<strong>Processing file..</strong>
<img src="img/hourglass.svg" width="30px" height="30px">
</div>
<table id="example" class="tablesorter table jambo_table">
<thead>
<tr class="headings">
<th class="col-md-10"><a href="#" onclick="return false;" style="color: #ffffff">Name <i class="fa fa-sort" aria-hidden="true"></i></a></th>
<th class=" no-link last col-md-2"><span class="nobr">Action</span>
</th>
</tr>
</thead>
<tbody id="table_body">
</tbody>
</table>
<div id="hidden_stuff">
<div id="print_button">
<button type="button" data-toggle="modal" data-target=".confirm_print_modal" class="btn btn-success btn-sm" ><i class="fa fa-bolt"></i> Print </button>
</div>
<div id="processing">
<strong>Processing..</strong>
<img src="img/hourglass.svg" width="30px" height="30px">
</div>
</div>
<div class="modal fade confirm_print_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel2">Confirm print</h4>
</div>
<div class="modal-body">
<h4 id="confirm_print_modal_dialogue"></h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" >No</button>
<button type="button" class="btn btn-primary" id="confirm_print_modal_yes">Yes</button>
</div>
</div>
</div>
</div>
<?php
}
?>