Index: branches/maintenance-work/maintenance/attribute.php |
— | — | @@ -1,106 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Script for re-attributing edits |
5 | | - * Use reassignEdits.php |
6 | | - * |
7 | | - * @file |
8 | | - * @ingroup Maintenance |
9 | | - */ |
10 | | - |
11 | | -/** */ |
12 | | -require_once( "commandLine.inc" ); |
13 | | - |
14 | | -# Parameters |
15 | | -if ( count( $args ) < 2 ) { |
16 | | - print "Not enough parameters\n"; |
17 | | - if ( $wgWikiFarm ) { |
18 | | - print "Usage: php attribute.php <language> <site> <source> <destination>\n"; |
19 | | - } else { |
20 | | - print "Usage: php attribute.php <source> <destination>\n"; |
21 | | - } |
22 | | - exit; |
23 | | -} |
24 | | - |
25 | | -$source = $args[0]; |
26 | | -$dest = $args[1]; |
27 | | - |
28 | | -$dbr = wfGetDB( DB_SLAVE ); |
29 | | -extract( $dbr->tableNames( 'page', 'revision','user' )); |
30 | | -$eSource = $dbr->strencode( $source ); |
31 | | -$eDest = $dbr->strencode( $dest ); |
32 | | - |
33 | | -# Get user id |
34 | | -$res = $dbr->query( "SELECT user_id FROM $user WHERE user_name='$eDest'" ); |
35 | | -$row = $dbr->fetchObject( $res ); |
36 | | -if ( !$row ) { |
37 | | - print "Warning: the target name \"$dest\" does not exist"; |
38 | | - $uid = 0; |
39 | | -} else { |
40 | | - $uid = $row->user_id; |
41 | | -} |
42 | | - |
43 | | -# Initialise files |
44 | | -$logfile = fopen( "attribute.log", "a" ); |
45 | | -$sqlfile = fopen( "attribute.sql", "a" ); |
46 | | - |
47 | | -fwrite( $logfile, "* $source → $dest\n" ); |
48 | | - |
49 | | -fwrite( $sqlfile, |
50 | | -"-- Changing attribution SQL file |
51 | | -"); |
52 | | - |
53 | | -$omitTitle = "Wikipedia:Changing_attribution_for_an_edit"; |
54 | | - |
55 | | -# Get revisions |
56 | | -print "\nPage revisions\n\n"; |
57 | | - |
58 | | -$res = $dbr->query( "SELECT page_namespace, page_title, rev_id, rev_timestamp |
59 | | -FROM $revision,$page |
60 | | -WHERE rev_user_text='$eSource' and rev_page=page_id" ); |
61 | | -$row = $dbr->fetchObject( $res ); |
62 | | - |
63 | | -if ( $row ) { |
64 | | -/* |
65 | | - if ( $row->old_title=='Votes_for_deletion' && $row->old_namespace == 4 ) { |
66 | | - # We don't have that long |
67 | | - break; |
68 | | - } |
69 | | -*/ |
70 | | - fwrite( $logfile, "**Revision IDs: " ); |
71 | | - fwrite( $sqlfile, "UPDATE $revision SET rev_user=$uid, rev_user_text='$eDest' WHERE rev_id IN (\n" ); |
72 | | - |
73 | | - for ( $first=true; $row; $row = $dbr->fetchObject( $res ) ) { |
74 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
75 | | - $fullTitle = $title->getPrefixedDbKey(); |
76 | | - if ( $fullTitle == $omitTitle ) { |
77 | | - continue; |
78 | | - } |
79 | | - |
80 | | - print "$fullTitle\n"; |
81 | | - $url = $title->getFullUrl( "oldid={$row->rev_id}" ); |
82 | | - |
83 | | - # Output |
84 | | - fwrite( $sqlfile, " " ); |
85 | | - if ( $first ) { |
86 | | - $first = false; |
87 | | - } else { |
88 | | - fwrite( $sqlfile, ", " ); |
89 | | - fwrite( $logfile, ", " ); |
90 | | - } |
91 | | - |
92 | | - fwrite( $sqlfile, "{$row->rev_id} -- $url\n" ); |
93 | | - fwrite( $logfile, "[$url {$row->rev_id}]" ); |
94 | | - |
95 | | - } |
96 | | - fwrite( $sqlfile, ");\n" ); |
97 | | - fwrite( $logfile, "\n" ); |
98 | | -} |
99 | | - |
100 | | -print "\n"; |
101 | | - |
102 | | -fclose( $sqlfile ); |
103 | | -fclose( $logfile ); |
104 | | - |
105 | | - |
Index: branches/maintenance-work/maintenance/apache-ampersand.diff |
— | — | @@ -1,53 +0,0 @@ |
2 | | -+++ apache_1.3.26/src/modules/standard/mod_rewrite.h Tue Oct 15 14:07:21 2002 |
3 | | -@@ -447,6 +447,7 @@ |
4 | | - static char *rewrite_mapfunc_toupper(request_rec *r, char *key); |
5 | | - static char *rewrite_mapfunc_tolower(request_rec *r, char *key); |
6 | | - static char *rewrite_mapfunc_escape(request_rec *r, char *key); |
7 | | -+static char *rewrite_mapfunc_ampescape(request_rec *r, char *key); |
8 | | - static char *rewrite_mapfunc_unescape(request_rec *r, char *key); |
9 | | - static char *select_random_value_part(request_rec *r, char *value); |
10 | | - static void rewrite_rand_init(void); |
11 | | -+++ apache_1.3.26/src/modules/standard/mod_rewrite.c Tue Oct 15 14:07:49 2002 |
12 | | -@@ -502,6 +502,9 @@ |
13 | | - else if (strcmp(a2+4, "unescape") == 0) { |
14 | | - new->func = rewrite_mapfunc_unescape; |
15 | | - } |
16 | | -+ else if (strcmp(a2+4, "ampescape") == 0) { |
17 | | -+ new->func = rewrite_mapfunc_ampescape; |
18 | | -+ } |
19 | | - else if (sconf->state == ENGINE_ENABLED) { |
20 | | - return ap_pstrcat(cmd->pool, "RewriteMap: internal map not found:", |
21 | | - a2+4, NULL); |
22 | | -@@ -2982,6 +2985,30 @@ |
23 | | - |
24 | | - value = ap_escape_uri(r->pool, key); |
25 | | - return value; |
26 | | -+} |
27 | | -+ |
28 | | -+static char *rewrite_mapfunc_ampescape(request_rec *r, char *key) |
29 | | -+{ |
30 | | -+ /* We only need to escape the ampersand */ |
31 | | -+ char *copy = ap_palloc(r->pool, 3 * strlen(key) + 3); |
32 | | -+ const unsigned char *s = (const unsigned char *)key; |
33 | | -+ unsigned char *d = (unsigned char *)copy; |
34 | | -+ unsigned c; |
35 | | -+ |
36 | | -+ while ((c = *s)) { |
37 | | -+ if (c == '&') { |
38 | | -+ *d++ = '%'; |
39 | | -+ *d++ = '2'; |
40 | | -+ *d++ = '6'; |
41 | | -+ } |
42 | | -+ else { |
43 | | -+ *d++ = c; |
44 | | -+ } |
45 | | -+ ++s; |
46 | | -+ } |
47 | | -+ *d = '\0'; |
48 | | -+ |
49 | | -+ return copy; |
50 | | - } |
51 | | - |
52 | | - static char *rewrite_mapfunc_unescape(request_rec *r, char *key) |
Index: branches/maintenance-work/maintenance/namespace2sql.php |
— | — | @@ -1,18 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Print SQL to insert namespace names into database. |
5 | | - * This source code is in the public domain. |
6 | | - * |
7 | | - * @file |
8 | | - * @ingroup Maintenance |
9 | | - */ |
10 | | - |
11 | | -require_once( "commandLine.inc" ); |
12 | | - |
13 | | -for ($i = -2; $i < 16; ++$i) { |
14 | | - $nsname = mysql_escape_string( $wgLang->getNsText( $i ) ); |
15 | | - $dbname = mysql_escape_string( $wgDBname ); |
16 | | - print "INSERT INTO ns_name(ns_db, ns_num, ns_name) VALUES('$dbname', $i, '$nsname');\n"; |
17 | | -} |
18 | | - |
19 | | - |
Index: branches/maintenance-work/maintenance/archives/upgradeWatchlist.php |
— | — | @@ -1,67 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * @file |
5 | | - * @deprecated |
6 | | - * @ingroup MaintenanceArchive |
7 | | - */ |
8 | | - |
9 | | -/** */ |
10 | | -print "This script is obsolete!"; |
11 | | -print "It is retained in the source here in case some of its |
12 | | -code might be useful for ad-hoc conversion tasks, but it is |
13 | | -not maintained and probably won't even work as is."; |
14 | | -exit(1); |
15 | | - |
16 | | -# Convert watchlists to new format |
17 | | - |
18 | | -global $IP; |
19 | | -require_once( "../LocalSettings.php" ); |
20 | | -require_once( "$IP/Setup.php" ); |
21 | | - |
22 | | -$wgTitle = Title::newFromText( "Rebuild links script" ); |
23 | | -set_time_limit(0); |
24 | | - |
25 | | -$wgDBuser = "wikiadmin"; |
26 | | -$wgDBpassword = $wgDBadminpassword; |
27 | | - |
28 | | -$sql = "DROP TABLE IF EXISTS watchlist"; |
29 | | -wfQuery( $sql, DB_MASTER ); |
30 | | -$sql = "CREATE TABLE watchlist ( |
31 | | - wl_user int(5) unsigned NOT NULL, |
32 | | - wl_page int(8) unsigned NOT NULL, |
33 | | - UNIQUE KEY (wl_user, wl_page) |
34 | | -) ENGINE=MyISAM PACK_KEYS=1"; |
35 | | -wfQuery( $sql, DB_MASTER ); |
36 | | - |
37 | | -$lc = new LinkCache; |
38 | | - |
39 | | -# Now, convert! |
40 | | -$sql = "SELECT user_id,user_watch FROM user"; |
41 | | -$res = wfQuery( $sql, DB_SLAVE ); |
42 | | -$nu = wfNumRows( $res ); |
43 | | -$sql = "INSERT into watchlist (wl_user,wl_page) VALUES "; |
44 | | -$i = $n = 0; |
45 | | -while( $row = wfFetchObject( $res ) ) { |
46 | | - $list = explode( "\n", $row->user_watch ); |
47 | | - $bits = array(); |
48 | | - foreach( $list as $title ) { |
49 | | - if( $id = $lc->addLink( $title ) and ! $bits[$id]++) { |
50 | | - $sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})"; |
51 | | - } |
52 | | - } |
53 | | - if( ($n++ % 100) == 0 ) echo "$n of $nu users done...\n"; |
54 | | -} |
55 | | -echo "$n users done.\n"; |
56 | | -if( $i ) { |
57 | | - wfQuery( $sql, DB_MASTER ); |
58 | | -} |
59 | | - |
60 | | - |
61 | | -# Add index |
62 | | -# is this necessary? |
63 | | -$sql = "ALTER TABLE watchlist |
64 | | - ADD INDEX wl_user (wl_user), |
65 | | - ADD INDEX wl_page (wl_page)"; |
66 | | -#wfQuery( $sql, DB_MASTER ); |
67 | | - |
68 | | - |