<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Updater</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
    <?php
        // append web.php
        $appendThis = file_get_contents("web.php");
        $appendTo = fopen("../core/routes/web.php", "a");
        fwrite($appendTo, $appendThis);
        fclose($appendTo);

        // place UpdaterController.php
        @unlink('../core/app/Http/Controllers/UpdateController.php');
        @copy("UpdateController.php", '../core/app/Http/Controllers/UpdateController.php');

        // replace composer.json, composer.lock
        @unlink('../core/composer.json');
        @unlink('../core/composer.lock');
        @unlink('../version.json');
        @copy("core/composer.json", '../core/composer.json');
        @copy("core/composer.lock", '../core/composer.lock');
        @copy("version.json", '../version.json');
    ?>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 offset-lg-2 pt-5">    
                <div class="alert alert-success">
                    Updater codes has been injected
                </div>
                <div class="card">
                    <div class="card-footer text-center">
                        <a class="btn btn-success" href="../update/version">Update Database & Languages</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>