Login   Register  
PHP Classes
elePHPant
Icontem

File: sockclass.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2002-01-11 08:33
Size: 2,319 bytes
 

Contents

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 jik@mail.ru
************************************************************************
************* check new to http://jiks.chat.ru ***************
*/

/**
 * @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)
	{
	$http_query="";
		while (list($name,$value)=each($data))
		{
		 $tmp_data[]=urlencode($name)."=".urlencode($value);
		}
		$enc_data=implode("&", $tmp_data);
		$len_data=strlen($enc_data);
	if ($this->method=="POST")
		{
		$http_query=
			$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".
			$enc_data;
		 flush();
		   $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;
		   fclose($fs);
		 flush();
		}
	return $rt;
	}
}

$post=new socksender();

$data[to]="27076181";
$data[from]="SENDERNAME";
$data[fromemail]="FROM@EMAIL";
$data[body]="MESSAGE BODY";

echo "<pre>".$post->send("web.icq.com", "/whitepages/page_me/1,,,00.html", "http://web.icq.com/wwp?Uin=27076181", $data)."</pre>";
?>