<?php
/**
* VCF5 Project - Open Federated Microformat Project
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Chronolabs Cooperative http://syd.au.snails.email
* @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/)
* @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html)
* @package vcf5.core
* @since 1.0.1
* @author Dr. Simon Antony Roberts <wishcraft@users.sourceforge.net>
* @version 1.0.0
* @description This is the core for the VCF5 the Variant Caller File is appified in version 5 for federation
* @link http://blog.vcf.email
* @link https://github.com/VCF5
* @link https://sourceforge.net/projects/vcf5
* @link https://facebook.com/vcf5project
* @link https://twitter.com/vcf5project
*
*/
if (file_exists(__DIR__ . '/mainfile.php')) {
include __DIR__ . '/mainfile.php';
}
if (!defined('VCF5_MAINFILE_INCLUDED')) {
if (file_exists(__DIR__ . '/install/index.php')) {
header('Location: install/index.php');
exit;
}
}
$vcf5Event = Vcf5Event::getInstance();
$vcf5Event->triggerEvent('core.index.start');
//check if start page is defined
if (isset($vcf5Config['startpage']) && $vcf5Config['startpage'] != '' && $vcf5Config['startpage'] != '--' && vcf5_isActiveApp($vcf5Config['startpage'])) {
// Temporary solution for start page redirection
define('VCF5_STARTPAGE_REDIRECTED', 1);
global $vcf5AppConfig;
/* @var $app_handler Vcf5AppHandler */
$app_handler = vcf5_getHandler('app');
$vcf5App = $app_handler->getByDirname($vcf5Config['startpage']);
if (!$vcf5App || !$vcf5App->getVar('isactive')) {
include_once $GLOBALS['vcf5']->path('header.php');
echo '<h4>' . _MODULENOEXIST . '</h4>';
include_once $GLOBALS['vcf5']->path('footer.php');
exit();
}
/* @var $appperm_handler Vcf5GroupPermHandler */
$appperm_handler = vcf5_getHandler('groupperm');
if ($vcf5User) {
if (!$appperm_handler->checkRight('app_read', $vcf5App->getVar('mid'), $vcf5User->getGroups())) {
redirect_header(VCF5_URL, 1, _NOPERM, false);
}
$vcf5UserIsAdmin = $vcf5User->isAdmin($vcf5App->getVar('mid'));
} else {
if (!$appperm_handler->checkRight('app_read', $vcf5App->getVar('mid'), VCF5_GROUP_ANONYMOUS)) {
redirect_header(VCF5_URL . '/user.php', 1, _NOPERM);
}
}
if ($vcf5App->getVar('hasconfig') == 1 || $vcf5App->getVar('hascomments') == 1 || $vcf5App->getVar('hasnotification') == 1) {
$vcf5AppConfig = $config_handler->getConfigsByCat(0, $vcf5App->getVar('mid'));
}
chdir('apps/' . $vcf5Config['startpage'] . '/');
vcf5_loadLanguage('main', $vcf5App->getVar('dirname', 'n'));
$parsed = parse_url(VCF5_URL);
$url = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : 'http://';
if (isset($parsed['host'])) {
$url .= $parsed['host'];
if (isset($parsed['port'])) {
$url .= ':' . $parsed['port'];
}
} else {
$url .= $_SERVER['HTTP_HOST'];
}
$_SERVER['REQUEST_URI'] = substr(VCF5_URL, strlen($url)) . '/apps/' . $vcf5Config['startpage'] . '/index.php';
include $GLOBALS['vcf5']->path('apps/' . $vcf5Config['startpage'] . '/index.php');
exit();
} else {
$vcf5Option['show_cblock'] = 1;
$GLOBALS['vcf5Option']['template_main'] = 'db:system_homepage.html';
include $GLOBALS['vcf5']->path('header.php');
include $GLOBALS['vcf5']->path('footer.php');
}