<?php
/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ************************************************************************************/

require_once('vendor/autoload.php');
include('adodb/adodb.inc.php');
require_once('vteversion.php'); // crmv@181168

// crmv@328869
require_once('include/vtenext/PHPConfigurator.php');
\Vtenext\PHPConfigurator::checkPhpVersion();
// crmv@328869e

//for migration
global $table_prefix;
if (empty($table_prefix)) {
	$table_prefix = 'vtiger';
}

require_once('include/install/language/en_us.lang.php');
require_once('include/install/resources/utils.php');
global $installationStrings, $vtiger_current_version;

// crmv@37463 check permissions
$oldinstall = glob('*install.php.txt');
if (is_array($oldinstall) && count($oldinstall) > 0) die('Unauthorized!');
// crmv@37463e

// crmv@244376
if (PHP_MAJOR_VERSION >= 8) {
	set_error_handler(function ($errno, $errstr) {
		$skipWarnings = [
			'Declaration of', 
			'Undefined variable',
			'Undefined property:',
			'Undefined array key',
			'Trying to access array offset on value of type ',
			'Attempt to read property',
		];
		foreach ($skipWarnings as $w) {
			if (substr($errstr, 0, strlen($w)) === $w) return true;
		}
		return false;
    }, E_WARNING);
}
// crmv@244376e

// crmv@272663
header('X-Frame-Options: SAMEORIGIN');
header("Content-Security-Policy: frame-ancestors 'self'");
// crmv@272663e

@include_once('config.db.php');
global $dbconfig, $vtconfig;
if(empty($_REQUEST['file']) && is_array($vtconfig) && $vtconfig['quickbuild'] == 'true') {
	$the_file = 'BuildInstallation.php';
} elseif (!empty($_REQUEST['file'])) {
	$the_file = $_REQUEST['file'];
} else {
	$the_file = "welcome.php";
}

Common_Install_Wizard_Utils::checkFileAccess("install/".$the_file);
include("install/".$the_file);
?>
