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';
|
2023-08-21 16:16:04 -07:00
|
|
|
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");
|
|
|
|
|
|
|
|
/* custom error page */
|
|
|
|
$f3->set('ONERROR',function($f3){
|
|
|
|
echo \Template::instance()->render('error.html');
|
|
|
|
});
|
|
|
|
|
|
|
|
$f3->run();
|
|
|
|
|