Description:
Stupid bum who missed deadline
In this challenge you are asked to code a $urltok() alias that will return a required fragment of a given URL.
The required fragment of the URL will be given as a property ($prop). The alias will take 2 parameters, 1 of them will be optional.
The format will be
$urltok(< url >[,N]).
N will be specified when getting a fragment of the url where there is a possibility there are more than 1 values. Look at the examples for
.dir, .attr, .val properties to understand.
You are required to return fragments for a given URL for
attr, val, dir, port, anchor, protocol, host, user, and pass
Example:
Using URL: http://user:pass@192.168.0.1:888/dir/gary/page.php?foo=bar&foo2=bar2#anchor
$urltok(url,1).attr = foo
$urltok(url,2).attr = foo2
$urltok(url,0).attr = 2
$urltok(url,1).val = bar
$urltok(url,2).val = bar2
$urltok(url).protocol = http
$urltok(url,0).dir = 3
$urltok(url,1).dir = dir
$urltok(url,2).dir = gary
$urltok(url,3).dir = page.php
$urltok(url,4).dir = $null
$urltok(url).user = user
$urltok(url).pass = pass
$urltok(url).port = 888
$urltok(url).host = 192.168.0.1
$urltok(url).anchor = #anchor |
See
http://www.ietf.org/rfc/rfc2396.txt for more information on the URI format.
Rules:
Alias name must be 'urltok'
No dlls, coms, sockets, regular expressions, OR ANY $*tok or /tokenize
One submission per user.
Your code will be taken for EXACTLY as submitted. Nothing will be changed in your submitted code - even if a subtle mistake is found.
Alias will be run on mIRC v6.21.
Script must give correct results after consecutive runs.
File will be loaded into the remotes section.
File we will be using to count the code: countcode.php
Code which exploits countcode will be rejected.
Alias will be run on a mIRC with no variables set - a clean mIRC.
Entries will be judged on code size and whether they return the correct result.
Feel free to ask any questions in the forum below.
Good luck!
FAQ:
any questions that you may have please DO ask in the forum. I will post the question here, with an answer, if I feel its important.
What should it return if no port is in the url? Should it return 80, as this is the default port?
No. It should return $null.
Does the alias need to check if the URL is the correct format?
Yes. If the url is the incorrect format it should return $null to all properties.
Update: 05/05/2007 - You do NOT need to validate a URL. See this forum post
Do I need to support mailto:, javascript:?
No. You only need to support a HTTP url.
Do I need to decode the URL, e.g. %3F
No. Return exactly as it is.
What should $urltok(url,1 OR any number here).protocol return?
The protocol. Ignore the number and simply return what was asked for.