POST Who result to PHP and read HTML content

By Nestoyeur on Jul 01, 2013

This code send a POST to my PHP script with the content of /who command. Then it use sockread for read the answer of my PHP script .. but my sockread get only the header. How can i get the HTML content ?

Actualy my PHP script answer 1 or 0 but i only get this :

HTTP/1.1 200 OK
Date: Mon, 01 Jul 2013 15:16:34 GMT
Server: Apache/2.2.22 (Win64) PHP/5.4.3
X-Powered-By: PHP/5.4.3
Content-Length: 1
Content-Type: text/html

alias apm {
  unset %who
  set %who viewer=
  who #nestoyeur
}
raw 352:*:{
  if ($2 == #nestoyeur) {
    set %who %who $+ $3 $+ ,
  }
}

raw 315:*:{
  if ($2 == #nestoyeur) {
    ;echo -a %who
    sendApm
  }
}

alias sendApm {
  sockclose sendApm
  sockopen sendApm 127.0.0.1 80
}

on *:sockopen:sendApm:{
  sockwrite -n $sockname POST /twizard/mirc/apm.php HTTP/1.1
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%who)
  sockwrite -n $sockname host: localhost
  sockwrite -n $sockname
  sockwrite $sockname %who
}

on *:sockread:sendApm:{ 
  var %result
  sockread %result
  echo -a %result
}

; SEE WHAT I GET FROM " ECHO -a %RESULT " ->
;HTTP/1.1 200 OK
;Date: Mon, 01 Jul 2013 15:16:34 GMT
;Server: Apache/2.2.22 (Win64) PHP/5.4.3
;X-Powered-By: PHP/5.4.3
;Content-Length: 1
;Content-Type: text/html

Comments

Sign in to comment.
Savage_CL   -  Aug 09, 2013

the echo is failing on the empty line after the header information. For the purposes of your testing, replace line 36 with:

echo -a $iif(%result,$v1,$chr(160))

This way it doesn't end up with nothing to echo on a blank line.

If your script only returns 1 or 0, you can be confident in:

if (%result isnum) { we have our number, 1 or 0, stored in %result. do stuff! }

Also make sure your php is sending PHP_EOL (end of line) so mIRC knows the line is done, as your code, even when that echo fails, should continue!

Last but not least.... Questions should go in the forums, not snippets!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.