<?php
/**
 * Author: Elijah Atkinson (eatkinson@streamguys.com)
 * Date:  09/26/2023
 *
 * This is the login page for the PureStream player that will
 * collect and transmit the user credentials. It first
 * checks if the user is currently logged in and then checks
 * if any POST data has been submitted. If neither condition
 * is true then it displays the login screen.
 */
require_once('application.php');
require_once(ROOT_DIR.'/includes/index.php');
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Whisperings Player</title>
        <meta charset="utf-8" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="description" content="Whisperings Purestream Player" />
        <meta name="keywords" content="solo piano, piano radio, piano music, new age music, yanni, george winston, jim brickman, piano music, new age music, yanni, george winston, jim brickman" />
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="0" />
        <link rel="shortcut icon" href="img/favwspr.ico" />
        <link href='https://fonts.googleapis.com/css?family=Lato:400,400italic,700,900' rel='stylesheet' type='text/css'>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/bootstrap-theme.min.css" rel="stylesheet">
        <link href="css/purestream.css" rel="stylesheet">
        <link href="css/login.css" rel="stylesheet">
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
        <?php
        //If user is on a mobile device, hide the custom player checkbox.
        if($detect->isMobile()) {
            echo '<style type="text/css">#login #customPlayerRow { display:none; }</style>';
        }
        ?>
    </head>
    <body>
        <div id="content" class="container-fluid">
            <div id="headerRow" class="row">
                <div class="wsprHeader">
                    <div class="wsprLogoHeader"></div>
                </div>
            </div>
            <div id="loginRow" class="row">
                <div class="col-left">
                    <div class="bigPlayBox">
                        <div class="bigPlayWrapper">
                            <img id="wsprBigPlayButton" src="img/big_play_button.png" title="Play" />
                            <div id="bigPlayText">Enter your Email and Password in the fields to the right and click Play or Login to start</div>
                        </div>
                    </div>
                </div>
                <div class="col-right">
                    <div class="loginHeader"></div>
                    <form id="login" role="form" class="form-minimal" method="POST" action="index.php">
                        <div class="form-heading">Login to PureStream</div>
                        <label for="email" class="sr-only">email</label>
                        <input id="email" name="email" type="text" class="login-input" placeholder="email" value="<?php echo $prevData['email']; ?>" tabindex="1" required autofocus />
                        <label for="password" class="sr-only">password</label>
                        <input id="password" name="password" type="password" class="login-input" placeholder="password" value="<?php echo $prevData['password']; ?>" tabindex="2" required />
                        <div class="submit-row">
                            <div class="inline-checkbox-group">
                                <div class="input-row"><input id="saveLogin" name="saveLogin" class="checkbox" type="checkbox" value="1" <?php echo $prevData['saveLogin']; ?>/><label for="saveLogin">Save Login</label></div>
                                <div id="customPlayerRow" class="input-row"><input id="customPlayer" name="customPlayer" class="checkbox" type="checkbox" value="1" <?php echo $prevData['customPlayer']; ?>/><label for="customPlayer">Customized</label></div></div>
                            <input id="login-form-button-submit" name="btnSubmit" type="submit" value="Login" class="btn btn-sm btn-default btn-login" role="button" tabindex="4" />
                        </div>
                    </form>
                    <div id="loginFooter">
                        <?php echo $loginFooterDiv; ?>
                        <!-- div id="forgot-password">forget your password? <a href="http://sp.streamguys.com/forgot_pw" target="_blank">retrieve it here</a></div-->

                        <div id="warning" class="warning">
                            <noscript>Javascript and Cookies must be enabled for this page to function properly.</noscript>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="js/purestream.vendor.min.js?v=1.2.1"></script>
        <script type="text/javascript">
            checkCookies('warning', 'Cookies must be enabled for this page to function properly.');

            $("#wsprBigPlayButton").on('click', function(event) {
                $("#login").submit();
            });
        </script>
    </body>
</html>