<?php
/**
 * Check if has connection error in session then show it with reconnect button
 *
 * PHP version 7.3
 *
 * @package        SMS
 * @version        Release 1.0.0
 * @create_by      Mohammad aljaouni
 * @create_date    16-08-2020
 * @edited_by
 * @last_edit_date
 * @todo           Nothing
 */

ob_start();
session_start();

if(empty($_SESSION['errorArray'])) {
    header("location: index.php");
    exit;
}
//Validation For Included Tree
$chain = "AWdrh78y892Djk*^523*%$#ghgHGHia&%$*)AsfdsLJnLaad";

include("includeInformation.php");
if($_SESSION['errorArray']['No'] != -1) {
    //One Try Before Error
    @$conn =mysqli_connect($hostSms, $userConnection, $passwordConnection, $dataBase);
    if(!mysqli_connect_errno()) {
        header("location: index.php");
        exit;
    } else {
        if(empty(mysqli_connect_errno($conn)) && empty(mysqli_connect_error($conn))) {
            header("location: index.php");
            exit;
        }
    }
}
?>
    <!DOCTYPE html>
    <html lang="<?php echo $_SESSION['langSymbol'];?>">

    <head>
        <meta charset="windows-1256" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- Page Title -->
        <title><?php echo $serverError;?></title>
        <!--- No Cache Meta --->
        <meta http-equiv="cache-control" content="max-age=0" />
        <meta http-equiv="cache-control" content="no-cache" />
        <meta http-equiv="expires" content="0" />
        <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
        <meta http-equiv="pragma" content="no-cache" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta content="SMS" name="description" />

        <!-- App favicon -->
        <link rel="shortcut icon" href="../assets/images/<?php echo $_SESSION['langSymbol'];?>/favicon.ico">
        <!-- Bootstrap Css -->
        <link href="../assets/css/<?php echo $_SESSION['langSymbol'];?>/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- Icons Css -->
        <link href="../assets/css/<?php echo $_SESSION['langSymbol'];?>/icons.min.css" rel="stylesheet" type="text/css" />
        <!-- App Css-->
        <link href="../assets/css/<?php echo $_SESSION['langSymbol'];?>/app.css" rel="stylesheet" type="text/css" />
        <!-- Custom Css-->
        <link href="../assets/css/<?php echo $_SESSION['langSymbol'];?>/custom.css" rel="stylesheet" type="text/css" />
        <!--Custom Database Error Page Style-->
        <style>
            *,::before,::after{box-sizing:inherit}
            body{box-sizing:border-box;width:100%;height:100vh;display:flex;justify-content:center;align-items:center;background-color:#444!important}
            .container .content-div{box-shadow:10px 10px 15px rgba(0,0,0,0.55);transform:scale(0);backface-visibility:hidden;-webkit-font-smoothing:antialiased}
            .content-div h4,.content-div p{margin:10px 0;text-align:center}
            .content-div h4{font-weight:700;opacity:.8;text-align:center;line-height:1.8}
            .content-div p{width:95%;margin-right:auto;margin-left:auto;line-height:24px;font-size:15px;opacity:.7;padding:10px 0;font-weight:700}
            .scale-in{animation:scaleIn 1.5s forwards;animation-delay:.5s}
            .scale-out{animation:scaleOut 1.5s forwards}
            @keyframes scaleOut {
                0%{transform:scale(1)}
                15%{transform:scale(1.05)}
                40%{transform:scale(0)}
                100%{transform:scale(0)}
            }
            @keyframes scaleIn {
                0%{transform:scale(0)}
                15%{transform:scale(1.05)}
                30%{transform:scale(0.95)}
                45%{transform:scale(1)}
                100%{transform:scale(1)}
            }
            .content-div{background:#fff;padding:20px 20px 0;border-radius:5px}
            .uim-svg svg{width:70px!important;height:auto!important}
            .footer-div{height:50px;margin:0 -20.1px;text-align:center;padding:15px;background:#46becf;color:#fff;border-bottom-left-radius:5px;border-bottom-right-radius:5px}
            .footer-div:hover{background:#3ca6b5;opacity:.8;transition:opacity .3s}
            .highlight{box-shadow:0 0 0 #460000;animation:pulse 1s infinite}
            @-webkit-keyframes pulse {
                0%{-webkit-box-shadow:0 0 0 0 rgba(100,173,204,0.4)}
                50%{-webkit-box-shadow:0 0 0 10px rgba(100,173,204,0)}
                70%{-webkit-box-shadow:0 0 0 10px rgba(100,173,204,0)}
                100%{-webkit-box-shadow:0 0 0 0 rgba(100,173,204,0)}
            }
            @keyframes pulse {
                0%{-moz-box-shadow:0 0 0 0 rgba(100,173,204,0.4);box-shadow:0 0 0 0 rgba(100,173,204,0.4)}
                50%{-moz-box-shadow:0 0 0 20px rgba(100,173,204,0);box-shadow:0 0 0 20px rgba(100,173,204,0)}
                70%{-moz-box-shadow:0 0 0 40px rgba(100,173,204,0);box-shadow:0 0 0 40px rgba(100,173,204,0)}
                100%{-moz-box-shadow:0 0 0 60px rgba(100,173,204,0);box-shadow:0 0 0 60px rgba(100,173,204,0)}
            }
            .footer-div .uim-svg svg{color:#FFF;fill:#FFF;width:25px!important;height:25px!important;margin:-4px 0}
        </style>
    </head>
    <body>
    <div class="container">
        <div class="row justify-content-center m-auto ">
            <div class="col-sm-12 col-md-7 justify-content-center align-self-center content-div scale-in">
                    <div class="row">
                        <div class="col-12 text-center mb-1">
                            <i class="uim uim-exclamation-triangle" ></i>
                        </div>
                        <div class="col-12 my-2">
                            <div class="text-center">
                                <h4><?php
                                    if(!empty($_SESSION['errorArray']['String'])){
                                        if($_SESSION['errorArray']['String']=="errorDb")
                                            echo $errorDb;
                                        elseif($_SESSION['errorArray']['String']=="errorConn")
                                            echo $errorConn;
                                        else
                                            echo $_SESSION['errorArray']['String'];
                                    }
                                    ?></h4>
                                <p style="color:#b30002" ><?php echo (($_SESSION['errorArray']['No'] != -1)? ''.$_SESSION['errorArray']['No'].": ".$_SESSION['errorArray']['MySql'].'' : "");?></p>
                            </div>
                        </div>
                        <div class="col-12">
                            <a href="#" class="serverError  ">
                                <div class="footer-div highlight">
                                    <i class="uim uim-repeat"></i> <?php echo $reCheckConnection;?>
                                </div>
                            </a>
                        </div>
                    </div>
            </div>
        </div>
    </div>

    <!-- JQUERY 3.4.1 -->
    <script src="../assets/libs/jquery/jquery.min.js"></script>
    <!-- Icons -->
    <script src="../assets/libs/monochrome/bundle.min.js"></script>
    <script>
        $(document).ready(function() {
            $(".content-div a").click(function() {
                $(".content-div").removeClass("scale-in").addClass("scale-out");
                setTimeout(function () {
                    window.location.href='index.php';
                },800);
            });
        });
    </script>
    </body>

</html>
<?php ob_end_flush(); ?>
