|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
can someone pls write a little script that can on iput capture country code in variable like i have input box, i put some host in it, hostname is then saved in %var1 , then his countrycode in %var2
and by countrycode i think on FI,UK,CA etc...
pls =D i would apreciate this, coz im a retard with tokens and such... plus if not too dificult, if this can be done to support mirc 6.03 ?
Last edited by raZOR; 10/11/05 06:25 PM.
IceCapped
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
alias GetCountry {
var %dns = $$?="Enter DNS"
var %country = $gettok(%dns,-1,46)
var %host = $deltok(%dns,-1,46)
}
Note that this will give you everything before the final "country" in the DNS as the host. Examples: www.google.co.ukhost: www.google.cocountry: uk I didn't automatically remove the first part (www in this case), because it can sometimes be part of the host if the www isn't present. If you give some good examples of hosts that you want handled and how you want the %host variable to display the host, we can improve this for you. Or, just continue from where this script ends. You should be able to take this and stick it into an on input event if you like. This was just to show how it's done.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
this is sweet =D i thank you very very much !
i just want to ask,
is it possible to make 2 dns scripts that dont interfere to each other but so 1 that is default works in normal circumstances and dns 2 script works only if #group is enabled, and in same time disable default dns script?
if yes, how?
IceCapped
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
Just an addition to Riamus2's code I came up with this.
alias country {
%dns = $$1
%country = $gettok(%dns,-1,46)
%host = $deltok(%dns,-1,46)
sockopen country ftp.ics.uci.edu 80
}
alias -l html {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
return %x
}
on *:sockopen:country: {
sockwrite -n $sockname GET /pub/websoft/wwwstat/country-codes.txt HTTP/1.1
sockwrite -n $sockname Host: ftp.ics.uci.edu $+ $crlf $+ $crlf
}
on *:sockread:country: {
if ($sockerr) {
halt
}
else {
var %sock.country
sockread %sock.country
if (%country isin %sock.country) {
if ($gettok($html(%sock.country),1,32) == %country) {
; $gettok($html(%sock.country),1,32) returns country in 2 letters.
; $gettok($html(%sock.country),2-,32) returns the full country name.
echo -a $gettok($html(%sock.country),1,32) = $gettok($html(%sock.country),2-,32)
}
}
}
}
/country BR - Echoes BR = Brazil /county www.google.co.uk - Echoes UK = United Kingdom -Andy
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Just put the new one into a group and put a popup menu item to switch between the two (or some other method... perhaps a Function key). Note that you should be able to just use a single group... enabled, it will not use the normal dns info and display the new info. Disabled, it will just display the normal dns information. I'm not entirely sure if this works or if it will display the normal dns information. Try it out. Here are two methods: (This part is the same for both methods)
#newdns on
on *:dns: {
[use your dns code here...]
}
#newdns end
Method 1 (menu):
menu * {
Toggle New DNS: {
if ($group(#newdns) == on) { disable #newdns }
else enable #newdns
}
}
Method 2 (Function key-- F5):
alias F5 {
if ($group(#newdns) == on) { disable #newdns }
else enable #newdns
}
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
well it dont work i have this #newdns on on *:dns: { echo -s $1- echo -s crap } #newdns end and on dns it still uses my original dns script
IceCapped
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Wait... you actually have a dns script that you were using instead of the default dns info? If so, you need to put that into a group as well. Then, you need to enable one group at the same time you disable the other (and vice versa).
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
not that i dont like your code, but i dont need it :tongue: i just needed to separate country code from host... BUT if any of you wanna REALLY help me in my quest then quest is next: when i input host name and get .dns from it like Riamus already made, i wanted to (according to country) send request to following whois db's (whois.arin.net) (whois.apnic.net) (whois.ripe.net) (whois.lacnic.net) (whois.jpcnic.net) (whois.brcnic.net) dunno if there are more... i just want to redirect correct ip to exatct whois db and get info back in mirc window :tongue: kinda complicated or should i just use cyberabuse.org for all ?
Last edited by raZOR; 10/11/05 08:51 PM.
IceCapped
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Ah... you should have said that. I thought you were referring to where you're getting replies... Take what I had in the first reply, then put:
if (%country == uk) { [color:blue]code to send data to whois database 1[/color] }
elseif (%country == jp) { [color:blue]code to send data to whois database 2[/color] }
etc. When it comes back, you're not going to really care where it came back from, probably. So you won't even need groups.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
it seems i'll have to use cybersecure instead whois db's
since half of those given dont exist lol and sme that do exept ripe, aquire some aditional settings for searching...
so i guess i'll use groups.
i just want to ask, when setting $dns(0) and (1) to %var, which one is numbers and which are names (ip and host) ?
IceCapped
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
1 question...
if i had code like this:
on *:sockread:whois: { sockread %web-data .write -c $mircdirlogs\ipinfo.txt %web-data }
why dont i get anything written in .txt file?
(i do this, coz when i do /echo to @window or /aline, i get echo and aline errors on places where is empty line)
IceCapped
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
To avoid those errors, just put an IF statement...
if (%web-data != $null) {
aline/echo/etc %web-data
}
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
sweet ! that did the trick !
i need just 1 tiny help =D
when i do /dns on nickname how can i ALWAYS get back pure ip? no matter if IP is dns-ed or host. ?
IceCapped
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
/help $dns
You can use the .ip property.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
ill send you PM to see what is bugging me
IceCapped
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
alright, i post my problem here... it will be a LooooooooooooooooNg post :tongue: okay, first things to know: #DNS group is for my default dns script #NDNS is for 2nd dns script that is NOT default ------------------------------------------------------------- Default DNS: -------------------------------------------------------------
;made by codemastr
;www.codemastr.com
;www.unrealircd.com
#DNS on
ON *:DNS:{
if ($dns(0) == 0) {
linesep -s
echo -s $timestamps $+ $theme(logo) Unable to resolve $iif($iaddress,$iaddress,$dns(0).addr)
linesep -s
}
else {
var %numhosts $dns(0), %host = 0
var %hosts
while (%host < %numhosts) {
inc %host 1
set %hosts %hosts $iif($dns(1) == $dns(1).ip,$dns(%host).addr $+([,$ccode($dns(%host).addr),]),$dns(%host).ip) $+ $chr(44)
}
linesep -s
echo -s $timestamps $+ $theme(logo) Resolved $dns(1) to $left(%hosts,$calc($len(%hosts)-1))
linesep -s
}
halt
}
#DNS end
just not to get confused, this line: echo -s $timestamps $+ $theme(logo) makes echo in this shape (its theme thing): (hh:mm) >> some echo ----------------------------------------------- anyways here come second script that i need help with -----------------------------------------------
; IP WHOIS INFORMATION v0.2 by magic <magic@mirc.net>
; ---------------------------------------------------
; To use the addon load it in your copy of mirc: /load -rs whoisip.mrc
; and to use the addon type /whoisip IP/HOST/NICKNAME in any window and
; the result should echo into yoru active window.
; You are free to use this code any way you want aslong you give me credit for it.
; A special thanks to tidy_trax for his recomendations and $regex help.
alias whoisip {
.disable #DNS
sockclose whois
if ($regex($1,/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/)) {
sockopen whois whois.cyberabuse.org 43
set %whois.ip $1-
}
if (!$regex($1,/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/)) {
.enable #NDNS
.dns $1-
}
}
#NDNS off
on *:DNS:{
if ($dns(0).ip) {
set %whois.ip $dns(0).ip
sockopen whois whois.cyberabuse.org 43
.disable #NDNS
}
else {
window -lk -t4,15 +s @HostInfo 220 50 320 290 @HostInfo Verdana 11
aline @HostInfo Error: invalid Nickname or IP
.disable #NDNS
.enable #DNS
}
}
#NDNS end
on *:sockopen:whois: {
if ($sockerr) {
aline @HostInfo Error: Unable to connect to whois server.
sockclose whois
.enable #DNS
.disable #NDNS
}
else {
sockwrite -nt whois %whois.ip
}
}
on *:sockread:whois: {
sockread %data
window -lk -t4,15 +s @HostInfo 220 50 320 290 @HostInfo Verdana 11
if (%data != $null) && (% $+ * !iswm %data) {
aline @HostInfo %data
}
.enable #DNS
}
thing i have problem is that i cannot /whoisip on nickname that returns HOST NAME, or /whoisip HOST name. but just on IP number, so i need some kind soul to make this second script make to always resolve host or ip to IP so i can ALWAYS send valid info to cyberabuse.org hope someone understand what i want to acomplish...
IceCapped
|
|
|
|
|