🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.php
Article #1343

Era - wysylanie sms-ow

#1343
From: Metempsychoza
Date: Tue, 28 Aug 2001 05:41
80 lines
3211 bytes
moze was zainteresuje:
<?php
# opis: wysylka sms-ow do abonentów sieci Era.
# autor: Metempsychoza <metempsychoza(at)wp.pl>
# do prawidlowego dzialania niezbedna jest biblioteka PEAR
# sposob uzycia:
# $era = new Era;
# $era->Send($numer, $wiadomosc, $podpis, $kontakt)
#

require_once "Net/Socket.php";

class Era extends Net_Socket {

var $url = "http://213.158.194.32/sms/sendsms.asp";
var $formdata = array();

 function Era() {
  $array = parse_url($this->url);
  $this->Net_Socket();
  Net_Socket::connect($array[host], 80);
  Net_Socket::writeLine ("POST ".$array[path]." HTTP/1.0");
  Net_Socket::writeLine ("Referer: ".$this->url);
  Net_Socket::writeLine ("User-Agent: Mozilla/4.77");
  Net_Socket::writeLine ("Accept: image/gif,  image/jpeg,  image/png,
*/*");
  Net_Socket::writeLine ("Accept-Encoding: gzip");
  Net_Socket::writeLine ("Accept-Language: en");
  Net_Socket::writeLine ("Accept-Charset: iso-8859-2,*,utf-8");
  Net_Socket::writeLine ("Content-type: application/x-www-form-urlencoded");
 }

 function Set($name, $value="0") {
  $this->formdata[] = $name."=".urlencode($value);
 }

 function Fetch() {
  $data_post = implode("&", $this->formdata)."\r\n";
  $length = strlen($data_post);
  Net_Socket::writeLine ("Content-length: ".$length."\r\n");
  Net_Socket::writeLine ($data_post);
  if("HTTP/1.1 200 OK" != Net_Socket::ReadLine())return false;
  return Net_Socket::readAll();
 }

 function Send($numer, $wiadomosc, $podpis="0", $kontakt="0") {
  $this->GetCode($code, $cookie);
  Net_Socket::writeLine ("Cookie: ".$cookie);
  $this->Set(bookopen);
  $this->Set(ksiazka);
  $this->Set(message, $wiadomosc);
  $this->Set(messagebis);
  $this->Set(numer, $numer);
  $this->Set(podpis, $podpis);
  $this->Set(kontakt, $kontakt);
  $this->Set(termin);
  $this->Set(Code, $code);
  $this->Set(Nadaj, "  tak-nadać  ");
  $s = $this->Fetch();
     Net_Socket::disconnect();
  return $s;
 }

 function GetCode(&$code, &$cookie) {
  $code = new Era;
  $code->Set(sms, 1);
  $answer = $code->Fetch();
  $code->disconnect();
  $pattern = "/.*name=\"Code\" value=\"(.+?)\".*/i";
  preg_match($pattern, $answer, $regs);
  $pattern = "/^Set-Cookie:\s(.+?)$/im";
  preg_match($pattern, $answer, $regs2);
  $cookie  = $regs2[1];
  $code = $regs[1];
 }
}
?>
--
metempsychoza(at)wp.pl
Technical Details
Message-ID: <9mfbca$afm$1@news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!news.task.gda.pl!news.tpi.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!news.task.gda.pl!news.tpi.pl!not-for-mail
From: "Metempsychoza" <metempsychoza@wp.pl>
Newsgroups: pl.comp.lang.php
Subject: Era - wysylanie sms-ow
Date: Tue, 28 Aug 2001 07:41:29 +0200
Organization: tp.internet - http://www.tpi.pl
Lines: 82
Message-ID: <9mfbca$afm$1@news.tpi.pl>
NNTP-Posting-Host: 217.97.128.82
X-Trace: news.tpi.pl 998977738 10742 217.97.128.82 (28 Aug 2001 05:48:58 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: 28 Aug 2001 05:48:58 GMT
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit