aboutsummaryrefslogtreecommitdiff
path: root/admin/panes/shortens.php
blob: 165c1988fc10fd26a2af9683b73a8ba64187385f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>

<style>
    ::-webkit-scrollbar {
        width: 5px;
    }

    ::-webkit-scrollbar-track {
        border-radius: 9999px;
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 9999px;
        background-color: rgba(136, 136, 136, 0.5);
        transition: background 200ms;
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: rgba(85, 85, 85, 0.75);
    }

    ::-webkit-scrollbar-thumb:active {
        background-color: #222;
    }

    .list-group-item {
        background: #34373c;
    }
</style>

<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
    <h2 style="text-align:center;">Shortened URLs</h2>

    <ul class="list-group" style="margin-top:20px;">
        <?php

        $links = explode("\n", file_get_contents("/mnt/minteckrolt-urls/links.txt"));

        foreach ($links as $link) {
            if (trim($link) !== "") {
                $url = explode(" ", $link)[0];
                $redirect = explode(" ", $link)[1];

                echo('<li class="list-group-item"><code>https://mt.ro.lt/<a href="https://mt.ro.lt/' . $url . '" target="_blank">' . $url . '</a></code> <span style="float:right;"><a href="#" onclick="deleteURL(\'' . $url . '\')">Delete</a></span></li>');
            }
        }

        ?><li class="list-group-item">
            <form id="creator" action="/admin/api/createURL.php">
                <code>https://mt.ro.lt/<input type="text" name="shortenedName" placeholder="superurl"></code><input type="text" name="redirectsTo" placeholder="https://kde.org"> <span style="float:right;"><a href="#" onclick="document.getElementById('creator').submit();">Create</a></span>
            </form>
        </li>
    </ul>
</div>

<script>
    let currurl;

    function deleteURL(url) {
        currurl = url;

        $("#myModal").modal()
    }

    function confirmDelete(url) {
        location.href = "/admin/api/deleteURL.php?_=" + url;
    }
</script>

    <div class="modal" id="myModal">
        <div class="modal-dialog">
            <div class="modal-content">

                <div class="modal-header">
                    <h4 class="modal-title">Delete this shortened URL?</h4>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>

                <div class="modal-body">
                    This cannot be undone and may have unwanted side effects. After this URL is deleted, it will redirect to Minteck's Space's homepage.
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-success" onclick="confirmDelete(currurl);">Confirm</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
                </div>

            </div>
        </div>
    </div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?>