00001 <?php
00002 ini_set(
"display_errors", 1 );
00003
$wgCommandLineMode =
true;
00004 $fmB = chr(2);
00005 $fmU = chr(31);
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 require_once(
"../maintenance/liveCmdLine.inc" );
00039
00040 $wgTitle = Title::newFromText(
"RC dumper" );
00041 $wgCommandLineMode =
true;
00042 set_time_limit(0);
00043
00044 sleep(30);
00045
00046 $res =
wfQuery(
"SELECT rc_timestamp FROM recentchanges ORDER BY rc_timestamp DESC LIMIT 1", DB_READ );
00047 $row =
wfFetchObject( $res );
00048
$oldTimestamp =
$row->rc_timestamp;
00049 $serverCount = 0;
00050
00051
while (1) {
00052
$res =
wfQuery(
"SELECT * FROM recentchanges WHERE rc_timestamp>'$oldTimestamp' ORDER BY rc_timestamp",
DB_READ );
00053 $rowIndex = 0;
00054
while (
$row =
wfFetchObject( $res ) ) {
00055
if ( ++
$serverCount % 20 == 0 ) {
00056 print
"/server irc.freenode.net\n";
00057 }
00058 $ns =
$wgLang->getNsText( $row->rc_namespace ) ;
00059
if ( $ns ) {
00060
$title =
"$ns:{$row->rc_title}";
00061 }
else {
00062
$title =
$row->rc_title;
00063 }
00064
00065
00066
00067
$comment =
$row->rc_comment;
00068
00069 $bad = array(
"\n",
"\r");
00070 $empty = array(
"",
"");
00071 $comment = str_replace($bad, $empty, $comment);
00072 $title = str_replace($bad, $empty, $title);
00073 $user = str_replace($bad, $empty, $row->rc_user_text);
00074 $lastid = IntVal($row->rc_last_oldid);
00075 $flag = (
$row->rc_minor ?
"M" :
"") . (
$row->rc_new ?
"N" :
"");
00076
if (
$row->rc_new ) {
00077
$url =
"http://$lang.wikipedia.org/wiki/" . urlencode($
title);
00078 }
else {
00079
$url =
"http://$lang.wikipedia.org/w/wiki.phtml?title=" . urlencode($title) .
00080
"&diff=0&oldid=$lastid";
00081 }
00082 $boldTitle =
$fmB . str_replace(
"_",
" ", $title) .
$fmB;
00083
00084
if ( $patterns ) {
00085 foreach ( $patterns as $pattern ) {
00086
if ( preg_match( $pattern, $comment ) ) {
00087 print chr(7);
00088 break;
00089 }
00090 }
00091 }
00092
if (
$comment !==
"" ) {
00093
$comment =
"($comment)";
00094 }
00095
00096 $fullString =
"$boldTitle $flag $url $user $comment\n";
00097
00098
if (
$fullString{0} ==
"/" ) {
00099
$fullString =
" $fullString";
00100 }
00101 print( $fullString );
00102 $oldTimestamp =
$row->rc_timestamp;
00103 sleep(2);
00104 }
00105 sleep(5);
00106 }
00107
00108
exit();
00109
00110 ?>