Compare commits

..

No commits in common. "ed48b460605daef5d07d0ce15406926f022a5931" and "f73aec13f4d91d6282af7b676e7c2bda3562e04f" have entirely different histories.

9 changed files with 94 additions and 179 deletions

View File

@ -133,7 +133,6 @@ class Login extends \Panel {
/* user authenticated, check if they own requested domain */ /* user authenticated, check if they own requested domain */
if ($domain_array = $f3->call('\Panel::vGet', array("vhost-get.sh -u $username -d $domain -c", FALSE))) { if ($domain_array = $f3->call('\Panel::vGet', array("vhost-get.sh -u $username -d $domain -c", FALSE))) {
$f3->set('SESSION.expiration', time() + $f3->get('TIMEOUT')); $f3->set('SESSION.expiration', time() + $f3->get('TIMEOUT'));
$f3->set('SESSION.vhostusername', $username);
$f3->reroute('/'); $f3->reroute('/');
} else { } else {
/* user does not own domain, check if user is a vpanel admin */ /* user does not own domain, check if user is a vpanel admin */
@ -143,7 +142,8 @@ class Login extends \Panel {
$f3->reroute('/'); $f3->reroute('/');
} else { } else {
/* user does not own domain, and is not a vpanel admin */ /* user does not own domain, and is not a vpanel admin */
$messages[] = "Invalid user. Please try another username."; $messages[] = "User validated, but does not have admin privileges for $domain.";
$messages[] = "Please try another username.";
$f3->set('SESSION.messages', $messages); $f3->set('SESSION.messages', $messages);
echo \Template::instance()->render('login.html'); echo \Template::instance()->render('login.html');
} }

View File

@ -15,27 +15,7 @@ class UsersEdit extends \Panel\Vhost {
parent::beforeRoute($f3); parent::beforeRoute($f3);
$username = $f3->get('PARAMS.username'); $username = $f3->get('PARAMS.username');
if ($user_array = $f3->call('\Panel::vGet', array("vhost-user-get.sh -u $username -c", FALSE))) {
/* exta auth checks if logged in via vhost mapping */
if ($f3->get('NAV.mapping') == 'vhost') {
if ($f3->exists('SESSION.vhostusername')) {
/* vhostusername indicates vhost user login */
$vhostusername = $f3->get('SESSION.vhostusername');
if ($username != $vhostusername) {
/* trying to edit wrong username, redirect back home */
$messages[] = "Unauthorized request.";
$f3->set('SESSION.messages', $messages);
$f3->reroute("/");
}
} else {
/* SESSION.vhostusername not set. Something went wrong, redirect back home */
$messages[] = "Error verifying system user for domain $domain, can not edit.";
$f3->set('SESSION.messages', $messages);
$f3->reroute("/");
}
}
if ($user_array = $f3->call('\Panel::vGet', array("vhost-user-get.sh -u $username -c -v", FALSE))) {
if ($user_array[0]['passwd'] == "") { if ($user_array[0]['passwd'] == "") {
$user_array[0]['passwd'] = '(unavailable)'; $user_array[0]['passwd'] = '(unavailable)';
} }
@ -76,7 +56,7 @@ class UsersEdit extends \Panel\Vhost {
} else { } else {
$password = escapeshellarg($password); $password = escapeshellarg($password);
if ($f3->get('WRITEUSERINFO') == '1') { if ($f3->get('WRITEUSERINFO') == '1') {
exec("/usr/local/bin/vhost-user-mod.sh -u $username -p $password -w 1", $output, $result_code); exec("/usr/local/bin/vhost-user-mod.sh -u $username -p $password -w", $output, $result_code);
} else { } else {
exec("/usr/local/bin/vhost-user-mod.sh -u $username -p $password", $output, $result_code); exec("/usr/local/bin/vhost-user-mod.sh -u $username -p $password", $output, $result_code);
} }
@ -89,6 +69,7 @@ class UsersEdit extends \Panel\Vhost {
} elseif ($action == 'jail') { } elseif ($action == 'jail') {
exec("/usr/local/bin/vhost-user-jail.sh -u $username >/dev/null 2>/dev/null &", $output, $result_code); exec("/usr/local/bin/vhost-user-jail.sh -u $username >/dev/null 2>/dev/null &", $output, $result_code);
$messages[] = "User is being jailed. Note: Setting up the jail environment takes about a minute to complete and is run in the background now."; $messages[] = "User is being jailed. Note: Setting up the jail environment takes about a minute to complete and is run in the background now.";
$f3->reroute("/Users/$username");
} elseif ($action == 'fpmmax') { } elseif ($action == 'fpmmax') {
$fpmmax = $_POST['fpmmax']; $fpmmax = $_POST['fpmmax'];
exec("/usr/local/bin/vhost-user-mod.sh -u $username -x $fpmmax", $output, $result_code); exec("/usr/local/bin/vhost-user-mod.sh -u $username -x $fpmmax", $output, $result_code);
@ -102,15 +83,8 @@ class UsersEdit extends \Panel\Vhost {
} }
$f3->set('SESSION.messages', $messages); $f3->set('SESSION.messages', $messages);
if ($f3->get('NAV.mapping') == 'vhost') { $f3->reroute("/Users/$username");
if (isset($result_code) && $result_code == 0) {
$f3->reroute("/");
} else {
$f3->reroute("/Users/$username/Edit");
}
} else {
$f3->reroute("/Users/$username");
}
// /* run mod command here */ // /* run mod command here */
// $mbox = $f3->get('PARAMS.mbox'); // $mbox = $f3->get('PARAMS.mbox');

View File

@ -17,23 +17,8 @@ class Vhosts extends \Panel\Vhost {
parent::beforeRoute($f3); parent::beforeRoute($f3);
if ($f3->exists('PARAMS.vhost')) { if ($f3->exists('PARAMS.vhost')) {
/* got here via vpanel link */
$vhost = $f3->get('PARAMS.vhost'); $vhost = $f3->get('PARAMS.vhost');
$vhost_get_cmd = "vhost-get.sh -d $vhost -c"; if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $vhost -c", FALSE))) {
} elseif ($f3->get('NAV.mapping') == 'vhost') {
/* got here via vhost page */
if ($f3->exists('SESSION.domain') && $f3->exists('SESSION.vhostusername')) {
/* SESSION.domain should be set for all vhost logins */
$vhost = $f3->get('SESSION.domain');
$vhostusername = $f3->get('SESSION.vhostusername');
$vhost_get_cmd = "vhost-get.sh -d $vhost -u $vhostusername -c";
} else {
/* should never get here, throw a 500 error to prevent further processing */
$f3->error(500);
}
}
if (isset($vhost_get_cmd)) {
if ($vhost_array = $f3->call('\Panel::vGet', array("$vhost_get_cmd", FALSE))) {
$f3->set('vhost_array', $vhost_array[0]); $f3->set('vhost_array', $vhost_array[0]);
/* get cert info */ /* get cert info */
if ($f3->call('\Panel::verifyCertificateExists', $vhost)) { if ($f3->call('\Panel::verifyCertificateExists', $vhost)) {
@ -97,13 +82,15 @@ class Vhosts extends \Panel\Vhost {
static function get($f3) { static function get($f3) {
if ($f3->exists('PARAMS.vhost')) { if ($f3->exists('PARAMS.vhost')) {
// $vhost_array = $f3->get('vhost_array');
/* convert data for frontend display */
// nothing to convert
// $f3->set('vhost_array', $vhost_array);
$vhost = $f3->get('PARAMS.vhost'); $vhost = $f3->get('PARAMS.vhost');
} elseif ($f3->exists('SESSION.domain')) {
$vhost = $f3->get('SESSION.domain');
}
if (isset($vhost)) {
$f3->set('page_header', "Details for $vhost"); $f3->set('page_header', "Details for $vhost");
echo \Template::instance()->render('vhost/vhosts-vhost.html'); echo \Template::instance()->render('vhost/vhosts-vhost.html');

View File

@ -49,8 +49,7 @@ class ForwardsAdd extends \Panel\Vmail {
if ($result_code == 0) { if ($result_code == 0) {
$messages[] = "Success: Forwarding for email account $mbox@$domain added."; $messages[] = "Success: Forwarding for email account $mbox@$domain added.";
$f3->set('SESSION.messages', $messages); $f3->set('SESSION.messages', $messages);
$mapping = $f3->get('NAV.mapping'); if ($f3->get('SESSION.access') == 'vmail') {
if ($mapping == 'vmail') {
$f3->reroute("/Accounts/$mbox/Forwarding"); $f3->reroute("/Accounts/$mbox/Forwarding");
} else { } else {
$f3->reroute("/Email/$domain/Accounts/$mbox/Forwarding"); $f3->reroute("/Email/$domain/Accounts/$mbox/Forwarding");

View File

@ -8,4 +8,8 @@
/ [sync] = Panel\Vhost\Vhosts / [sync] = Panel\Vhost\Vhosts
/Login [sync] = Panel\Login /Login [sync] = Panel\Login
/Logout [sync] = Panel\Logout /Logout [sync] = Panel\Logout
/Users/@username/Edit [sync] = Panel\Vhost\UsersEdit /Websites [sync] = Panel\Vhost\Vhosts
/Websites/Add [sync] = Panel\Vhost\VhostsAdd
/Websites/@vhost [sync] = Panel\Vhost\Vhosts
/Websites/@vhost/Edit [sync] = Panel\Vhost\VhostsEdit
/Websites/@vhost/Delete [sync] = Panel\Vhost\VhostsDelete

View File

@ -26,13 +26,6 @@ if ($f3->get('HOST') == $f3->get('NAV.hostname')) {
if ($f3->exists('SESSION.domain')) { if ($f3->exists('SESSION.domain')) {
$f3->clear('SESSION.domain'); $f3->clear('SESSION.domain');
} }
if ($f3->exists('SESSION.vhostusername')) {
$f3->clear('SESSION.vhostusername');
}
/* load DNS mapping, if enabled */
if ($f3->get('VDNSADMIN') == '1') {
$f3->config("config/maps-vdns.ini");
}
} elseif (preg_match('/^mail\./i', $f3->get('HOST'))) { } elseif (preg_match('/^mail\./i', $f3->get('HOST'))) {
$mapping = 'vmail'; $mapping = 'vmail';
$domain = preg_replace('/^mail\./i', '', $f3->get('HOST')); $domain = preg_replace('/^mail\./i', '', $f3->get('HOST'));
@ -41,20 +34,15 @@ if ($f3->get('HOST') == $f3->get('NAV.hostname')) {
$mapping = 'vhost'; $mapping = 'vhost';
$domain = preg_replace('/^www\./i', '', $f3->get('HOST')); $domain = preg_replace('/^www\./i', '', $f3->get('HOST'));
$f3->set('SESSION.domain', $domain); $f3->set('SESSION.domain', $domain);
/* vhostusername is not set when logging in to vhost admin as vpanel user or via ADMIN IP */
if (!$f3->exists('SESSION.vhostusername')) {
if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $domain -c", FALSE))) {
$vhostusername = $vhost_array[0]['username'];
$f3->set('SESSION.vhostusername', $vhostusername);
} else {
$messages[] = "System error verifying system user for domain $domain. Please contact support for further assistance.";
$f3->set('SESSION.messages', $messages);
}
}
} }
$f3->set('NAV.mapping', $mapping); $f3->set('NAV.mapping', $mapping);
$f3->config("config/maps-$mapping.ini"); $f3->config("config/maps-$mapping.ini");
/* load DNS mapping, if enabled */
if ($f3->get('VDNSADMIN') == '1') {
$f3->config("config/maps-vdns.ini");
}
/* custom error page */ /* custom error page */
$f3->set('ONERROR',function($f3){ $f3->set('ONERROR',function($f3){
echo \Template::instance()->render('error.html'); echo \Template::instance()->render('error.html');

View File

@ -26,52 +26,43 @@
<header> <header>
<h1><a href="{{@SCHEME}}://{{@HOST}}{{@BASE}}">{{@PACKAGE}}</a></h1> <h1><a href="{{@SCHEME}}://{{@HOST}}{{@BASE}}">{{@PACKAGE}}</a></h1>
<check if="isset(@SESSION.expiration)"> <nav>
<check if="{{@NAV.mapping=='vpanel'}}">
<a href="{{@BASE}}/Websites">Websites</a> |
<a href="{{@BASE}}/Email">Email</a> |
<a href="{{@BASE}}/Databases">Databases</a> |
<a href="{{@BASE}}/Certs">Certificates</a> |
<a href="{{@BASE}}/Users">Users</a> |
<check if="{{ @VDNSADMIN=='1' }}"><a href="{{@BASE}}/DNS">DNS</a> |</check>
<a href="{{@BASE}}/Logout">Logout</a>
</check>
<nav> <check if="isset(@NAV.subnav)">
<check if="{{@NAV.mapping=='vpanel'}}"> <true>
<a href="{{@BASE}}/Websites">Websites</a> | <p style="padding-top: 5px">
<a href="{{@BASE}}/Email">Email</a> | >>
<a href="{{@BASE}}/Databases">Databases</a> | <repeat group="{{ @NAV.subnav }}" key="{{ @NAV.subnav_path }}" value="{{ @NAV.subnav_name }}" counter="{{ @ctr }}">
<a href="{{@BASE}}/Certs">Certificates</a> | <check if="{{ @ctr }} > 1">/</check>
<a href="{{@BASE}}/Users">Users</a> | <check if="{{ @NAV.subnav_count }} == {{ @ctr }}">
<check if="{{ @VDNSADMIN=='1' }}"><a href="{{@BASE}}/DNS">DNS</a> |</check> <true>
<a href="{{@BASE}}/Logout">Logout</a> {{ @NAV.subnav_name }}
</check> </true>
<check if="{{ @NAV.mapping=='vhost' }}"> <false>
<a href="{{@BASE}}/Logout">Logout</a> <a href="{{ @NAV.subnav_path }}">{{ @NAV.subnav_name }}</a>
</check> </false>
</check>
<check if="{{ @NAV.mapping!='vhost' }}"> </repeat>
<check if="isset(@NAV.subnav)"> </p>
<true> </true>
<false>
<check if="{{@NAV.mapping != 'vpanel'}}">
<p style="padding-top: 5px"> <p style="padding-top: 5px">
>> >>
<repeat group="{{ @NAV.subnav }}" key="{{ @NAV.subnav_path }}" value="{{ @NAV.subnav_name }}" counter="{{ @ctr }}"> <a href="{{@BASE}}/Logout">Logout</a>
<check if="{{ @ctr }} > 1">/</check> </check>
<check if="{{ @NAV.subnav_count }} == {{ @ctr }}"> </false>
<true>
{{ @NAV.subnav_name }}
</true>
<false>
<a href="{{ @NAV.subnav_path }}">{{ @NAV.subnav_name }}</a>
</false>
</check>
</repeat>
</p>
</true>
<false>
<check if="{{@NAV.mapping != 'vpanel'}}">
<p style="padding-top: 5px">
>>
<a href="{{@BASE}}/Logout">Logout</a>
</check>
</false>
</check>
</check> </check>
</nav> </nav>
</check>
<check if="isset(@page_header)"> <check if="isset(@page_header)">
<h1>{{@page_header}}</h1> <h1>{{@page_header}}</h1>
</check> </check>

View File

@ -26,7 +26,6 @@ Passwords 15 or more characters long do not have any complexity requirements.<br
</form> </form>
</p> </p>
<check if="{{ @NAV.mapping=='vpanel' }}">
<p> <p>
<!-- jail --> <!-- jail -->
<form action="{{@REALM}}" method="POST"> <form action="{{@REALM}}" method="POST">
@ -174,21 +173,4 @@ Passwords 15 or more characters long do not have any complexity requirements.<br
</form> </form>
</p> </p>
</check>
<check if="{{ @NAV.mapping=='vhost' }}">
<!-- show php workers -->
<p>
<form action="{{@REALM}}" method="POST">
<fieldset>
<b>PHP Workers for {{ @user_array.username }}: {{ @user_array.fpmmax }}</b>
<br><br>
PHP Workers is maximum number of PHP processes that this user can have running at one time. Any website(s) installed for this user will be limited by this.
<br><br>
This can not be changed here, contact tech support if you think you need more PHP workers.<br>
</fieldset>
</form>
</p>
</check>
<include href="footer.html" /> <include href="footer.html" />

View File

@ -1,7 +1,5 @@
<include href="header.html" /> <include href="header.html" />
<check if="{{ @NAV.mapping=='vpanel' }}">
<table> <table>
<tr> <tr>
<th>Website</th> <th>Website</th>
@ -23,8 +21,6 @@
<br><br> <br><br>
</check>
<table> <table>
<tr> <tr>
<th>System User</th> <th>System User</th>
@ -34,14 +30,10 @@
<tr> <tr>
<td>{{ @vhost_array.username }}</td> <td>{{ @vhost_array.username }}</td>
<td>{{ @users_array.fpmmax }}</td> <td>{{ @users_array.fpmmax }}</td>
<check if="{{ @NAV.mapping=='vhost' }}"> <td><a href="{{@BASE}}/Users/{{ @users_array.username }}/Edit">Edit User</a></td>
<true><td><a href="{{@BASE}}/Users/{{ @users_array.username }}/Edit">Change Password</a></td></true>
<false><td><a href="{{@BASE}}/Users/{{ @users_array.username }}/Edit">Edit User</a></td></false>
</check>
</tr> </tr>
</table> </table>
<check if="isset(@cert_array)"> <check if="isset(@cert_array)">
<true> <true>
<br><br> <br><br>
@ -50,52 +42,50 @@
<th style="white-space: nowrap;">Certificate</th> <th style="white-space: nowrap;">Certificate</th>
<th style="white-space: nowrap;">Expiration</th> <th style="white-space: nowrap;">Expiration</th>
<th style="white-space: nowrap;">Secured Hostnames</th> <th style="white-space: nowrap;">Secured Hostnames</th>
<check if="{{ @NAV.mapping=='vpanel' }}"><th>Action</th></check> <th>Action</th>
</tr> </tr>
<tr> <tr>
<td style="white-space: nowrap;">{{ @cert_array.common }}</td> <td style="white-space: nowrap;">{{ @cert_array.common }}</td>
<td style="white-space: nowrap;">{{ @cert_array.end }}</td> <td style="white-space: nowrap;">{{ @cert_array.end }}</td>
<td style="white-space: nowrap; text-align: right;">{{ @cert_array.alternative | raw }}</td> <td style="white-space: nowrap; text-align: right;">{{ @cert_array.alternative | raw }}</td>
<check if="{{ @NAV.mapping=='vpanel' }}"><td style="white-space: nowrap;"><a href="{{@BASE}}/Certs/{{@vhost_array.virtualhost}}/Delete?r={{@PATH}}">Delete</a></td></check> <td style="white-space: nowrap;"><a href="{{@BASE}}/Certs/{{@vhost_array.virtualhost}}/Delete?r={{@PATH}}">Delete</a></td>
</tr> </tr>
</table> </table>
<br><br> <br><br>
</true> </true>
<false> <false>
<check if="{{ @NAV.mapping=='vpanel' }}"> <hr>
<hr> <check if="{{ @dnsinfo.a.status=='Verified' }}">
<check if="{{ @dnsinfo.a.status=='Verified' }}"> <true>
<true> You need a Security Certificate. <a href="{{@BASE}}/Certs/{{@vhost_array.virtualhost}}/Add?r={{@PATH}}">Click Here</a> to add one now.
You need a Security Certificate. <a href="{{@BASE}}/Certs/{{@vhost_array.virtualhost}}/Add?r={{@PATH}}">Click Here</a> to add one now. </true>
</true> <false>
<false> <span style="color:red">You need a Security Certificate for {{ @vhost_array.virtualhost }}.</span>
<span style="color:red">You need a Security Certificate for {{ @vhost_array.virtualhost }}.</span> <br>
<br> Before you can add one you must make the DNS change listed below. Once that's completed come back here and this message will change to an option to create a Security Certificate.
Before you can add one you must make the DNS change listed below. Once that's completed come back here and this message will change to an option to create a Security Certificate. <br>
<br> <small>Note that after you add DNS records it can take some time for the changes to propagate and show up here.</small>
<small>Note that after you add DNS records it can take some time for the changes to propagate and show up here.</small> <br><br>
<br><br> <table>
<table> <tr><th style="color:{{ @dnsinfo.a.color }}" colspan="2">{{ @dnsinfo.a.status }} A Record for {{ @vhost_array.virtualhost }}</th></tr>
<tr><th style="color:{{ @dnsinfo.a.color }}" colspan="2">{{ @dnsinfo.a.status }} A Record for {{ @vhost_array.virtualhost }}</th></tr> <tr><td style="text-align: right;">Type:</td><td>A</td></tr>
<tr><td style="text-align: right;">Type:</td><td>A</td></tr> <tr><td style="text-align: right;">Host:</td><td>{{ @vhost_array.virtualhost }}</td></tr>
<tr><td style="text-align: right;">Host:</td><td>{{ @vhost_array.virtualhost }}</td></tr> <tr><td style="text-align: right;">Value:</td><td>{{ @dnsinfo.server_addr }}</td></tr>
<tr><td style="text-align: right;">Value:</td><td>{{ @dnsinfo.server_addr }}</td></tr> <tr><td style="text-align: right;">TTL:</td><td>3600 (or default)</td></tr>
<tr><td style="text-align: right;">TTL:</td><td>3600 (or default)</td></tr> <tr><td></td><td><small>This should be the only A record for {{ @vhost_array.virtualhost }}.</small></td></tr>
<tr><td></td><td><small>This should be the only A record for {{ @vhost_array.virtualhost }}.</small></td></tr> </table>
</table> <br><br>
<br><br> <table>
<table> <tr><th style="color:{{ @dnsinfo.a.color }}" colspan="2">Verify CNAME Record for www.{{ @vhost_array.virtualhost }}</th></tr>
<tr><th style="color:{{ @dnsinfo.a.color }}" colspan="2">Verify CNAME Record for www.{{ @vhost_array.virtualhost }}</th></tr> <tr><td style="text-align: right;">Type:</td><td>CNAME</td></tr>
<tr><td style="text-align: right;">Type:</td><td>CNAME</td></tr> <tr><td style="text-align: right;">Host:</td><td>www.{{ @vhost_array.virtualhost }}</td></tr>
<tr><td style="text-align: right;">Host:</td><td>www.{{ @vhost_array.virtualhost }}</td></tr> <tr><td style="text-align: right;">Value:</td><td>{{ @vhost_array.virtualhost }}</td></tr>
<tr><td style="text-align: right;">Value:</td><td>{{ @vhost_array.virtualhost }}</td></tr> <tr><td style="text-align: right;">TTL:</td><td>3600 (or default)</td></tr>
<tr><td style="text-align: right;">TTL:</td><td>3600 (or default)</td></tr> <tr><td></td><td><small>This should be the only record for www.{{ @vhost_array.virtualhost }}.<br>Note this admin did not check for this record, it may already exist.</small></td></tr>
<tr><td></td><td><small>This should be the only record for www.{{ @vhost_array.virtualhost }}.<br>Note this admin did not check for this record, it may already exist.</small></td></tr> </table>
</table> </false>
</false>
</check>
<hr>
</check> </check>
<hr>
</false> </false>
</check> </check>