From 5c87dfb2dd21225581a7b761a4fe744b750f1cee Mon Sep 17 00:00:00 2001 From: naumov-socolov Date: Wed, 25 Jan 2012 04:24:23 +0300 Subject: [PATCH] [js, php] permsions fixes, date format --- web/js/__init__.js | 2 + web/js/actions.js | 4 +- web/js/html.js | 22 +- web/js/pages.js | 21 +- web/js/templates.js | 14 +- web/js/user_templates.js | 231 +++--- web/js/user_templates_old.js | 1151 ++++++++++++++++++++++++++++ web/vesta/api/CRON.class.php | 2 +- web/vesta/api/DB.class.php | 2 +- web/vesta/api/DNS.class.php | 2 +- web/vesta/api/IP.class.php | 2 +- web/vesta/api/USER.class.php | 46 +- web/vesta/api/WEB_DOMAIN.class.php | 2 +- web/vesta/config/vesta_config.ini | 2 +- 14 files changed, 1356 insertions(+), 147 deletions(-) create mode 100644 web/js/user_templates_old.js diff --git a/web/js/__init__.js b/web/js/__init__.js index 0926352f8..719c90eda 100644 --- a/web/js/__init__.js +++ b/web/js/__init__.js @@ -6,6 +6,8 @@ App.Ajax.request('MAIN.about', {}, function(reply) { App.Settings.VestaAbout.version_name = reply.data.version_name; } }); + + $('document').ready(function() { try { App.Utils.detectBrowser(); diff --git a/web/js/actions.js b/web/js/actions.js index dd5bbe4c7..cff0d88d9 100644 --- a/web/js/actions.js +++ b/web/js/actions.js @@ -378,8 +378,8 @@ App.Actions.save_form = function(evt) { else { // OLD ITEM, UPDATING IT var source = $(elm).find('.source').val(); var values = App.Helpers.getFormValues(elm); - if(App.Validate.form(values, $('#'+elm_id))) { - App.Model.update(values, source, elm); + if(App.Validate.form(values, $('#'+elm_id))) { + App.Model.update(values, source, elm); } } } diff --git a/web/js/html.js b/web/js/html.js index f8c5d94d0..2616bf36c 100644 --- a/web/js/html.js +++ b/web/js/html.js @@ -112,10 +112,11 @@ App.HTML.Build.user_form = function (options, id) { } else { tpl.set(':NS', ''); } + tpl = App.HTML.setTplKeys(tpl, options, true); tpl = App.HTML.Build.user_selects(tpl, options); tpl = App.HTML.toggle_suspended_form(tpl, options); - if (options.REPORTS_ENABLED == 'yes') { + if (options.REPORTS_ENABLED == 'yes' || options.REPORTS_ENABLED == 'on') { tpl.set(':CHECKED', 'checked="checked"'); } else { tpl.set(':CHECKED', ''); @@ -177,10 +178,13 @@ App.HTML.Build.web_domain_form = function (options, id) { tpl = App.HTML.setTplKeys(tpl, options, true); tpl = App.HTML.Build.web_domain_selects(tpl, options); tpl = App.HTML.toggle_suspended_form(tpl, options); - if (options.CGI == 'yes' || !in_edit) { + + if (options.CGI == 'yes' || options.CGI == 'on' || !in_edit) { tpl.set(':CHECKED_CGI', 'checked="checked"'); } - if (options.ELOG == 'yes') { + + + if (options.ELOG == 'yes' || options.ELOG == 'on') { tpl.set(':CHECKED_ELOG', 'checked="checked"'); } if (options.STATS_LOGIN.trim() != '') { @@ -212,6 +216,9 @@ App.HTML.Build.web_domain_form = function (options, id) { tpl.set(':SSL_CA', ''); } + tpl.set(':DNS_DOMAIN_ALSO', in_edit? 'hidden' : ''); + + return tpl.finalize(); } @@ -290,16 +297,12 @@ App.HTML.Build.ip_entry = function (o) { return tpl.finalize(); } -App.HTML.Build.dns_entry = function (o, is_new) { +App.HTML.Build.dns_entry = function (o) { var tpl = App.Templates.get('ENTRY', 'dns'); tpl = App.HTML.setTplKeys(tpl, o); var ip = o.IP.split('.'); tpl.set(':IP', ip.join('.')); tpl.set(':CHECKED', ''); - if (is_new) { - var now = new Date(); - tpl.set(':DATE', now.format("d.mm.yyyy")); - } tpl.set(':TPL_VAL', o.TPL); tpl = App.HTML.toggle_suspended_entry(tpl, o); @@ -354,7 +357,8 @@ App.HTML.Build.user_entry = function (o, key) { tpl.set(':NS', ns_custom.finalize()); } tpl = App.HTML.Build.user_web_tpl(tpl, o); - tpl.set(':REPORTS_ENABLED', o.REPORTS_ENABLED == 'yes' ? 'enabled' : 'DISABLED'); + + tpl.set(':REPORTS_ENABLED', o.REPORTS_ENABLED == 'yes' || o.REPORTS_ENABLED == 'on' ? 'enabled' : 'DISABLED'); if (o.U_DISK_PERCENTAGE > 100) { var tpl_over = App.Templates.get('over_bar', 'general'); var difference = parseInt(o.U_DISK_PERCENTAGE, 10) - 100; diff --git a/web/js/pages.js b/web/js/pages.js index 1343e4496..e5d465ead 100644 --- a/web/js/pages.js +++ b/web/js/pages.js @@ -4,14 +4,27 @@ App.Pages.init = function() App.Ajax.request('MAIN.getInitial', {}, function(reply) { App.Env.initialParams = reply.data; App.Helpers.updateInitial(); - if (!App.Env.initialParams.auth_user.admin) { + }); + + +/* + if (!App.Env.initialParams.auth_user.admin) { var head= document.getElementsByTagName('head')[0]; var script= document.createElement('script'); script.type= 'text/javascript'; script.src= App.Helpers.generateUrl('js/user_templates.js?'+Math.random()); head.appendChild(script); - } - }); + } + else{ + var head= document.getElementsByTagName('head')[0]; + var script= document.createElement('script'); + script.type= 'text/javascript'; + script.src= App.Helpers.generateUrl('js/templates.js?'+Math.random()); + head.appendChild(script); + } +*/ + + } App.Pages.prepareHTML(); @@ -45,6 +58,8 @@ App.Pages.prepareHTML = function() App.Pages.DNS.showSubform = function(ref) { + fb.log('loading'); + return; App.Helpers.showLoading(); var data = ref.find('.source:first').val(); App.Ajax.request('DNS.getListRecords', { diff --git a/web/js/templates.js b/web/js/templates.js index 42d64f20b..bfc39d4d7 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -144,14 +144,14 @@ App.Templates.html = { \ View template settings\ \ - \ + \
\ \ \ @@ -474,9 +474,9 @@ App.Templates.html = { ~!:FULLNAME~!\ \
\
\ - \ + \ \ email:\ \ @@ -650,10 +650,10 @@ App.Templates.html = { \
\
\ -
\ + \
\ \ \ @@ -715,7 +715,7 @@ App.Templates.html = {
\
\
\ -
\ +
\ \ \
\ diff --git a/web/js/user_templates.js b/web/js/user_templates.js index beefbc05d..42d64f20b 100644 --- a/web/js/user_templates.js +++ b/web/js/user_templates.js @@ -1,4 +1,3 @@ -alert('User templates loaded'); App.Templates.html = { help: { DNS_form: ['

Some Things You Just Can\'t Explain

\ @@ -36,7 +35,8 @@ App.Templates.html = { select_option: [''], error_elm: ['
~!:ERROR~!
'], SUSPENDED_TPL_NOT_SUSPENDED : ['enabled'], - SUSPENDED_TPL_SUSPENDED : ['suspended'] + SUSPENDED_TPL_SUSPENDED : ['suspended'], + DELETE_ACTION: ['Delete'] }, popup: { error: ['

Important: An Error Has Occured.


    Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.
,    However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on this email: BLABLA,

Sorry for inconvinience. (We recommend you to reload the page)
'], @@ -88,11 +88,11 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ \ - \ + \
\ \
\ @@ -138,20 +138,20 @@ App.Templates.html = {
\
\ \ - ~!:TPL_DEFAULT_VALUE~!\ + ~!:TPL_DEFAULT_VALUE~! t \ \ View template settings\
\ -
\ + \
\ \ \ @@ -159,7 +159,7 @@ App.Templates.html = {
\ \ Cancel\ - Delete\ + ~!:DELETE_ACTION~!\
\
' ], @@ -241,7 +241,7 @@ App.Templates.html = { \ \
\ -
\ + \
'] }, ip: { @@ -286,14 +286,14 @@ App.Templates.html = { \ \ \ -
\ + \
\ \ Cancel\ - Delete\ + ~!:DELETE_ACTION~!\
\
\ '], @@ -303,7 +303,7 @@ App.Templates.html = { \ \
\ -
\ +
\
\ ~!:SUSPENDED_TPL~!\
\ @@ -320,14 +320,14 @@ App.Templates.html = { netmask:\ ~!:NETMASK~!\ \ - \ - interface:\ - ~!:INTERFACE~!\ - \ \ name:\ ~!:NAME~!\ \ + \ + interface:\ + ~!:INTERFACE~!\ + \
\
\ \ @@ -341,7 +341,7 @@ App.Templates.html = {
\
\ \ - sys users:\ + users:\ ~!:U_SYS_USERS~!\ \ \ @@ -362,7 +362,7 @@ App.Templates.html = { user: { WEB_TPL_MINIMIZED: ['~!:WEB_TPL_MINI~!\ \ - ~!:MORE_NUMBER~! more\ + ~!:MORE_NUMBER~! more\ '], WEB_TPL: ['~!:NAME~!'], NS_MINIMIZED: ['~!:NS_MINI~!\ @@ -378,7 +378,7 @@ App.Templates.html = { PLUS_ONE_NS: [''], ENTRIES_WRAPPER: ['
~!:content~!
'], @@ -403,7 +403,7 @@ App.Templates.html = { ~!:PACKAGE_OPTIONS~!\ \
\ -
\ +
\ \ \
\
\ - \ + \ \
\
\ - \ + \ \
\ ~!:NS~!\ @@ -447,7 +447,7 @@ App.Templates.html = {
\ \ Cancel\ - Delete\ + ~!:DELETE_ACTION~!\
\
'], ENTRY: ['
\ @@ -470,16 +470,13 @@ App.Templates.html = { ~!:LOGIN_NAME~!\ \ \ - \ - package:\ - ~!:PACKAGE~!\ - \ -
\ -
\ \ - name:\ ~!:FULLNAME~!\ - \ + \
\ +
\ + \ \ email:\ \ @@ -487,9 +484,14 @@ App.Templates.html = { (reports ~!:REPORTS_ENABLED~!)\ \ \ + \ + package:\ + ~!:PACKAGE~!\ + \
\ \ - \ + \ + \ \
\
stats
\ @@ -507,24 +509,27 @@ App.Templates.html = {
~!:DISK_QUOTA~! ~!:DISK_QUOTA_MEASURE_2~!
\
\ \ - \ - \ -
\ - bandwidth:\ -
\ -
\ -
\ - ~!:U_BANDWIDTH_PERCENTAGE~!% (~!:U_BANDWIDTH~! ~!:BANDWIDTH_MEASURE~!)\ - \ - ~!:OVER_BAR_2~!\ +
\ + bandwidth:\ +
\ +
\ +
\ + ~!:U_BANDWIDTH_PERCENTAGE~!% (~!:U_BANDWIDTH~! ~!:BANDWIDTH_MEASURE~!)\ + \ + ~!:OVER_BAR_2~!\ +
\
\ +
~!:BANDWIDTH~! ~!:BANDWIDTH_MEASURE_2~!
\
\ -
~!:BANDWIDTH~! ~!:BANDWIDTH_MEASURE_2~!
\
\ -
\ +
\ \
\
\ + \ + web domains:\ + ~!:U_WEB_DOMAINS~! (~!:WEB_DOMAINS~!)\ + \ \ web ssl:\ ~!:U_WEB_SSL~! (~!:WEB_SSL~!)\ @@ -543,6 +548,37 @@ App.Templates.html = { databases:\ ~!:U_DATABASES~! (~!:DATABASES~!)\ \ + \ + Dedicated IP\'s:\ + ~!:IP_OWNED~!\ + \ + \ + cron jobs:\ + ~!:U_CRON_JOBS~!\ + \ +
\ +
\ + \ + mail domains:\ + ~!:U_MAIL_DOMAINS~! (~!:MAIL_DOMAINS~!)\ + \ + \ + mail accounts:\ + ~!:MAIL_BOXES~! per domain\ + \ + \ + mail forwarders:\ + ~!:MAIL_FORWARDERS~! per domain\ + \ + \ + dns domains:\ + ~!:U_DNS_DOMAINS~! (~!:DNS_DOMAINS~!)\ + \ + \ + name servers:\ + \ + ~!:NS~!\ + \ \ shell:\ ~!:SHELL~!\ @@ -550,35 +586,7 @@ App.Templates.html = { \ backups:\ retention ~!:BACKUPS~!\ - \ -
\ -
\ - \ - mailboxes:\ - ~!:U_MAIL_BOXES~! (~!:MAIL_BOXES~!)\ - \ - \ - mail forwarders:\ - ~!:U_MAIL_FORWARDERS~! (~!:MAIL_FORWARDERS~!)\ - \ - \ - mail domains:\ - ~!:U_MAIL_DOMAINS~! (~!:MAIL_DOMAINS~!)\ - \ - \ - web domains:\ - ~!:U_WEB_DOMAINS~! (~!:WEB_DOMAINS~!)\ - \ - \ - dns domains:\ - ~!:U_DNS_DOMAINS~! (~!:DNS_DOMAINS~!)\ - \ - \ - ns list:\ - \ - ~!:NS~!\ - \ -
\ + \
\ \ '] }, @@ -633,6 +641,10 @@ App.Templates.html = { \ \ \ + \
\ \ \ @@ -652,13 +664,18 @@ App.Templates.html = { Generate\
\ \ - \
\ - \ - \ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + ...\ + \
\
\ \ @@ -666,9 +683,9 @@ App.Templates.html = { \
\
\ - \ - ...\ - \ + \ + ...\ + \
\ \ \ @@ -680,7 +697,7 @@ App.Templates.html = { \ \ @@ -698,10 +715,14 @@ App.Templates.html = { \ \ \ +
\ + \ + \ +
\
\ \ Cancel\ - Delete\ + ~!:DELETE_ACTION~!\
\ '], ENTRIES_WRAPPER: ['
~!:content~!
'], @@ -720,7 +741,6 @@ App.Templates.html = {
\
\ ~!:DOMAIN~!\ - Alias:\ ~!:ALIAS~!\
\
\ @@ -731,6 +751,8 @@ App.Templates.html = { ~!:TPL~!\ \
\ + \ + \
\
stats
\ \ @@ -747,9 +769,8 @@ App.Templates.html = {
~!:DISK_QUOTA~! ~!:DISK_QUOTA_MEASURE_2~!
\
\
\ - \ - \ -
\ + \ +
\ bandwidth:\
\
\ @@ -761,7 +782,9 @@ App.Templates.html = {
\
~!:BANDWIDTH~! ~!:BANDWIDTH_MEASURE_2~!
\
\ -
\ +
\ + \ + \ \
\ \ @@ -792,9 +815,9 @@ App.Templates.html = { \ nginx:\ ~!:NGINX~!\ - extension list\ + extension list\ \ -
\ + \ \ '] }, @@ -823,12 +846,12 @@ App.Templates.html = { \ \
\ - \ + \ \
\
\
\ - \ + \ \
\
\ @@ -837,10 +860,14 @@ App.Templates.html = { Generate\
\
\ -