mIRC Homepage
Posted By: r_alien Geting a webpage's data - 03/09/05 03:10 AM
Hello, i'm a n00b to this programming language! :tongue: I mainly program in PHP. I can create a PHP script that can get data from a mySQL database on request and display it for an IRC bot to read the data from. I was wondering how can i get the IRC bot to goto an address like http://localhost:6080/s3h/getdetails.php?requestedusername

requestedusername is what the IRC user who puts in !data requestedusername has specified as a user. If that makes sense, i can program the PHP code to display the data in Tables or just a list on a simple page and it will display something like this:

Username Details: requestedusername
Generated: <<TIME>>
Invisibility Shields: xxx
Black Powder Missiles: xxx

e.t.c. the weapons keep going on (there is around 36 from memory)

But how would i get the "xxx" details from it to display what weapons of each type have been damaged? :P If that makes sense, all i need to know is how to get data from a page, and what would be the best way to setout the page! xD
Posted By: SladeKraven Re: Geting a webpage's data - 03/09/05 04:05 AM
I have no idea if this works dude, don't have the files and such. So, you'll have to test it and come back with any results.. smile

Code:
alias lh {
  %un = $$1
  sockopen lh localhost 6080
}

on *:sockopen:lh: { 
  sockwrite -n $sockname GET $+(/s3h/getdetails.php?,%un) HTTP/1.1 
  sockwrite -n $sockname Host: $+(localhost,$crlf,$crlf)
}

on 1:sockread:lh: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %lh
  if ($sockbr == 0) return
  if (%lh == $null) %lh = -
  if (Generated* iswm %lh) return
  if (: isin %lh) echo -a $gettok(%lh,2,58)
  goto nextread
}


-Andy
Posted By: IR_n00b Re: Geting a webpage's data - 03/09/05 04:06 AM
/help sockets

thats about all you need, also http headers for firefox is usefull as well, to see what firefox sent the server (the webpage) it. smirk
Posted By: r_alien Re: Geting a webpage's data - 03/09/05 05:26 AM
I have modified the coding a little, basically just the URL of:

Code:
alias lh {
  %un = $$1
  sockopen lh localhost 6080
}

on *:sockopen:lh: { 
  sockwrite -n $sockname GET $+(/s3h/getdetails.php?name=,%un) HTTP/1.1 
  sockwrite -n $sockname Host: $+(localhost,$crlf,$crlf)
}

on 1:sockread:lh: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %lh
  if ($sockbr == 0) return
  if (%lh == $null) %lh = -
  if (Generated* iswm %lh) return
  if (: isin %lh) echo -a $gettok(%lh,2,58)
  goto nextread
}


I have made the file that outputs the data like this (if you look at the source code, if you view it with IE or a browser it's just 1 continous line:

Quote:
--- Sabotage Details of rshield ---
Blackpowder Missiles: 0, Invisibility Shields: 0
Excaliburs: 0, Battle Axes: 0, Dragons: 0, Flaming Arrows: 0, Dragonskins: 0
Steeds: 0, Hammers of Thor: 0, Wargs: 0
Mithrils: 0, Gauntlets: 0, Heavy Shields: 0, Elven Cloaks: 0
Broadswords: 0, Warhammers: 0, Warblades: 0, Steel Bows: 0, Plate Armors: 0
Lances: 0, Maces: 0, Spears: 0, Longbows: 0, Chainmails: 0
Long Sword: 0, Pikes: 1, Clubs: 0, Crossbows: 0, Shields: 0
Staves: 0, Hatchets: 0, Slings: 0, Short Bows: 0
Helmets: 0, Knives: , Sticks: 0
--- Powered By Hawk Works ---


Now i'm a total n00b and i'd like to test it straight away! :P I've been Working on Hawk Works for ages. So how would i get the code above to react on !sabdetails <<requestedname>> then it goes to http://localhost:6080/s3h/getdetails.php?name=<<requestedname>> then gets the details and messages it back to the Channel Window? I don't really care if the script grabs the data straight away and messages it or if it saves the data to a text file somewhere and then opens the file, reading line by line the message and sending it! :P

If you have no idea how to do the above, how would you grab data from a text file and read it line by line and messaging it? Because if i open a socket connection with that page and then get the PHP script to write it to a file it might be easier coding.
Posted By: r_alien Re: Geting a webpage's data - 03/09/05 03:00 PM
Since i can't edit my last post here is what i've gotten up to:

Code:
on *:text:!sabdetails*:* {
 %un = $2
 /sockopen bot http://localhost:6080 6080
} 

on *:sockopen:bot: { 
  sockwrite -n $sockname GET /s3h/getdetails.php?name=,%un 
  sockwrite -n $sockname Host: http://localhost:6080 
  sockwrite -n $sockname User-Agent: $version 
  sockwrite -n $sockname $crlf 
} 

on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  if (Generated* iswm %bot) return
  if (: isin %bot) echo -a $gettok(%bot,2,58)
  goto nextread
}


But it doesn't work, yet it doesn't return any errors! When a user puts in !sabdetails rshield for example! blush

Can i get some help please? BTW the PHP script is outputting the data just like a notepad file with new lines in each, just if loaded in Internet Explorer, it comes up as one line.
Posted By: Kelder Re: Geting a webpage's data - 03/09/05 08:34 PM
Don't edit your previous post, about everything you changed since then is wrong...
red = wrong, green = good, blue = comment

Code:
on *:text:!sabdetails*:* {
  %un = [color:green]$2[/color]
  [color:red]/[/color]sockopen bot [color:red]http://localhost:6080[/color] 6080
  [color:blue]; above is not an ip or named address, it's a HTTP request
  ;the slash isn't needed in a script[/color]
} 

on *:sockopen:bot: { 
  sockwrite -n $sockname GET [color:red]/s3h/getdetails.php?name=,%un [/color]
  [color:blue]; The previous snippet appended the contents of %un using $+, this code
  ; really sends that url, %un will just be percent u n[/color]
  sockwrite -n $sockname Host: [color:red]http://localhost:6080 [/color]
  [color:blue]; again, this is not a host, it's a http request[/color]
  [color:red]sockwrite -n $sockname User-Agent: $version[/color]
  [color:blue]; not needed[/color]
  sockwrite -n $sockname [color:red]$crlf [/color]
  [color:blue]; you really need 2 $crlf's right after another, only one means
  ; the server will wait a few seconds/minutes for the end of the request that is never sent[/color]
} 
[color:blue]; rest omitted[/color]
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 01:36 AM
OK here is what i've got fixing the errors and stuff:

Code:
on *:text:!sabdetails*:* {
 %un = $2
 sockopen bot 192.168.1.2 6080
} 

on *:sockopen:bot: { 
  sockwrite -n $sockname GET $+(/s3h/getdetails.php?name=,%un)
  sockwrite -n $sockname Host: $+(192.168.1.2,$crlf,$crlf)
} 

on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  if (Generated* iswm %bot) return
  if (: isin %bot) echo -a $gettok(%bot,2,58)
  goto nextread
}


Just a question, is that going to the url http://192.168.1.2:6080/s3h/getdetails.php?name=%un
Where $un is the second word after !sabdetails ? My web server only runs on port 6080 because port 80 is blocked by my ISP to stop hacking attempts.

Anyway, here is what i did in another IRC window:

Quote:
[11:19:54] *** Initial topic:
[11:19:54] *** #alien: r_alien- ~alien-
[11:19:58] alien-: r_alien- has just arrived! r_alien- is the Owner of this bot.
[11:19:58] *** Mode change "+v r_alien-" for channel #alien by alien-.
[11:20:00] *** #alien was created on Sun Sep 04 01:03:27 2005.
[11:20:39] r_alien-: !shutdown
[11:20:56] *** alien- has joined #alien.
[11:20:58] *** Mode change "+qo alien- alien-" for channel #alien by ChanServ.
[11:22:28] r_alien-: !sabdetails rshield
[11:30:06] r_alien-: !shutdown
[11:30:07] *** alien- has signed off IRC (Quit: Alien IRC Bot 1.0 based on YBBot> You cannot get this bot frown May i interest you in Hawk Works instead at http://220.237.150.18:6080/s3h/).
[11:30:19] *** alien- has joined #alien.
[11:30:21] *** Mode change "+qo alien- alien-" for channel #alien by ChanServ.
[11:31:02] r_alien-: !sabdetails rshield


When i typed the !shutdown commands the bot exits and i save the code and reload mIRC. Anway, i typed !sabdetails rshield and nothing comes up! Nothing in the window, and nothing in the mIRC connection window saying there is an error! >.< I programmed the PHP script to write to a log file just quickly to tell me when it ran, i typed the !sabdetails rshield command again, and nothing showed up in the log, which means that the PHP file wasn't executed! The log file would have recieved an extra line even if the name= parameter wasn't filled! frown
Posted By: MikeChat Re: Geting a webpage's data - 04/09/05 01:51 AM
we cannot connect to your server to test this

but you might change the sockread to be more "generic" so that you are only changing one thing at a time

Code:
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}


when you have that working then you can tweak the output with a $remove() or whatever
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 02:29 AM
I tried that code, and still nothing! blush So what i've done is opened up that script to the world, the PHP coding used t check to make sure the IP was only one IP (192.168.1.2), but i've removed that for now.

The script can be found at:

http://220.237.150.18:6080/s3h/getdetails.php?name=rshield

That will give you what people have sabbed from me! Here is a non existant one record:

http://220.237.150.18:6080/s3h/getdetails.php?name=nonexistantname
Posted By: MikeChat Re: Geting a webpage's data - 04/09/05 02:53 AM
Code:
alias bot sockopen bot 220.237.150.18 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET http://220.237.150.18:6080/s3h/getdetails.php?name=rshield 
} 

on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}

I used the above and connected, here is the output:
[quote]
--- Sabotage Details of rshield ---
Blackpowder Missiles: 0, Invisibility Shields: 0
Excaliburs: 0, Battle Axes: 0, Dragons: 0, Flaming Arrows: 0, Dragonskins: 0
Steeds: 0, Hammers of Thor: 0, Wargs: 0
Mithrils: 0, Gauntlets: 0, Heavy Shields: 0, Elven Cloaks: 0
Broadswords: 0, Warhammers: 0, Warblades: 0, Steel Bows: 0, Plate Armors: 0
Lances: 0, Maces: 0, Spears: 0, Longbows: 0, Chainmails: 0
Long Sword: 0, Pikes: 1, Clubs: 0, Crossbows: 0, Shields: 0
Staves: 0, Hatchets: 0, Slings: 0, Short Bows: 0
Helmets: 0, Knives: 0, Sticks: 0
[quote]
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 03:04 AM
I put your code in so it looks like this and still no message popped up in the window.

Code:
on *:text:!sabdetails*:* {
 %un = $2
 sockopen bot 220.237.150.18 6080
} 

;on *:sockopen:bot: { 
;  sockwrite -n $sockname GET $+(/s3h/getdetails.php?name=,%un)
;  sockwrite -n $sockname Host: $+(192.168.1.2,$crlf,$crlf)
;} 

alias bot sockopen bot 220.237.150.18 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET http://220.237.150.18:6080/s3h/getdetails.php?name=rshield 
} 

on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}
}


Just two questions here, how can i get !sabdetails <<a username>> to trigger it and then the URL is http://220.237.150.18:6080/s3h/getdetails.php?name=<<a username>>

Well that link is for you anyway, i'll change the IP address to internal IP's later. And why doesn't my above code work! *cries* confused
Posted By: MikeChat Re: Geting a webpage's data - 04/09/05 03:19 AM
on *:text:!sabdetails*:*: {
%un = $2
sockopen bot 220.237.150.18 6080
}


you left off a :
Posted By: MikeChat Re: Geting a webpage's data - 04/09/05 03:26 AM
here is what I just tested
Code:
on *:text:!sabdetails*:*: {
  set %un $2
  set %chan $chan
  sockopen bot 220.237.150.18 6080
} 

alias bot sockopen bot 220.237.150.18 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET http://220.237.150.18:6080/s3h/getdetails.php?name= $+ %un
} 

on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  msg %chan %bot
  goto nextread
}

and the channel output
Quote:

<buzz44> !sabdetails rshield
<MikeChat> --- Sabotage Details of rshield ---
<MikeChat> Blackpowder Missiles: 0, Invisibility Shields: 0
<MikeChat> Excaliburs: 0, Battle Axes: 0, Dragons: 0, Flaming Arrows: 0, Dragonskins: 0
<MikeChat> Steeds: 0, Hammers of Thor: 0, Wargs: 0
<MikeChat> Mithrils: 0, Gauntlets: 0, Heavy Shields: 0, Elven Cloaks: 0
<MikeChat> Broadswords: 0, Warhammers: 0, Warblades: 0, Steel Bows: 0, Plate Armors: 0
<MikeChat> Lances: 0, Maces: 0, Spears: 0, Longbows: 0, Chainmails: 0
<MikeChat> Long Sword: 0, Pikes: 1, Clubs: 0, Crossbows: 0, Shields: 0
<MikeChat> Staves: 0, Hatchets: 0, Slings: 0, Short Bows: 0
<MikeChat> Helmets: 0, Knives: 0, Sticks: 0
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 03:32 AM
I still have nothing! blush

Code:
on *:text:!sabdetails*:*: {
 %un = $2
 sockopen bot 192.168.1.2 6080
} 

;on *:sockopen:bot: { 
;  sockwrite -n $sockname GET $+(/s3h/getdetails.php?name=,%un)
;  sockwrite -n $sockname Host: $+(192.168.1.2,$crlf,$crlf)
;} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET http://192.168.1.2:6080/s3h/getdetails.php?name=rshield 
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}


Thats my code! xD

Quote:
[13:30:54] *** alien- has joined #alien.
[13:30:56] *** Mode change "+qo alien- alien-" for channel #alien by ChanServ.
[13:31:01] r_alien-: !sabdetails
[13:31:17] r_alien-: !sabdetails rshield


Still nothing confused
Posted By: MikeChat Re: Geting a webpage's data - 04/09/05 03:45 AM
Code:
change to  this:
on *:text:!sabdetails*:*: {
 [color:red]set %un  $2[/color]
 sockopen bot 192.168.1.2 6080
} 
[color:blue]
remove this completely
;on *:sockopen:bot: { 
;  sockwrite -n $sockname GET $+(/s3h/getdetails.php?name=,%un)
;  sockwrite -n $sockname Host: $+(192.168.1.2,$crlf,$crlf)
;} [/color]

also change the next red part

on *:sockopen:bot: { 
  sockwrite -n bot GET http://192.168.1.2:6080/s3h/getdetails.php?name=[color:red] $+ %un [/color]
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 05:12 AM
Ok i changed the code to:

Code:
on *:text:!sabdetails*:*: {
 set %un $2
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET http://192.168.1.2:6080/s3h/getdetails.php?name= $+ %un
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}


And still nothing! No messages in the channel where it was requested, an no errors in mIRC. frown

Quote:
[15:07:13] *** Initial topic:
[15:07:13] *** #alien: r_alien- ~alien-
[15:07:19] alien-: r_alien- has just arrived! r_alien- is the Owner of this bot.
[15:07:19] *** Mode change "+v r_alien-" for channel #alien by alien-.
[15:07:22] *** #alien was created on Sun Sep 04 14:55:36 2005.
[15:07:30] r_alien-: !shutdown
[15:07:45] *** alien- has joined #alien.
[15:07:47] *** Mode change "+qo alien- alien-" for channel #alien by ChanServ.
[15:08:16] r_alien-: !sabdetails r_alien
[15:08:25] r_alien-: !sabdetails rshield
[15:10:03] r_alien-: !shutdown
[15:10:04] *** alien- has signed off IRC (Quit: Alien IRC Bot 1.0 based on YBBot> You cannot get this bot frown May i interest you in Hawk Works instead at http://220.237.150.18:6080/s3h/).
[15:10:15] *** alien- has joined #alien.
[15:10:17] *** Mode change "+qo alien- alien-" for channel #alien by ChanServ.
[15:10:55] r_alien-: !sabdetails rshield


Any ideas now?
Posted By: Kelder Re: Geting a webpage's data - 04/09/05 08:03 AM
Code:
on *:text:!sabdetails*:*: {
 set %un $2
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
; Why this alias? It doesn't set %un, might be ok if it's for testing now and you didn't unset %un.

on *:sockopen:bot: { 
  sockwrite -n bot GET http://192.168.1.2:6080/s3h/getdetails.php?name= $+ %un [color:green]HTTP/1.0
  sockwrite bot $str($crlf,2)[/color]
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}

If it still doesn't work, download ethereal (or some other sniffer) and find out what your script sends, and what a browser sends. Then find out what the differences are and see if they are preventing the script or not. Not all headers from your browser are necessary, some can even make it more difficult (chunked encoding, deflate, ...)
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 08:55 AM
OK, i have now modified my script a little. It reads:

Code:
on *:text:!sabdetails*:*: {
 set %un $2
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET /s3h/getdetails.php?name= $+ %un HTTP/1.1
  sockwrite -n bot Host: 192.168.1.2
  sockwrite -n bot User-Agent: Omg dont block this T_T I love you!!!! :P
  sockwrite -n bot $str($crlf,2)
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  :nextread
  sockread %bot
  if ($sockbr == 0) return
  if (%bot == $null) %bot = -
  echo -a %bot
  goto nextread
}


I typed !sabdetails rshield into one window with another account and the script executed, however it displayed the data in the topmost channel window in the mIRC window. It displayed this:

Quote:
HTTP/1.1 200 OK
Date: Sun, 04 Sep 2005 08:44:00 GMT
Server: Apache/2.0.54 (Win32) PHP/5.0.4
X-Powered-By: PHP/5.0.4
Content-Length: 569
Content-Type: text/html
-
--- Sabotage Details of rshield ---
Blackpowder Missiles: 0, Invisibility Shields: 0
Excaliburs: 0, Battle Axes: 0, Dragons: 0, Flaming Arrows: 0, Dragonskins: 0
Steeds: 0, Hammers of Thor: 0, Wargs: 0
Mithrils: 0, Gauntlets: 0, Heavy Shields: 0, Elven Cloaks: 0
Broadswords: 0, Warhammers: 0, Warblades: 0, Steel Bows: 0, Plate Armors: 0
Lances: 0, Maces: 0, Spears: 0, Longbows: 0, Chainmails: 0
Long Sword: 0, Pikes: 1, Clubs: 0, Crossbows: 0, Shields: 0
Staves: 0, Hatchets: 0, Slings: 0, Short Bows: 0
Helmets: 0, Knives: 0, Sticks: 0


Now i'm wondering how do i get that data after the first bit which just has some info, so from --- Sabotage details of <<username>> --- to the end of the data, sent to the channel window, where it was requested from? Sorry, i'm a n00b to this IRC langauge! xD Oh and i put the host socket line back in because someone i konw suggested putting it in because his won't work withouth it! :P
Posted By: Kelder Re: Geting a webpage's data - 04/09/05 10:01 AM
The display used echo -a , that is echo the active window...
Added a var %untarget that keeps the channel or query window where it was typed.

Used /sockmark to tell when the headers are gone (empty line)

Code:
on *:text:!sabdetails*:*: {
 set %un $2
 set %untarget $target
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET /s3h/getdetails.php?name= $+ %un HTTP/1.1
  sockwrite -n bot Host: 192.168.1.2
  sockwrite -n bot User-Agent: Omg dont block this T_T I love you!!!! :P
  sockwrite -n bot $str($crlf,2)
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  sockread %bot
  while (($sockbr) &amp;&amp; (!$sockerr)) {
    if ($sock($sockname).mark) echo %untarget $iif(%bot != $null,%bot,-)
    elseif (%bot == $null) sockmark $sockname 1
    sockread %bot
  }
}
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 10:16 AM
OK, i have that script, and it returns it to the window in mIRC, but it doesn't send it as a messge! frown How do i get it to do that? so that EVERYONE in that channel can see it? Sorry, i'm a real n00b, and getting tired now frown
Posted By: Kelder Re: Geting a webpage's data - 04/09/05 11:44 AM
Change echo to msg, changed the if tests to ignore empty lines instead of sending a - sign.
Do enable floodprotection, because 2 requests will get you killed from the server.

Code:
  while (($sockbr) &amp;&amp; (!$sockerr)) {
    if (%bot == $null) sockmark $sockname 1
    elseif ($sock($sockname).mark) [color:blue]msg[/color] %untarget %bot
    sockread %bot
  }
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 12:10 PM
Here is my current code:

Code:
on *:text:!sabdetails*:*: {
 set %un $2
 set %untarget $target
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET /s3h/getdetails.php?name= $+ %un HTTP/1.1
  sockwrite -n bot Host: 192.168.1.2
  sockwrite -n bot User-Agent: Omg dont block this T_T I love you!!!! :P
  sockwrite -n bot $str($crlf,2)
} 
on 1:sockread:bot: {
  if ($sockerr &gt; 0) return
  sockread %bot
  while (($sockbr) &amp;&amp; (!$sockerr)) {
    if ($sock($sockname).mark) msg %untarget $iif(%bot != $null,%bot,-)
    elseif (%bot == $null) sockmark $sockname 1
    sockread %bot
  }
}


I sometimes get these as well:

Quote:
* /sockopen: 'bot' socket in use (line 4, sabreport.mrc)


Is that because i need flood protection? Or is it because i need to close the socket? And how do it? :S
Posted By: SladeKraven Re: Geting a webpage's data - 04/09/05 12:20 PM
Replace line 4 with..

Code:
if (!$sock(bot)) sockopen bot 192.168.1.2 6080


-Andy
Posted By: Kelder Re: Geting a webpage's data - 04/09/05 12:46 PM
You can only do one request at a time with this script. You do not need to close the socket normally, it should happen automatically once the entire page is transmitted.

Add this as second line so that you can see (echo -> only you see it) when a request is done when a previous was still underway. The floodprotection is needed because of the amount of data, you can normally send about once message each second (or 2) without being flooded off, if you type more/faster, the server might kick you for flooding. This can happen because of one long page, or many shorter pages, or a short page + very active chatting, or ...

if ($sock(bot)) { echo $target Request denied, previous entry not finished yet. | return }
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 12:58 PM
Thanks for that, that is solved, but when someone puts in a nonexistant user, the PHP file gives this:

Quote:
--- Sorry, no details for Nonexistantuser ---


But the IRC Script isn't sending that? How would i get it to send those? :P
Posted By: Kelder Re: Geting a webpage's data - 04/09/05 01:58 PM
If you can edit the PHP script: send a line break after that line.

Now I'm wondering, do you get ALL output when the user exists? Or is the last line missing too?
If that's the case, it's because /sockread %bot only reads a line if it ends in $crlf. If there's no line break, nothing is read... Use /sockread -f %bot to force the read, even if it doesn't end in a line break. This might give partial lines sometimes (a line split over 2 lines), but everything should be displayed...
Posted By: r_alien Re: Geting a webpage's data - 04/09/05 09:53 PM
Thanks for that Kelder! :P Yes the last line wasn't coming through on the existant user search, but i just added a line break after it. Same with the non existant user, because that's easier, and quicker, and results in no down time! :P

Thanls for all your help everyone.
© mIRC Discussion Forums