mIRC Home    About    Download    Register    News    Help

Print Thread
F
flexer
flexer
F
I am trying to post data from mirc to a website.
what I use is:
Code:
var %data = text= $+ %text

  sockwrite -n $sockname POST /post.php HTTP/1.0
  sockwrite -n $sockname Host: the-host.com
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%data)
  sockwrite -n $sockname
  sockwrite $sockname %data 

now everything works but the problem is that %text is from an editbox with options "multi return autovs vsbar" and when the users write in the box multiple lines (with enter) to the site is send only the first line frown
Please I am doing the script for 4 days and am almost done,.

Joined: Mar 2003
Posts: 1,256
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,256
loop through all the lines in your box, and sockwrite them one at a time.

F
flexer
flexer
F
I don't understand.
you mean something like
sockwrite -n $sockname text=%line_1_from_textbox
sockwrite -n $sockname text=%line_2_from_textbox
sockwrite -n $sockname text=%line_3_from_textbox
sockwrite -n $sockname text=%line_4_from_textbox
confused
can you provide an example pls.

Joined: Dec 2002
Posts: 117
R
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
Code:
  sockwrite -n $sockname POST /post.php HTTP/1.0
  sockwrite -n $sockname Host: the-host.com
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%data)
  sockwrite -n $sockname

  var %i = 0,%num = $did([i]<dialog>[/i],[i]<id>[/i]).lines
  while (%i < %num) {
    inc %i
    sockwrite -n $sockname $did([i]<dialog>[/i],[i]<id>[/i],%i).text
  }

This only works if the dialog is still open when you sockwrite this stuff.
If the dialog is supposed to close before that, you'll have to store the contents of the edit somewhere (like in a hidden custum window) and then send it from there.

K
KoRn18
KoRn18
K
can i have ur php code plz?

(replied to wrong person)

Last edited by KoRn18; 09/09/03 09:11 PM.
Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
Always send an encoded string to avoid parsing problems. Put this alias in your remotes,
Code:
alias urlencode {
  var %i = 1, %r
  while $mid($1-,%i,1) != $null {
    var %r = $+(%r,%,$base($asc($ifmatch),10,16)), %i = %i + 1
  } 
  return %r
}

and use: var %data = text= $+ $urlencode(%text)

Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
what about $didtok and make the delimiter a space character? It shouldnt interfere because mirc will kill two spaces.

F
flexer
flexer
F
Here is what code I have done by myself which work perfectly smile
Code:
alias _multi {
var %i = 0,%num = $did(cutenews,$$2).lines
unset %r
while (%i < %num) {
inc %i
var %r = %r $+ & $+ $$1 $+ []= $+ $did(cutenews,$$2,%i).text
}
return %r
}

on *:sockopen:mysite:{


var %data = hello=1&username= $+ %tmp.username $+ $_multi(news_short,16) $+ &password= $+ %tmp.password $+ &news_title= $+ %tmp.news.title $+ $_multi(news_full,17)

  sockwrite -n $sockname POST / $+ %cn.path $+ /mirc2cn.php HTTP/1.0
  sockwrite -n $sockname Host: %cn.domain
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%data)
  sockwrite -n $sockname
  sockwrite -n $sockname %data

}

now In my PHP script I get an array like this
$news_full = array(
0 => line1
1 => line2
2 => line3
3 => line4
)
and with the php I can walk through the array $news_full and make only one string with all lines separated with <br>

Also I am doing this mirc script for my PHP script called CuteNews @ http://cutephp.com so you can post news at your site with just using your mIRC smile

Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
eww... GET passwords? >:\

F
flexer
flexer
F
Quote:
eww... GET passwords? >:\
what do you mean ? everything is send through POST methot not GET.

Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
Arg...

Sorry, i noticed the first line and only took note of the &username= , &password=, so i assumed. I been really tired latly, so guess just didnt think it thorugh too well. My mistake >:D

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
How about this?
Code:
alias urlencode {
  bset -t &amp;a 1 $1- 
  tokenize 32 $bvar(&amp;a,1-) 
  var %a
  scid -r var % $+ b = $* , $eval(%a = %a $+ $iif($chr(%b) isalnum,$ifmatch,% $+ $base(%b,10,16,2)),0) 
  return %a
}
/scid -r allows you to "pass" $* to /var, /set or identifiers (something you can't do directly in a script) smile


Link Copied to Clipboard