-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
82 lines (71 loc) · 1.98 KB
/
Copy pathindex.php
File metadata and controls
82 lines (71 loc) · 1.98 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
<!Doctype html>
<html>
<head>
<center>
<br><br> <br><br>
<title>S121 - Url shortener</title>
<h1>S121</h1>
</center>
</head>
<br><br>
<body>
<center>
<h1>URL shortener</h1>
<br><br>
<form method="post" action="<?php ?>">
<label>Enter URL with http or https</label>
<input type="text" required name="url" placeholder="Enter URL with http or https"/><br><br>
<label style="color:blue">s121.ml/ </label>
<input type="text" required name="key" placeholder="Enter keyword" /><br><br>
<input type="submit" style="background-color:green" width="50" height="30" value="Shorten"/>
</form>
<br><br>
<h1>
<?php
if(!empty($_POST['url'])){
$keyword=$_POST['key'];
$url=$_POST['url'];
if(!strstr($url,"http") && !strstr($url,"https") )
{
$url = "http://".$url;
}
$content='<?php
$myurl="'.$url.
'";
header("Location:$myurl", true, 302);
exit();
?>';
if(empty($_POST['url'])){
echo "Url cannot be empty!";
exit();
}
if(!empty($_POST['key'])&& strlen($keyword)>2) {
if (!file_exists($keyword)) {
mkdir($keyword, 0777, true);
$fp =fopen("./$keyword/index.php",'wp');
fwrite($fp,$content);
fclose($fp);
$surl = "s121.ml/".$keyword;
$rurl = "https://s121.ml/".$keyword;
echo "<a href=$rurl>$surl</a>";
}
else{
echo "Keyword Already exists!";
}
}
else{
echo "Minimum keyword length should be 3!";
}
}
?>
</h1>
<center>
</body>
<footer>
<h3>URLs Shortened -
<?php
echo count( glob("*", GLOB_ONLYDIR) );
?>
</h3>
<p>Copyright © 2018, S121, <a href="https://linkedin.com/in/ashishayadav/">Ashish Yadav</a></p>
</footer>