<?php

$db = new SQLite3("./db/studiolivecode_sports.db");
$table_name = "sports";
$base_file = basename($_SERVER["SCRIPT_NAME"]);
$db->exec("CREATE TABLE IF NOT EXISTS " . $table_name . "(id INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, header_n TEXT, border_c TEXT, background_c TEXT, text_c TEXT, days TEXT, auto_s TEXT, url VARCHAR(100), type TEXT)");
$rows = $db->query("SELECT COUNT(*) as count FROM " . $table_name);
$row = $rows->fetchArray();
$numRows = $row["count"];
if ($numRows == 0) {
    $db->exec("INSERT INTO " . $table_name . "(id, header_n, border_c, background_c, text_c, days, auto_s, url, type) VALUES('1', 'Event', '#000000', '#000000', '#ffffff', '3', '1', 'https://www.tvsportguide.com/widget/5cc316f797659?filter_mode=all&filter_value=&days=3&heading=Event&border_color=custom&autoscroll=1&prev_nonce=a7242d2019&custom_colors=000000,000000,ffffff', '0')");
}
$res = $db->query("SELECT * \r\n\t\t\t\t  FROM sports \r\n\t\t\t\t  WHERE ID='1'");
	$row = $res->fetchArray(SQLITE3_ASSOC);

	if ($row['type'] == '0') {
		$_1 = $row['header_n'];
		$_2 = str_replace('#', '', $row['border_c']);
		$_3 = str_replace('#', '', $row['background_c']);
		$_4 = str_replace('#', '', $row['text_c']);
		$_5 = $row['days'];
		$_6 = $row['auto_s'];
		$api = '5cc316f797659';
		$url = 'https:\\/\\/www.tvsportguide.com\\/widget\\/' . $api . '?filter_mode=all&filter_value=&days=' . $_5 . '&heading=' . $_1 . '&border_color=custom&autoscroll=' . $_6 . '&prev_nonce=a7242d2019&custom_colors=' . $_2 . ',' . $_3 . ',' . $_4;
	}
	else {
		$url = $row['url'];
	}

	echo "\r\n" . '<html>' . "\r\n" . '<head>' . "\r\n" . '<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />' . "\r\n" . '<meta http-equiv="Pragma" content="no-cache" />' . "\r\n" . '<meta http-equiv="Expires" content="0" />' . "\r\n\t" . '<meta name="viewport" content="width=device-width, initial-scale=1.0,text/html,charset=utf-8">' . "\r\n\t" . '<style>' . "\r\n\t" . 'body {' . "\r\n\t" . 'background: black;' . "\r\n\t\t" . 'margin: 0;' . "\r\n\t\t" . '/* Reset default margin */' . "\r\n\t" . '}' . "\r\n\t" . 'iframe {' . "\r\n\t\t" . 'display: block;' . "\r\n\t\t" . 'background: transparent;' . "\r\n\t\t" . 'border: none;' . "\r\n\t\t" . 'height: 100vh;' . "\r\n\t\t" . 'width: 100vw;' . "\r\n\t" . '}' . "\r\n\t" . 'div {' . "\r\n\r\n" . '    background: transparent;' . "\r\n\r\n" . '    width: 70vw;' . "\r\n" . '    position: relative;' . "\r\n" . '    top: 50%;' . "\r\n" . '    transform: translateY(-50%);' . "\r\n" . '    margin: 0 auto;' . "\r\n" . '    padding: 30px 30px 10px;' . "\r\n" . 'display: none;' . "\r\n" . '    z-index: 3;' . "\r\n" . '}' . "\r\n\r\n\t" . '</style>' . "\r\n" . '</head>' . "\r\n" . '<body>' . "\r\n" . '<iframe  allowtransparency="true" style="background: transparent;" id="iframe" src="' . $url . '" frameborder="0"></iframe>' . "\r\n" . '</body>' . "\r\n" . '</html> ';


?>
