<?php

// Connect to the database
require_once('pdo.php');
require_once('get_provider_translit.php');
require('create_images.php');

$id = 23;
$provider_translit = getProviderTranslit($id);

// Load HTML content from a locally stored file
//https://www.fazi-interactive.com/
$html_content = file_get_contents('manual_dom_fazi.html');

// Include the Simple HTML DOM Parser library
require_once('simple_html_dom.php');

$html = str_get_html($html_content);

$insertedGames = [];

foreach ($html->find('div.singleGame') as $div) {

        $link = "";

        $name = $div->find('.expander p', 0);
        $name = $name->plaintext;

        $provider_id = $id;
        
        $translit = str_replace(" ", "-", $name);
        $translit = str_replace("&#039;", "-", $translit);
        $translit = preg_replace("/[^a-zA-Z0-9\-]/", "", $translit);
        $translit = str_replace("---", "-", $translit);
        $translit = str_replace("--", "-", $translit);

        $gameId = $div->find('.gameImage', 0);
        $gameId = $gameId->src;
        $gameId = str_replace(".png", "", $gameId);
        $gameId = str_replace(".gif", "", $gameId);
        $parts = explode('/', $gameId);
        $gameId = end($parts);
        $demo_desk = "https://onlinegamespromo.fazi.rs/Home/IntegrationGameLaunch?moneyType=0&gameName=".$gameId."&platform=desktop&languageCode=eng&currency=EUR";

        $demo_mob = "https://onlinegamespromo.fazi.rs/Home/IntegrationGameLaunch?moneyType=0&gameName=".$gameId."&platform=mobile&languageCode=eng&currency=EUR";
        
        $volatility = 0;

        $rtp = 0.0;

        $rtp_low = 0.0;
        
        $rtp_high = 0.0;
        
        $max_win = 0.0;
        
        $img = $div->find('.gameImage', 0);
        $img = $img->src;

        createImage($provider_translit, $translit, $img);

        require ('insert_values.php');

        require ('inserted_games.php');
}

// echo json_encode(['insertedGames' => $insertedGames]);
?>
