2022-07-01 15:24:26 -07:00
|
|
|
<?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 Vhosts extends \Panel\Vhost {
|
|
|
|
|
|
|
|
/* use this to make query */
|
|
|
|
function beforeRoute($f3) {
|
|
|
|
|
|
|
|
parent::beforeRoute($f3);
|
|
|
|
|
|
|
|
if ($f3->exists('PARAMS.vhost')) {
|
|
|
|
$vhost = $f3->get('PARAMS.vhost');
|
|
|
|
if ($vhost_array = $f3->call('\Panel::vGet', array("vhost-get.sh -d $vhost -c", FALSE))) {
|
|
|
|
$f3->set('vhost_array', $vhost_array[0]);
|
2023-06-19 11:53:16 -07:00
|
|
|
/* get cert info */
|
|
|
|
if ($f3->call('\Panel::verifyCertificateExists', $vhost)) {
|
|
|
|
if ($cert_array = $f3->call('\Panel::vGet', array("letsencrypt-get.sh -d $vhost -c", FALSE))) {
|
|
|
|
$cert_array = $cert_array[0];
|
|
|
|
/* remove time from expiration date */
|
|
|
|
$end = $cert_array['end'];
|
|
|
|
$end_array = explode(' ', $end);
|
|
|
|
unset($end_array[2]);
|
|
|
|
$end = implode(' ', $end_array);
|
|
|
|
$cert_array['end'] = $end;
|
|
|
|
/* add line breaks */
|
|
|
|
$common = $cert_array['common'];
|
|
|
|
$alternative = $cert_array['alternative'];
|
|
|
|
$alternative = preg_replace('/ /', '<br>', $alternative);
|
|
|
|
$cert_array['alternative'] = $alternative;
|
|
|
|
$f3->set('cert_array', $cert_array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* get user info */
|
|
|
|
$username = $vhost_array[0]['username'];
|
|
|
|
if ($users_array = $f3->call('\Panel::vGet', array("vhost-user-get.sh -u $username -c", FALSE))) {
|
|
|
|
if ($users_array[0]['passwd'] == "") {
|
|
|
|
$users_array[0]['passwd'] = '(unavailable)';
|
|
|
|
}
|
|
|
|
$f3->set('users_array', $users_array[0]);
|
|
|
|
}
|
|
|
|
/* get mysql db info */
|
|
|
|
if ($mysqlinfo_array = $f3->call('\Panel::vGet', array("vhost-mysql-db-get.sh -d $vhost -c", FALSE))) {
|
|
|
|
$f3->set('mysqlinfo_array', $mysqlinfo_array[0]);
|
|
|
|
} else {
|
|
|
|
$mysqlinfo_array = array('(unknown)', '(unknown)', '(unknown)', '(unknown)');
|
|
|
|
$f3->set('mysqlinfo_array', $mysqlinfo_array);
|
|
|
|
}
|
2022-07-01 15:24:26 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($vhosts_array = $f3->call('\Panel::vGet', array("vhost-get.sh -c", FALSE))) {
|
|
|
|
$f3->set('vhosts_array', $vhosts_array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static function get($f3) {
|
|
|
|
|
|
|
|
if ($f3->exists('PARAMS.vhost')) {
|
|
|
|
|
|
|
|
$vhost_array = $f3->get('vhost_array');
|
|
|
|
|
|
|
|
/* convert data for frontend display */
|
2023-03-30 10:12:16 -07:00
|
|
|
// nothing to convert
|
2022-07-01 15:24:26 -07:00
|
|
|
|
|
|
|
$f3->set('vhost_array', $vhost_array);
|
|
|
|
|
|
|
|
$vhost = $f3->get('PARAMS.vhost');
|
2023-06-19 11:53:16 -07:00
|
|
|
$f3->set('page_header', "Details for $vhost");
|
2022-07-01 15:24:26 -07:00
|
|
|
echo \Template::instance()->render('vhost/vhosts-vhost.html');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$f3->set('page_header', "Websites");
|
|
|
|
echo \Template::instance()->render('vhost/vhosts.html');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|