mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
I know that people have already asked about it.
I have a text file which I wanna download from my website in netfirm... 2 files actualy. The first file is an ini file and it seems to be OK. The other file is a hash table which was saved into a text file using hsave.

I did a search on the forum and I found a script that someone wrote which is supposed to download EXE files, but it has one major flaw (It doesn't matter in which server the files are located, it still happens):
The downloaded file has the HTTP/1.1 ...... which get the fire corrupted. The actual writting to the file should only begin after the other data that the server sends is over.
In the method suggested, it can not be removed IMO because it is using &binvar.
Since netfirms also has useless ads, then the ads are also being added to the file and corrupt it even more.

My solution off course was using sockread %temp and searching for "//start" and "//end" which I have added to the text file so I will know when it starts and when it ends:

on *:sockopen:getfile: {
if ($sockerr == 0 ) {
set %getfile = 0
write -c " $+ $scriptdirgetfile.tmp"
sockwrite -n $sockname GET / $+ %getfilename HTTP/1.1
sockwrite -n $sockname Host: %server $+ $str($crlf ,2)
.timerclosegetfile 1 60 sockclose getfile
}
else { sockclose getfile | halt }
}
on *:sockread:getfile: {
sockread %temp
if (%temp == //end) %getfile = 0
if (%getfile == 1) {
if (%temp != $null) write " $+ $scriptdirgetfile.tmp" %temp
else write " $+ $scriptdirgetfile.tmp" $crlf
}
if (%temp == //start) {
%getfile = 1
}
}



This way I get the file downloaded without the HTTP 1.1 .......... and the useless ads of netfirms.
I get the file, but it take about 5 seconds to download 1 9KB file and in all of this time mIRC doesn't react to commands (It is like it is locked up).
Furthermore, after I have loaded the hash table from the text file I downlaoded, I saw that one or more of the items got corrupted (It might have been because of the else write " $+ $scriptdirgetfile.tmp" $crlf)

I'm building a spam blocker, and I want it to be able to update itseld automatically whenever there is a update for the spam messages.
I'm using a hash table cause it works better (I don't have to use a while loop in order to search the hash table):


on *:TEXT:*:?: {
tokenize 32 $strip($1-)
if ($hfind(antispam,$1-,0,R).data > 0) {
echo 4 -s You probably got spammed by $nick $+ . $nick was added to your ignore list.
ignore $nick
close -m $nick
}
}

If I would use a text file, then i will have to use a loop which scan each line of the text file to see if it matches the text.


Can anyone suggest the bext solution for downloading the text file? (Or any file, but without getting it corrupted)??

Thank you grin

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
This was just thrown together, should work fine.


alias dlfile {
sockclose dlfile
unset %dl.go
sockopen dlfile [color:red]www.site.com
80
}

On *:Sockopen:dlfile:{
sockwrite -n $sockname GET /dir/to/file.txt HTTP/1.1
sockwrite -n $sockname Host: www.site.com
sockwrite -n $sockname
}

On *:Sockread:dlfile:{
sockread %dlfile
if ((!%dlfile) && (!%dl.go)) { set %dl.go 1 }
elseif (%dl.go) { echo -s Got: %dlfile }
}
[/color]

Edit the red to the according, www.site.com becomes your website address, without http:// and any directory information, /dir/to/file.txt, becomes the EXACT directory to the file including .extention.

Also note this will NOT work for Binary files.

Syntax; /dlfile

Eamonn.

Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Thats a nice way of getting rid of all the data that the server sends at first. I have no idea what you did and why it is working though.

Btw, any way of making it work with binary files too by:
elseif (%dl.go) {
sockread &dlfile
bwrite %file -1 -1 &dlfile
}


?? smile

Thanks

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
See here.

Eamonn.

Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Thank you. smile

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Sure thing smile

Eamonn.


Link Copied to Clipboard