5 * Send some text to UDP
7 * @param string $prefix
8 * @param string $address
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
18 $conn = socket_create( AF_INET
, SOCK_DGRAM
, SOL_UDP
);
20 $line = $prefix . $line;
21 socket_sendto( $conn, $line, strlen($line), 0, $address, $wgRC2UDPPort );
22 socket_close( $conn );
30 * Remove newlines and carriage returns
34 public static function cleanupForIRC( $text ) {
35 return str_replace(array("\n", "\r"), array("", ""), $text);