Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

rcdumper.php

Go to the documentation of this file.
00001 <?php 00002 ini_set( "display_errors", 1 ); 00003 $wgCommandLineMode = true; 00004 $fmB = chr(2); 00005 $fmU = chr(31); 00006 /* 00007 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":"; 00008 if ( $argv[1] ) { 00009 $lang = $argv[1]; 00010 $site = "wikipedia"; 00011 putenv( "wikilang=$lang"); 00012 $settingsFile = "/apache/htdocs/{$argv[1]}/w/LocalSettings.php"; 00013 $newpath = "/apache/common/php$sep"; 00014 } else { 00015 $settingsFile = "../LocalSettings.php"; 00016 $newpath = ""; 00017 } 00018 00019 if ( $argv[2] ) { 00020 $patterns = explode( ",", $argv[2]); 00021 } else { 00022 $patterns = false; 00023 } 00024 00025 if ( ! is_readable( $settingsFile ) ) { 00026 print "A copy of your installation's LocalSettings.php\n" . 00027 "must exist in the source directory.\n"; 00028 exit(); 00029 } 00030 00031 ini_set( "include_path", "$newpath$IP$sep$include_path" ); 00032 00033 $wgCommandLineMode = true; 00034 $DP = "../includes"; 00035 include_once( $settingsFile ); 00036 include_once( "Setup.php" );*/ 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 /*if ( strlen( $row->rc_comment ) > 50 ) { 00065 $comment = substr( $row->rc_comment, 0, 50 ); 00066 } else {*/ 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 ?>

Generated on Tue Jun 29 23:40:06 2004 for Mediawiki by doxygen 1.3.7