forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
93 lines (85 loc) · 4.44 KB
/
Copy pathupload.php
File metadata and controls
93 lines (85 loc) · 4.44 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
<?php
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
require_once V_ROOT_DIR . 'config/Config.class.php';
require_once V_ROOT_DIR . 'core/utils/Utils.class.php';
require_once V_ROOT_DIR . 'core/VestaSession.class.php';
require_once V_ROOT_DIR . 'core/Vesta.class.php';
require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php';
require_once V_ROOT_DIR . 'core/exceptions/ProtectionException.class.php';
require_once V_ROOT_DIR . 'core/utils/Message.class.php';
require_once V_ROOT_DIR . 'core/Request.class.php';
require_once V_ROOT_DIR . 'api/AjaxHandler.php';
switch ($_GET['action']) {
case 'show':
if (!empty($_POST['process'])) {
handleUpload();
}
else {
show_form();
}
break;
}
function pass_contents($content)
{
if (trim($content) == '') {
show_form(); print("<span id='msg' style='font-size:9px;color: red;'>Error occured. Please try to upload again</span>");
return;
}
$type = $_GET['type'];
print <<<JS
<textarea id="result" style="display: none;">{$content}</textarea>
<script type="text/javascript">parent.App.Pages.WEB_DOMAIN.setSSL('{$type}', this);</script>
JS;
}
function handleUpload()
{
if ($_FILES["upload-ssl"]["size"] < 20000) {
if ($_FILES["upload-ssl"]["error"] > 0) {
show_form(); print("<span id='msg' style='font-size:9px;color: red;'>Error occured. Please try to upload again</span>");
return;
}
else {
$contents = file_get_contents($_FILES["upload-ssl"]['tmp_name']);
return show_form().pass_contents($contents);
}
}
else {
show_form(); print("<span id='msg' style='font-size:9px;color: red;'>Filesize is too large. Please ensure you are uploading correct file</span>");
return;
}
}
//
// functions
function show_form()
{
$type = $_GET['type'];
if (!in_array($type, array('key', 'cert'))) {
exit;
}
print <<<HTML
<script type="text/javascript">
function upload()
{
var l_dot = '';
document.getElementById('form-upl').style.display = 'none';
try {
document.getElementById('msg').style.display = 'none';
} catch(e){};
document.getElementById('form-loading').style.display = 'block';
setInterval(function(){
if (l_dot == '...') {
l_dot = '';
}
l_dot += '.';
document.getElementById('form-loading').innerHTML = 'Processing'+l_dot;
}, 500);
setTimeout(function() {
document.forms[0].submit();
}, 1000);
}
</script>
<p id="form-loading" style="font-size:11px;color:#333;"></p>
<form id="form-upl" action="" method="post" style="padding:0;margin:0" enctype="multipart/form-data"><input type="hidden" value="true" name="process"><input type="file" name="upload-ssl" onChange="upload();"/></form>
HTML;
}
?>