mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#234971 - 18/11/11 03:44 PM Socket's website connection
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
Code:
on *:sockopen:x:{ 
  sockwrite -n $sockname GET / HTTP/1.1 
  sockwrite -n $sockname Host: eawedat.zxq.net $+ $crlf
  ;I DO NOT KNOW IF CODE BELOW IS NECESSARY
  ;sockwrite -n $sockname Connection: Keep-Alive
}

on *:sockread:x:{
  if ($sockerr) {
    echo -a Error
    halt
  }
  else {
    sockread %temptext
    echo -a %temptext
  }
}


Code:
Usage:- /sockopen x eawedat.zxq.net 80


but I do not get desired results!
I get this:-

Code:
HTTP/1.1 400 Bad Request
Date: Fri, 18 Nov 2011 15:40:52 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>


thanks a lot.

Top
#234978 - 18/11/11 05:22 PM Re: Socket's website connection [Re: eawedat]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Code:
on *:sockopen:x:{ 
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Host: eawedat.zxq.net
  sockwrite -n $sockname
}
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#234982 - 18/11/11 05:40 PM Re: Socket's website connection [Re: Riamus2]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
yeah thanks a lot it is working
but Riamus2 ,

Code:
sockwrite -n $sockname Host: eawedat.zxq.net $+ $crlf



Code:
sockwrite -n $sockname Host: eawedat.zxq.net
sockwrite -n $sockname


aren't the same?

because: $+ $crlf is also sending a newline

thanks.


Edited by eawedat (18/11/11 05:40 PM)

Top
#234988 - 18/11/11 08:48 PM Re: Socket's website connection [Re: eawedat]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
If you sent 2 $crlf's, it would probably work on yours. But it's considered better to use a single -n at the end instead of manually doing $crlf.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#234990 - 18/11/11 09:12 PM Re: Socket's website connection [Re: Riamus2]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
I see thanks a lot:))

Top
#234994 - 18/11/11 10:00 PM Re: Socket's website connection [Re: eawedat]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
Riamus2
by the way , when I run :
/sockopen x eawedat.zxq.net 80

it complains about 31 times that :
* /echo: insufficient parameters (line 16, remote.ini)

line 16 :
echo -a %temptext

why's that? & how can I avoid those messages?

thanks.

Top
#234996 - 18/11/11 11:49 PM Re: Socket's website connection [Re: eawedat]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
It's because your page has a lot of blank lines in the code. Just put a check to only echo if != $null.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#234998 - 19/11/11 02:31 PM Re: Socket's website connection [Re: Riamus2]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
Riamus2
Php Code:

sockread %temptext
	if (%temptext != $null) {
	  echo -a %temptext
	}
 


still getting
/echo: insufficient parameters

Top
#234999 - 19/11/11 06:08 PM Re: Socket's website connection [Re: eawedat]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1057
There are a few values that can still produce that error.

//var %x $chr(32) | echo -a %x

Change from
echo -a %temptext
to
echo -a $len(temptext) $asc(%temptext) %temptext
and see what happens

Top
#235000 - 19/11/11 06:33 PM Re: Socket's website connection [Re: maroon]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
yea it works fine maroon but the thing is I do not like to show numbers beside lines which I think present length of line.

is there no another way?

Top
#235001 - 19/11/11 06:52 PM Re: Socket's website connection [Re: eawedat]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1057
well you could put the control-o colour-code in front, that guarantees an output.

echo -a $chr(15) $+ %temptext

if your output has colours that you don't want to destroy, then a pair of control-r's will do it.

echo -a $+($chr(22),$chr(22),%temptext)

Top
#235002 - 19/11/11 07:56 PM Re: Socket's website connection [Re: maroon]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
yes that worked! 100% is okay:)
what does chr(15) present? is it an empty char or what?

what about those :
Php Code:

HTTP/1.1 200 OK
Date: Sat, 19 Nov 2011 19:53:24 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Content-Length: 4480
Connection: close
Content-Type: text/html
 


How can I avoid them?

thanks.


Edited by eawedat (19/11/11 07:58 PM)

Top
#235003 - 19/11/11 07:59 PM Re: Socket's website connection [Re: eawedat]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1057
15 is the ascii char sent with a control-o, you can put any of the control-b/u/r/k/o colour codes inside the parenthesis for
echo -a $asc()
and see what the receiver sees as the ascii value for that code

Top
#235004 - 19/11/11 08:08 PM Re: Socket's website connection [Re: maroon]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
ah I see , so what you have done is that you put a "hidden" char
that guarantees the output so if there is an empty line it still outputs to avoid error message with echo...nice trick :-)
it is better than to ask with conditions if(...!=$null)....

Top
#235005 - 20/11/11 02:34 AM Re: Socket's website connection [Re: eawedat]
CoLdFeAr Offline
Nutrimatic drinks dispenser

Registered: 19/11/11
Posts: 7
ice tried all the above code an all i get is

HTTP/1.1 200 OK
Date: Sun, 20 Nov 2011 02:32:22 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Sat, 19 Nov 2011 14:31:59 GMT
ETag: "5e0219-c2-4b21750f3f5c0"
Accept-Ranges: bytes
Content-Length: 194
Content-Type: text/html


Top
#235008 - 20/11/11 06:19 AM Re: Socket's website connection [Re: eawedat]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Usage: /check
Code:
alias check {
  sockclose x
  sockopen x eawedat.zxq.net 80
}
on *:sockopen:x:{ 
  sockwrite -n x GET / HTTP/1.1 
  sockwrite -n x Host: eawedat.zxq.net
  sockwrite -n x
}
on *:sockread:x:{
  if ($sockerr) {
    echo -a Error
  }
  else {
    var %temptext
    sockread %temptext
    if ($regex(%temptext,/<title>(.+)<\/title>|$&
      $+ <a href="\S+">(.+)<\/a><\/font>|(.+\d{4} &copy;)/)) {
      echo -a $remove($replace($regml(1),&copy;,$chr(169)),$chr(9))
    }
  }
}
Output:
Quote:
Blog of Muhamad Eawedat - Wall
Info
CV
Works
Books
Story
Photos
Thanks
Blog's Birth
Contact Me
all rights reserved 2011

Top
#235010 - 20/11/11 10:22 AM Re: Socket's website connection [Re: Tomao]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
Tomao , with your code -> in my situation it still outputs HTML Tags(All of Page's source)-I have already code to strip HTML tags but what we need to avoid those below

Php Code:

HTTP/1.1 200 OK
Server: Apache
Content-Length: 4480
Content-Type: text/html
 


thanks.

Top
#235029 - 20/11/11 05:45 PM Re: Socket's website connection [Re: eawedat]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Why not show people the current script you have? And yes, it's very possible to escape the header fields from being shown.

Top
#235031 - 20/11/11 05:58 PM Re: Socket's website connection [Re: Tomao]
eawedat Offline
Babel fish

Registered: 11/11/11
Posts: 52
Tomao , I did not understand your question about not showing people my script.. which script? the first one which I pasted above is my script ,,the first Reply of this Thread is my script.

2)How to escape the header fields?

Top
#235035 - 20/11/11 06:57 PM Re: Socket's website connection [Re: eawedat]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
My question was clear, unless I wrote a language other than English.

You mentioned you had the html tags stripped out, and that you'd like to avoid the header fields as I said in the last post. The example I showed you used regex, which matched the targeted strings you're after.

It's evident you want to keep the code the way you have, and I have nothing against that. Now, what you've posted in the original post is partial, not a complete code. I was basically asking you to show people what you have gotten so far, so it's easier to see is all.

Perhaps my English is still not understandable to you, so I'll see if someone who speaks perfect English can assist you further.

Top
Page 1 of 2 1 2 >