1

I am writing a script for mIRC that will fetch data from my webserver, that code is generated via PHP.

It works just fine when i connect via my browser (firefox). However, when i connect via the mIRC sockets, server fails to "compile" my PHP code. I can still able to fetch any other text or html. Seems like the webserver (litespeed) does not acknowledge my http requests(?!)

This is my header information that I pass to the server:

  sockwrite -n ccsw_sock_reg GET /ccsw/ccsw.php?action=register&username= $+ %ccsw_username_temp $+ &password= $+ %ccsw_username_temp HTTP/1.1
  sockwrite -n ccsw_sock_reg Host: www.[HIDDEN].com
  sockwrite -n ccsw_sock_reg Connection: close
  sockwrite -n ccsw_sock_reg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9) Gecko/2008052906 Firefox/3.0
  sockwrite -n ccsw_sock_reg Accept-Encoding: gzip
  sockwrite -n ccsw_sock_reg Accept:Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  sockwrite -n ccsw_sock_reg Accept-Language: en-us,en;q=0.5
  sockwrite -n ccsw_sock_reg Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7
  ;sockwrite -n ccsw_sock_reg Cache-Control: no-cache
  sockwrite -n ccsw_sock_reg Cache-Control: no-store, no-cache, must-revalidate
  sockwrite -n ccsw_sock_reg Cache-Control: post-check=0, pre-check=0
  sockwrite -n ccsw_sock_reg Pragma: no-cache
  sockwrite -n ccsw_sock_reg $crlf 

I've tried using a apache server instead of litespeed, but it doesn't solve either. I still don't get any PHP generated code to show.

Am i missing some headers? Should I do it in a completely different way?

update:

mIRC code:

alias testsock {
  sockclose testsock
  sockopen testsock www.[HIDDEN].com 80
}
on *:sockopen:testsock: {
  sockwrite -nt testsock GET /ccsw/ccsw.php?action=register&username= $+ %ccsw_username_temp $+ &password= $+ %ccsw_username_temp HTTP/1.0
  sockwrite -nt testsock Host: www.[HIDDEN].com
  sockwrite -nt testsock $crlf  
} 

on *:sockread:testsock: {
  %ccsw_content_start = 0

  if ($sockerr > 0) return
  sockread %temp
  while ($sockbr) {
    echo response: %temp
    sockread %temp
  }
}

response:

reponse: HTTP/1.0 200 OK
reponse: Date: Thu, 02 May 2013 14:45:07 GMT
reponse: Server: LiteSpeed
reponse: Connection: close
reponse: X-Powered-By: PHP/5.2.17
reponse: Content-Type: text/html
reponse: Content-Length: 43
reponse:

and after that last "reponse: " i should get a php generated line with "reponse: true" the "reponse: " is just a prefix for my echo..

sleepr
  • 11
  • 2
  • 2
    what response do you get when requesting a php file? An error? A disconnect? The php source? And have you checked your logs (both Apache AND PHP logs)? – nl-x May 02 '13 at 12:15
  • 2
    Have you noticed that on the 6th line you have `Accept:Accept:` twice? – nl-x May 02 '13 at 12:17
  • First stop should always be both access- and error logs for the webserver. Especially Apache logs *everything* that might be relevant, in the first on success, in the second on failure. – Niels Keurentjes May 02 '13 at 12:29
  • (im new to stackopverflow, dunno if i can reply to a specific comment?) when i request a php file i get all content of it except anything between tags.. so basically just the HTTP Headers and the html/text. i havnt noticed the dual Accept:! ill give it a try! unfortunately i dont have access to the server logs (webhosting service) last resort could of course be to setup a local apache just for testing.. Thanks alot, ill give all your suggestions ago and come back :) – sleepr May 02 '13 at 12:56
  • "when i request a php file i get all content of it except anything between tags" ... um... that's how it is supposed to work. everything between php tags is something that is supposed to be processed by the server, not sent to the client. – eis May 02 '13 at 14:43
  • and you should have local apache for testing. it should be no "last resort", but first step *before* you deploy your code in the hosting environment. I don't know how you've managed to develop anything without logs and without local deployment. – eis May 02 '13 at 14:45
  • i removed the second Accept: but it didnt do it. I had access to the log-files! ive checked them, but i cant find anything unusual. looks like normal HTTP GET requests and nothing in the error.log – sleepr May 02 '13 at 14:47
  • eis, ok i mean i dont get any php generated content.. all text/html content gets loaded.. well its easier for me to just go with my webhosting :P – sleepr May 02 '13 at 14:48
  • check the first post for my mIRC script and response.. The php script should return true if its provided with a username and a password.. and when i echo that row of sockwrite it looks OK. (ie the variables works.) – sleepr May 02 '13 at 14:59

1 Answers1

0

If you look carefully you will see the following response header
"Content-Length: 43"
That means you are getting response and the problem lies inside your SOCKREAD event.

Try this following code:

on *:sockread:testsock: {
  if ($sockerr) {
    return
  }

  var %line
  :start
  sockread %line
  if (%line) {
    echo -ag SOCKREAD: %line
  }
  if ($sockbr) {
    goto start
  }
}
Orel Eraki
  • 11,940
  • 3
  • 28
  • 36