Skip to content

Commit 5b48ba7

Browse files
committed
Web Ui Admin update custom doc root
1 parent eaeb890 commit 5b48ba7

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

bin/v-list-web-domain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ json_list() {
4141
"BACKEND": "'$BACKEND'",
4242
"PROXY": "'$PROXY'",
4343
"PROXY_EXT": "'$PROXY_EXT'",
44+
"CUSTOM_DOCROOT": "'$CUSTOM_DOCROOT'",
4445
"SUSPENDED": "'$SUSPENDED'",
4546
"TIME": "'$TIME'",
4647
"DATE": "'$DATE'"

web/edit/web/index.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@
7373
$v_stats = $data[$v_domain]['STATS'];
7474
$v_stats_user = $data[$v_domain]['STATS_USER'];
7575
if (!empty($v_stats_user)) $v_stats_password = "";
76+
$v_custom_doc_root_prepath = '/home/'.$v_username.'/web/';
77+
$v_costum_doc_root = $data[$v_domain]['CUSTOM_DOCROOT'];
78+
79+
$m = preg_match('/\/home\/'.$v_username.'\/web\/([A-Za-z0-9.-].*)\/([A-Za-z0-9.-\/].*)/', $v_costum_doc_root, $matches);
80+
$v_costum_doc_domain = $matches[1];
81+
$v_costum_doc_folder = str_replace('public_html/','',$matches[2]);
82+
7683
$v_ftp_user = $data[$v_domain]['FTP_USER'];
7784
$v_ftp_path = $data[$v_domain]['FTP_PATH'];
7885
if (!empty($v_ftp_user)) $v_ftp_password = "";
79-
$v_ftp_user_prepath = $data[$v_domain]['DOCUMENT_ROOT'];
80-
$v_ftp_user_prepath = str_replace('/public_html', '', $v_ftp_user_prepath, $occurance = 1);
86+
$v_ftp_user_prepath = '/home/'.$v_username.'/web/'.$v_domain;
8187
$v_ftp_email = $panel[$user]['CONTACT'];
8288
$v_suspended = $data[$v_domain]['SUSPENDED'];
8389
if ( $v_suspended == 'yes' ) {
@@ -119,6 +125,11 @@
119125
$stats = json_decode(implode('', $output), true);
120126
unset($output);
121127

128+
//List web doamins
129+
exec (HESTIA_CMD."v-list-web-domains ".$user." json", $output, $return_var);
130+
$domains = json_decode(implode('', $output), true);
131+
unset($output);
132+
122133
// Check POST request
123134
if (!empty($_POST['save'])) {
124135
$v_domain = $_POST['v_domain'];
@@ -736,6 +747,27 @@
736747
}
737748
}
738749
}
750+
//custom docoot with check box disabled
751+
if( !empty($v_costum_doc_root) && empty($_POST['v_custom_doc_root_check']) ){
752+
exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." default", $output, $return_var);
753+
check_return_code($return_var,$output);
754+
unset($output);
755+
unset($_POST['v-costum-doc-domain'], $_POST['v-costum-doc-folder']);
756+
}
757+
758+
if ( !empty($_POST['v-costum-doc-domain']) && $v_custom_doc_root_prepath.$v_costum_doc_domain.'/public_html'.$v_costum_doc_folder != $v_costum_doc_root){
759+
760+
$v_costum_doc_domain = escapeshellarg($_POST['v-costum-doc-domain']);
761+
$v_costum_doc_folder = escapeshellarg($_POST['v-costum-doc-folder']);
762+
763+
exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." ".$v_costum_doc_domain." ".$v_costum_doc_folder, $output, $return_var);
764+
check_return_code($return_var,$output);
765+
unset($output);
766+
$v_costum_doc_root = 1;
767+
768+
769+
}
770+
739771

740772
// Restart web server
741773
if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {

web/js/pages/edit_web.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
App.Actions.WEB.update_custom_doc_root = function(elm, hint) {
2+
var prepath = $('input[name="v-costum-doc-root_prepath"]').val();
3+
var domain = $('select[name="v-costum-doc-domain"]').val();
4+
var folder = $('input[name="v-costum-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-costum-doc-folder"]');
10+
var current_rec = ref.val();
11+
App.Actions.WEB.update_custom_doc_root(ref, current_rec);
12+
13+
14+
ref.bind('keypress input', function(evt) {
15+
clearTimeout(window.frp_usr_tmt);
16+
window.frp_usr_tmt = setTimeout(function() {
17+
var elm = $(evt.target);
18+
App.Actions.WEB.update_custom_doc_root(elm, $(elm).val());
19+
});
20+
});
21+
}
22+
23+
App.Listeners.DB.change_custom_doc = function() {
24+
var ref = $('select[name="v-custom-domain"]');
25+
var current_rec = ref.val();
26+
ref.bind('change select', function(evt) {
27+
clearTimeout(window.frp_usr_tmt);
28+
window.frp_usr_tmt = setTimeout(function() {
29+
var elm = $(evt.target);
30+
App.Actions.WEB.update_custom_doc_root(elm, $(elm).val());
31+
});
32+
});
33+
}
34+
35+
// Page entry point
36+
// Trigger listeners
37+
App.Listeners.DB.keypress_custom_folder();
38+
App.Listeners.DB.change_custom_doc();
39+
140
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
241
if (hint.trim() == '') {
342
$(elm).parent().find('.hint').html('');

web/templates/admin/edit_web.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,63 @@
243243
</td>
244244
</tr>
245245
<?php } ?>
246+
<tr>
247+
<td class="vst-text step-top">
248+
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_custom_doc_root_check" <?php if (!empty($v_costum_doc_root)) echo "checked=yes" ?> onclick="javascript:elementHideShow('v_custom_doc_root');"> <?php print __('Custom document root');?></label>
249+
</td>
250+
</tr>
251+
<tr>
252+
<td class="step-left">
253+
<table style="display:<?php if (empty($v_costum_doc_root)) { echo 'none';} else {echo 'block';}?> ;" id="v_custom_doc_root">
254+
<tr>
255+
<td class="vst-text input-label">
256+
<?php print __('Point to');?>
257+
</td>
258+
</tr>
259+
<tr>
260+
<td>
261+
<input type="hidden" name="v-costum-doc-root_prepath"" value="<?php echo $v_custom_doc_root_prepath;?>">
262+
<select class="vst-list" name="v-costum-doc-domain">
263+
<option value="<?php echo $v_domain;?>"><?php echo $v_domain;?></option>
264+
<?php
265+
foreach ($domains as $key => $d) {
266+
if($key != $v_domain ){
267+
if($v_costum_doc_domain == $key){
268+
?>
269+
<option value="<?php echo $key;?>" selected="selected"><?php echo $key;?></option>
270+
<?php
271+
}else{
272+
?>
273+
<option value="<?php echo $key;?>"><?php echo $key;?></option>
274+
<?php
275+
}
276+
}
277+
}
278+
?>
279+
</select>
280+
</td>
281+
</tr>
282+
<tr>
283+
<td class="vst-text input-label">
284+
<?php print( __('Folder'));?>
285+
</td>
286+
</tr>
287+
<tr>
288+
<td>
289+
<input type="text" size="20" class="vst-input"
290+
name="v-costum-doc-folder" value="<?=htmlentities(trim($v_costum_doc_folder, "'"))?>">
291+
</td>
292+
</tr>
293+
<tr>
294+
<td>
295+
<small class="custom_docroot_hint"></small>
296+
</td>
297+
</tr>
298+
299+
</table>
300+
</td>
301+
</tr>
302+
246303
<tr>
247304
<td class="vst-text step-top">
248305
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_ssl" <?php if ($v_ssl == 'yes') echo "checked=yes" ?> onclick="javascript:elementHideShow('ssltable');"> <?php print __('SSL Support');?></label>

0 commit comments

Comments
 (0)