mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 4
F
flexer Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Sep 2003
Posts: 4
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,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
loop through all the lines in your box, and sockwrite them one at a time.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Sep 2003
Posts: 4
F
flexer Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Sep 2003
Posts: 4
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.


$input(Me like stars, You too?)
Joined: Aug 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Aug 2003
Posts: 148
can i have ur php code plz?

(replied to wrong person)

Last edited by KoRn18; 09/09/03 09:11 PM.

_________
may death strike you.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
what about $didtok and make the delimiter a space character? It shouldnt interfere because mirc will kill two spaces.


-KingTomato
Joined: Sep 2003
Posts: 4
F
flexer Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Sep 2003
Posts: 4
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: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
eww... GET passwords? >:\


-KingTomato
Joined: Sep 2003
Posts: 4
F
flexer Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Sep 2003
Posts: 4
Quote:
eww... GET passwords? >:\
what do you mean ? everything is send through POST methot not GET.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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


-KingTomato
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard