1+ <?php
2+
3+ define ('V_ROOT_DIR ' , dirname (__FILE__ ) . DIRECTORY_SEPARATOR );
4+
5+ require_once V_ROOT_DIR . 'config/Config.class.php ' ;
6+ require_once V_ROOT_DIR . 'core/utils/Utils.class.php ' ;
7+ require_once V_ROOT_DIR . 'core/VestaSession.class.php ' ;
8+ require_once V_ROOT_DIR . 'core/Vesta.class.php ' ;
9+ require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php ' ;
10+ require_once V_ROOT_DIR . 'core/exceptions/ProtectionException.class.php ' ;
11+ require_once V_ROOT_DIR . 'core/utils/Message.class.php ' ;
12+ require_once V_ROOT_DIR . 'core/Request.class.php ' ;
13+ require_once V_ROOT_DIR . 'api/AjaxHandler.php ' ;
14+
15+ switch ($ _GET ['action ' ]) {
16+ case 'show ' :
17+ if (!empty ($ _POST ['process ' ])) {
18+ handleUpload ();
19+ }
20+ else {
21+ show_form ();
22+ }
23+ break ;
24+ }
25+
26+ function pass_contents ($ content )
27+ {
28+ $ type = $ _GET ['type ' ];
29+ print <<<JS
30+ <script type="text/javascript">parent.App.Pages.WEB_DOMAIN.setSSL(' {$ contents }', ' {$ type }');</script>
31+ JS ;
32+ }
33+
34+ function handleUpload ()
35+ {
36+ if ($ _FILES ["upload-ssl " ]["size " ] < 20000 ) {
37+ if ($ _FILES ["upload-ssl " ]["error " ] > 0 ) {
38+ return show_form () . "Error occured. Please try to upload again " ;
39+ }
40+ else {
41+ /*echo "Upload: " . $_FILES["file"]["name"] . "<br />";
42+ echo "Type: " . $_FILES["file"]["type"] . "<br />";
43+ echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
44+ echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";*/
45+
46+ $ contents = file_get_contents ($ _FILES ["upload-ssl " ]['tmp_name ' ]);
47+ return show_form ().pass_contents ($ contents );
48+
49+ /*if (file_exists("upload/" . $_FILES["file"]["name"])) {
50+ echo $_FILES["file"]["name"] . " already exists. ";
51+ }
52+ else {
53+ move_uploaded_file($_FILES["file"]["tmp_name"],
54+ "upload/" . $_FILES["file"]["name"]);
55+ echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
56+ }*/
57+ }
58+ }
59+ else {
60+ return show_form () . "Filesize is too large. Please ensure you are uploading correct file " ;
61+ }
62+ }
63+
64+ //
65+ // functions
66+ function show_form ()
67+ {
68+ $ type = $ _GET ['type ' ];
69+ if (!in_array ($ type , array ('key ' , 'cert ' ))) {
70+ exit ;
71+ }
72+
73+ print <<<HTML
74+ <form action="" method="post" enctype="multipart/form-data"><input type="hidden" value="true" name="process"><input type="file" name="upload-ssl" onChange="document.forms[0].submit()"/></form>
75+ HTML ;
76+ }
77+
78+ ?>
0 commit comments