<?
/*****************************
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 [email][email protected][/email]
*******************************
check new to [url]http://jiks.chat.ru[/url]
*/
/**
* @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']="#нужный UIN";
$data['from']="Имя Юзера";
$data['fromemail']="info@домен.ру";
$data['body']="TEST MESSAGE";
echo "<pre>".$post->send("web.icq.com",
"/whitepages/page_me/1,,,00.html",
"http://web.icq.com/wwp?Uin=#нужный UIN",
$data)."</pre>";
?>