Index: trunk/phase3/includes/RecentChange.php |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | |
178 | 178 | # Notify external application via UDP |
179 | 179 | if ( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) { |
180 | | - self::sendToUDP( $this->getIRCLine() ); |
| 180 | + UDP::sendToUDP( $this->getIRCLine() ); |
181 | 181 | } |
182 | 182 | |
183 | 183 | # E-mail notifications |
— | — | @@ -206,40 +206,6 @@ |
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | | - * Send some text to UDP |
211 | | - * @param string $line |
212 | | - * @param string $prefix |
213 | | - * @param string $address |
214 | | - * @return bool success |
215 | | - */ |
216 | | - public static function sendToUDP( $line, $address = '', $prefix = '' ) { |
217 | | - global $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPPort; |
218 | | - # Assume default for standard RC case |
219 | | - $address = $address ? $address : $wgRC2UDPAddress; |
220 | | - $prefix = $prefix ? $prefix : $wgRC2UDPPrefix; |
221 | | - # Notify external application via UDP |
222 | | - if( $address ) { |
223 | | - $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
224 | | - if( $conn ) { |
225 | | - $line = $prefix . $line; |
226 | | - socket_sendto( $conn, $line, strlen($line), 0, $address, $wgRC2UDPPort ); |
227 | | - socket_close( $conn ); |
228 | | - return true; |
229 | | - } |
230 | | - } |
231 | | - return false; |
232 | | - } |
233 | | - |
234 | | - /** |
235 | | - * Remove newlines and carriage returns |
236 | | - * @param string $line |
237 | | - * @return string |
238 | | - */ |
239 | | - public static function cleanupForIRC( $text ) { |
240 | | - return str_replace(array("\n", "\r"), array("", ""), $text); |
241 | | - } |
242 | | - |
243 | | - /** |
244 | 210 | * Mark a given change as patrolled |
245 | 211 | * |
246 | 212 | * @param mixed $change RecentChange or corresponding rc_id |
— | — | @@ -618,7 +584,7 @@ |
619 | 585 | $titleObj =& $this->getTitle(); |
620 | 586 | } |
621 | 587 | $title = $titleObj->getPrefixedText(); |
622 | | - $title = self::cleanupForIRC( $title ); |
| 588 | + $title = UDP::cleanupForIRC( $title ); |
623 | 589 | |
624 | 590 | // FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26 |
625 | 591 | if ( $rc_type == RC_LOG ) { |
— | — | @@ -645,14 +611,14 @@ |
646 | 612 | $szdiff = ''; |
647 | 613 | } |
648 | 614 | |
649 | | - $user = self::cleanupForIRC( $rc_user_text ); |
| 615 | + $user = UDP::cleanupForIRC( $rc_user_text ); |
650 | 616 | |
651 | 617 | if ( $rc_type == RC_LOG ) { |
652 | 618 | $targetText = $this->getTitle()->getPrefixedText(); |
653 | | - $comment = self::cleanupForIRC( str_replace("[[$targetText]]","[[\00302$targetText\00310]]",$actionComment) ); |
| 619 | + $comment = UDP::cleanupForIRC( str_replace("[[$targetText]]","[[\00302$targetText\00310]]",$actionComment) ); |
654 | 620 | $flag = $rc_log_action; |
655 | 621 | } else { |
656 | | - $comment = self::cleanupForIRC( $rc_comment ); |
| 622 | + $comment = UDP::cleanupForIRC( $rc_comment ); |
657 | 623 | $flag = ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : ""); |
658 | 624 | } |
659 | 625 | # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003, |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -505,6 +505,9 @@ |
506 | 506 | 'WikiImporter' => 'includes/Import.php', |
507 | 507 | 'WikiRevision' => 'includes/Import.php', |
508 | 508 | 'WithoutInterwikiPage' => 'includes/specials/SpecialWithoutinterwiki.php', |
| 509 | + |
| 510 | + # UDP logging |
| 511 | + 'UDP' => 'includes/UDP.php', |
509 | 512 | |
510 | 513 | # includes/templates |
511 | 514 | 'UsercreateTemplate' => 'includes/templates/Userlogin.php', |
Index: trunk/phase3/includes/UDP.php |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class UDP { |
| 5 | + /** |
| 6 | + * Send some text to UDP |
| 7 | + * @param string $line |
| 8 | + * @param string $prefix |
| 9 | + * @param string $address |
| 10 | + * @return bool success |
| 11 | + */ |
| 12 | + public static function sendToUDP( $line, $address = '', $prefix = '' ) { |
| 13 | + global $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPPort; |
| 14 | + # Assume default for standard RC case |
| 15 | + $address = $address ? $address : $wgRC2UDPAddress; |
| 16 | + $prefix = $prefix ? $prefix : $wgRC2UDPPrefix; |
| 17 | + # Notify external application via UDP |
| 18 | + if( $address ) { |
| 19 | + $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
| 20 | + if( $conn ) { |
| 21 | + $line = $prefix . $line; |
| 22 | + socket_sendto( $conn, $line, strlen($line), 0, $address, $wgRC2UDPPort ); |
| 23 | + socket_close( $conn ); |
| 24 | + return true; |
| 25 | + } |
| 26 | + } |
| 27 | + return false; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Remove newlines and carriage returns |
| 32 | + * @param string $line |
| 33 | + * @return string |
| 34 | + */ |
| 35 | + public static function cleanupForIRC( $text ) { |
| 36 | + return str_replace(array("\n", "\r"), array("", ""), $text); |
| 37 | + } |
| 38 | +} |
\ No newline at end of file |
Property changes on: trunk/phase3/includes/UDP.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 39 | + native |
Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -1018,7 +1018,7 @@ |
1019 | 1019 | global $wgCentralAuthUDPAddress, $wgCentralAuthNew2UDPPrefix; |
1020 | 1020 | if( $wgCentralAuthUDPAddress ) { |
1021 | 1021 | $userpage = Title::makeTitleSafe( NS_USER, $this->mName ); |
1022 | | - RecentChange::sendToUDP( self::getIRCLine( $userpage, $wikiID ), |
| 1022 | + UDP::sendToUDP( self::getIRCLine( $userpage, $wikiID ), |
1023 | 1023 | $wgCentralAuthUDPAddress, $wgCentralAuthNew2UDPPrefix ); |
1024 | 1024 | } |
1025 | 1025 | } |
— | — | @@ -1030,11 +1030,11 @@ |
1031 | 1031 | * @return string |
1032 | 1032 | */ |
1033 | 1033 | protected static function getIRCLine( $userpage, $wikiID ) { |
1034 | | - $title = RecentChange::cleanupForIRC( $userpage->getPrefixedText() ); |
1035 | | - $wikiID = RecentChange::cleanupForIRC( $wikiID ); |
| 1034 | + $title = UDP::cleanupForIRC( $userpage->getPrefixedText() ); |
| 1035 | + $wikiID = UDP::cleanupForIRC( $wikiID ); |
1036 | 1036 | // FIXME: *HACK* should be getFullURL(), hacked for SSL madness |
1037 | 1037 | $url = $userpage->getInternalURL(); |
1038 | | - $user = RecentChange::cleanupForIRC( $userpage->getText() ); |
| 1038 | + $user = UDP::cleanupForIRC( $userpage->getText() ); |
1039 | 1039 | # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003, |
1040 | 1040 | # no colour (\003) switches back to the term default |
1041 | 1041 | $fullString = "\00314[[\00307$title\00314]]\0034@$wikiID\00310 " . |