5 php rcdumper.php | irc -d -c \#channel-to-join nick-of-bot some.irc.server
6 where irc is the name of the ircII executable.
7 The name of the IRC server should match $ircServer below.
10 $ircServer = "irc.freenode.net";
12 # Set the below if this is running on a non-Wikimedia site:
13 #$serverName="your.site.here";
16 ini_set( "display_errors", 1 );
17 $wgCommandLineMode = true;
18 $optionsWithArgs = array( 'm' );
19 require_once("../maintenance/commandLine.inc" );
21 if ( !empty( $options['m'] ) ) {
22 $channel = $options['m'];
27 if ($lang == "commons") $site = "wikimedia";
30 $serverName="$lang.$site.org";
31 $newPageURLFirstPart="http://$serverName/wiki/";
32 $URLFirstPart="http://$serverName/w/wiki.phtml?title=";
34 $newPageURLFirstPart="http://$serverName$wgScript/";
35 $URLFirstPart="http://$serverName$wgScript?title=";
38 $wgTitle = Title
::newFromText( "RC dumper" );
39 $wgCommandLineMode = true;
42 if ( empty($options['b']) ) {
43 $bots = "AND NOT(rc_bot)";
48 if (isset($args[0]) && isset($args[1])) {
52 #$highest = $args[0][1];
56 $res = $dbr->query( "SELECT rc_timestamp FROM $recentchanges ORDER BY rc_timestamp DESC LIMIT 1" );
57 $row = $dbr->fetchObject( $res );
58 $oldTimestamp = $row->rc_timestamp
;
62 $res = $dbr->query( "SELECT * FROM $recentchanges WHERE rc_timestamp>'$oldTimestamp' ORDER BY rc_timestamp" );
64 while ( $row = $dbr->fetchObject( $res ) ) {
65 if ( ++
$serverCount %
20 == 0 ) {
66 print "/server $ircServer\n";
68 $ns = $wgLang->getNsText( $row->rc_namespace
) ;
70 $title = "$ns:{$row->rc_title}";
72 $title = $row->rc_title
;
74 /*if ( strlen( $row->rc_comment ) > 50 ) {
75 $comment = substr( $row->rc_comment, 0, 50 );
77 $comment = $row->rc_comment
;
79 $bad = array("\n", "\r");
80 $empty = array("", "");
81 $comment = str_replace($bad, $empty, $comment);
82 $title = str_replace($bad, $empty, $title);
84 if ($a < 'A' ||
$a > 'Z')
86 #if ((isset($highest)) && (($what == "<" && $a > "$highest") || ($what == ">" && $a <= "$highest")))
87 if ((isset($highest) && ($a > $highest)) ||
(isset($lowest) && $a <= $lowest))
89 $user = str_replace($bad, $empty, $row->rc_user_text
);
90 $lastid = IntVal($row->rc_last_oldid
);
91 $flag = ($row->rc_minor ?
"M" : "") . ($row->rc_new ?
"N" : "");
92 $stupid_urlencode = array("%2F", "%3A");
93 $haha_take_that = array("/", ":");
95 $url = $newPageURLFirstPart . urlencode($title);
97 $url = $URLFirstPart . urlencode($title) .
98 "&diff=0&oldid=$lastid";
100 $url = str_replace($stupid_urlencode, $haha_take_that, $url);
101 $title = str_replace("_", " ", $title);
102 # see http://www.irssi.org/?page=docs&doc=formats for some colour codes. prefix is \003,
103 # no colour (\003) switches back to the term default
104 $comment = preg_replace("/\/\* (.*) \*\/(.*)/", "\00315\$1\003 - \00310\$2\003", $comment);
105 $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
106 "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 \00310$comment\003\n";
108 $fullString = "$channel\t$fullString";
111 print( $fullString );
112 $oldTimestamp = $row->rc_timestamp
;