/
index.php
177 lines (144 loc) · 5.16 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/*
* xr.com - Unreliable. Goes down a lot.
* xrl.us - Marked as spam on Twitter
* fong.us - Manually approves links.
*/
class Multishort
{
/*
* Boolean; Decides whether or not a form should be shown
*/
public $show_form;
/*
* String; Set when form is posted from
*/
public $long_url;
/*
* Array; An array of all the short URLs generated
*/
public $short_urls;
public function __construct()
{
$this->main();
}
/*
* Function names are formatted like so:
* domain_tld
* Maintain this.
*/
public function tiny_cc($url='http://brandonkprobst.com')
{
$tiny_cc = 'http://tiny.cc/?c=rest_api&m=shorten&version=2.0.3&format=json&longUrl='.$url.'&login=d0pus&apiKey=8e1c9918-1e08-48ea-a228-bb02e15050e5';
$response = file_get_contents($tiny_cc);
$json = @json_decode($response,true);
$this->short_urls[] = $json['results']['short_url'];
}
public function is_gd($url='http://brandonkprobst.com')
{
$is_gd = file_get_contents('http://is.gd/create.php?format=simple&url='.$url);
$this->short_urls[] = $is_gd;
}
public function alturl_com($url='http://brandonkprobst.com')
{
$alturl_com = file_get_contents('http://shorturl.com/make_url.php?longurl='.$url);
if(preg_match_all("/(\[)(<)(a)( )(href)(=)((?:http|https)(?::\/{2}[\w]+)(?:[\/|\.]?)(?:[^\s\"]*))/is", $alturl_com, $matches))
{
$this->short_urls[] = $matches[7][0];
}
}
public function to_ly($url='http://brandonkprobst.com')
{
$to_ly = file_get_contents('http://to.ly/api.php?longurl='.$url);
$this->short_urls[] = $to_ly;
}
public function url_ie($url='http://brandonkprobst.com')
{
$url_ie = file_get_contents('http://url.ie/site/api/tinyurl/create/?url='.$url);
$this->short_urls[] = $url_ie;
}
public function moourl_com($url='http://brandonkprobst.com')
{
$moourl_com = file_get_contents('http://moourl.com/create/?source='.$url);
if (preg_match_all("/(<div id=\"milked_url\" style=\"display:none;\">)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))/is", $moourl_com, $matches))
{
$this->short_urls[] = $matches[2][0];
}
}
public function snipr_com($url='http://brandonkprobst.com')
{
$snipr_com = file_get_contents('http://snipr.com/site/snip?link='.$url);
if(preg_match_all("/(<)(div)( )(class)(=)(\"cbutton\")( )(val)(=)(\")((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))/is", $snipr_com, $matches))
{
$this->short_urls[] = $matches[11][0];
}
}
public function ze_tl($url='http://brandonkprobst.com')
{
$ze_tl = file_get_contents('http://ze.tl/?url='.$url);
$ze_tl = json_decode($ze_tl);
$this->short_urls[] = $ze_tl->url;
}
public function tinyy_me($url='http://brandonkprobst.com')
{
$tinyy_me = file_get_contents('http://tinyy.me/api.php?url='.$url);
$this->short_urls[] = $tinyy_me;
}
public function shrinkr_me($url='http://brandonkprobst.com')
{
$shrinkr_me = file_get_contents('http://shrinkr.me/api.php?url='.$url);
$this->short_urls[] = $shrinkr_me;
}
public function lnk_in($url='http://brandonkprobst.com')
{
$lnk_in = file_get_contents('http://lnk.in/remote.php?url='.$url);
if(preg_match_all("/(id)(=)(\"divMessageBox\")(>).*?((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))/is", $lnk_in, $matches))
{
$this->short_urls[] = $matches[5][0];
}
}
public function bit_ly($url='http://brandonkprobst.com')
{
$bit_ly = file_get_contents('http://api.bit.ly/shorten?version=2.0.1&longUrl='.$url.'&login=d0pus&apiKey=R_1b7ef98c4c59295606a0efe1a0bb217c&format=json');
$bit_ly = json_decode($bit_ly,true);
$this->short_urls[] = $bit_ly['results'][$url]['shortUrl'];
}
public function main()
{
if(count($_POST)<1)
{
return $this->show_form = TRUE;
}
else
{
$long_url = $_POST['uri'];
$this->tiny_cc($long_url);
$this->is_gd($long_url);
$this->alturl_com($long_url);
$this->to_ly($long_url);
$this->url_ie($long_url);
$this->moourl_com($long_url);
$this->snipr_com($long_url);
$this->ze_tl($long_url);
$this->tinyy_me($long_url);
$this->shrinkr_me($longurl);
$this->lnk_in($longurl);
$this->bit_ly($longurl);
return $this->show_form = FALSE;
}
}
}
$multishort = new Multishort();
?>
<?php if($multishort->show_form == TRUE):?>
<form action="" method="post">
<div>
<input type="text" name="uri" placeholder="Enter URL here" /> <input type="submit" name="submit" value="Shorten" />
</div>
</form>
<?php elseif($multishort->show_form == FALSE):
foreach($multishort->short_urls as $short_url):
echo $short_url.'<br />';
endforeach;
endif;
?>