<?php
header('Content-Type: application/json');

$settings = parse_ini_file(__DIR__ . '/../setting_template.txt');
require_once(__DIR__ . '/../odbconexion/config.php');

try{    
  $Odbj_conexion = new odbconexion;
  $conexion=$Odbj_conexion->openconection();
  $consulta="SELECT * FROM configuracion_app_appquadrata";
  $Array_adapter_config=$conexion->query($consulta);
  $conexion->close();
  while($Field_config=$Array_adapter_config->fetch_assoc())
  {   
      $nombreProyecto=$Field_config['Titulo_App'];
  }
}catch (Exception $e) {
    $nombreProyecto = "App Genérica";
}

$rgb = explode(' ', $settings['Color']);
$themeColor = sprintf("#%02x%02x%02x", $rgb[0], $rgb[1], $rgb[2]);

$manifest = [
    "name" => $nombreProyecto,
    "short_name" => $nombreProyecto,
    "start_url" => "../",
    "scope" => "../",
    "display" => "standalone",
    "theme_color" => $themeColor,
    "background_color" => '#ffffff',
    "icons" => [
        [
            "src" => "icon-192x192.png?dummy=" . time(),
            "sizes" => "192x192",
            "type" => "image/png"
        ],
        [
            "src" => "icon-512x512.png?dummy=" . time(),
            "sizes" => "512x512",
            "type" => "image/png"
        ]
    ]
];

echo json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);