tsfix
[lhc/web/wiklou.git] / irc / rcdumper.php
index 76ff91d..684f53a 100644 (file)
@@ -4,7 +4,7 @@
 Example command-line:
        php rcdumper.php | irc -d -c \#channel-to-join nick-of-bot some.irc.server
 where irc is the name of the ircII executable.
-The name of the the IRC should match $ircServer below.
+The name of the IRC server should match $ircServer below.
 */
 
 $ircServer = "irc.freenode.net";
@@ -15,8 +15,6 @@ $ircServer = "irc.freenode.net";
 
 ini_set( "display_errors", 1 );
 $wgCommandLineMode = true;
-$fmB = chr(2);
-$fmU = chr(31);
 
 require_once("../maintenance/commandLine.inc" );
 
@@ -34,16 +32,18 @@ $wgCommandLineMode = true;
 set_time_limit(0);
 
 sleep(30);
+$dbr =& wfGetDB( DB_SLAVE );
+$recentchanges = $dbr->tableName( 'recentchanges' );
 
-$res = wfQuery( "SELECT rc_timestamp FROM recentchanges ORDER BY rc_timestamp DESC LIMIT 1", DB_READ ); 
-$row = wfFetchObject( $res );
+$res = $dbr->query( "SELECT rc_timestamp FROM $recentchanges ORDER BY rc_timestamp DESC LIMIT 1" ); 
+$row = $dbr->fetchObject( $res );
 $oldTimestamp = $row->rc_timestamp;
 $serverCount = 0;
 
 while (1) {
-       $res = wfQuery( "SELECT * FROM recentchanges WHERE rc_timestamp>'$oldTimestamp' ORDER BY rc_timestamp", DB_READ );
+       $res = $dbr->query( "SELECT * FROM $recentchanges WHERE rc_timestamp>'$oldTimestamp' ORDER BY rc_timestamp" );
        $rowIndex = 0;
-       while ( $row = wfFetchObject( $res ) ) {
+       while ( $row = $dbr->fetchObject( $res ) ) {
                if ( ++$serverCount % 20 == 0 ) {
                        print "/server $ircServer\n";
                }
@@ -71,17 +71,11 @@ while (1) {
                        $url = $URLFirstPart . urlencode($title) .
                                "&diff=0&oldid=$lastid";
                }
-               $boldTitle = $fmB . str_replace("_", " ", $title) . $fmB;
+               $title = str_replace("_", " ", $title);
+                # see http://www.irssi.org/?page=docs&doc=formats for some colour codes. prefix is \003, 
+               # no colour (\003) switches back to the term default
+               $fullString = "\00303$title\0037 $flag\00310 $url \0037*\003 $user \0037*\003 $comment\n";
 
-               if ( $comment !== "" ) {
-                       $comment = "($comment)";
-               }
-               
-               $fullString = "$boldTitle   $flag   $url   $user $comment\n"; 
-
-               if ( $fullString{0} == "/" ) {
-                       $fullString = " $fullString";
-               }
                print( $fullString );
                $oldTimestamp = $row->rc_timestamp;
                sleep(2);