This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
shortener.php
78 lines (60 loc) · 2.14 KB
/
shortener.php
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
<?php
// official link to wmflabs server
$LABS_HOST = "tools.wmflabs.org/durl-shortener/shortener.php";
// official link to the localhost server
$LOCAL_HOST = "localhost:3000/shortener.php";
// request link (link with hash)
$request_link = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$html = <<<EOD
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>URL Shortener - d3r1ck</title>
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="main-container">
<div class="inner cover">
<span class="glyphicon glyphicon-link"></span>
<h1>URL Shortener</h1>
<h4>d3r1ck</h4>
<div class="row">
<div class="col-lg-12">
<div class="input-group input-group-lg">
<input id="urlfield" type="text" name="link" class="form-control" placeholder="Paste a link here..." required>
<span class="input-group-btn">
<button class="btn btn-shorten" type="submit">SHORTEN URL</button>
</span>
</div>
</div>
<div class="col-lg-12">
<div id="link"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="js/shorten.js"></script>
</body>
</html>
EOD;
if ( $request_link === $LABS_HOST ) {
echo $html;
} elseif ( $request_link === $LOCAL_HOST ) {
echo $html;
} else {
require_once 'vendor/autoload.php';
// Include the Checker.php file
include 'php/Checker.php';
exit();
}