Index: trunk/phpwiki/newcodebase/maintenance/buildusers.sql |
— | — | @@ -1,9 +1,11 @@ |
2 | 2 | # MySQL script to create required database users |
3 | 3 | # with proper access rights. Must be run as root! |
4 | | -# Replace "wikidb", "adminpass", and "userpass" |
| 4 | +# Replace "wikidb", "adminpass", "sqlpass", "userpass" |
5 | 5 | # with your local settings. |
6 | 6 | # |
| 7 | +# FIXME: this script should be more automated |
7 | 8 | |
| 9 | + |
8 | 10 | GRANT ALL ON wikidb.* |
9 | 11 | TO wikiadmin@'%' IDENTIFIED BY 'adminpass'; |
10 | 12 | GRANT ALL ON wikidb.* |
— | — | @@ -17,3 +19,57 @@ |
18 | 20 | TO wikiuser@localhost IDENTIFIED BY 'userpass'; |
19 | 21 | GRANT DELETE,INSERT,SELECT,UPDATE ON wikidb.* |
20 | 22 | TO wikiuser@localhost.localdomain IDENTIFIED BY 'userpass'; |
| 23 | + |
| 24 | +# wikisql user is for direct sql queries by sysops |
| 25 | +# We don't want to give out e-mails or passwords on |
| 26 | +# a public site where sysops are only _mostly_ trusted. |
| 27 | +GRANT SELECT (user_id,user_name,user_rights,user_options,user_newtalk) on wikidb.user |
| 28 | +TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 29 | +GRANT SELECT on wikidb.cur TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 30 | +GRANT SELECT on wikidb.old TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 31 | +GRANT SELECT on wikidb.archive TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 32 | +GRANT SELECT on wikidb.links TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 33 | +GRANT SELECT on wikidb.brokenlinks TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 34 | +GRANT SELECT on wikidb.imagelinks TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 35 | +GRANT SELECT on wikidb.site_stats TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 36 | +GRANT SELECT on wikidb.ipblocks TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 37 | +GRANT SELECT on wikidb.image TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 38 | +GRANT SELECT on wikidb.oldimage TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 39 | +GRANT SELECT on wikidb.random TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 40 | +GRANT SELECT on wikidb.recentchanges TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 41 | +GRANT SELECT on wikidb.watchlist TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 42 | +GRANT SELECT on wikidb.math TO wikisql@'%' IDENTIFIED BY 'sqlpass'; |
| 43 | + |
| 44 | +GRANT SELECT (user_id,user_name,user_rights,user_options,user_newtalk) on wikidb.user |
| 45 | +TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 46 | +GRANT SELECT on wikidb.cur TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 47 | +GRANT SELECT on wikidb.old TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 48 | +GRANT SELECT on wikidb.archive TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 49 | +GRANT SELECT on wikidb.links TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 50 | +GRANT SELECT on wikidb.brokenlinks TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 51 | +GRANT SELECT on wikidb.imagelinks TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 52 | +GRANT SELECT on wikidb.site_stats TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 53 | +GRANT SELECT on wikidb.ipblocks TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 54 | +GRANT SELECT on wikidb.image TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 55 | +GRANT SELECT on wikidb.oldimage TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 56 | +GRANT SELECT on wikidb.random TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 57 | +GRANT SELECT on wikidb.recentchanges TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 58 | +GRANT SELECT on wikidb.watchlist TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 59 | +GRANT SELECT on wikidb.math TO wikisql@localhost IDENTIFIED BY 'sqlpass'; |
| 60 | + |
| 61 | +GRANT SELECT (user_id,user_name,user_rights,user_options,user_newtalk) on wikidb.user |
| 62 | +TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 63 | +GRANT SELECT on wikidb.cur TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 64 | +GRANT SELECT on wikidb.old TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 65 | +GRANT SELECT on wikidb.archive TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 66 | +GRANT SELECT on wikidb.links TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 67 | +GRANT SELECT on wikidb.brokenlinks TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 68 | +GRANT SELECT on wikidb.imagelinks TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 69 | +GRANT SELECT on wikidb.site_stats TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 70 | +GRANT SELECT on wikidb.ipblocks TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 71 | +GRANT SELECT on wikidb.image TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 72 | +GRANT SELECT on wikidb.oldimage TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 73 | +GRANT SELECT on wikidb.random TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 74 | +GRANT SELECT on wikidb.recentchanges TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 75 | +GRANT SELECT on wikidb.watchlist TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
| 76 | +GRANT SELECT on wikidb.math TO wikisql@localhost.localdomain IDENTIFIED BY 'sqlpass'; |
Index: trunk/phpwiki/newcodebase/SpecialAsksql.php |
— | — | @@ -54,13 +54,15 @@ |
55 | 55 | { |
56 | 56 | global $wgOut, $wgUser, $wgServer, $wgScript, $wgArticlePath; |
57 | 57 | global $wpSqlQuery; |
| 58 | + global $wgDBsqluser, $wgDBsqlpassword; |
58 | 59 | |
59 | 60 | if ( ! $wgUser->isDeveloper() ) { |
60 | | - if ( 0 != strcmp( "select", strtolower( |
61 | | - substr( $wpSqlQuery, 0, 6 ) ) ) ) { |
62 | | - $this->showForm( wfMsg( "selectonly" ) ); |
63 | | - return; |
64 | | - } |
| 61 | + #if ( 0 != strcmp( "select", strtolower( |
| 62 | + # substr( $wpSqlQuery, 0, 6 ) ) ) ) { |
| 63 | + # $this->showForm( wfMsg( "selectonly" ) ); |
| 64 | + # return; |
| 65 | + #} |
| 66 | + $connection = wfGetDB( $wgDBsqluser, $wgDBsqlpassword ); |
65 | 67 | } |
66 | 68 | $res = wfQuery( $wpSqlQuery, "SpecialAsksql::doSubmit" ); |
67 | 69 | |
Index: trunk/phpwiki/newcodebase/LocalSettings.php |
— | — | @@ -24,8 +24,9 @@ |
25 | 25 | $wgDBname = "wikidb"; |
26 | 26 | $wgDBuser = "wikiuser"; |
27 | 27 | $wgDBpassword = "userpass"; |
28 | | -$wgDBadminpassword = "adminpass"; |
29 | | -$wgDBminWordLen = 3; |
| 28 | +$wgDBadminpassword = "adminpass"; # Only needed for admin works |
| 29 | +$wgDBsqluser = "sqlpass"; # For read-only sql queries by sysops |
| 30 | +$wgDBminWordLen = 3; # Match this to your MySQL fulltext |
30 | 31 | |
31 | 32 | # Turn this on during database maintenance |
32 | 33 | # |
Index: trunk/phpwiki/newcodebase/DefaultSettings.php |
— | — | @@ -22,6 +22,8 @@ |
23 | 23 | $wgDBuser = "wikiuser"; |
24 | 24 | $wgDBpassword = "userpwd"; |
25 | 25 | $wgDBconnection = ""; |
| 26 | +$wgDBsqluser = "wikisql"; |
| 27 | +$wgDBsqlpassword = "sqlpass"; |
26 | 28 | |
27 | 29 | $wgReadOnlyFile = "/usr/local/apache/htdocs/upload/dblockflag838942"; |
28 | 30 | $wgDebugComments = false; |
Index: trunk/phpwiki/newcodebase/DatabaseFunctions.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | |
6 | 6 | $wgLastDatabaseQuery = ""; |
7 | 7 | |
8 | | -function wfGetDB() |
| 8 | +function wfGetDB( $altuser = "", $altpassword = "" ) |
9 | 9 | { |
10 | 10 | global $wgDBserver, $wgDBuser, $wgDBpassword; |
11 | 11 | global $wgDBname, $wgDBconnection; |
— | — | @@ -14,6 +14,13 @@ |
15 | 15 | $helpme = "\n<p>If this error persists after reloading and clearing your browser cache, |
16 | 16 | please notify the <a href=\"mailto:wikidown@bomis.com\">Wikipedia developers</a>.</p>"; |
17 | 17 | |
| 18 | + if ( $altuser != "" ) { |
| 19 | + $wgDBconnection = mysql_connect( $wgDBserver, $altuser, $altpassword ) |
| 20 | + or die( "bad sql user" ); |
| 21 | + mysql_select_db( $wgDBname, $wgDBconnection ) or die( |
| 22 | + htmlspecialchars(mysql_error()) ); |
| 23 | + } |
| 24 | + |
18 | 25 | if ( ! $wgDBconnection ) { |
19 | 26 | $wgDBconnection = mysql_pconnect( $wgDBserver, $wgDBuser, |
20 | 27 | $wgDBpassword ) or die( $noconn . |