-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
89 lines (75 loc) · 2.68 KB
/
index.php
File metadata and controls
89 lines (75 loc) · 2.68 KB
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
<?php
use Shortener\Api\Minify\UrlShortener;
if (isset($_GET["code"])) {
require "api/db/config.php";
require "api/mini/shortener.php";
$sh = new UrlShortener();
$url = $sh->getUrlFromCode($_GET["code"]);
$host = str_replace("www.", "", $_SERVER["SERVER_NAME"]);
if ($url != null && strpos($url, $host) === false) {
header("location: " . $url);
} else {
header("location: /" . basename(__DIR__));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/include/bootstrap/bootsrap.min.css">
<script src="assets/include/bootstrap/boostrap-3.3.6.js"></script>
<script src="assets/include/jquery/jquery-1.12.0.js"></script>
<link rel="stylesheet" href="assets/css/core.css">
<title>Shortn - URL Shortener</title>
</head>
<body>
<div class="container">
<div class="page-header">
<h1 id="headerTitle" >Shortn -
<small id="slur">Shorten your URL today!</small>
</h1>
</div>
<section class="center">
<form>
<input id="btnSubmit" type="submit" class="btn btn-primary" value="Shortn"/>
<div class="form-group inline-form">
<input id="inputUrl" type="url" class="form-control" placeholder="Enter URL here"/>
</div>
</form>
<div class="alert alert-success hidden" role="alert">
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>URL shortened successfully.</strong>
<p id="txtSuccess"></p>
</div>
<div class="alert alert-danger hidden" role="alert">
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong id="txtError"></strong>
</div>
<br>
<div id="statistics-panel" class="panel panel-info center">
<div class="panel-heading">
<h3 class="panel-title">Page Statistics</h3>
</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">
<span id="totalShortened" class="badge">0</span>
Total URLs shortened
</li>
<li class="list-group-item">
<span id="shortenedToday" class="badge">0</span>
Total URLs shortened today
</li>
</ul>
</div>
</div>
</section>
</div>
<script src="assets/js/main.js"></script>
</body>
</html>