Skip to content

Commit

Permalink
Ported protocol module
Browse files Browse the repository at this point in the history
git-svn-id: https://cobihome.external.cluenet.org:8443/svn/phpserv/trunk@237 cb14c9df-8a02-4fc1-9b40-3ccfc4edb2c1
  • Loading branch information
snofox committed Apr 3, 2010
1 parent d02a602 commit 480c625
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
4 changes: 2 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Legend:
[+] AccountProperties class
[ ] Rewrite IRC protocol module
[-] `-More network state awareness
[ ] |-User awayness (good for MemoServ notices on un-/away)
[?] |-User awayness (good for MemoServ notices on un-/away)
[?] |-Detection of netbursts
[?] `-What nicks PHPserv has introduced (less likely to accidentally collide)
[ ] `-What nicks PHPserv has introduced (less likely to accidentally collide)
[ ] Port PHPserv 1.0-stable modules
[ ] |-PHPserv
[ ] |-BotServ
Expand Down
50 changes: 20 additions & 30 deletions modules/ircds/unreal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class Unreal {

function event_raw_in( $data ) {

global $mysql;

$data = str_replace( array( "\n", "\r" ), '', $data );

$dataParts = explode( ' ', $data );
Expand Down Expand Up @@ -105,6 +103,7 @@ function event_raw_in( $data ) {
case 'L': // Limit redirect
case 'l': // Limit
case 'j': // Join throttle
// Spams #services when modes are set without params. Possible with /mode # -k (and likes)
event( 'chanmode_' . $modes{ $j }, $from, $to, $t, $dataParts[ $i ] );
$i++;
break;
Expand Down Expand Up @@ -169,7 +168,7 @@ function event_raw_in( $data ) {
$connected = true;
global $aml3;
$aml3 = 1;
$this->smo( 'o', "\002(\002Burst\002)\002 [" . $mysql->getsetting( 'server' ) . "] End of Incomming NetBurst." );
$this->smo( 'o', "\002(\002Burst\002)\002 [" . MySQL::getsetting( 'server' ) . "] End of Incomming NetBurst." );
event( 'eos', substr( $dataParts[ 0 ], 1 ) );
}
} elseif( @strtolower( $dataParts[ 1 ] ) == "kick" ) {
Expand All @@ -184,10 +183,9 @@ function event_raw_in( $data ) {
}

function event_connected() {
global $mysql;
$this->raw( 'PASS ' . $mysql->getsetting( 'pass' ) );
$this->raw( 'PASS ' . MySQL::getsetting( 'pass' ) );
$this->raw( 'PROTOCTL NICKv2 NICKIP' );
$this->raw( 'SERVER ' . $mysql->getsetting( 'server' ) . ' ' . $mysql->getsetting( 'numeric' ) . ' :' . $mysql->getsetting( 'desc' ) );
$this->raw( 'SERVER ' . MySQL::getsetting( 'server' ) . ' ' . MySQL::getsetting( 'numeric' ) . ' :' . MySQL::getsetting( 'desc' ) );
}

function raw( $data ) {
Expand All @@ -196,13 +194,11 @@ function raw( $data ) {
}

function addserv( $name , $desc ) {
global $mysql;
$this->raw( ':' . $mysql->getsetting( 'server' ) . ' SERVER ' . $name . ' 2 :' . $desc );
$this->raw( ':' . MySQL::getsetting( 'server' ) . ' SERVER ' . $name . ' 2 :' . $desc );
}

function smo( $mode , $message ) {
global $mysql;
$this->raw( ':' . $mysql->getsetting( 'server' ) . ' SMO ' . $mode . ' :' . $message );
$this->raw( ':' . MySQL::getsetting( 'server' ) . ' SMO ' . $mode . ' :' . $message );
}

function addserv2serv( $new , $old , $desc ) {
Expand All @@ -226,10 +222,10 @@ function ctcpreply( $src , $dest , $ctcp , $reply = NULL ) {
}

function addnick( $server , $nick , $ident , $host , $name ) {
// static $counter = 0;
// $this->raw('SVSKILL ' . $nick . ' :Nick collision by services');
// $this->quit($nick,'Required nickname held.');
$this->raw( 'NICK ' . $nick . ' 1 './*(time() + ($counter++))*/ time() . ' ' . $ident . ' ' . $host . ' ' . $server . ' 0 :' . $name );
if ( User::newFromNick( $nick ) != null) {
$this->raw('SVSKILL ' . $nick . ' :Nick collision by services');
}
$this->raw( 'NICK ' . $nick . ' 1 '. time() . ' ' . $ident . ' ' . $host . ' ' . $server . ' 0 :' . $name );
}

function join( $nick , $chan ) {
Expand Down Expand Up @@ -313,15 +309,13 @@ function servnotice( $dest , $message ) {
}

function svsnick( $old , $new ) {
global $mysql;
$this->raw( ':' . $mysql->getsetting( 'server' ) . ' SVSNICK ' . $old . ' ' . $new . ' ' . time() );
event( 'nick', $old, $new );
$this->raw( ':' . MySQL::getsetting( 'server' ) . ' SVSNICK ' . $old . ' ' . $new . ' ' . time() );
// Don't emit an event here because the nick message gets echoed back to PHPserv
}

function kill( $nick , $reason ) {
global $mysql;
$this->raw( 'KILL ' . $nick . ' :' . $reason );
event( 'kill', $mysql->getsetting( 'server' ), $nick, $reason );
event( 'kill', MySQL::getsetting( 'server' ), $nick, $reason );
}

function shun( $from , $to , $time , $reason ) {
Expand All @@ -342,17 +336,15 @@ function sajoin( $from , $who , $to ) {
}

function svskill( $nick , $reason ) {
global $mysql;
$this->raw( 'SVSKILL ' . $nick . ' :' . $reason );
event( 'svskill', $mysql->getsetting( 'server' ), $nick, $reason );
event( 'svskill', MySQL::getsetting( 'server' ), $nick, $reason );
}

function swhois( $nick , $swhois = '' ) {
$this->raw( 'SWHOIS ' . $nick . ' :' . $swhois );
}

function nicetkl( $type , $mask , $duration , $reason , $source = null ) {
global $mysql;

if( $mask{ 0 } == '+' ) {
$mode = '+';
Expand Down Expand Up @@ -395,16 +387,16 @@ function nicetkl( $type , $mask , $duration , $reason , $source = null ) {

if( ( ( $type == 'z' ) or ( $type == 'Z' ) ) and ( $mode == '+' ) ) {
if( $usermask != '*' ) {
logit( '[ircd] [tkl] [error] (g)zlines must be placed at *@ipmask, not user@ipmask. This is ' . 'because (g)zlines are processed BEFORE dns and ident lookups are done. ' . 'If you want to use usermasks, use a KLINE/GLINE instead.' );
logit( '[ircd] [tkl] [error] (g)zlines must be placed at *@ipmask, not user@ipmask. This is because (g)zlines are processed BEFORE dns and ident lookups are done. If you want to use usermasks, use a KLINE/GLINE instead.' );
return -1;
}
if( preg_match( '/[A-Za-z]/', $hostmask ) ) {
logit( '[ircd] [tkl] [error] (g)zlines must be placed at *@\037IPMASK\037, not *@HOSTMASK ' . '(so for example *@192.168.* is ok, but *@*.aol.com is not). ' . 'This is because (g)zlines are processed BEFORE dns and ident lookups are done. ' . 'If you want to use hostmasks instead of ipmasks, use a KLINE/GLINE instead.' );
logit( '[ircd] [tkl] [error] (g)zlines must be placed at *@IPMASK, not *@HOSTMASK (so for example *@192.168.* is ok, but *@*.aol.com is not). This is because (g)zlines are processed BEFORE dns and ident lookups are done. If you want to use hostmasks instead of ipmasks, use a KLINE/GLINE instead.' );
return -1;
}
}
} else {
$nickdata = $mysql->get( $mysql->sql( 'SELECT * FROM `users` WHERE `nick` = ' . $mysql->escape( $mask ) ) );
$nickdata = MySQL::get( MySQL::sql( 'SELECT * FROM `users` WHERE `nick` = ' . MySQL::escape( $mask ) ) );
if( is_array( $nickdata ) ) {
$usermask = '*';
if( ( $type == 'z' ) or ( $type == 'Z' ) ) {
Expand Down Expand Up @@ -440,7 +432,7 @@ function nicetkl( $type , $mask , $duration , $reason , $source = null ) {
$secs += time();
}

$this->tkl( $mysql->getsetting( 'server' ), $mode, $type, $usermask, $hostmask, ( $source == null ) ? 'PHPServ!PHPServ@PHPServ' : $source, $secs, time(), $reason );
$this->tkl( MySQL::getsetting( 'server' ), $mode, $type, $usermask, $hostmask, ( $source == null ) ? 'PHPServ!PHPServ@phpserv.cluenet.org' : $source, $secs, time(), $reason );
}

function tkl( $server , $mode , $type , $ident , $host , $source , $expiry , $set , $reason ) {
Expand All @@ -467,15 +459,13 @@ function isValidHost( $host ) {
}

function event_logout( $from ) {
global $mysql;
$me = $mysql->getsetting( 'server' );
$me = MySQL::getsetting( 'server' );
$this->svsmode( $me, $from, '+d 0' );
$this->svsmode( $me, $from, '-r' );
}

function event_identify( $from , $uid ) {
global $mysql;
$me = $mysql->getsetting( 'server' );
$me = MySQL::getsetting( 'server' );
$this->svsmode( $me, $from, '+d ' . $uid );
$this->svsmode( $me, $from, '+r' );
}
Expand Down

0 comments on commit 480c625

Please sign in to comment.