Skip to content

Commit 73e46d9

Browse files
authored
Allow sorting package name + Fix issue with DNS disabled (hestiacp#3726)
* Sort by package https://forum.hestiacp.com/t/sort-users-by-package-type/9909/2 * Fix sorting * Check if DNS System is enabled * Fix: 3712 Unable to restore domain with custom doc root Closes hestiacp#3712
1 parent 98bc6cd commit 73e46d9

File tree

3 files changed

+85
-77
lines changed

3 files changed

+85
-77
lines changed

bin/v-restore-user

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ if [ "$web" != 'no' ] && [ -n "$WEB_SYSTEM" ]; then
291291
fi
292292

293293
if [ -n "$CUSTOM_DOCROOT" ]; then
294-
CUSTOM_DOCROOT=$(echo "$CUSTOM_DOCROOT" | sed -e "s|/home/${old_user}/web/|/home/${user}/web/")
294+
CUSTOM_DOCROOT=$(echo "$CUSTOM_DOCROOT" | sed -e "s|/home/${old_user}/web/|/home/${user}/web/|g")
295295
fi
296296
if [ -n "$CUSTOM_PHPROOT" ]; then
297-
CUSTOM_PHPROOT=$(echo "$CUSTOM_PHPROOT" | sed -e "s|/home/${old_user}/web/|/home/${user}/web/")
297+
CUSTOM_PHPROOT=$(echo "$CUSTOM_PHPROOT" | sed -e "s|/home/${old_user}/web/|/home/${user}/web/|g")
298298
fi
299299

300300
# Converting FTP users

web/edit/user/index.php

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -451,88 +451,92 @@
451451
}
452452
}
453453

454-
// Change NameServers
455-
if (empty($_POST["v_ns1"])) {
456-
$_POST["v_ns1"] = "";
457-
}
458-
if (empty($_POST["v_ns2"])) {
459-
$_POST["v_ns2"] = "";
460-
}
461-
if (empty($_POST["v_ns3"])) {
462-
$_POST["v_ns3"] = "";
463-
}
464-
if (empty($_POST["v_ns4"])) {
465-
$_POST["v_ns4"] = "";
466-
}
467-
if (empty($_POST["v_ns5"])) {
468-
$_POST["v_ns5"] = "";
469-
}
470-
if (empty($_POST["v_ns6"])) {
471-
$_POST["v_ns6"] = "";
472-
}
473-
if (empty($_POST["v_ns7"])) {
474-
$_POST["v_ns7"] = "";
475-
}
476-
if (empty($_POST["v_ns8"])) {
477-
$_POST["v_ns8"] = "";
478-
}
479-
480-
if (
481-
$v_ns1 != $_POST["v_ns1"] ||
482-
$v_ns2 != $_POST["v_ns2"] ||
483-
$v_ns3 != $_POST["v_ns3"] ||
484-
$v_ns4 != $_POST["v_ns4"] ||
485-
$v_ns5 != $_POST["v_ns5"] ||
486-
$v_ns6 != $_POST["v_ns6"] ||
487-
$v_ns7 != $_POST["v_ns7"] ||
488-
($v_ns8 != $_POST["v_ns8"] && empty($_SESSION["error_msg"]))
489-
) {
490-
$v_ns1 = quoteshellarg($_POST["v_ns1"]);
491-
$v_ns2 = quoteshellarg($_POST["v_ns2"]);
492-
$v_ns3 = quoteshellarg($_POST["v_ns3"]);
493-
$v_ns4 = quoteshellarg($_POST["v_ns4"]);
494-
$v_ns5 = quoteshellarg($_POST["v_ns5"]);
495-
$v_ns6 = quoteshellarg($_POST["v_ns6"]);
496-
$v_ns7 = quoteshellarg($_POST["v_ns7"]);
497-
$v_ns8 = quoteshellarg($_POST["v_ns8"]);
498-
$ns_cmd =
499-
HESTIA_CMD .
500-
"v-change-user-ns " .
501-
quoteshellarg($v_username) .
502-
" " .
503-
$v_ns1 .
504-
" " .
505-
$v_ns2;
506-
if (!empty($_POST["v_ns3"])) {
507-
$ns_cmd = $ns_cmd . " " . $v_ns3;
454+
if (!empty($_SESSION["DNS_SYSTEM"])) {
455+
// Change NameServers
456+
if (empty($_POST["v_ns1"])) {
457+
$_POST["v_ns1"] = "";
508458
}
509-
if (!empty($_POST["v_ns4"])) {
510-
$ns_cmd = $ns_cmd . " " . $v_ns4;
459+
if (empty($_POST["v_ns2"])) {
460+
$_POST["v_ns2"] = "";
511461
}
512-
if (!empty($_POST["v_ns5"])) {
513-
$ns_cmd = $ns_cmd . " " . $v_ns5;
462+
if (empty($_POST["v_ns3"])) {
463+
$_POST["v_ns3"] = "";
514464
}
515-
if (!empty($_POST["v_ns6"])) {
516-
$ns_cmd = $ns_cmd . " " . $v_ns6;
465+
if (empty($_POST["v_ns4"])) {
466+
$_POST["v_ns4"] = "";
517467
}
518-
if (!empty($_POST["v_ns7"])) {
519-
$ns_cmd = $ns_cmd . " " . $v_ns7;
468+
if (empty($_POST["v_ns5"])) {
469+
$_POST["v_ns5"] = "";
520470
}
521-
if (!empty($_POST["v_ns8"])) {
522-
$ns_cmd = $ns_cmd . " " . $v_ns8;
471+
if (empty($_POST["v_ns6"])) {
472+
$_POST["v_ns6"] = "";
523473
}
524-
exec($ns_cmd, $output, $return_var);
525-
check_return_code($return_var, $output);
526-
unset($output);
474+
if (empty($_POST["v_ns7"])) {
475+
$_POST["v_ns7"] = "";
476+
}
477+
if (empty($_POST["v_ns8"])) {
478+
$_POST["v_ns8"] = "";
479+
}
480+
481+
if (
482+
$v_ns1 != $_POST["v_ns1"] ||
483+
$v_ns2 != $_POST["v_ns2"] ||
484+
$v_ns3 != $_POST["v_ns3"] ||
485+
$v_ns4 != $_POST["v_ns4"] ||
486+
$v_ns5 != $_POST["v_ns5"] ||
487+
$v_ns6 != $_POST["v_ns6"] ||
488+
$v_ns7 != $_POST["v_ns7"] ||
489+
($v_ns8 != $_POST["v_ns8"] &&
490+
empty($_SESSION["error_msg"] && !empty($_POST["v_ns1"]) && $_POST["v_ns2"]))
491+
) {
492+
$v_ns1 = quoteshellarg($_POST["v_ns1"]);
493+
$v_ns2 = quoteshellarg($_POST["v_ns2"]);
494+
$v_ns3 = quoteshellarg($_POST["v_ns3"]);
495+
$v_ns4 = quoteshellarg($_POST["v_ns4"]);
496+
$v_ns5 = quoteshellarg($_POST["v_ns5"]);
497+
$v_ns6 = quoteshellarg($_POST["v_ns6"]);
498+
$v_ns7 = quoteshellarg($_POST["v_ns7"]);
499+
$v_ns8 = quoteshellarg($_POST["v_ns8"]);
500+
501+
$ns_cmd =
502+
HESTIA_CMD .
503+
"v-change-user-ns " .
504+
quoteshellarg($v_username) .
505+
" " .
506+
$v_ns1 .
507+
" " .
508+
$v_ns2;
509+
if (!empty($_POST["v_ns3"])) {
510+
$ns_cmd = $ns_cmd . " " . $v_ns3;
511+
}
512+
if (!empty($_POST["v_ns4"])) {
513+
$ns_cmd = $ns_cmd . " " . $v_ns4;
514+
}
515+
if (!empty($_POST["v_ns5"])) {
516+
$ns_cmd = $ns_cmd . " " . $v_ns5;
517+
}
518+
if (!empty($_POST["v_ns6"])) {
519+
$ns_cmd = $ns_cmd . " " . $v_ns6;
520+
}
521+
if (!empty($_POST["v_ns7"])) {
522+
$ns_cmd = $ns_cmd . " " . $v_ns7;
523+
}
524+
if (!empty($_POST["v_ns8"])) {
525+
$ns_cmd = $ns_cmd . " " . $v_ns8;
526+
}
527+
exec($ns_cmd, $output, $return_var);
528+
check_return_code($return_var, $output);
529+
unset($output);
527530

528-
$v_ns1 = str_replace("'", "", $v_ns1);
529-
$v_ns2 = str_replace("'", "", $v_ns2);
530-
$v_ns3 = str_replace("'", "", $v_ns3);
531-
$v_ns4 = str_replace("'", "", $v_ns4);
532-
$v_ns5 = str_replace("'", "", $v_ns5);
533-
$v_ns6 = str_replace("'", "", $v_ns6);
534-
$v_ns7 = str_replace("'", "", $v_ns7);
535-
$v_ns8 = str_replace("'", "", $v_ns8);
531+
$v_ns1 = str_replace("'", "", $v_ns1);
532+
$v_ns2 = str_replace("'", "", $v_ns2);
533+
$v_ns3 = str_replace("'", "", $v_ns3);
534+
$v_ns4 = str_replace("'", "", $v_ns4);
535+
$v_ns5 = str_replace("'", "", $v_ns5);
536+
$v_ns6 = str_replace("'", "", $v_ns6);
537+
$v_ns7 = str_replace("'", "", $v_ns7);
538+
$v_ns8 = str_replace("'", "", $v_ns8);
539+
}
536540
}
537541

538542
// Set success message

web/templates/pages/list_user.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<li data-entity="sort-disk" data-sort-as-int="1">
2929
<span class="name"><?= _("Disk") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
3030
</li>
31+
<li data-entity="sort-package">
32+
<span class="name"><?= _("Package") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
33+
</li>
3134
<li data-entity="sort-name">
3235
<span class="name <?php if ($_SESSION['userSortOrder'] === 'name') { echo 'active'; } ?>"><?= _("Name") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
3336
</li>
@@ -133,6 +136,7 @@
133136
<div class="units-table-row <?php if ($status == 'suspended') echo 'disabled'; ?> animate__animated animate__fadeIn js-unit <?php if (($_SESSION['POLICY_SYSTEM_HIDE_ADMIN'] === 'yes') && ($_SESSION['user'] !== 'admin') && ($key === 'admin')) { echo 'u-hidden'; } ?>"
134137
data-sort-date="<?= strtotime($data[$key]['DATE'].' '.$data[$key]['TIME']) ?>"
135138
data-sort-name="<?= strtolower($key) ?>"
139+
data-sort-package="<?= strtolower($data[$key]['PACKAGE']) ?>"
136140
data-sort-bandwidth="<?= $data[$key]["U_BANDWIDTH"] ?>"
137141
data-sort-disk="<?= $data[$key]["U_DISK"] ?>">
138142
<div class="units-table-cell">

0 commit comments

Comments
 (0)