We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
[MOD] Admin package power - add domain control
[MOD] Admin package power - add domain control
If you need a package that only grants the admin power to add new web,dns,email,db and web alias domains yet allows the user the freedom to edit domains already added, then this is for you.
What this mod does.
All users that are within a package named "Managed" are restricted as follows;
Deny users the ability to add new domain under WEB,DNS,EMAIL tab without permission.
Deny users the ability to create web aliases on listed domain edit tab to create extra dns domains without permission.
Deny users the ability to create Databases under DB tab without permission.
Allow users to edit all domains added by the admin under all conditions met except the above restrictions.
----
Please note this will not survive any vestacp updates and will break your installation.
When updating vestacp check what files are being updated by vestacp and patch files with your mods as needed... always backup.
Lets start...
First lets create a package and name it "Managed".
1). If you name the package something else change the package name reference in each below.
2). Select unlimited for everything, except the backups and other things you don't want users to have on the package.
Second, lets create a test user, assign the user to the "Managed" package.
Thirdly, lets create a page with some information.
This page is what users will see when trying to add domains that are in the package named "Managed".
This is a sample of what to put inside. Customize it to your liking....
=====================================================================
Now lets edit 4 index.php files and one html file.
===== WEB
===== WEB ALIASES
===== MAIL
===== DNS
===== DB
=================== DONE ===================
That's it.
Now that you have backups you can revert back when every you want if something went wrong.
Hope you can make use of this quick and dirty little mod, may need some tlc and tweaking, but it worked for us today when we needed it.
Modifications, changes, suggestions will be amended to this first post.
Just remember this mod is only a temporary workaround until something permanent is made.
happy coding....
What this mod does.
All users that are within a package named "Managed" are restricted as follows;
Deny users the ability to add new domain under WEB,DNS,EMAIL tab without permission.
Deny users the ability to create web aliases on listed domain edit tab to create extra dns domains without permission.
Deny users the ability to create Databases under DB tab without permission.
Allow users to edit all domains added by the admin under all conditions met except the above restrictions.
----
Please note this will not survive any vestacp updates and will break your installation.
When updating vestacp check what files are being updated by vestacp and patch files with your mods as needed... always backup.
This will only take 30 minutes to implement. Test each before proceeding to the next sectionI hope vestacp in the future will have a more permanent solution in the core perhaps a flag feature (0/1) CANADDWEB=0 CANADDDNS=1 CANADDMAIL=1 CANADDALIASES=0 in the (user.conf), so when setting up packages we can give permission on each section not just how many, web,dns,email,aliases. This way we can offer free or other types of accounts fully controlled by admins which can prevent abuse or for types of subscriptions like free services based on another purchase. get my drift :)
Lets start...
First lets create a package and name it "Managed".
1). If you name the package something else change the package name reference in each below.
2). Select unlimited for everything, except the backups and other things you don't want users to have on the package.
Second, lets create a test user, assign the user to the "Managed" package.
Thirdly, lets create a page with some information.
This page is what users will see when trying to add domains that are in the package named "Managed".
Code: Select all
nano /usr/local/vesta/web/templates/admin/admin_managed.html
Code: Select all
<div class="l-center" style="padding-top: 259px;">
<h2>Your current hosting package is <font color="#ff6701">Managed</font>.</h2>
Please submit new domain hosting requests for web, dns, email & db accounts to the admin.<br />
Limits apply based on your subscription.<br /><br />
☆ Want to add domains yourself? Upgrade to Premium domain hosting to unlock it.<br />
☆ See our website for available premium hosting packages and upgrades.
</div>
Now lets edit 4 index.php files and one html file.
===== WEB
SpoilerShow
block the adding of new web domains without permission
BACKUP
OPEN
FIND
CHANGE TO
BACKUP WITH MOD
Test it! All good continue to next part....
BACKUP
Code: Select all
cp /usr/local/vesta/web/add/web/index.php /usr/local/vesta/web/add/web/index.php.backup_orig
Code: Select all
nano /usr/local/vesta/web/add/web/index.php
Code: Select all
// Display body
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html');
Code: Select all
// Display body
if ($_SESSION['user'] == 'admin' && isset($_SESSION['look'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html');
} else {
if ($panel[$user]['PACKAGE'] == "Managed") {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/admin_managed.html');
} else {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html');
}
}
Code: Select all
cp /usr/local/vesta/web/add/web/index.php /usr/local/vesta/web/add/web/index.php.backup_mod
SpoilerShow
block the adding of domain aliases so extra DNS domains aren't created without permission.
BACKUP
OPEN
FIND
CHANGE TO
BACKUP WITH MOD
Test it! All good continue to next part...
BACKUP
Code: Select all
cp /usr/local/vesta/web/templates/user/edit_web.html /usr/local/vesta/web/templates/user/edit_web.html.backup_orig
Code: Select all
nano /usr/local/vesta/web/templates/user/edit_web.html
Code: Select all
<td class="vst-text input-label">
<?php print __('Aliases');?>
</td>
</tr>
<tr>
<td>
<textarea size="20" class="vst-textinput" name="v_aliases"><?php if (!empty($v_aliases)) echo htmlentities($v_aliases); ?></textarea>
</td>
Code: Select all
<td class="vst-text input-label">
<?php print __('Aliases');?>
</td>
</tr>
<tr>
<td>
<?php if ($_SESSION['user'] == 'admin' && isset($_SESSION['look'])) { ?>
<textarea size="20" class="vst-textinput" name="v_aliases"><?php if (!empty($v_aliases)) echo htmlentities($v_aliases); ?></textarea>
<?php } else {
if ($panel[$user]['PACKAGE'] == "Managed") { ?>
<textarea size="20" class="vst-textinput" disabled><?php if (!empty($v_aliases)) echo htmlentities($v_aliases); ?></textarea>
<?php } else { ?>
<textarea size="20" class="vst-textinput" name="v_aliases"><?php if (!empty($v_aliases)) echo htmlentities($v_aliases); ?></textarea>
<? }
}
?>
</td>
Code: Select all
cp /usr/local/vesta/web/templates/user/edit_web.html /usr/local/vesta/web/templates/user/edit_web.html.backup_mod
SpoilerShow
block the adding of new email domains without permission
BACKUP
OPEN
FIND
CHANGE TO
BACKUP WITH MOD
Test it! All good continue to next part...
BACKUP
Code: Select all
cp /usr/local/vesta/web/add/mail/index.php /usr/local/vesta/web/add/mail/index.php.backup_orig
Code: Select all
nano /usr/local/vesta/web/add/mail/index.php
Code: Select all
// Display body for mail domain
if (empty($_GET['domain'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html');
}
// Display body for mail account
if (!empty($_GET['domain'])) {
$v_domain = $_GET['domain'];
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html');
}
Code: Select all
if ($_SESSION['user'] == 'admin' && isset($_SESSION['look']) ) {
// Display body for mail domain
if (empty($_GET['domain'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html');
}
// Display body for mail account
if (!empty($_GET['domain'])) {
$v_domain = $_GET['domain'];
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html');
}
} else {
if ($panel[$user]['PACKAGE'] == "Managed") {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/admin_managed.html');
} else {
// Display body for mail domain
if (empty($_GET['domain'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html');
}
// Display body for mail account
if (!empty($_GET['domain'])) {
$v_domain = $_GET['domain'];
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html');
}
}
}
Code: Select all
cp /usr/local/vesta/web/add/mail/index.php /usr/local/vesta/web/add/mail/index.php.backup_mod
SpoilerShow
block the adding of new dns domains without permission
BACKUP
OPEN
FIND
CHANGE TO
BACKUP WITH MOD
Test it! All good continue to next part...
BACKUP
Code: Select all
cp /usr/local/vesta/web/add/dns/index.php /usr/local/vesta/web/add/dns/index.php.backup_orig
Code: Select all
nano /usr/local/vesta/web/add/dns/index.php
Code: Select all
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
Code: Select all
if ($_SESSION['user'] == 'admin' && isset($_SESSION['look'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
} else {
if ($panel[$user]['PACKAGE'] == "Managed") {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/admin_managed.html');
} else {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html');
}
}
Code: Select all
cp /usr/local/vesta/web/add/dns/index.php /usr/local/vesta/web/add/dns/index.php.backup_mod
SpoilerShow
block the adding of new databases without permission
BACKUP
OPEN
FIND
CHANGE TO
BACKUP WITH MOD
BACKUP
Code: Select all
cp /usr/local/vesta/web/add/db/index.php /usr/local/vesta/web/add/db/index.php.backup_orig
Code: Select all
nano /usr/local/vesta/web/add/db/index.php
Code: Select all
// Display body
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
Code: Select all
if ($_SESSION['user'] == 'admin' && isset($_SESSION['look'])) {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
} else {
if ($panel[$user]['PACKAGE'] == "Managed") {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/admin_managed.html');
} else {
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html');
}
}
Code: Select all
cp /usr/local/vesta/web/add/db/index.php /usr/local/vesta/web/add/db/index.php.backup_mod
That's it.
Now that you have backups you can revert back when every you want if something went wrong.
Hope you can make use of this quick and dirty little mod, may need some tlc and tweaking, but it worked for us today when we needed it.
Modifications, changes, suggestions will be amended to this first post.
Just remember this mod is only a temporary workaround until something permanent is made.
happy coding....