vpanel-stack/panel/index.php

64 lines
2.0 KiB
PHP
Raw Normal View History

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)
*/
/* include framework */
$f3 = require('f3/base.php');
/* load f3 */
$f3 = \Base::instance();
/* load [globals] configuration */
$f3->config('config/config.ini');
/* start session, used for authentication data */
new Session();
/* initialize NAV array */
$f3->set('NAV', array());
$f3->set('NAV.hostname', trim(`/bin/hostname -f`));
/* configurations based on hostname */
if ($f3->get('HOST') == $f3->get('NAV.hostname')) {
$mapping = 'vpanel';
if ($f3->exists('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");
}
2022-07-01 15:24:26 -07:00
} elseif (preg_match('/^mail\./i', $f3->get('HOST'))) {
$mapping = 'vmail';
$domain = preg_replace('/^mail\./i', '', $f3->get('HOST'));
$f3->set('SESSION.domain', $domain);
} else {
$mapping = 'vhost';
$domain = preg_replace('/^www\./i', '', $f3->get('HOST'));
$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);
}
}
2022-07-01 15:24:26 -07:00
}
$f3->set('NAV.mapping', $mapping);
$f3->config("config/maps-$mapping.ini");
/* custom error page */
$f3->set('ONERROR',function($f3){
echo \Template::instance()->render('error.html');
});
$f3->run();