add vhosts edit page
This commit is contained in:
parent
48f80379a4
commit
8960fb9ae7
99
panel/classes/Panel/Vhost/VhostsEdit.php
Normal file
99
panel/classes/Panel/Vhost/VhostsEdit.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vpanel-stack
|
||||||
|
* https://git.stack-source.com/msb/vpanel-stack
|
||||||
|
* Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||||
|
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Panel\Vhost;
|
||||||
|
|
||||||
|
class VhostsEdit extends \Panel\Vhost {
|
||||||
|
|
||||||
|
function beforeRoute($f3) {
|
||||||
|
|
||||||
|
parent::beforeRoute($f3);
|
||||||
|
$vhost = $f3->get('PARAMS.vhost');
|
||||||
|
|
||||||
|
if ($f3->get('NAV.mapping') == 'vpanel') {
|
||||||
|
if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $vhost -c", FALSE))) {
|
||||||
|
$vhost_array = $vhost_array[0];
|
||||||
|
} else {
|
||||||
|
$messages[] = "Error getting info for $vhost.";
|
||||||
|
$f3->set('SESSION.messages', $messages);
|
||||||
|
$f3->reroute("/");
|
||||||
|
}
|
||||||
|
} elseif ($f3->get('NAV.mapping') == 'vhost') {
|
||||||
|
/* exta auth checks if logged in via vhost mapping */
|
||||||
|
if ($f3->exists('SESSION.vhostusername')) {
|
||||||
|
/* vhostusername indicates vhost user login */
|
||||||
|
$username = $f3->get('SESSION.vhostusername');
|
||||||
|
if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -u $username -d $vhost -c", FALSE))) {
|
||||||
|
$vhost_array = $vhost_array[0];
|
||||||
|
} else {
|
||||||
|
$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("/");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$messages[] = "Invalid request.";
|
||||||
|
$f3->set('SESSION.messages', $messages);
|
||||||
|
$f3->reroute("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set php fpm version vars */
|
||||||
|
$f3->call('\Panel::setPHPVersions', $f3);
|
||||||
|
$vhost_array['fpm_version'] = $f3->get('PHP.fpm_version');
|
||||||
|
$vhost_array['fpm_versions_array'] = $f3->get('PHP.fpm_versions_array');
|
||||||
|
$vhost_array['fpm_version_count'] = $f3->get('PHP.fpm_version_count');
|
||||||
|
|
||||||
|
$f3->set('vhost_array', $vhost_array);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get($f3) {
|
||||||
|
|
||||||
|
if ($f3->exists('PARAMS.vhost')) {
|
||||||
|
|
||||||
|
$vhost = $f3->get('PARAMS.vhost');
|
||||||
|
$f3->set('page_header', "Edit Website: $vhost");
|
||||||
|
echo \Template::instance()->render('vhost/vhosts-edit.html');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/* vhost should always be set, if not reroute to home */
|
||||||
|
$f3->reroute("/");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function post($f3) {
|
||||||
|
|
||||||
|
$vhost = $f3->get('PARAMS.vhost');
|
||||||
|
$fpm_version = $_POST['fpm_version'];
|
||||||
|
$config = $f3->get('vhost_array.config');
|
||||||
|
|
||||||
|
exec("/usr/local/bin/vhost-enable.sh -d $vhost -m $config -f $fpm_version", $output, $result_code);
|
||||||
|
if ($result_code == 0) {
|
||||||
|
$messages[] = "Success: PHP set to version $fpm_version for $vhost.";
|
||||||
|
$f3->set('SESSION.messages', $messages);
|
||||||
|
if ($f3->get('NAV.mapping') == 'vhost') {
|
||||||
|
$f3->reroute("/");
|
||||||
|
} else {
|
||||||
|
$f3->reroute("/Websites/$vhost");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$f3->reroute("/Websites/$vhost");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
panel/ui/vhost/vhosts-edit.html
Normal file
30
panel/ui/vhost/vhosts-edit.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<include href="header.html" />
|
||||||
|
|
||||||
|
<!-- php-fpm version -->
|
||||||
|
<p>
|
||||||
|
<form action="{{@REALM}}" method="POST">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Change PHP Version for {{ @vhost_array.virtualhost }}</legend>
|
||||||
|
<label for="fpmmax">Change PHP Version <small>(Default on this server is {{ @vhost_array.fpm_version }})</small></label>
|
||||||
|
<select id="fpm_version" name="fpm_version">
|
||||||
|
<repeat group="{{ @vhost_array.fpm_versions_array }}" value="{{ @fpm_version }}">
|
||||||
|
<check if="{{ @fpm_version==@vhost_array.php }}">
|
||||||
|
<true>
|
||||||
|
<option value="{{ @fpm_version }}" selected>{{ @fpm_version }}</option>
|
||||||
|
</true>
|
||||||
|
<false>
|
||||||
|
<option value="{{ @fpm_version }}">{{ @fpm_version }}</option>
|
||||||
|
</false>
|
||||||
|
</check>
|
||||||
|
</repeat>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
<button id="reset" type="reset">Reset</button><br>
|
||||||
|
<b>PHP Version</b> It's recommended to either use the default version (listed above) or the very latest version (highest number) if that works for your website. Only use an older version if you absolutely must do so to make your website code work.<br>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<include href="footer.html" />
|
Loading…
Reference in New Issue
Block a user