forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-from-computer.php
159 lines (136 loc) · 4.31 KB
/
upload-from-computer.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Uploading files from computer, step 1
* Shows the plupload form that handles the uploads and moves
* them to a temporary folder. When the queue is empty, the user
* is redirected to step 2, and prompted to enter the name,
* description and client for each uploaded file.
*
* @package ProjectSend
* @subpackage Upload
*/
require_once('bootstrap.php');
$active_nav = 'files';
$page_title = __('Upload files', 'cftp_admin');
$allowed_levels = array(9,8,7);
if (CLIENTS_CAN_UPLOAD == 1) {
$allowed_levels[] = 0;
}
include_once ADMIN_TEMPLATES_DIR . DS . 'header.php';
?>
<div class="col-xs-12">
<?php
/** Count the clients to show an error or the form */
$statement = $dbh->query("SELECT id FROM " . TABLE_USERS . " WHERE level = '0'");
$count_clients = $statement->rowCount();
$statement = $dbh->query("SELECT id FROM " . TABLE_GROUPS);
$count_groups = $statement->rowCount();
if ( ( !$count_clients or $count_clients < 1 ) && ( !$count_groups or $count_groups < 1 ) ) {
message_no_clients();
}
?>
<p>
<?php
$msg = __('Click on Add files to select all the files that you want to upload, and then click continue. On the next step, you will be able to set a name and description for each uploaded file. Remember that the maximum allowed file size (in mb.) is ','cftp_admin') . ' <strong>'.UPLOAD_MAX_FILESIZE.'</strong>';
echo system_message('info', $msg);
?>
</p>
<script type="text/javascript">
$(document).ready(function() {
setInterval(function(){
// Send a keep alive action every 1 minute
var timestamp = new Date().getTime()
$.ajax({
type: 'GET',
cache: false,
url: '<?php echo INCLUDES_URI; ?>/session.keep.alive.php',
data: 'timestamp='+timestamp,
success: function(result) {
var dummy = result;
}
});
},1000*60);
});
$(function() {
$("#uploader").pluploadQueue({
runtimes : 'html5,flash,silverlight,html4',
url : 'app/includes/upload.process.php',
chunk_size : '1mb',
rename : true,
dragdrop: true,
multipart : true,
filters : {
max_file_size : '<?php echo UPLOAD_MAX_FILESIZE; ?>mb'
<?php
if ( false === CAN_UPLOAD_ANY_FILE_TYPE ) {
?>
,mime_types: [
{title : "Allowed files", extensions : "<?php echo ALLOWED_FILE_TYPES; ?>"}
]
<?php
}
?>
},
flash_swf_url : 'vendor/moxiecode/plupload/js/Moxie.swf',
silverlight_xap_url : 'vendor/moxiecode/plupload/js/Moxie.xap',
preinit: {
Init: function (up, info) {
//$('#uploader_container').removeAttr("title");
}
}
,init : {
/*
FilesAdded: function(up, files) {
uploader.start();
}
QueueChanged: function(up) {
var uploader = $('#uploader').pluploadQueue();
uploader.start();
}
*/
}
});
var uploader = $('#uploader').pluploadQueue();
$('form').submit(function(e) {
if (uploader.files.length > 0) {
uploader.bind('StateChanged', function() {
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
$('form')[0].submit();
}
});
uploader.start();
$("#btn-submit").hide();
$(".message_uploading").fadeIn();
uploader.bind('FileUploaded', function (up, file, info) {
var obj = JSON.parse(info.response);
var new_file_field = '<input type="hidden" name="files[]" value="'+obj.NewFileName+'" />'
$('form').append(new_file_field);
});
return false;
} else {
alert('<?php _e("You must select at least one file to upload.",'cftp_admin'); ?>');
}
return false;
});
window.onbeforeunload = function (e) {
var e = e || window.event;
console.log('state? ' + uploader.state);
// if uploading
if(uploader.state === 2) {
<?php
$confirmation_msg = "Are you sure? Files currently being uploaded will be discarded if you leave this page.";
?>
//IE & Firefox
if (e) {
e.returnValue = '<?php _e($confirmation_msg,'cftp_admin'); ?>';
}
// For Safari
return '<?php _e($confirmation_msg,'cftp_admin'); ?>';
}
};
});
</script>
<?php include_once FORMS_DIR . DS . 'upload.php'; ?>
</div>
<?php
include_once ADMIN_TEMPLATES_DIR . DS . 'footer.php';