tableName( 'recentchanges' );
$result =& $dbw->safeQuery( "SELECT * FROM $recentchanges WHERE rc_timestamp >= "
. $dbw->timestamp( $start ) . ' ORDER BY rc_timestamp');
global $wgInputEncoding;
echo '<' . '?xml version="1.0" encoding="' . $wgInputEncoding . '" ?' . ">\n";
echo "\n";
echo "\n";
while( $row = $dbw->fetchObject( $result ) ) {
echo dumpReplayEntry( $row );
}
echo "\n";
$dbw->freeResult( $result );
}
/** */
function dumpReplayEntry( $row ) {
$title = Title::MakeTitle( $row->rc_namespace, $row->rc_title );
switch( $row->rc_type ) {
case RC_EDIT:
case RC_NEW:
# Edit
$dbr =& wfGetDB( DB_MASTER );
$out = " \n";
$out .= " " . xmlsafe( $title->getPrefixedText() ) . "\n";
# Get previous edit timestamp
if( $row->rc_last_oldid ) {
$s = $dbr->selectRow( 'old',
array( 'old_timestamp' ),
array( 'old_id' => $row->rc_last_oldid ) );
$out .= " " . wfTimestamp2ISO8601( $s->old_timestamp ) . "\n";
} else {
$out .= " \n";
}
if( $row->rc_this_oldid ) {
$s = $dbr->selectRow( 'old', array( 'old_id as id','old_timestamp as timestamp',
'old_user as user', 'old_user_text as user_text', 'old_comment as comment',
'old_text as text', 'old_flags as flags' ),
array( 'old_id' => $row->rc_this_oldid ) );
$out .= revision2xml( $s, true, false );
} else {
$s = $dbr->selectRow( 'cur', array( 'cur_id as id','cur_timestamp as timestamp','cur_user as user',
'cur_user_text as user_text', 'cur_restrictions as restrictions','cur_comment as comment',
'cur_text as text' ),
array( 'cur_id' => $row->rc_cur_id ) );
$out .= revision2xml( $s, true, true );
}
$out .= " \n";
break;
case RC_LOG:
$dbr =& wfGetDB( DB_MASTER );
$s = $dbr->selectRow( 'logging',
array( 'log_type', 'log_action', 'log_timestamp', 'log_user',
'log_namespace', 'log_title', 'log_comment' ),
array( 'log_timestamp' => $row->rc_timestamp,
'log_user' => $row->rc_user ) );
$ts = wfTimestamp2ISO8601( $row->rc_timestamp );
$target = Title::MakeTitle( $s->log_namespace, $s->log_title );
$out = " \n";
$out .= " " . xmlsafe( $s->log_type ) . "\n";
$out .= " " . xmlsafe( $s->log_action ) . "\n";
$out .= " " . $ts . "\n";
$out .= " " . xmlsafe( $row->rc_user_text ) . "\n";
$out .= " " . xmlsafe( $target->getPrefixedText() ) . "\n";
$out .= " " . xmlsafe( $s->log_comment ) . "\n";
$out .= " \n";
break;
case RC_MOVE:
case RC_MOVE_OVER_REDIRECT:
$target = Title::MakeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
$out = " \n";
$out .= " " . xmlsafe( $title->getPrefixedText() ) . "\n";
$out .= " " . xmlsafe( $target->getPrefixedText() ) . "\n";
if( $row->rc_type == RC_MOVE_OVER_REDIRECT ) {
$out .= " \n";
}
$ts = wfTimestamp2ISO8601( $row->rc_timestamp );
$out .= " $row->rc_cur_id\n";
$out .= " $ts\n";
if($row->rc_user_text) {
$u = "" . xmlsafe( $row->rc_user_text ) . "";
$u .= "$row->rc_user";
} else {
$u = "" . xmlsafe( $row->rc_user_text ) . "";
}
$out .= " $u\n";
$out .= " \n";
}
return $out;
}
if( isset( $options['start'] ) ) {
$start = wfTimestamp( TS_MW, $options['start'] );
dumpReplayLog( $start );
} else {
echo "This is an experimental script to encapsulate data from recent edits.\n";
echo "Usage: php dumpReplayLog.php --start=20050118032544\n";
}
?>