PHP Classes

File: sockclass.php

Recommend this page to a friend!
  Classes of Alexey A. Zaitsev  >  sockclass  >  sockclass.php  >  Download  
File: sockclass.php
Role: ???
Content type: text/plain
Description: sockclass file
Class: sockclass
Author: By
Last change:
Date: 20 years ago
Size: 2,319 bytes


Class file image Download
* Jik All rights reserved.
* This is a standard copyright header for all source code appearing
* at Jik. This application/class/script may be redistributed,
* as long as the above copyright remains intact. 
* Comments to
************* check new to ***************

 * @title Sock Sender
 * @author Jik 
 * @version 0.1 - first version. Supported only POST method
 it's class allow send any POST http query to any server and get answer.
 Use for send from script (and cron) any posts to any servers: icq, sms, boards, and other.

	Open html source code from server, mark a "input" tags, values, write $data array and send it!

class socksender
	var $User_Agent="Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)";
	var $Accept_Encoding="gzip, deflate";
	var $method="POST";
	var $protocol="HTTP/1.0";
	var $send2port=80;

	function send($host, $send2url, $referer, $data)
		while (list($name,$value)=each($data))
		$enc_data=implode("&", $tmp_data);
	if ($this->method=="POST")
			$this->method." ".$send2url." HTTP/1.0\r\n".
			"Referer: ".$referer."\r\n".
			"Content-Type: application/x-www-form-urlencoded"."\r\n".
			"Content-Length: ".$len_data."\r\n".
			"Host: ".$host."\r\n".
			"Accept: */*\r\n".
			"Accept-Encoding: ".$this->Accept_Encoding."\r\n".
			"Connection: Keep-Alive"."\r\n".
			"User-Agent: ".$this->User_Agent."\r\n"."\r\n".
		   $fs = fsockopen($host, $this->send2port, &$errno, &$errstr, 30);
	           if (!$fs) { die ("unable open socket: $errstr ($errno)");}
		   fputs ($fs, $http_query);
		   while($r=fgets ($fs, 20048)) $rt.=$r;
	return $rt;

$post=new socksender();

$data[body]="MESSAGE BODY";

echo "<pre>".$post->send("", "/whitepages/page_me/1,,,00.html", "", $data)."</pre>";
For more information send a message to info at phpclasses dot org.