<?php

ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);

if ($Tag == 'imgs') {
	$folder_name = 'img/';
	$bg_color = 'transparent';
	if (isset($_GET['img']) && ($_GET['img'] == 'bg')) {
		$db = new SQLite3('./db/brbox_imgbg.db');
		$res = $db->query('SELECT * FROM brboxbg');
		$rowU = $res->fetchArray();
		$new_url = str_replace(' ', '', $rowU['url']);
		$bgon_off = $rowU['on_off'];

		if ($bgon_off == 'yes') {
			$bg_img = $new_url . '?' . time();
		}
		else {
			$real_file_location_path_or_url = '/api/img/nobg.gif?' . time();
			$bg_img = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off') ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF'], 2) . $real_file_location_path_or_url . '?' . time();
		}
	}
	else if (isset($_GET['img']) && ($_GET['img'] != NULL)) {
		$bg_img = $folder_name . 'gif' . $_GET['img'] . '.gif';
	}
	else {
		$bg_img = $folder_name . 'noimg.png';
	}

	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\t";
	echo "\r\n" . '<style>' . "\r\n" . '@import url(\'https://fonts.googleapis.com/css?family=Share+Tech+Mono|Montserrat:700\');' . "\r\n\r\n" . '* {' . "\r\n" . '    margin: 0;' . "\r\n" . '    padding: 0;' . "\r\n" . '    border: 0;' . "\r\n" . '    font-size: 100%;' . "\r\n" . '    font: inherit;' . "\r\n" . '    vertical-align: baseline;' . "\r\n" . '    box-sizing: border-box;' . "\r\n" . '    color: inherit;' . "\r\n" . '}' . "\r\n\r\n" . 'body {' . "\r\n" . '       background-image: url(\'' . $bg_img . '\');' . "\r\n" . '    height: 100vh;' . "\r\n" . '    ' . "\r\n" . '    color: ' . $bg_color . ';' . "\r\n" . '    background-color:' . $bg_color . ';' . "\r\n" . '  background-size: 100% 100%;' . "\r\n" . '  background-attachment: fixed;' . "\r\n" . '  background-position: center;' . "\r\n" . '  ' . "\r\n" . '  background-repeat: no-repeat;}' . "\r\n\r\n" . 'div {' . "\r\n" . '    background: rgba(0, 0, 0, 0);' . "\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" . 'P {' . "\r\n" . '    font-family: "" , monospace;' . "\r\n" . '    color: #000000;' . "\r\n" . '    margin: 0 0 20px;' . "\r\n" . '    font-size: 17px;' . "\r\n" . '    line-height: 1.2;' . "\r\n" . '}' . "\r\n\r\n" . 'span {' . "\r\n" . '    color: #000000;' . "\r\n" . '}' . "\r\n\r\n" . 'i {' . "\r\n" . '    color: #000000;' . "\r\n" . '}' . "\r\n\r\n" . 'j {' . "\r\n" . '    color: #000000;' . "\r\n" . '}' . "\r\n\r\n" . 'div a {' . "\r\n" . '    text-decoration: none;' . "\r\n" . '}' . "\r\n\r\n" . 'b {' . "\r\n" . '    color: #000000;' . "\r\n" . '}' . "\r\n\r\n" . 'a {' . "\r\n" . '    color: #000000;' . "\r\n" . '}' . "\r\n\r\n" . '</style>' . "\r\n\r\n" . '<body bgcolor=\'' . $bg_color . '\'>' . "\r\n" . '</body>    ' . "\r\n" . '</html>' . "\r\n\t\t";
}

?>