-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
111 lines (88 loc) · 2.36 KB
/
test.php
File metadata and controls
111 lines (88 loc) · 2.36 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
<?php
include "model.php";
if (isset($_GET["upload"]))
{
$request = array(
"ends" => date('Y-m-d\TH:i:s\Z',time() + 3600),
"path" => $_POST["path"],
"size" => 1024 * 1024
);
$hmac = hmac($request);
$request['hmac'] = $hmac;
respond($request);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>SelfStore Test Page</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2>Files</h2>
<div class="row">
<div class="span7">
<table class="table">
<tr><th>Path</th><th>Hash</th></tr>
<?php foreach (all_files() as $file): ?>
<tr>
<td><a href="<?php
$request = array(
"ends" => date('Y-m-d\TH:i:s\Z', time() + 3600),
"path" => $file->path,
"what" => "GET"
);
$hmac = hmac($request);
echo $file->path . "?ends=" . $request['ends'] . "&hmac=$hmac";
?>"><?php echo $file->path; ?></a></td>
<td><?php echo md5($file->path); ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="span5">
<h3>Upload File</h3>
<form id="upload" class="form-horizontal" action="/upload" method="POST" enctype="multipart/form-data">
<input id="token" type="hidden" name="token"/>
<input type="hidden" name="next" value="http://<?php echo $_SERVER["SERVER_NAME"]; ?>/test"/>
<div class="control-group">
<label class="control-label" for="path">Upload path</label>
<div class="controls">
<input id="path" name="path" type="text" placeholder="/path/to/file" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="file">Local file</label>
<div class="controls">
<input id="file" name="file" type="file" />
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" type="submit">Upload</button>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
var old_token = "";
$("#upload").submit(function(){
if ($("#token").val() != old_token) {
old_token = $("#token").val();
return true;
}
$.post("/test?upload",{path:$("#path").val()},function(data){
$.post("/prepare",data,function(allowed){
$("#token").val(allowed.token);
$("#upload").submit();
});
});
return false;
});
});
</script>
</body>
</html>