vpanel-stack/panel/index.php
Matthew Saunders Brown 144d8a23b3 add vdns code
2024-02-13 14:41:15 -08:00

53 lines
1.4 KiB
PHP

<?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');
}
} 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);
}
$f3->set('NAV.mapping', $mapping);
$f3->config("config/maps-$mapping.ini");
/* load DNS mapping, if enabled */
if ($f3->get('PDNSADMIN') == '1') {
$f3->config("config/maps-vdns.ini");
}
/* custom error page */
$f3->set('ONERROR',function($f3){
echo \Template::instance()->render('error.html');
});
$f3->run();