<?php ob_start();session_start();$file = $_POST['file'] ? $_POST['file'] : $_GET['file'];?>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="ckeditor.js" charset="utf-8"></script>
    <link href="sample.css" rel="stylesheet">

    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

    <script>
        $( document ).ready(function() {
            var file = $('#file').val();
            $('#btn_back').click(function(e){
                e.preventDefault();
                window.location.replace('../../'+file);
            });
        });

    </script>
</head>
<body>




<?php
if ( isset($_POST['file']) && isset($_POST['editor1']) ){
    @file_put_contents('../../' . $file, $_POST['editor1']);
}

if($_POST['password'] == 'azabu'){										//   Set Password
    $_SESSION["status"] = true;
}

if(!isset( $_SESSION["status"] )):?>
    <form method="post" action="index.php">
        <center>
            <div style="margin:100px;width:400px;padding:15px;">
                Password: 
                <input hidden type="text" name="file" value="<?php echo $file;?>">
                <input type="password" name="password">
                <input type="submit" value="Login">
            </div>
        </center>
    </form>;
<?php endif; ?>

<?php if(isset( $_SESSION["status"] )):?>
    <?php $data = @file_get_contents('../../' . $file );?>
    <form action='index.php' method='post'>
        <input id="file" hidden type="text" name="file" value="<?php echo $file;?>">
        <textarea cols='100'  name='editor1' rows='60'>
            <?php echo $data; ?>
        </textarea>
        <script>CKEDITOR.replace( 'editor1', {filebrowserUploadUrl: 'uploader.php'});</script>
        <p><input id="btn_save" class="btn btn-xs btn-success" type='submit' value='save' /><input class="btn btn-xs btn-danger" id="btn_back" type='submit' value='back' /></p>
    </form>
<?php endif; ?>

</body>
</html>