-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
109 lines (102 loc) · 4.76 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start()
?>
<!DOCTYPE html>
<html lang="TR" class="no-js">
<head>
<title>Simple URL Shortening Service</title>
<!-- Google Main Meta -->
<meta charset='utf-8'>
<meta name="robots" content="noindex, nofollow">
<meta name="description" content="Secure, fast and anonymous url Shortener Services for free">
<!-- Meta -->
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Language" content="tr">
<meta name="author" content="Mertcan GOKGOZ, [email protected], https://mertcangokgoz.com/"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="inc/custom.css">
<script>
$(document).ready(function () {
$("#send").click(function () {
$('.alert').remove();
var check = document.getElementById('longurl').value;
var MatcUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if (MatcUrl.test(check)) {
$.ajax({
type: "POST",
url: "ajax.php",
data: $("#shortener").serialize(),
success: function (data) {
var json = JSON.parse(data);
$('.result').html('');
$('.result').html('<input type="text" name="url" class="form-control" value="' + json.url + '">');
}
});
} else {
$('.result').append('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>HATA!</strong> Tanımsız URL.</div>');
return false;
}
});
});
</script>
<!-- Content -->
</head>
<body>
<!--[if lt IE 8]>
<p class="chromeframe">outdated</p>
<![endif]-->
<div class="container">
<div class="row">
<div class=" col-md-10 ">
<h1 class='title text-center'>Simple URL Shortening Service</h1>
</div>
<br>
<?php if (isset($_SESSION['username']) && $_SESSION['username']) { ?>
<div
class="col-md-2"><?php echo '<p >Welcome ' . htmlentities($_SESSION['username']) . ' <a href="/panel/">Profile</a><span> | </span><a href="logout.php"> Logout</a></p> '; ?></div>
<?php } else { ?>
<div class="col-md-2"><?php echo '<p class="text-center"><a href="login.php"> Login</a></p>' ?></div>
<?php } ?>
</div>
<div class="well content">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<form method="post" action="" id="shortener" onsubmit="return false">
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">URL:</span>
<label for="longurl"></label><input type="text" name="url" id="longurl" class="form-control"
placeholder="URL"
aria-describedby="sizing-addon1" required>
<label for="alias"></label><input type="text" name="alias" id="alias" class="form-control"
placeholder="Alias"
aria-describedby="sizing-addon1" maxlength="10">
<span class="input-group-btn">
<button type="submit" id="send" class="btn btn-success">Short</button>
</span>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 center">
<div class="result">
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<ul>
<li><a href="mailto:[email protected]">Feedback</a></li>
<li><a href="https://github.com/mertcangokgoz/simple-url-shortener">Github</a></li>
</ul>
</div>
</body>
</html>