vpanel-stack/panel/index.php

52 lines
1.4 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');
}
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);
}
$f3->set('NAV.mapping', $mapping);
$f3->config("config/maps-$mapping.ini");
2024-02-13 14:41:15 -08:00
/* load DNS mapping, if enabled */
if ($f3->get('PDNSADMIN') == '1') {
$f3->config("config/maps-vdns.ini");
}
2022-07-01 15:24:26 -07:00
/* custom error page */
$f3->set('ONERROR',function($f3){
echo \Template::instance()->render('error.html');
});
$f3->run();