Top

TinyUrl Previewer\Checker


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Apr 15, 2009
Last Updated  Apr 15, 2009
Tags  check  preview  tinyurl 

Introduction

This script allows you to see where a TinyUrl will go before you click it on.

If you wanted to check where http://tinyurl.com/1 redirected you could type either:

1) /tinyurl 1

or

2) /tinyurl http://tinyurl.com/1

The result either way would be:
* Getting information for http://tinyurl.com/1
* http://tinyurl.com/1 redirects to http://www.gilby.com

Grab the Code

alias tinyurl {
  sockopen tinyurl_check tinyurl.com 80
  sockmark tinyurl_check $gettok($1,1,61)
}
on *:sockopen:tinyurl_check:{
  echo 2 -a * Getting information for http://tinyurl.com/ $+ $sock($sockname).mark
  timertinyurlcheck 1 20 echo 2 -a * There appears to be no redirect for http://tinyurl.com/ $+ $sock($sockname).mark
  sockwrite -n $sockname GET /preview.php?num= $+ $sock($sockname).mark HTTP/1.0
  sockwrite -n $sockname Host: tinyurl.com
  sockwrite -n $sockname $crlf
}
on *:sockread:tinyurl_check:{
  var %x
  sockread -f %x
  if (<blockquote><b> isin %x) {
    timertinyurlcheck off
    echo 2 -a * http://tinyurl.com/ $+ $sock($sockname).mark redirects to $remove(%x,<blockquote><b>,<br /></b></blockquote>)
  }
}
 

Comments

  (8)  RSS
tv3636
Comments: 84
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 7:43 pm
Pretty cool, you should probably add an option to echo the redirects on TEXT too so that people can automatically see them when they're messaged.
Blitzjager
Comments: 193
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 7:57 pm
an on hotlink that does what tv suggested would be nice.
vSkyzv
Comments: 22
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 7:58 pm
If somebody spammed a TinyUrl and this were on TEXT, your computer might lag a bit.

However, an on HOTLINK does make more sense... I might make it later.
tv3636
Comments: 84
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 9:26 pm
That would have to be some serious spamming, but yeah HOTLINK does make more sense, shouldn't be too difficult to add either :)
Kirby
Comments: 475
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 10:26 pm
Cool, I really like the idea. :-)

Though your script works, I thought you can use some regex to make your sockread event a little shorter and add some error checks.

Code:
on *:sockread:tinyurl_check:{
  var %x
  sockread -f %x
  if (<blockquote><b> isin %x) {
    timertinyurlcheck off
    echo 2 -a * http://tinyurl.com/ $+ $sock($sockname).mark redirects to $remove(%x,<blockquote><b>,<br /></b></blockquote>)
  }
}

can be rewritten as:
Code:
on *:sockread:tinyurl_check:{
  sockread %x
  if ($regex(%x,<blockquote><b>(.*)<br /></b></blockquote>)) { echo -a $+(http://tinyurl.com/,$sock($sockname).mark) redirects to $regml(1) }
  elseif (class="intro"> isin %x) { echo -a * There appears to be no redirect for $+(http://tinyurl.com/, $sock($sockname).mark) }
}

I wouldn't use timers to check socket results, as sockets are quite (unbelievably) fast.
Instead of timers, resort to a unique tag that you will not find in a normal, working page. As the tags class="intro"> used in the code above, can be used to differentiate the two. You also don't need var %variable in the beginning of the sockread event.
Thus, you can remove
Code:
  timertinyurlcheck 1 20 echo 2 -a * There appears to be no redirect for http://tinyurl.com/ $+ $sock($sockname).mark
in the sockopen event.
I would also use a unique variable such as %tinyurl in this case, to prevent errors.

Although regex may seem complicated, in larger scripts, they will prove quite worthy. Most of all, they can shorten repetitiveness in scripts and even hasten them.
And yes, a Hotlink -> Echo would be nice.


On a second note, please make sure your code works.
Quote:
2) /tinyurl http://tinyurl.com/1
does not work.
Code:
  sockmark tinyurl_check $gettok($1,1,61)
as specified in the alias means that you are getting the first token separated by equal signs =. In TinyURL links, there are no = signs in the URL.
And if you are going to use timers, put a dot . in front of them so they are silent.

Here's a rewrite of yours that works both ways as
Quote:
If you wanted to check where http://tinyurl.com/1 redirected you could type either:
1) /tinyurl 1
or
2) /tinyurl http://tinyurl.com/1
The result either way would be:
* Getting information for http://tinyurl.com/1
* http://tinyurl.com/1 redirects to http://www.gilby.com
says:
Code:
alias tinyurl {
  if ($sock(tinyurl)) sockclose tinyurl
  sockopen tinyurl tinyurl.com 80
  sockmark tinyurl $iif($gettok($gettok($1,2,46),2,47),$v1,$1)
}
on *:sockopen:tinyurl: {
  echo -a * Getting information for $+(http://,$sock(tinyurl).addr,/,$sock(tinyurl).mark)
  sockwrite -n $sockname GET /preview.php?num= $+ $sock(tinyurl).mark HTTP/1.0
  sockwrite -n $sockname Host: tinyurl.com $+ $crlf $+ $crlf
}
on *:sockread:tinyurl: {
  sockread %tinyurl
  if ($regex(%tinyurl,<blockquote><b>(.*)<br /></b></blockquote>)) {
    echo -a * $+(http://tinyurl.com/,$sock(tinyurl).mark) redirects to $regml(1)
  }
  elseif (class="intro"> isin %x) {
    echo -a * There appears to be no redirect for $+(http://tinyurl.com/,$sock($sockname).mark)
  }
  unset %tinyurl
}
Firstmate
Comments: 119
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 11:05 pm
I was gonna do this D:
No fair...
Btw, Kirby complicates things. All you have to do is:
Code:

;if you have a link returned
set -u10 %tinyurl.temp 1

;check for </html>
if (</html> isin %x) { sockclose tinyurl_check | if (!%tinyurl.temp) { echo -a can't find it }
Kirby
Comments: 475
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 15, 2009 11:55 pm
PATX
Comments: 390
 
mIRC Snippet:  TinyUrl Previewer\Checker
Posted on Apr 29, 2009 7:39 pm
good script i like the point.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom