Remove hard coded colon in h2 after loginerror
[mediawiki.git] / includes / UDP.php
blobde7dddc9d65ef902fc4a87e35beb70199d3f9995
1 <?php
3 class UDP {
4 /**
5 * Send some text to UDP
6 * @param string $line
7 * @param string $prefix
8 * @param string $address
9 * @return bool success
11 public static function sendToUDP( $line, $address = '', $prefix = '' ) {
12 global $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPPort;
13 # Assume default for standard RC case
14 $address = $address ? $address : $wgRC2UDPAddress;
15 $prefix = $prefix ? $prefix : $wgRC2UDPPrefix;
16 # Notify external application via UDP
17 if( $address ) {
18 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
19 if( $conn ) {
20 $line = $prefix . $line;
21 socket_sendto( $conn, $line, strlen($line), 0, $address, $wgRC2UDPPort );
22 socket_close( $conn );
23 return true;
26 return false;
29 /**
30 * Remove newlines and carriage returns
31 * @param string $line
32 * @return string
34 public static function cleanupForIRC( $text ) {
35 return str_replace(array("\n", "\r"), array("", ""), $text);