Skip to content

Commit 373c5f2

Browse files
committed
SLL certificates upload implementation step hestiacp#1
1 parent 994b0cf commit 373c5f2

File tree

10 files changed

+52
-171
lines changed

10 files changed

+52
-171
lines changed

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ <h1 class="logo"><a href="#">Vesta panel <span>&nbsp;</span></a></h1>
187187
<div id="actions-toolbar" class="cc">
188188
<a class="add-domain do_action_new_entry" href="javascript:void(0)">
189189
<i class="icon do_action_new_entry">&nbsp;</i>
190-
add new <span id="new-entry-keyword">entry</span>
190+
add new <span id="new-entry-keyword" class="do_action_new_entry">entry</span>
191191
</a>
192192
</div>
193193

web/js/_settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ App.Settings.Imutable.IP = ['INTERFACE'];
5555
// Empty
5656
App.Empty = {};
5757
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
58-
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
58+
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_KEY':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
5959
App.Empty.DB = {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
6060

6161
App.Settings.getMethodName = function(action)

web/js/app.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,19 @@ App.Ajax.request = function(jedi_method, data, callback)
184184
dataType: "text",
185185
async: true,
186186
success: function(reply)
187-
{
187+
{
188188
reply = reply.replace(/\\'/gi, '');
189189
reply = reply.replace(/\'/gi, '');
190+
191+
reply = jsonParse(reply);
192+
193+
if (reply.result == 'NOT_AUTHORISED') {
194+
195+
return alert('NOT AUTH');
196+
}
197+
190198
//timer.start();
191-
callback && callback(jsonParse(reply));
199+
callback && callback(reply);
192200
App.Helpers.afterAjax();
193201
//timer.stop(jedi_method);
194202
},

web/js/html.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ App.HTML.Build.dns_subrecord = function(record)
473473
return tpl;
474474
}
475475

476+
App.HTML.Build.ssl_key_file = function()
477+
{
478+
return '<iframe src="http://dev.vestacp.com:8083/vesta/upload.php?action=show&type=key" width="500px;" height="50px;" framevorder="0" scroll="no">..</iframe>';
479+
}
480+
481+
476482
App.HTML.Build.user_selects = function(tpl, options)
477483
{
478484
var acc = [];

web/js/lib/custom-form-elements.js

Lines changed: 0 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1 @@
1-
/*
21

3-
CUSTOM FORM ELEMENTS
4-
5-
Created by Ryan Fait
6-
www.ryanfait.com
7-
8-
The only things you may need to change in this file are the following
9-
variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)
10-
11-
The numbers you set for checkboxHeight and radioHeight should be one quarter
12-
of the total height of the image want to use for checkboxes and radio
13-
buttons. Both images should contain the four stages of both inputs stacked
14-
on top of each other in this order: unchecked, unchecked-clicked, checked,
15-
checked-clicked.
16-
17-
You may need to adjust your images a bit if there is a slight vertical
18-
movement during the different stages of the button activation.
19-
20-
The value of selectWidth should be the width of your select list image.
21-
22-
Visit http://ryanfait.com/ for more information.
23-
24-
*/
25-
26-
var checkboxHeight = "25";
27-
var radioHeight = "25";
28-
var selectWidth = "210";
29-
30-
31-
/* No need to change anything after this */
32-
33-
34-
document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');
35-
36-
var Custom = {
37-
init: function() {
38-
var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
39-
for(a = 0; a < inputs.length; a++) {
40-
if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
41-
span[a] = document.createElement("span");
42-
span[a].className = inputs[a].type;
43-
44-
if(inputs[a].checked == true) {
45-
if(inputs[a].type == "checkbox") {
46-
position = "0 -" + (checkboxHeight*2) + "px";
47-
span[a].style.backgroundPosition = position;
48-
} else {
49-
position = "0 -" + (radioHeight*2) + "px";
50-
span[a].style.backgroundPosition = position;
51-
}
52-
}
53-
inputs[a].parentNode.insertBefore(span[a], inputs[a]);
54-
inputs[a].onchange = Custom.clear;
55-
if(!inputs[a].getAttribute("disabled")) {
56-
span[a].onmousedown = Custom.pushed;
57-
span[a].onmouseup = Custom.check;
58-
} else {
59-
span[a].className = span[a].className += " disabled";
60-
}
61-
}
62-
}
63-
inputs = document.getElementsByTagName("select");
64-
for(a = 0; a < inputs.length; a++) {
65-
try{
66-
fb.log($(inputs[a]).hasClass("styled"));
67-
if($(inputs[a]).hasClass("styled")) {
68-
option = inputs[a].getElementsByTagName("option");
69-
active = option[0].childNodes[0].nodeValue;
70-
textnode = document.createTextNode(active);
71-
for(b = 0; b < option.length; b++) {
72-
if(option[b].selected == true) {
73-
textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
74-
}
75-
}
76-
span[a] = document.createElement("span");
77-
span[a].className = "select";
78-
span[a].id = "select-" + inputs[a].name + a;
79-
span[a].appendChild(textnode);
80-
inputs[a].parentNode.insertBefore(span[a], inputs[a]);
81-
inputs[a].id = inputs[a].name + a;
82-
if(!inputs[a].getAttribute("disabled")) {
83-
inputs[a].onchange = Custom.choose;
84-
} else {
85-
inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
86-
}
87-
}
88-
}catch(e){fb.error(e);}
89-
}
90-
document.onmouseup = Custom.clear;
91-
},
92-
pushed: function() {
93-
element = this.nextSibling;
94-
if(element.checked == true && element.type == "checkbox") {
95-
this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
96-
} else if(element.checked == true && element.type == "radio") {
97-
this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
98-
} else if(element.checked != true && element.type == "checkbox") {
99-
this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
100-
} else {
101-
this.style.backgroundPosition = "0 -" + radioHeight + "px";
102-
}
103-
},
104-
check: function() {
105-
element = this.nextSibling;
106-
if(element.checked == true && element.type == "checkbox") {
107-
this.style.backgroundPosition = "0 0";
108-
element.checked = false;
109-
} else {
110-
if(element.type == "checkbox") {
111-
this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
112-
} else {
113-
this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
114-
group = this.nextSibling.name;
115-
inputs = document.getElementsByTagName("input");
116-
for(a = 0; a < inputs.length; a++) {
117-
if(inputs[a].name == group && inputs[a] != this.nextSibling) {
118-
inputs[a].previousSibling.style.backgroundPosition = "0 0";
119-
}
120-
}
121-
}
122-
element.checked = true;
123-
}
124-
},
125-
clear: function() {
126-
inputs = document.getElementsByTagName("input");
127-
for(var b = 0; b < inputs.length; b++) {
128-
if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
129-
inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
130-
} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
131-
inputs[b].previousSibling.style.backgroundPosition = "0 0";
132-
} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
133-
inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
134-
} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
135-
inputs[b].previousSibling.style.backgroundPosition = "0 0";
136-
}
137-
}
138-
},
139-
choose: function() {
140-
option = this.getElementsByTagName("option");
141-
for(d = 0; d < option.length; d++) {
142-
if(option[d].selected == true) {
143-
//
144-
var expr = '#select-' + this.id;
145-
fb.log(expr);
146-
$(expr).text(option[d].childNodes[0].nodeValue);
147-
// bad!
148-
//document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
149-
}
150-
}
151-
}
152-
}
153-
window.onload = Custom.init;

web/js/pages.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,23 @@ App.Pages.USER.new_entry = function(evt)
5858
var tpl = App.HTML.Build[build_method]({}, form_id);
5959
App.Ref.CONTENT.prepend(tpl);
6060
App.Helpers.updateScreen();
61-
$('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden');
61+
$('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden');
62+
}
63+
64+
App.Pages.WEB_DOMAIN.new_entry = function(evt)
65+
{
66+
var form_id = App.Constants[App.Env.world + '_FORM_ID'];
67+
$('#'+form_id).remove();
68+
var build_method = App.Env.getWorldName() + '_form';
69+
var tpl = App.HTML.Build[build_method]({}, form_id);
70+
App.Ref.CONTENT.prepend(tpl);
71+
App.Helpers.updateScreen();
72+
$('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden');
73+
var ssl_key_upload = App.HTML.Build.ssl_key_file();
74+
$('#'+form_id).find('.ssl-key-input-dummy:first').replaceWith(ssl_key_upload);
75+
}
76+
77+
App.Pages.WEB_DOMAIN.setSSL = function(content, type)
78+
{
79+
fb.warn(content);
6280
}

web/js/templates.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ App.Templates.html = {
492492
</div><!-- // .row-details -->\
493493
</div>']
494494
},
495-
web_domain: {
495+
web_domain: {
496496
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_domain form">\
497497
<input type="hidden" class="source" name="source" value=\'~!:source~!\' />\
498498
<input type="hidden" class="target" name="target" value="" />\
@@ -565,8 +565,13 @@ App.Templates.html = {
565565
<input type="text" name="SSL_HOME" class="text-field" value="~!:SSL_HOME~!">\
566566
</div>\
567567
<div class="form-row ssl-crtfct-box cc">\
568+
<label for="#" class="field-label">ssl key: <span class="remark">(upload file or insert text)</span></label>\
569+
<span class="ssl-key-input-dummy">...</span>\
570+
<textarea name="SSL_KEY" class="textarea">~!:SSL_KEY~!</textarea>\
571+
</div>\
572+
<div class="form-row ssl-crtfct-box cc">\
568573
<label for="#" class="field-label">ssl certificate: <span class="remark">(upload file or insert text)</span></label>\
569-
<input type="file" value="" size="43" class="file-upload">\
574+
<span class="ssl-cert-input-dummy">...</span>\
570575
<textarea name="SSL_CERT" class="textarea">~!:SSL_CERT~!</textarea>\
571576
</div>\
572577
</div><!-- // advanced options -->\

web/vesta/api/AjaxHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function dispatch(Request $request)
4747
throw new SystemException(Message::INVALID_METHOD);
4848
}
4949

50+
// return $this->reply('NOT_AUTHORISED');
51+
5052
require $inc_file;
5153

5254
$space = new $method['namespace'];

web/vesta/app.init.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
<?php
22

3-
$url = "http://dev.vestacp.com:8083/dispatch.php";
4-
$useragent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
5-
$ch = curl_init();
6-
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
7-
curl_setopt($ch, CURLOPT_POST, 1);
8-
curl_setopt($ch, CURLOPT_URL,$url);
9-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
10-
$result= curl_exec ($ch);
11-
curl_close ($ch);
12-
die();
13-
14-
153
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
164

175
require_once V_ROOT_DIR . 'config/Config.class.php';

web/vesta/core/VestaSession.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ class VestaSession
55

66
static public $instance = null;
77

8+
public function __construct()
9+
{
10+
//session_start();
11+
}
12+
813
/**
914
* Grab current instance or create it
1015
*
@@ -17,6 +22,7 @@ static function getInstance()
1722

1823
public function getUser()
1924
{
25+
//var_dump($_SESSION);die();
2026
return array('uid' => 'vesta');
2127
}
2228

0 commit comments

Comments
 (0)