1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| <?PHP
class Irc {
var $RemoteHost;
var $Nick;
var $Port;
var $ircsocket;
function Irc ( $RemoteHost, $Nick, $Port = 6667 )
{
set_time_limit(0);
ob_end_flush();
$this->RemoteHost = $RemoteHost;
$this->Nick = $Nick;
$this->Port = $Port;
$this->Connect();
}
function Connect()
{
$this->ircsocket = fsockopen ($this->remotehost, $this->remoteport) ;
if (! $this->ircsocket) {
die ("Error connecting to host.");
}
fputs ($this->ircsocket, "USER ".$this->Nick." 66.119.161.165 irc.tooltime.net :Nice Guyrn");
fputs ($this->ircsocket, "NICK ".$this->Nick."rn");
}
function Encoden()
{
while (!feof($this->ircsocket))
{
$incoming = fgets ($this->ircsocket, 1024);
$incoming = str_replace( "r", "", $incoming);
$incoming = str_replace("n", "", $incoming);
if (substr($incoming, 0, 1) == ":") {
$prefix = substr ($incoming, 0, strpos($incoming, ' '));
$incoming = substr ($incoming, strpos($incoming, ' ') + 1);
} else {
$prefix = "";
}
$command = substr ($incoming, 0, strpos($incoming, ' '));
$incoming = substr ($incoming, strpos($incoming, ' ') + 1);
$params = explode (" ", $incoming);
if ($command == "PING") fputs($this->ircsocket, "PONG $incomingrn");
if ($command == "367")
{
$this->MsgSend("Caminus","...........");
fputs($this->ircsocket, "QUIT Unexpectedrn");
}
}
fputs($this->ircsocket, "QUIT Unexpectedrn");
}
function SocketWrite ($Message)
{
fputs ($this->ircsocket, $Message."rn");
}
function MsgSend($Target, $Text)
{
$this->SocketWrite("PRIVMSG ".$Target." :".$Text);
}
};
$Irc = new Irc("de.quakenet.org","TestNick");
$Irc->Encoden();
?> |