<?php
ob_start();
session_start();
ini_set('memory_limit', -1);

header("Content-Type: text/html;charset=UTF-8");

$config_ini = parse_ini_file('config.ini');

if (empty(trim($config_ini['user']))) {
    header("Location:install/index.php");
    exit;
}

// mostrar todos los errores
if (@$config_ini['debug'] == 1) {
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
	ini_set('error_log', 'errores.log');
    error_reporting (E_ALL);
} else {
    ini_set('display_errors', 0);
    ini_set('display_startup_errors', 0);
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
}

$mysqli = @new mysqli($config_ini['host'],$config_ini['user'],$config_ini['pass'],$config_ini['name']);
if ($mysqli->connect_errno) {
    /* Use your preferred error logging method here */
    die("Connection failed: " . $mysqli->connect_error);
} else {
    mysqli_query($mysqli,"SET NAMES 'utf8'");

    $setting_qry="SELECT * FROM tbl_settings where id='1'";
    $setting_result=mysqli_query($mysqli,$setting_qry);
    $settings_details=mysqli_fetch_assoc($setting_result);
    
    define("APP_API_KEY",'UzCbzsPZhsH8aeh1JlsK0gR0nYtmpgwcjtXm9g9lAUt4p');
    define("ONESIGNAL_APP_ID",$settings_details['onesignal_app_id']);
    define("ONESIGNAL_REST_KEY",$settings_details['onesignal_rest_key']);
    define("APP_PURCHASE",$settings_details['purchase_code']);
    define("APP_NAME",$settings_details['app_name']);
    define("APP_LOGO",$settings_details['app_logo']);
    define("APP_TOKEN",$settings_details['api_key']);
	
    if(isset($_SESSION['id'])){
    	$profile_qry="SELECT * FROM tbl_admin where id='".$_SESSION['id']."'";
    	$profile_result=mysqli_query($mysqli,$profile_qry);
    	$profile_details=mysqli_fetch_assoc($profile_result);
    	define("PROFILE_IMG",$profile_details['image']);
    }
}
?>