Remove Special:Asksql; moving it out to an extension.
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 18 Feb 2005 12:22:28 +0000 (12:22 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 18 Feb 2005 12:22:28 +0000 (12:22 +0000)
config/index.php
includes/DefaultSettings.php
includes/SpecialAsksql.php [deleted file]
includes/SpecialPage.php
includes/SpecialSpecialpages.php
index.php

index 69e1d2e..e612bf3 100644 (file)
@@ -1065,16 +1065,6 @@ if ( \$wgCommandLineMode ) {
 \$wgDBpassword       = \"{$slconf['DBpassword']}\";
 \$wgDBprefix         = \"{$slconf['DBprefix']}\";
 
-## To allow SQL queries through the wiki's Special:Askaql page,
-## uncomment the next lines. THIS IS VERY INSECURE. If you want
-## to allow semipublic read-only SQL access for your sysops,
-## you should define a MySQL user with limited privileges.
-## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
-#
-# \$wgAllowSysopQueries = true;
-# \$wgDBsqluser        = \"sqluser\";
-# \$wgDBsqlpassword    = \"sqlpass\";
-
 # If you're on MySQL 3.x, this next line must be FALSE:
 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
 
index 36387f0..e7d619e 100644 (file)
@@ -259,16 +259,6 @@ $wgDBservers               = false;
 /** How long to wait for a slave to catch up to the master */ 
 $wgMasterWaitTimeout = 10;
 
-# Sysop SQL queries
-#   The sql user shouldn't have too many rights other the database, restrict
-#   it to SELECT only on 'page', 'revision' and 'text' tables for example
-#
-/** Dangerous if not configured properly. */
-$wgAllowSysopQueries = false;
-$wgDBsqluser = 'sqluser';
-$wgDBsqlpassword = 'sqlpass';
-$wgDBpassword = 'userpass';
-$wgSqlLogFile = "{$wgUploadDirectory}/sqllog_mFhyRe6";
 /** File to log MySQL errors to */
 $wgDBerrorLog          = false;
 
diff --git a/includes/SpecialAsksql.php b/includes/SpecialAsksql.php
deleted file mode 100644 (file)
index 02f6d01..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * If enabled through $wgAllowSysopQueries = true, this class
- * let users with sysop right the possibility to make sql queries
- * against the cur table.
- * Heavy queries could slow down the database specially for the
- * biggest wikis.
- *
- * @package MediaWiki
- * @subpackage SpecialPage
- */
-
-/**
- *
- */
-function wfSpecialAsksql() {
-       global $wgUser, $wgOut, $wgRequest, $wgAllowSysopQueries;
-
-       if( !$wgAllowSysopQueries ) {
-               $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' );
-               return;
-       }
-       if( !$wgUser->isAllowed('asksql') ) {
-               $wgOut->sysopRequired();
-               return;
-       }
-       
-       if( $wgRequest->wasPosted() ) {
-               $query = $wgRequest->getVal( 'wpSqlQuery' );
-               $action = $wgRequest->getVal( 'action' );
-       } else {
-               $query = '';
-               $action = '';
-       }
-       $f = new SqlQueryForm( $query);
-
-       if ( "submit" == $action ) {
-               $f->doSubmit();
-       } else {
-               $f->showForm( '' );
-       }
-}
-
-/**
- * @access private
- * @package MediaWiki
- * @subpackage SpecialPage
- */
-class SqlQueryForm {
-       var $query = '';
-       
-       function SqlQueryForm( $query ) {
-               $this->query = $query;
-       }
-               
-       function showForm( $err ) {
-               global $wgOut, $wgUser, $wgLang;
-               global $wgLogQueries;
-
-               $wgOut->setPagetitle( wfMsg( 'asksql' ) );
-               $note = wfMsg( 'asksqltext' );
-               if($wgLogQueries)
-                       $note .= ' ' . wfMsg( 'sqlislogged' );
-               $wgOut->addWikiText( $note );
-
-               if ( '' != $err ) {
-                       $wgOut->addHTML( '<p><font color="red" size="+1">' . htmlspecialchars($err) . "</font>\n" );
-               }
-               if ( ! $this->query ) { $this->query = 'SELECT ... FROM ... WHERE ...'; }
-               $q = wfMsg( 'sqlquery' );
-               $qb = wfMsg( 'querybtn' );
-               $titleObj = Title::makeTitle( NS_SPECIAL, 'Asksql' );
-               $action = $titleObj->escapeLocalURL( 'action=submit' );
-
-               $wgOut->addHTML( "<p>
-<form id=\"asksql\" method=\"post\" action=\"{$action}\">
-<table border=0><tr>
-<td align=right>{$q}:</td>
-<td align=left>
-<textarea name=\"wpSqlQuery\" cols=80 rows=4 wrap=\"virtual\">"
-. htmlspecialchars($this->query) ."
-</textarea>
-</td>
-</tr><tr>
-<td>&nbsp;</td><td align=\"left\">
-<input type=submit name=\"wpQueryBtn\" value=\"{$qb}\">
-</td></tr></table>
-</form>\n" );
-
-       }
-
-       function doSubmit() {
-               global $wgOut, $wgUser, $wgServer, $wgScript, $wgArticlePath, $wgLang, $wgContLang;
-               global $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname, $wgSqlTimeout;
-
-               # Use a limit, folks!
-               $this->query = trim( $this->query );
-               if( preg_match( '/^SELECT/i', $this->query )
-                       and !preg_match( '/LIMIT/i', $this->query ) ) {
-                       $this->query .= ' LIMIT 100';
-               }
-               $conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
-
-               $this->logQuery( $this->query );
-
-               # Start timer, will kill the DB thread in $wgSqlTimeout seconds
-               $conn->startTimer( $wgSqlTimeout );
-               $res = $conn->query( $this->query, 'SpecialAsksql::doSubmit' );
-               $conn->stopTimer();
-               $this->logFinishedQuery();
-
-               $n = 0;
-               @$n = $conn->numFields( $res );
-               $titleList = false;
-
-               if ( $n ) {
-                       $k = array();
-                       for ( $x = 0; $x < $n; ++$x ) {
-                               array_push( $k, $conn->fieldName( $res, $x ) );
-                       }
-
-                       if ( $n == 2 && in_array( 'page_title', $k ) && in_array( 'page_namespace', $k ) ) {
-                               $titleList = true;
-                       }
-
-                       $a = array();
-                       while ( $s = $conn->fetchObject( $res ) ) {
-                               array_push( $a, $s );
-                       }
-                       $conn->freeResult( $res );
-
-                       if ( $titleList ) {
-                               $r = "";
-                               foreach ( $a as $y ) {
-                                       $sTitle = htmlspecialchars( $y->page_title );
-                                       if ( $y->page_namespace ) {
-                                               $sNamespace = $wgContLang->getNsText( $y->page_namespace );
-                                               $link = "$sNamespace:$sTitle";
-                                       } else {
-                                               $link = "$sTitle";
-                                       }
-                                       $skin = $wgUser->getSkin();
-                                       $link = $skin->makeLink( $link );
-                                       $r .= "* [[$link]]<br />\n";    
-                               }
-                       } else {
-
-                               $r = "<table border=1 bordercolor=black cellspacing=0 " .
-                                 "cellpadding=2><tr>\n";
-                               foreach ( $k as $x ) $r .= "<th>" . htmlspecialchars( $x ) . "</th>";
-                               $r .= "</tr>\n";
-
-                               foreach ( $a as $y ) {
-                                       $r .= '<tr>';
-                                       foreach ( $k as $x ) {
-                                               $o = $y->$x ;
-                                               if ( $x == 'page_title'  or $x == 'rc_title') {
-                                                       $namespace = 0;
-                                                       if( $x == 'page_title' && isset( $y->page_namespace ) ) $namespace = $y->page_namespace;
-                                                       if( $x == 'rc_title' && isset( $y->rc_namespace ) ) $namespace = $y->rc_namespace;
-                                                       $title =& Title::makeTitle( $namespace, $o );
-                                                       $o = "<a href=\"" . $title->escapeLocalUrl() . "\" class='internal'>" .
-                                                         htmlspecialchars( $y->$x ) . '</a>' ;
-                                               } else {
-                                                       $o = htmlspecialchars( $o );
-                                               }
-                                               $r .= '<td>' . $o . "</td>\n";
-                                       }
-                                       $r .= "</tr>\n";
-                               }
-                               $r .= "</table>\n";
-                       }
-               }
-               $this->showForm( wfMsg( "querysuccessful" ) );
-               $wgOut->addHTML( "<hr>{$r}\n" );
-       }
-
-       function logQuery( $q ) {
-               global $wgSqlLogFile, $wgLogQueries, $wgUser;
-               if(!$wgLogQueries) return;
-               
-               $f = fopen( $wgSqlLogFile, 'a' );
-               fputs( $f, "\n\n" . wfTimestampNow() .
-                       " query by " . $wgUser->getName() .
-                       ":\n$q\n" );
-               fclose( $f );
-               $this->starttime = wfTime();
-       }
-       
-       function logFinishedQuery() {
-               global $wgSqlLogFile, $wgLogQueries;
-               if(!$wgLogQueries) return;
-               
-               $interval = wfTime() - $this->starttime;
-               
-               $f = fopen( $wgSqlLogFile, 'a' );
-               fputs( $f, 'finished at ' . wfTimestampNow() . "; took $interval secs\n" );
-               fclose( $f );
-       }
-
-}
-
-?>
index 17f24a3..25a6471 100644 (file)
@@ -85,7 +85,6 @@ $wgSpecialPages = array_merge($wgSpecialPages, array (
        'Allmessages'   => new SpecialPage( 'Allmessages' ),
        'Log'           => new SpecialPage( 'Log' ),
        'Blockip'               => new SpecialPage( 'Blockip', 'block' ),
-       'Asksql'                => new SpecialPage( 'Asksql', 'asksql' ),
        'Undelete'              => new SpecialPage( 'Undelete', 'delete' ),
        // Makesysop is obsolete, replaced by Special:Userlevels [av]
        # 'Makesysop'           => new SpecialPage( 'Makesysop', 'userrights' ),
index bc59328..677ed31 100644 (file)
@@ -58,7 +58,7 @@ from language files [av] */
  * @param $sk skin object ???
  */
 function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
-       global $wgLang, $wgOut, $wgAllowSysopQueries;
+       global $wgLang, $wgOut;
 
        $wgOut->addHTML( '<h2>' . wfMsg( $heading ) . "</h2>\n<ul>" );
        foreach ( $pages as $name => $page ) {
index 2c21a5a..26bacbf 100644 (file)
--- a/index.php
+++ b/index.php
@@ -87,7 +87,6 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
        # actions that need to be made when we have a special pages
        require_once( 'includes/SpecialPage.php' );
-       if ( !$wgAllowSysopQueries ) {SpecialPage::removePage( 'Asksql' ); }
        SpecialPage::executePath( $wgTitle );
 } else {
        if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {