From 373c5f25b2efb3b281f174d9674578ac84068ef1 Mon Sep 17 00:00:00 2001 From: Dima Malishev Date: Sat, 10 Sep 2011 22:35:16 +0300 Subject: [PATCH] SLL certificates upload implementation step #1 --- web/index.html | 2 +- web/js/_settings.js | 2 +- web/js/app.js | 12 +- web/js/html.js | 6 + web/js/lib/custom-form-elements.js | 152 -------------------------- web/js/pages.js | 20 +++- web/js/templates.js | 9 +- web/vesta/api/AjaxHandler.php | 2 + web/vesta/app.init.php | 12 -- web/vesta/core/VestaSession.class.php | 6 + 10 files changed, 52 insertions(+), 171 deletions(-) diff --git a/web/index.html b/web/index.html index 0d0e1635a..9fbd8a73e 100644 --- a/web/index.html +++ b/web/index.html @@ -187,7 +187,7 @@
  - add new entry + add new entry
diff --git a/web/js/_settings.js b/web/js/_settings.js index 8121358f3..41b81957f 100644 --- a/web/js/_settings.js +++ b/web/js/_settings.js @@ -55,7 +55,7 @@ App.Settings.Imutable.IP = ['INTERFACE']; // Empty App.Empty = {}; App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''}; -App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''}; +App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_KEY':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''}; App.Empty.DB = {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''}; App.Settings.getMethodName = function(action) diff --git a/web/js/app.js b/web/js/app.js index 373e403f3..21d791d6a 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -184,11 +184,19 @@ App.Ajax.request = function(jedi_method, data, callback) dataType: "text", async: true, success: function(reply) - { + { reply = reply.replace(/\\'/gi, ''); reply = reply.replace(/\'/gi, ''); + + reply = jsonParse(reply); + + if (reply.result == 'NOT_AUTHORISED') { + + return alert('NOT AUTH'); + } + //timer.start(); - callback && callback(jsonParse(reply)); + callback && callback(reply); App.Helpers.afterAjax(); //timer.stop(jedi_method); }, diff --git a/web/js/html.js b/web/js/html.js index 135e3146a..a37610928 100644 --- a/web/js/html.js +++ b/web/js/html.js @@ -473,6 +473,12 @@ App.HTML.Build.dns_subrecord = function(record) return tpl; } +App.HTML.Build.ssl_key_file = function() +{ + return ''; +} + + App.HTML.Build.user_selects = function(tpl, options) { var acc = []; diff --git a/web/js/lib/custom-form-elements.js b/web/js/lib/custom-form-elements.js index 27954f2d0..8b1378917 100644 --- a/web/js/lib/custom-form-elements.js +++ b/web/js/lib/custom-form-elements.js @@ -1,153 +1 @@ -/* -CUSTOM FORM ELEMENTS - -Created by Ryan Fait -www.ryanfait.com - -The only things you may need to change in this file are the following -variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26) - -The numbers you set for checkboxHeight and radioHeight should be one quarter -of the total height of the image want to use for checkboxes and radio -buttons. Both images should contain the four stages of both inputs stacked -on top of each other in this order: unchecked, unchecked-clicked, checked, -checked-clicked. - -You may need to adjust your images a bit if there is a slight vertical -movement during the different stages of the button activation. - -The value of selectWidth should be the width of your select list image. - -Visit http://ryanfait.com/ for more information. - -*/ - -var checkboxHeight = "25"; -var radioHeight = "25"; -var selectWidth = "210"; - - -/* No need to change anything after this */ - - -document.write(''); - -var Custom = { - init: function() { - var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active; - for(a = 0; a < inputs.length; a++) { - if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") { - span[a] = document.createElement("span"); - span[a].className = inputs[a].type; - - if(inputs[a].checked == true) { - if(inputs[a].type == "checkbox") { - position = "0 -" + (checkboxHeight*2) + "px"; - span[a].style.backgroundPosition = position; - } else { - position = "0 -" + (radioHeight*2) + "px"; - span[a].style.backgroundPosition = position; - } - } - inputs[a].parentNode.insertBefore(span[a], inputs[a]); - inputs[a].onchange = Custom.clear; - if(!inputs[a].getAttribute("disabled")) { - span[a].onmousedown = Custom.pushed; - span[a].onmouseup = Custom.check; - } else { - span[a].className = span[a].className += " disabled"; - } - } - } - inputs = document.getElementsByTagName("select"); - for(a = 0; a < inputs.length; a++) { - try{ - fb.log($(inputs[a]).hasClass("styled")); - if($(inputs[a]).hasClass("styled")) { - option = inputs[a].getElementsByTagName("option"); - active = option[0].childNodes[0].nodeValue; - textnode = document.createTextNode(active); - for(b = 0; b < option.length; b++) { - if(option[b].selected == true) { - textnode = document.createTextNode(option[b].childNodes[0].nodeValue); - } - } - span[a] = document.createElement("span"); - span[a].className = "select"; - span[a].id = "select-" + inputs[a].name + a; - span[a].appendChild(textnode); - inputs[a].parentNode.insertBefore(span[a], inputs[a]); - inputs[a].id = inputs[a].name + a; - if(!inputs[a].getAttribute("disabled")) { - inputs[a].onchange = Custom.choose; - } else { - inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled"; - } - } - }catch(e){fb.error(e);} - } - document.onmouseup = Custom.clear; - }, - pushed: function() { - element = this.nextSibling; - if(element.checked == true && element.type == "checkbox") { - this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px"; - } else if(element.checked == true && element.type == "radio") { - this.style.backgroundPosition = "0 -" + radioHeight*3 + "px"; - } else if(element.checked != true && element.type == "checkbox") { - this.style.backgroundPosition = "0 -" + checkboxHeight + "px"; - } else { - this.style.backgroundPosition = "0 -" + radioHeight + "px"; - } - }, - check: function() { - element = this.nextSibling; - if(element.checked == true && element.type == "checkbox") { - this.style.backgroundPosition = "0 0"; - element.checked = false; - } else { - if(element.type == "checkbox") { - this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px"; - } else { - this.style.backgroundPosition = "0 -" + radioHeight*2 + "px"; - group = this.nextSibling.name; - inputs = document.getElementsByTagName("input"); - for(a = 0; a < inputs.length; a++) { - if(inputs[a].name == group && inputs[a] != this.nextSibling) { - inputs[a].previousSibling.style.backgroundPosition = "0 0"; - } - } - } - element.checked = true; - } - }, - clear: function() { - inputs = document.getElementsByTagName("input"); - for(var b = 0; b < inputs.length; b++) { - if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") { - inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px"; - } else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") { - inputs[b].previousSibling.style.backgroundPosition = "0 0"; - } else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") { - inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px"; - } else if(inputs[b].type == "radio" && inputs[b].className == "styled") { - inputs[b].previousSibling.style.backgroundPosition = "0 0"; - } - } - }, - choose: function() { - option = this.getElementsByTagName("option"); - for(d = 0; d < option.length; d++) { - if(option[d].selected == true) { - // - var expr = '#select-' + this.id; - fb.log(expr); - $(expr).text(option[d].childNodes[0].nodeValue); - // bad! - //document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue; - } - } - } -} -window.onload = Custom.init; \ No newline at end of file diff --git a/web/js/pages.js b/web/js/pages.js index f42832888..ebca69f46 100644 --- a/web/js/pages.js +++ b/web/js/pages.js @@ -58,5 +58,23 @@ App.Pages.USER.new_entry = function(evt) var tpl = App.HTML.Build[build_method]({}, form_id); App.Ref.CONTENT.prepend(tpl); App.Helpers.updateScreen(); - $('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden'); + $('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden'); +} + +App.Pages.WEB_DOMAIN.new_entry = function(evt) +{ + var form_id = App.Constants[App.Env.world + '_FORM_ID']; + $('#'+form_id).remove(); + var build_method = App.Env.getWorldName() + '_form'; + var tpl = App.HTML.Build[build_method]({}, form_id); + App.Ref.CONTENT.prepend(tpl); + App.Helpers.updateScreen(); + $('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden'); + var ssl_key_upload = App.HTML.Build.ssl_key_file(); + $('#'+form_id).find('.ssl-key-input-dummy:first').replaceWith(ssl_key_upload); +} + +App.Pages.WEB_DOMAIN.setSSL = function(content, type) +{ + fb.warn(content); } diff --git a/web/js/templates.js b/web/js/templates.js index b3a073a1c..395507ac2 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -492,7 +492,7 @@ App.Templates.html = { \ '] }, - web_domain: { + web_domain: { FORM: ['
\ \ \ @@ -565,8 +565,13 @@ App.Templates.html = { \
\
\ + \ + ...\ + \ +
\ +
\ \ - \ + ...\ \
\ \ diff --git a/web/vesta/api/AjaxHandler.php b/web/vesta/api/AjaxHandler.php index beab6ff77..36a0097d3 100644 --- a/web/vesta/api/AjaxHandler.php +++ b/web/vesta/api/AjaxHandler.php @@ -47,6 +47,8 @@ class AjaxHandler { throw new SystemException(Message::INVALID_METHOD); } +// return $this->reply('NOT_AUTHORISED'); + require $inc_file; $space = new $method['namespace']; diff --git a/web/vesta/app.init.php b/web/vesta/app.init.php index 2db6a7641..f37519442 100644 --- a/web/vesta/app.init.php +++ b/web/vesta/app.init.php @@ -1,17 +1,5 @@ 'vesta'); }