<?php
	exit;
    ################################################## CONEXÃO COM BANCO DE DADOS ##################################################
    unset($mysqli);
    // Conecta-se ao banco de dados MySQL
    $host = '107.161.191.186';
    $user = 'sysbet_fscores';
    $pass = 'Madha2018!';
    $db = 'sysbet_fscores';

    $mysqli = new mysqli($host, $user, $pass, $db); 

    // Caso algo tenha dado errado, exibe uma mensagem de erro
    if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
    $charset = mysqli_set_charset($mysqli, "utf-8");

    ################################################## CONEXÃO COM BANCO DE DADOS ##################################################


    $x = simplexml_load_file('http://sysfbet.com.br/cdn/times_futebol.xml');
    $i = 0;
    $consulta = '';
    foreach ($x as $j) {
    	// if($i == 1){ continue; }
    	// echo 'T: '.$j->attributes()->name.' <br />'; 
    	$i++;

    	$time = $j->attributes()->name;
    	$id = $j->attributes()->id;
    	$image = $j->attributes()->image_id;
    	$pais = $j->attributes()->cc;

    	$time = str_replace("'", "", $time);

    	$consulta .= "INSERT INTO times SET time_esporte = '1', time_cod = '$id', time_nome = '$time', time_pais = '$pais', time_imagem = '$image'; ";
    }

    file_put_contents('times.txt', $consulta);

?>