Skip to content

Commit 2c1acbe

Browse files
committed
Update add domain
With new Doc root feature
1 parent 63525df commit 2c1acbe

File tree

3 files changed

+123
-2
lines changed

3 files changed

+123
-2
lines changed

web/add/web/index.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
$v_stats = escapeshellarg($_POST['v_stats']);
9595
$v_stats_user = $data[$v_domain]['STATS_USER'];
9696
$v_stats_password = $data[$v_domain]['STATS_PASSWORD'];
97+
$v_custom_doc_domain = $_POST['v-custom-doc-domain'];
98+
$v_custom_doc_folder = $_POST['v-custom-doc-folder'];
99+
97100
$v_ftp = $_POST['v_ftp'];
98101
$v_ftp_user = $_POST['v_ftp_user'];
99102
$v_ftp_password = $_POST['v_ftp_password'];
@@ -109,7 +112,8 @@
109112
if ((!empty($_POST['v_ssl_crt'])) || (!empty($_POST['v_ssl_key']))) $v_adv = 'yes';
110113
if ((!empty($_POST['v_ssl_ca'])) || ($_POST['v_stats'] != 'none')) $v_adv = 'yes';
111114
if ((!empty($_POST['v_letsencrypt']))) $v_adv = 'yes';
112-
115+
if (!empty($_POST['v_custom_doc_root_check'])){$v_adv = 'yes'; $v_custom_doc_root = 1; }
116+
113117
// Check advanced features
114118
if (empty($_POST['v_dns'])) $v_dns = 'off';
115119
if (empty($_POST['v_mail'])) $v_mail = 'off';
@@ -227,6 +231,23 @@
227231
unlink($v_stats_password);
228232
$v_stats_password = escapeshellarg($_POST['v_stats_password']);
229233
}
234+
if ( !empty($_POST['v-custom-doc-domain']) && !empty($_POST['v_custom_doc_root_check']) && $v_custom_doc_root_prepath.$v_custom_doc_domain.'/public_html'.$v_custom_doc_folder != $v_custom_doc_root){
235+
if($_POST['v-custom-doc-domain'] == $v_domain && empty($_POST['v-custom-doc-folder'])){
236+
237+
}else{
238+
$v_custom_doc_domain = escapeshellarg($_POST['v-custom-doc-domain']);
239+
$v_custom_doc_folder = escapeshellarg($_POST['v-custom-doc-folder']);
240+
$v_domain = escapeshellarg(trim($_POST['v_domain']));
241+
242+
exec(HESTIA_CMD."v-change-web-domain-docroot ".$user." ".$v_domain." ".$v_custom_doc_domain." ".$v_custom_doc_folder, $output, $return_var);
243+
check_return_code($return_var,$output);
244+
unset($output);
245+
$v_custom_doc_root = 1;
246+
}
247+
}else{
248+
unset($v_custom_doc_root);
249+
}
250+
230251

231252
// Restart DNS server
232253
if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
@@ -365,6 +386,12 @@
365386
$stats = json_decode(implode('', $output), true);
366387
unset($output);
367388

389+
// Get all user domains
390+
exec (HESTIA_CMD."v-list-web-domains ".escapeshellarg($user)." json", $output, $return_var);
391+
$user_domains = json_decode(implode('', $output), true);
392+
$user_domains = array_keys($user_domains);
393+
unset($output);
394+
368395
// Render page
369396
render_page($user, $TAB, 'add_web');
370397

web/js/pages/add_web.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
App.Actions.WEB.update_custom_doc_root = function(elm, hint) {
2+
var prepath = $('input[name="v-custom-doc-root_prepath"]').val();
3+
var domain = $('select[name="v-custom-doc-domain"]').val();
4+
var folder = $('input[name="v-custom-doc-folder"]').val();
5+
console.log(domain, folder);
6+
$('.custom_docroot_hint').html(prepath+domain+'/public_html/'+folder);
7+
}
8+
App.Listeners.DB.keypress_custom_folder = function() {
9+
var ref = $('input[name="v-custom-doc-folder"]');
10+
var current_rec = ref.val();
11+
App.Actions.WEB.update_custom_doc_root(ref, current_rec);
12+
13+
ref.bind('keypress input', function(evt) {
14+
clearTimeout(window.frp_usr_tmt);
15+
window.frp_usr_tmt = setTimeout(function() {
16+
var elm = $(evt.target);
17+
App.Actions.WEB.update_custom_doc_root(elm, $(elm).val());
18+
});
19+
});
20+
}
21+
22+
App.Listeners.DB.change_custom_doc = function() {
23+
var ref = $('select[name="v-custom-doc-domain"]');
24+
var current_rec = ref.val();
25+
ref.bind('change select', function(evt) {
26+
clearTimeout(window.frp_usr_tmt);
27+
window.frp_usr_tmt = setTimeout(function() {
28+
var elm = $(evt.target);
29+
App.Actions.WEB.update_custom_doc_root(elm, $(elm).val());
30+
var domain = $('.ftp-path-prefix').text(GLOBAL.FTP_USER_PREPATH + '/' + $(evt.target));
31+
32+
});
33+
});
34+
}
35+
136
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
237
if (hint.trim() == '') {
338
$(elm).parent().find('.hint').html('');
@@ -38,6 +73,9 @@ App.Listeners.WEB.keypress_domain_name = function() {
3873
//var elm = $(evt.target);
3974
//App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
4075
var domain = $('.ftp-path-prefix').text(GLOBAL.FTP_USER_PREPATH + '/' + $('#v_domain').val());
76+
$('#v-custom-doc-domain-main').text($('#v_domain').val());
77+
$('#v-custom-doc-domain-main').val($('#v_domain').val());
78+
4179
}, 100);
4280
});
4381
}

web/templates/admin/add_web.html

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,63 @@
195195
</table>
196196
</td>
197197
</tr>
198-
198+
<tr>
199+
<td class="vst-text step-top">
200+
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_custom_doc_root_check" <?php if (!empty($v_custom_doc_root)) echo "checked=yes" ?> onclick="javascript:elementHideShow('v_custom_doc_root');"> <?php print __('Custom document root');?></label>
201+
</td>
202+
</tr>
203+
<tr>
204+
<td class="step-left">
205+
<table style="display:<?php if (empty($v_custom_doc_root)) { echo 'none';} else {echo 'block';}?> ;" id="v_custom_doc_root">
206+
<tr>
207+
<td class="vst-text input-label">
208+
<?php print __('Point to');?>
209+
</td>
210+
</tr>
211+
<tr>
212+
<td>
213+
<input type="hidden" name="v-custom-doc-root_prepath"" value="<?php echo $v_custom_doc_root_prepath;?>">
214+
<select class="vst-list" name="v-custom-doc-domain">
215+
<option value="<?=htmlentities(trim($v_domain, "'"))?>" id="v-custom-doc-domain-main"><?=htmlentities(trim($v_domain, "'"))?></option>
216+
<?php
217+
foreach ($user_domains as $domain) {
218+
if($domain != $v_domain ){
219+
if($v_custom_doc_domain == $domain){
220+
?>
221+
<option value="<?php echo $domain;?>" selected="selected"><?php echo $domain;?></option>
222+
<?php
223+
}else{
224+
?>
225+
<option value="<?php echo $domain;?>"><?php echo $domain;?></option>
226+
<?php
227+
}
228+
}
229+
}
230+
?>
231+
</select>
232+
</td>
233+
</tr>
234+
<tr>
235+
<td class="vst-text input-label">
236+
<?php print( __('Folder'));?>
237+
</td>
238+
</tr>
239+
<tr>
240+
<td>
241+
<input type="text" size="20" class="vst-input"
242+
name="v-custom-doc-folder" value="<?=htmlentities(trim($v_custom_doc_folder, "'"))?>">
243+
</td>
244+
</tr>
245+
<tr>
246+
<td>
247+
<small class="custom_docroot_hint"></small>
248+
</td>
249+
</tr>
250+
251+
</table>
252+
</td>
253+
</tr>
254+
199255
<tr>
200256
<td class="step-top vst-text">
201257
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_ssl" <?php if($v_ssl == 'yes' || $v_ssl == 'on') echo "checked=yes" ?> onclick="javascript:elementHideShow('ssltable');"> <?php print __('SSL Support');?></label>

0 commit comments

Comments
 (0)