Raised This Month: $ Target: $400
 0% 

sending data to php script


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
hackziner
Senior Member
Join Date: Sep 2006
Location: France
Old 07-18-2007 , 12:38   Re: sending data to php script
Reply With Quote #2

Hum, so you want send data from a amxmodx plugin to a php script or send data from a php script to a amxmodx plugin ? who open the connexion ? In fact I think you've no choice because the socket module doesn't allow to listen for tcp connection ( I'm not sure @ 100% ).

edit : I've read your pm too fast ... ...


There is to method to send datas to a php script, get and post ... but get is easier


First we've to know how do a post/get request ...

The best way to understand is to analyse a post request.
//Open wireshark, which is certainly the best packet sniffer
//Open a thread
//Write a reply
//Record packet & click on reply

We get in the first packet
PHP Code:
POST http://forums.alliedmods.net/newreply.php?do=postreply&t=58056 HTTP/1.1
Hostforums.alliedmods.net
User
-AgentMozilla/5.0 (WindowsUWindows NT 5.1frrv:1.8.1.4Gecko/20070515 Firefox/2.0.0.4
Accept
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*;q=0.5
Accept
-Languagefr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept
-Encodinggzip,deflate
Accept
-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep
-Alive300
Proxy
-Connectionkeep-alive
Content
-Typeapplication/x-www-form-urlencoded
Referer
http://forums.alliedmods.net/showthread.php?t=58056
Content-Length215
Pragma
no-cache
Cache
-Controlno-cache 
ofc there is a \r\n at the end of each line and a double at the end of the first packet

in the second packet
PHP Code:
ajax=1&ajax_lastpost=1184769975&message=Just%20useless%2C%20but%20well%20coded%20%3A%29%3Cbr%3E&wysiwyg=1&styleid=0&signature=1&fromquickreply=1&s=&do=postreply&t=58056&p=who%20cares&parseurl=1&loggedinuser=21173&s
So, most of the thing here are useless for us.


so to do a get request you've just to send:
PHP Code:
hackziner@hackziner:/usr/lib/cgi-bin/server/pr_directurltelnet amxmodx.org 80
Trying 74.52.23.194
...
Connected to c2.17.344a.static.theplanet.com.
Escape character is '^]'.
get http://forums.alliedmods.net/showthread.php?t=58038\r\n 
t take the value 58038 ... to get this value in php "$t = _GET["t"];"

If you wanna try, just open telnet and do the same thing ...

after sending this request, the http server reply on the same connexion.
So you can see if your request works with telnet ...


The second one with the post ... I'm too lazy It's the same thing but datas are after the http header ( here in the second packet )


So, how do to this thing in pawn ... just copy an other code


Admin mail do the same thing.

#include <sockets>

new buff[1024]
new socket = socket_open( "http://www.amxmodx.org"", 80, SOCKET_TCP, error );

//http uses tcp and the default port is 80 ...
formatex( buff, 1023, "get http://forums.alliedmods.net/showthread.php?t=58038^r^n" );

socket_send( socket, buff, 1024);


set a task with
if (socket_change( socket) socket_recv( socket, buff, 1023)
to get the reply...

The reply is something like that :



PHP Code:
HTTP/1.0 200 OK
Date: Wed, 18 Jul 2007 16:11:07 GMT
Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7a DAV/2
X-Powered-By: PHP/5.2.2
Cache-Control: private
Pragma: private
Content-Type: text/xml; charset=windows-1252
X-Cache: MISS from proxy.free.fr
X-Cache-Lookup: MISS from proxy.free.fr:3128
Proxy-Connection: close

<?xml version="1.0" encoding="windows-1252"?>
<postbits>
<postbit postid="504914"><![CDATA[<!-- post #504914 -->

<!-- open content container -->
Some servers need a full and correct request, other only need something which looks like the normal request
__________________

Last edited by hackziner; 07-19-2007 at 02:15. Reason: deleted something
hackziner is offline
Send a message via ICQ to hackziner Send a message via AIM to hackziner Send a message via MSN to hackziner Send a message via Yahoo to hackziner Send a message via Skype™ to hackziner
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode