-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
105 lines (88 loc) · 3.54 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
<?php
include_once 'connect.inc.php';
?>
<!DOCTYPE html>
<html lan='en'>
<head>
<title>URL Shortener</title>
<meta name='author' content='Romit Choudhary'>
<meta http-equiv='cache-control' content='public'>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv='content-language' content='en-US'>
<meta name='copyright' content='© 2014 Romit Choudhary'>
<meta name='description' content='URL shortener converts long url to short url.'>
<meta name='keywords' content='url shortener, short url, tiny url, small url , long url, big url, convert long url to short url, romits url shortener'>
<meta name='robots' content='index,follow'>
<meta property='og:title' content='URL Shortener'>
<meta property='og:type' content='website'>
<meta property='og:site_name' content='URL Shortener'>
<meta property='fb:admins' content='100002095998425'>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=460517324050343";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id='content' align='center'>
<div id='logo'>
<p>
<span id='one'>URL</span>
<span id='two'>short.en.er</span>
</p>
</div>
<div id='form'>
<form action='index.php' method='post'>
<input type='text' name='url' placeholder='Paste Your long URL here'>
<button name='submitbutton'>
Shorten URL
</button>
<br>
</form>
</div>
</div>
<span id='encodedurl' align='center'>
<?php
if (isset($_POST['url'])) {
$url = $_POST['url'];
if (empty($url)) {
echo $message = '<p>No url was supplied</p>';
}
elseif (validateUrlFormat($url) == false) {
echo $message = '<p>URL does not have a valid format.</p>';
}
elseif (checkUrlExists($url) == false) {
echo $message = '<p>URL does not appear to exist.</p>';
}
elseif (urlExistsinDB($url) == true) {
$shortcode = urlExistsinDB($url);
echo $message = "<div id='error' title='Copy this code'>Copy this url to share - <b style='font:bold 18px arial;margin-left:5px;color:green;'>$shortcode</b></div>";
}
else{
$shortcode = createShortCode($url);
echo "<div id='error' title='Copy this code'>Copy this url to share - <b style='font:bold 18px arial;margin-left:5px;color:green;'>$shortcode</b></div>";
}
}
?>
</span>
<div id='facebook'><div class="fb-facepile" data-href="http://facebook.com/longurl2shorturl" data-width="560" data-max-rows="1" data-colorscheme="light" data-size="medium" data-show-count="true"></div></div>
<div id='footer'>
<span id='copy'>Copyright © Romit Choudhary 2014</span>
<span id='social'>
<a href="https://www.facebook.com/choudharyromit" target='_blank'>Facebook</a> | <a href="https://github.com/romitgithub/URL-Shortener" target='_blank'>Github</a>
</span>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-43364785-3', 'bl.ee');
ga('send', 'pageview');
</script>
</body>
</html>