[Ircphpstats-devel] [CVS] Module phpstats: Change committed
Status: Inactive
Brought to you by:
mrvolta
|
From: Mr. v. <mr...@us...> - 2003-03-09 21:51:41
|
Committer : volta <mr...@us...>
CVSROOT : /cvsroot/ircphpstats
Module : phpstats
Commit time: 2003-03-09 21:51:40 UTC
Added files:
handlers/account.php handlers/away.php handlers/burst.php
handlers/clearmode.php handlers/create.php
handlers/end_of_burst.php handlers/end_of_burst_ack.php
handlers/info.php handlers/join.php handlers/kick.php
handlers/kill.php handlers/mode.php handlers/nick.php
handlers/part.php handlers/pass.php handlers/ping.php
handlers/quit.php handlers/server.php handlers/squit.php
handlers/topic.php handlers/uplinkserver.php handlers/version.php
Log message:
Initial import
---------------------- diff included ----------------------
Index: phpstats/handlers/account.php
diff -u /dev/null phpstats/handlers/account.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/account.php Sun Mar 9 13:51:28 2003
@@ -0,0 +1,25 @@
+<?
+/*
+ Handler for AC.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: account.php,v 1.1 2003/03/09 21:51:28 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => target numeric
+ $array[3] => username
+*/
+function account ($source,$array) {
+ global $client;
+ $target = $array[2];
+ if (!isset($client[$target])) return;
+ $account = $array[3];
+ $client[$target]->account($account);
+ sql_account($target,$account);
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/away.php
diff -u /dev/null phpstats/handlers/away.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/away.php Sun Mar 9 13:51:28 2003
@@ -0,0 +1,35 @@
+<?
+/*
+ Handler for A.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: away.php,v 1.1 2003/03/09 21:51:28 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2-end] => :reason
+*/
+function away ($source,$array) {
+ global $client;
+ // too few parameters
+ if (count($array) < 3) return;
+ // no client?
+ if (!isset($client[$source])) return;
+ // Set the nick away
+ if ($array[2][1] != "") {
+ $string = implode(" ",$array);
+ $reason = substr($string,strpos($string,":") + 1);
+ $client[$source]->away($reason);
+ sql_away($source,$reason);
+ }
+ // Nick comes back
+ else {
+ $client[$source]->back();
+ sql_back($source);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/burst.php
diff -u /dev/null phpstats/handlers/burst.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/burst.php Sun Mar 9 13:51:28 2003
@@ -0,0 +1,239 @@
+<?
+/*
+ Handler for B.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: burst.php,v 1.1 2003/03/09 21:51:28 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+ $array[3] => timestamp
+
+ // First method: without modes
+ $array[4] => userlist
+ $array[5-end] => banlist
+ // Second method: with modes, but no key or limit
+ $array[4] => modes
+ $array[5] => userlist
+ $array[6-end] => banlist
+ // Third method: with modes and key or limit
+ $array[4] => modes
+ $array[5] => key or limit
+ $array[6] => userlist
+ $array[7] => banlist
+ // Fourth method: with modes and key and limit
+ $array[4] => modes
+ $array[5] => key
+ $array[6] => limit
+ $array[7] => userlist
+ $array[8] => banlist
+*/
+function burst ($source,$array) {
+ global $channel,$client,$server,$channelnumber;
+ $name = $array[2];
+ $timestamp = $array[3];
+
+ // we have modes
+ if ($array[4][0] == "+") {
+ $modes = string2array($array[4]);
+ reset($modes);next($modes);
+ // checking if l or k is there
+ $keyed = false;
+ $limited = false;
+ foreach($modes as $key => $val) {
+ if ($val == "k") { $keyed = true; countinue; };
+ if ($val == "l") { $limited = true; countinue; };
+ };
+ unset($modes);
+
+ $modes = substr($array[4],1);
+
+ // key only
+ if ($keyed && !$limited) {
+ $users = $array[6];
+ $limit = NULL;
+ $key = $array[5];
+
+ // do we have bans?
+ if (($array[7][0] == ":") && ($array[7][1] == "%")) {
+ $bans[] = substr($array[7],2);
+ reset($array);
+ next($array);next($array);next($array);next($array);next($array);next($array);next($array);next($array);
+ while (list($key,$val) = each($array)) {
+ $bans[] = $val;
+ };
+ }
+ // no bans
+ else {
+ $bans = NULL;
+ };
+ }
+
+ // limit only
+ elseif ($limited && !$keyed) {
+ $users = $array[6];
+ $key = NULL;
+ $limit = $array[5];
+
+ // do we have bans?
+ if (($array[7][0] == ":") && ($array[7][1] == "%")) {
+ $bans[] = substr($array[7],2);
+ reset($array);
+ next($array);next($array);next($array);next($array);next($array);next($array);next($array);next($array);
+ while (list($key,$val) = each($array)) {
+ $bans[] = $val;
+ };
+ }
+ // no bans
+ else {
+ $bans = NULL;
+ };
+ }
+
+ // both limit and key
+ elseif ($limited && $keyed) {
+ $users = $array[7];
+ $key = $array[6];
+ $limit = $array[5];
+
+ // do we have bans?
+ if (($array[8][0] == ":") && ($array[8][1] == "%")) {
+ $bans[] = substr($array[8],2);
+ reset($array);
+ next($array);next($array);next($array);next($array);next($array);next($array);next($array);next($array);next($array);
+ while (list($key,$val) = each($array)) {
+ $bans[] = $val;
+ };
+ }
+
+ // no bans
+ else {
+ $bans = NULL;
+ };
+ }
+
+ // no key or limit
+ else {
+ $users = $array[5];
+ $limit = NULL;
+ $key = NULL;
+
+ // do we have bans?
+ if (($array[6][0] == ":") && ($array[5][1] == "%")) {
+ $bans[] = substr($array[6],2);
+ reset($array);
+ next($array);next($array);next($array);next($array);next($array);next($array);next($array);
+ while (list($key,$val) = each($array)) {
+ $bans[] = $val;
+ };
+ }
+
+ // no bans
+ else {
+ $bans = NULL;
+ };
+ };
+ }
+
+ // we have no modes, no limit and no key
+ else {
+ $users = $array[4];
+ $modes = "";
+ $limit = NULL;
+ $key = NULL;
+
+ // do we have bans?
+ if (($array[5][0] == ":") && ($array[5][1] == "%")) {
+ $bans[] = substr($array[5],2);
+ reset($array);
+ next($array);next($array);next($array);next($array);next($array);next($array);
+ while (list($key,$val) = each($array)) {
+ $bans[] = $val;
+ };
+ }
+
+ // no bans
+ else {
+ $bans = NULL;
+ };
+ };
+
+ // channel exists
+ if (isset($channel[$name])) {
+ // our channel is younger
+ if ($channel[$name]->returnts() > $timestamp) {
+ // deop and devoice all users, remove all modes, add new modes,
+ // remove all bans, apply new bans, reset the creationts
+ $channel[$name]->changets($timestamp,$name);
+ $channel[$name]->burst_younger($modes,$limit,$key,$name);
+ if (count($bans) != 0) {
+ foreach ($bans as $key => $val) {
+ $channel[$name]->addban($val,$name,$server[$source]->returnname(),time());
+ };
+ };
+ }
+ // same timestamp
+ elseif ($channel[$name]->returnts() == $timestamp) {
+ $channel[$name]->burst_same($modes,$limit,$key,$name);
+ if (count($bans) != 0) {
+ foreach ($bans as $key1 => $val1) {
+ $isadded = false;
+ foreach ($channel[$name]->bans as $key2 => $val2) {
+ if ($val1 == $val2) $isadded = true;
+ };
+ if (!$isadded) $channel[$name]->addban($val1,$name,$server[$source]->returnname(),time());
+ };
+ };
+ }
+ // our channel is older
+ else {
+ // Do nothing
+ };
+ }
+ // channel doesn't exist
+ else {
+ $channel[$name] = new channel($timestamp,$modes,$limit,$key,NULL,NULL);
+ sql_createchannel($name,$channel[$name]);
+ sql_channelnumber(++$channelnumber);
+ if ($bans != NULL) {
+ foreach ($bans as $key => $val) {
+ $channel[$name]->addban($val,$name,$server[$source]->returnname(),time());
+ };
+ };
+ };
+
+ // users
+ $userarray = explode(",",$users);
+ // 0 = no mode, 1 = voiceop, 2 = op, 3 = voice
+ $status = 0;
+ foreach ($userarray as $key => $val) {
+ $temparray = explode(":",$val);
+ if ($temparray[1] == "ov") $status = 1;
+ elseif ($temparray[1] == "o") $status = 2;
+ elseif ($temparray[1] == "v") $status = 3;
+
+ if ($status == 0) {
+ $channel[$name]->burstjoin($temparray[0],"");
+ sql_joinuser($name,$temparray[0],"");
+ }
+ elseif ($status == 1) {
+ $channel[$name]->burstjoin($temparray[0],"ov");
+ sql_joinuser($name,$temparray[0],"ov");
+ }
+ elseif ($status == 2) {
+ $channel[$name]->burstjoin($temparray[0],"o");
+ sql_joinuser($name,$temparray[0],"o");
+ }
+ elseif ($status == 3) {
+ $channel[$name]->burstjoin($temparray[0],"v");
+ sql_joinuser($name,$temparray[0],"v");
+ };
+ $client[$temparray[0]]->addchan($name);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/clearmode.php
diff -u /dev/null phpstats/handlers/clearmode.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/clearmode.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,39 @@
+<?
+/*
+ Handler for CM.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: clearmode.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => #channel
+ $array[3] => modes to clear
+*/
+function clearmode ($source,$array) {
+ global $channel;
+ if ($array[2][0] != "#") return;
+ $modestoclear = string2array($array[3]);
+ foreach ($modestoclear as $key => $val) {
+ switch ($val) {
+ case "b": $channel[$array[2]]->remallbans(); break;
+ case "k": $channel[$array[2]]->remmode($val); $channel[$array[2]]->remkey(); break;
+ case "l": $channel[$array[2]]->remmode($val); $channel[$array[2]]->remlimit(); break;
+ case "i": $channel[$array[2]]->remmode($val); break;
+ case "m": $channel[$array[2]]->remmode($val); break;
+ case "n": $channel[$array[2]]->remmode($val); break;
+ case "p": $channel[$array[2]]->remmode($val); break;
+ case "s": $channel[$array[2]]->remmode($val); break;
+ case "t": $channel[$array[2]]->remmode($val); break;
+ case "r": $channel[$array[2]]->remmode($val); break;
+ case "o": $channel[$array[2]]->deopall(); break;
+ case "v": $channel[$array[2]]->devoiceall(); break;
+ //default: echo "Unknown channelmode: $val\n";
+ };
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/create.php
diff -u /dev/null phpstats/handlers/create.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/create.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,40 @@
+<?
+/*
+ Handler for C.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: create.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+ $array[3] => timestamp
+*/
+function create ($source,$array) {
+ global $channel,$client,$channelnumber;
+ // channel was already created?
+ // happens sometimes when the users join at the same time
+ if (isset($channel[$array[2]])) {
+ if ($channel[$array[2]]->returnts() > $array[3]) {
+ $channel[$array[2]]->changets($array[3],$array[2]);
+ $channel[$array[2]]->joincreate($source);
+ sql_joinuser($array[2],$source,"o");
+ }
+ else {
+ $channel[$array[2]]->joinuser($array[3]);
+ sql_joinuser($array[2],$source,"");
+ };
+ }
+ else {
+ $channel[$array[2]] = new channel($array[3],"",NULL,NULL,$source,"o");
+ sql_createchannel($array[2],$channel[$array[2]]);
+ sql_joinuser($array[2],$source,"o");
+ sql_channelnumber(++$channelnumber);
+ };
+ $client[$source]->addchan($array[2]);
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/end_of_burst.php
diff -u /dev/null phpstats/handlers/end_of_burst.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/end_of_burst.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,21 @@
+<?
+/*
+ Handler for EB.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: end_of_burst.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric (our uplink only!)
+ $parameters can be ignored (if there were any :P)
+*/
+function end_of_burst ($source,$parameters) {
+ if ($source == UPLINKNUM) {
+ send_to_uplink("EB");
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/end_of_burst_ack.php
diff -u /dev/null phpstats/handlers/end_of_burst_ack.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/end_of_burst_ack.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,22 @@
+<?
+/*
+ Handler for EA.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: end_of_burst_ack.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric (our uplink only!)
+ $parameters can be ignored (if there were any :P)
+*/
+function end_of_burst_ack ($source,$parameters) {
+ if ($source == UPLINKNUM) {
+ send_to_uplink("EA");
+ sql_isbursted("t");
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/info.php
diff -u /dev/null phpstats/handlers/info.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/info.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,27 @@
+<?
+/*
+ Handler for F.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: info.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => :our numeric
+*/
+$infotext[] = chr(31) . "Author:" . chr(31) . " volta";
+$infotext[] = chr(31) . "Beta testers:" . chr(31) . " ";
+$infotext[] = "On-line since " . date("D M j H:i:s Y");
+
+function info ($source,$array) {
+ global $infotext;
+ foreach ($infotext as $key => $val) {
+ send_to_uplink("371 " . $source . " :$val");
+ };
+ send_to_uplink("374 " . $source . " :End of /INFO list.");
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/join.php
diff -u /dev/null phpstats/handlers/join.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/join.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,31 @@
+<?
+/*
+ Handler for J.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: join.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+ $array[3] => timestamp (=createts)
+*/
+// join is already a php function ....
+function dojoin ($source,$array) {
+ global $channel,$client,$channelnumber;
+ // Create the channel, but without oping the founder
+ if (!isset($channel[$array[2]])) {
+ $channel[$array[2]] = new channel($array[3],"",NULL,NULL,$source,"");
+ sql_createchannel($array[2],$channel[$array[2]]);
+ sql_channelnumber(++$channelnumber);
+ return;
+ };
+ $channel[$array[2]]->joinuser($source);
+ $client[$source]->addchan($array[2]);
+ sql_joinuser($array[2],$source,"");
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/kick.php
diff -u /dev/null phpstats/handlers/kick.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/kick.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,30 @@
+<?
+/*
+ Handler for K.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: kick.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+ $array[3] => target
+ $array[4-end] => reason
+*/
+function kick ($source,$array) {
+ global $channel,$client,$channelnumber;
+ if (!isset($channel[$array[2]])) return;
+ $client[$array[3]]->remchan($array[2]);
+ $channel[$array[2]]->partuser($array[3]);
+ // is the channel empty?
+ if ($channel[$array[2]]->isempty()) {
+ unset($channel[$array[2]]);
+ sql_removechannel($array[2]);
+ sql_channelnumber(--$channelnumber);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/kill.php
diff -u /dev/null phpstats/handlers/kill.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/kill.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,40 @@
+<?
+/*
+ Handler for D.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: kill.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => target
+ $array[3] => hostname!nick of the killer
+ $array[4-end] => reason
+*/
+function kill ($source,$array) {
+ global $client,$channel,$server,$usernumber,$channelnumber;
+ $target = $array[2];
+ if (!isset($client[$target])) return;
+ // Removing the user from all channels
+ $channels = $client[$target]->getchannels();
+ foreach ($channels as $key => $val) {
+ $channel[$val]->partuser($target);
+ sql_partuser($val,$target);
+ // destroy the channel when noone's in there
+ if ($channel[$val]->isempty()) {
+ unset($channel[$val]);
+ sql_removechannel($val);
+ sql_channelnumber(--$channelnumber);
+ };
+ };
+ unset($client[$target]);
+ $snumeric = $target[0] . $target[1];
+ $server[$snumeric]->remuser($target);
+ sql_unregisterclient($target);
+ sql_usernumber(--$usernumber);
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/mode.php
diff -u /dev/null phpstats/handlers/mode.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/mode.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,123 @@
+<?
+/*
+ Handler for M.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: mode.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ First method: set usermodes
+ $array[2] => own nick
+ $array[3] => usermodes
+ Second method: set channelmodes
+ $array[2] => #channel
+ $array[3] => channelmodes
+ $array[4-end] => parameters
+*/
+function mode ($source,$array) {
+ // Usermodes
+ if (($array[2][0] != "#") and ($array[2][0] != "+")) {
+ global $client;
+ if ($client[$source]->returnnick() != $array[2]) return;
+ $modearray = string2array($array[3]);
+ $modeaddstr = "";
+ $moderemstr = "";
+ // $method: 0 for adding (+), 1 for removing (-)
+ foreach ($modearray as $key => $val) {
+ switch ($val) {
+ case "+": $method = 0; break;
+ case "-": $method = 1; break;
+ default: {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ };
+ };
+ };
+ if ($modeaddstr != "") $client[$source]->addmode($modeaddstr,$source);
+ if ($moderemstr != "") $client[$source]->remmode($moderemstr,$source);
+ }
+ // Channelmodes
+ else {
+ global $channel,$client;
+ $modearray = string2array($array[3]);
+ $param = 0;
+ $modeaddstr = "";
+ $moderemstr = "";
+ // $method: 0 for adding (+), 1 for removing (-)
+ foreach ($modearray as $key => $val) {
+ switch ($val) {
+ case "+": $method = 0; break;
+ case "-": $method = 1; break;
+ case "b": {
+ if ($method == 0) $channel[$array[2]]->addban($array[4 + $param++],$array[2],$client[$source]->returnnick(),time());
+ elseif ($method == 1) $channel[$array[2]]->remban($array[4 + $param++],$array[2]);
+ break;
+ };
+ case "k": {
+ if ($method == 0) { $modeaddstr .= $val; $channel[$array[2]]->addkey($array[4 + $param++],$array[2]);}
+ elseif ($method == 1) { $moderemstr .= $val; $channel[$array[2]]->remkey($array[2]); $param++; };
+ break;
+ };
+ case "l": {
+ if ($method == 0) { $modeaddstr .= $val; $channel[$array[2]]->addlimit($array[4 + $param++],$array[2]); }
+ elseif ($method == 1) { $moderemstr .= $val; $channel[$array[2]]->remlimit($array[2]); };
+ break;
+ };
+ case "i": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "m": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "n": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "p": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "s": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "t": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "r": {
+ if ($method == 0) $modeaddstr .= $val;
+ elseif ($method == 1) $moderemstr .= $val;
+ break;
+ };
+ case "o": {
+ if ($method == 0) $channel[$array[2]]->giveop($array[4 + $param++],$array[2]);
+ elseif ($method == 1) $channel[$array[2]]->remop($array[4 + $param++],$array[2]);
+ break;
+ };
+ case "v": {
+ if ($method == 0) $channel[$array[2]]->givevoice($array[4 + $param++],$array[2]);
+ elseif ($method == 1) $channel[$array[2]]->remvoice($array[4 + $param++],$array[2]);
+ break;
+ };
+ //default: echo "Unknown channelmode: $val\n";
+ };
+ };
+ if ($modeaddstr != "") $channel[$array[2]]->addmode($modeaddstr,$array[2]);
+ if ($moderemstr != "") $channel[$array[2]]->remmode($moderemstr,$array[2]);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/nick.php
diff -u /dev/null phpstats/handlers/nick.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/nick.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,97 @@
+<?
+/*
+ Handler for N.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: nick.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* First method: registred a new nick
+ Parameters:
+ $source => sender's numeric
+ $array[2] => nickname
+ $array[3] => hopcount (not needed)
+ $array[4] => timestamp
+ $array[5] => username
+ $array[6] => hostname
+
+ Case no usermode:
+ $array[7] => base64 ip
+ $array[8] => numeric
+ $array[9-end] => userinfo
+
+ Case with username:
+ $array[7] => usermode
+ $array[8] => base64 ip
+ $array[9] => numeric
+ $array[10-end] => userinfo
+
+ Case with account
+ $array[7] => usermode
+ $array[8] => account
+ $array[9] => base64 ip
+ $array[10] => numeric
+ $array[11-end] => userinfo
+
+ Second method: change the nick
+ Parameters:
+ $source => sender's numeric
+ $array[2] => new nickname
+ $array[3] => timestamp
+*/
+function nick ($source,$array) {
+ global $client,$usernumber;
+ /* First method */
+ if (count($array) > 4) {
+ global $server;
+ $nickname = $array[2];
+ $timestamp = $array[4];
+ $username = $array[5];
+ $hostname = $array[6];
+
+ $string = implode(" ",$array);
+ $userinfo = str_replace(":","",strstr($string,":"));
+
+ $array3 = explode(":",$string);
+ /* First case: no usermode */
+ if (count(explode(" ",$array3[0])) == 10) {
+ $usermode = "";
+ $account = "";
+ $ip = $array[7];
+ $numeric = $array[8];
+ }
+ /* Second case: with usermode */
+ elseif (count(explode(" ",$array3[0])) == 11) {
+ $usermode = substr($array[7],1);
+ $account = "";
+ $ip = $array[8];
+ $numeric = $array[9];
+ }
+ /* Third case: with account */
+ elseif (count(explode(" ",$array3[0])) == 12) {
+ $usermode = str_replace("+","",str_replace("r","",$array[7]));
+ $account = $array[8];
+ $ip = $array[9];
+ $numeric = $array[10];
+ };
+ $realip = mylong2ip(base64toint($ip));
+
+ /* create the client */
+ $client[$numeric] = new client($nickname,$timestamp,$username,$hostname,$usermode,$account,$realip,$userinfo);
+ $server[$source]->adduser($numeric);
+ sql_registerclient ($numeric,$source,$client[$numeric]);
+ sql_usernumber(++$usernumber);
+ }
+ /* Second method */
+ else {
+ if (!isset($client[$source])) return;
+ $newnick = $array[2];
+ $timestamp = $array[3];
+ $client[$source]->changenick($newnick,$timestamp);
+ sql_changenick($source,$newnick,$timestamp);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/part.php
diff -u /dev/null phpstats/handlers/part.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/part.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,29 @@
+<?
+/*
+ Handler for L.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: part.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+*/
+function part ($source,$array) {
+ global $channel,$client,$channelnumber;
+ if (!isset($channel[$array[2]])) return;
+ if (!isset($channel[$array[2]]->users[$source])) return;
+ $client[$source]->remchan($array[2]);
+ $channel[$array[2]]->partuser($source);
+ sql_partuser($array[2],$source);
+ if ($channel[$array[2]]->isempty()) {
+ unset($channel[$array[2]]);
+ sql_removechannel($array[2]);
+ sql_channelnumber(--$channelnumber);
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/pass.php
diff -u /dev/null phpstats/handlers/pass.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/pass.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,24 @@
+<?
+/*
+ Handler for PASS.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: pass.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $array[1] => password
+*/
+function pass ($array) {
+ $pass = explode(":",$array[1]);
+ if ($pass[1] != PASS) {
+ send_raw_to_uplink("ERROR :Closing Link: by " . SERVERNAME . " (No Access (passwd mismatch))");
+ close_socket();
+ echo "\nWrong uplink password from server\nService is dying!! *arg*\n";
+ die();
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/ping.php
diff -u /dev/null phpstats/handlers/ping.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/ping.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,45 @@
+<?
+/*
+ Handler for G.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: ping.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ asll format:
+ $source => source numeric (=UPLINKNUM)
+ $array[2] => !localts
+ $array[3] => target
+ $array[4] => localts
+
+ normal format:
+ $array[2-end] = :string
+*/
+function ping ($source,$array) {
+ // normal format
+ $array2 = explode("!",$array[2]);
+ if (($array[2][2] != "!") && (!is_real($array2[1])) && ($array[3] != SERVERNAME) && (!is_real($array[4]))) {
+ // building $text
+ $temparray = $array;
+ $text = str_replace(":","",$temparray[2]);
+ reset($temparray);
+ next($temparray);next($temparray);next($temparray);
+ while (list($key,$val) = each($temparray)) {
+ $text .= " " . $val;
+ };
+ send_to_uplink("Z :$text");
+ return;
+ };
+ // Asll
+ list($usec,$sec) = explode(" ",microtime());
+ $localts = $sec . "." . $usec[2] . $usec[3] . $usec[4] . $usec[5] . $usec[6] . $usec[7];
+ $remotets = $array[4];
+ $diff = round((($localts - $remotets) * 1000),0);
+ // Reply with a PONG in asll format
+ send_to_uplink("Z " . SERVERNUM . " !$remotets $remotets $diff $localts");
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/quit.php
diff -u /dev/null phpstats/handlers/quit.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/quit.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,37 @@
+<?
+/*
+ Handler for Q.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: quit.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2-end] => quit reason
+*/
+function quit ($source,$array) {
+ global $client,$channel,$server,$usernumber,$channelnumber;
+ if (!isset($client[$source])) return;
+ // Removing the user from all channels
+ $channels = $client[$source]->getchannels();
+ foreach ($channels as $key => $val) {
+ $channel[$val]->partuser($source);
+ sql_partuser($val,$source);
+ // destroy the channel when noone's in there
+ if ($channel[$val]->isempty()) {
+ unset($channel[$val]);
+ sql_removechannel($val);
+ sql_channelnumber(--$channelnumber);
+ };
+ };
+ unset($client[$source]);
+ $snumeric = $source[0] . $source[1];
+ $server[$snumeric]->remuser($source);
+ sql_unregisterclient($source);
+ sql_usernumber(--$usernumber);
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/server.php
diff -u /dev/null phpstats/handlers/server.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/server.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,42 @@
+<?
+/*
+ Handler for S.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: server.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => new server's name
+ $array[3] => hops
+ $array[4] => startts
+ $array[5] => linkts
+ $array[6] => protocol
+ $array[7] => servernumeric + maxusers in base64
+ $array[8] => server mode (+, +h, +s)
+ $array[9-end] => description
+*/
+function server ($source,$array) {
+ global $server,$servernumber;
+ // too few parameters
+ if (count($array) < 10) return;
+ $numeric = $array[7][0] . $array[7][1];
+ // we already have such a server
+ if (isset($server[$numeric])) return;
+ $hops = (int) $array[3];
+ $protocol = str_replace("J","P",$array[6]);
+ $maxconn = base64toint($array[7][2] . $array[7][3] . $array[7][4]);
+ $string = implode(" ",$array);
+ $desc = strstr($string,":");
+ $mode = str_replace("+","",$array[8]);
+ if ($array[8] == "0") $mode = "";
+ $server[$numeric] = new server($array[2],$hops,$array[4],$array[5],$protocol,$maxconn,$mode,substr($desc,1));
+ sql_registerserver($numeric,$server[$numeric]);
+ sql_servernumber(++$servernumber);
+ $server[$source]->linkserver($numeric);
+ sql_linkserver($source,$numeric);
+};
\ No newline at end of file
Index: phpstats/handlers/squit.php
diff -u /dev/null phpstats/handlers/squit.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/squit.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,45 @@
+<?
+/*
+ Handler for SQ.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: squit.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => target servername (not numeric!!)
+ $array[3] => timestamp
+ $array[4-end] => squit reason
+*/
+function squit ($source,$array) {
+ global $server,$client,$channel,$servernumber;
+ // too few parameters
+ if (count($array) < 5) return;
+ foreach ($server as $key => $value) {
+ if ($value->returnname() == $array[2]) {
+ $numeric = $key;
+ break;
+ };
+ };
+ // our uplink squits us; let it send EOF, so we can exit the prog clearly
+ if (($numeric == UPLINKNUM) && ($array[3] == 0)) return;
+ $server[$numeric]->clearserver($numeric);
+ unset($server[$numeric]);
+ sql_removeserver($numeric);
+ sql_servernumber(--$servernumber);
+ // remove $numeric in the list of links of the server before the squitted one
+ foreach ($server as $key1 => $val1) {
+ foreach ($val1->links as $key2 => $val2) {
+ if ($numeric == $val2) {
+ $server[$key1]->remlink($key2);
+ sql_remlink($key1,$val2);
+ break 2;
+ };
+ };
+ };
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/topic.php
diff -u /dev/null phpstats/handlers/topic.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/topic.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,28 @@
+<?
+/*
+ Handler for T.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: topic.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $array[2] => channel name
+ $array[3-end] => topic
+*/
+function topic ($source,$array) {
+ global $channel,$client;
+ if (!isset($channel[$array[2]])) return;
+ $topic = "";
+ while (list($key,$val) = each ($array)) {
+ if ($key == 3) $topic .= substr($val,1);
+ elseif ($key > 3) $topic .= " " . $val;
+ };
+ $channel[$array[2]]->changetopic($source,$topic);
+ sql_changetopic($array[2],$topic,$client[$source]->returnnick(),time());
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/uplinkserver.php
diff -u /dev/null phpstats/handlers/uplinkserver.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/uplinkserver.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,57 @@
+<?
+/*
+ Handler for SERVER.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: uplinkserver.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* parameters:
+ $array[1] => servername
+ $array[2] => hops (always 1)
+ $array[3] => startts
+ $array[4] => linkts
+ $array[5] => protocol version
+ $array[6] => server numeric + max clients
+ $array[7] => server mode (+, +h, +s)
+ $array[8-end] => description
+*/
+function uplinkserver ($array) {
+ global $server,$servernumber;
+ // checking if the ircd sends the right syntax (= 9 parameters)
+ // else don't accept the link
+ if ($array[8] == "") {
+ send_raw_to_uplink(":" . SERVERNAME . " 461 * SERVER :Not enough Parameters");
+ send_raw_to_uplink("ERROR :Closing Link: " . $array[1] . " by " . SERVERNAME . " (Need more Parameters)");
+ close_socket();
+ echo "\nNot enough parameters for SERVER\nService is dying!! *arg*\n";
+ die();
+ };
+
+ // checking if the ircd is using the right protocol
+ if ($array[5] != "J10") {
+ send_raw_to_uplink("ERROR :Closing Link: by " . SERVERNAME . " (Bogus protocol (" . $array[5] . ")");
+ close_socket();
+ echo "\nBogus protocol for uplink\nService is dying!! *arg*\n";
+ die();
+ };
+
+ // This creates the constant UPLINKNUM,
+ // which contains the base64 numeric of the uplinkserver
+ $numeric = $array[6];
+ $snumeric = $numeric[0] . $numeric[1];
+ define(UPLINKSERVER,$array[1]);
+ define(UPLINKNUM,$snumeric);
+ $protocol = str_replace("J","P",$array[5]);
+ $maxconn = base64toint($numeric[2] . $numeric[3] . $numeric[4]);
+ $string = implode(" ",$array);
+ $desc = strstr($string,":");
+ $server[UPLINKNUM] = new server(UPLINKSERVER,1,$array[3],$array[4],$protocol,$maxconn,"h",substr($desc,1));
+ sql_registerserver(UPLINKNUM,$server[UPLINKNUM]);
+ sql_linkserver(SERVERNUM,UPLINKNUM);
+ sql_servernumber(++$servernumber);
+};
+?>
\ No newline at end of file
Index: phpstats/handlers/version.php
diff -u /dev/null phpstats/handlers/version.php:1.1
--- /dev/null Sun Mar 9 13:51:40 2003
+++ phpstats/handlers/version.php Sun Mar 9 13:51:29 2003
@@ -0,0 +1,21 @@
+<?
+/*
+ Handler for V.
+ PHP Stats Service is copyright (c) 2002-2003 volta.
+ E-mail: <vo...@gm...>
+ This program is free but copyrighted software; see the file LICENSE for
+ details.
+ $Id: version.php,v 1.1 2003/03/09 21:51:29 mrvolta Exp $
+*/
+
+$b = 1;
+/* Parameters:
+ $source => sender's numeric
+ $parameters can be ignored
+*/
+define(BASE_VERSION,"PHP Stats Service");
+define(VERSION,"0.6 alpha");
+function version ($source,$parameters) {
+ send_to_uplink("351 " . $source . " :" . BASE_VERSION . " " . VERSION . " " . SERVERNAME);
+};
+?>
\ No newline at end of file
----------------------- End of diff -----------------------
|