Index: trunk/extensions/Asksql/Asksql_body.php |
— | — | @@ -1,6 +1,5 @@ |
2 | 2 | <?php |
3 | | - |
4 | | -if (!defined('MEDIAWIKI')) { |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
5 | 4 | exit; |
6 | 5 | } |
7 | 6 | |
— | — | @@ -16,23 +15,23 @@ |
17 | 16 | |
18 | 17 | wfLoadExtensionMessages( 'Asksql' ); |
19 | 18 | |
20 | | - if( !$wgAllowSysopQueries ) { |
| 19 | + if ( !$wgAllowSysopQueries ) { |
21 | 20 | $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' ); |
22 | 21 | return; |
23 | 22 | } |
24 | | - if( !$wgUser->isAllowed('asksql') ) { |
| 23 | + if ( !$wgUser->isAllowed( 'asksql' ) ) { |
25 | 24 | $wgOut->permissionRequired( 'asksql' ); |
26 | 25 | return; |
27 | 26 | } |
28 | 27 | |
29 | | - if( $wgRequest->wasPosted() ) { |
| 28 | + if ( $wgRequest->wasPosted() ) { |
30 | 29 | $query = $wgRequest->getVal( 'wpSqlQuery' ); |
31 | 30 | $action = $wgRequest->getVal( 'action' ); |
32 | 31 | } else { |
33 | 32 | $query = ''; |
34 | 33 | $action = ''; |
35 | 34 | } |
36 | | - $f = new SqlQueryForm( $query); |
| 35 | + $f = new SqlQueryForm( $query ); |
37 | 36 | |
38 | 37 | if ( "submit" == $action ) { |
39 | 38 | $f->doSubmit(); |
— | — | @@ -59,12 +58,12 @@ |
60 | 59 | |
61 | 60 | $wgOut->setPagetitle( wfMsg( 'asksql' ) ); |
62 | 61 | $note = wfMsg( 'asksqltext' ); |
63 | | - if($wgLogQueries) |
| 62 | + if ( $wgLogQueries ) |
64 | 63 | $note .= ' ' . wfMsg( 'sqlislogged' ); |
65 | 64 | $wgOut->addWikiText( $note ); |
66 | 65 | |
67 | 66 | if ( '' != $err ) { |
68 | | - $wgOut->addHTML( '<p><font color="red" size="+1">' . htmlspecialchars($err) . "</font>\n" ); |
| 67 | + $wgOut->addHTML( '<p><font color="red" size="+1">' . htmlspecialchars( $err ) . "</font>\n" ); |
69 | 68 | } |
70 | 69 | if ( ! $this->query ) { $this->query = 'SELECT ... FROM ... WHERE ...'; } |
71 | 70 | $q = wfMsg( 'sqlquery' ); |
— | — | @@ -76,7 +75,7 @@ |
77 | 76 | <form id=\"asksql\" method=\"post\" action=\"{$action}\"> |
78 | 77 | <p>{$q}:</p> |
79 | 78 | <textarea name=\"wpSqlQuery\" cols='80' rows='4' tabindex='1' style='width:100%'>" |
80 | | -. htmlspecialchars($this->query) ." |
| 79 | +. htmlspecialchars( $this->query ) . " |
81 | 80 | </textarea> |
82 | 81 | <p><input type=submit name=\"wpQueryBtn\" value=\"{$qb}\"></p> |
83 | 82 | </form>\n" ); |
— | — | @@ -89,7 +88,7 @@ |
90 | 89 | |
91 | 90 | # Use a limit, folks! |
92 | 91 | $this->query = trim( $this->query ); |
93 | | - if( preg_match( '/^SELECT/i', $this->query ) |
| 92 | + if ( preg_match( '/^SELECT/i', $this->query ) |
94 | 93 | and !preg_match( '/LIMIT/i', $this->query ) ) { |
95 | 94 | $this->query .= ' LIMIT 100'; |
96 | 95 | } |
— | — | @@ -99,9 +98,9 @@ |
100 | 99 | |
101 | 100 | # Start timer, will kill the DB thread in $wgSqlTimeout seconds |
102 | 101 | # FIXME: timer functions needed! |
103 | | - #$conn->startTimer( $wgSqlTimeout ); |
| 102 | + # $conn->startTimer( $wgSqlTimeout ); |
104 | 103 | $res = $conn->query( $this->query, 'SpecialAsksql::doSubmit' ); |
105 | | - #$conn->stopTimer(); |
| 104 | + # $conn->stopTimer(); |
106 | 105 | $this->logFinishedQuery(); |
107 | 106 | |
108 | 107 | $n = 0; |
— | — | @@ -149,10 +148,10 @@ |
150 | 149 | $r .= '<tr>'; |
151 | 150 | foreach ( $k as $x ) { |
152 | 151 | $o = $y->$x ; |
153 | | - if ( $x == 'page_title' or $x == 'rc_title') { |
| 152 | + if ( $x == 'page_title' or $x == 'rc_title' ) { |
154 | 153 | $namespace = 0; |
155 | | - if( $x == 'page_title' && isset( $y->page_namespace ) ) $namespace = $y->page_namespace; |
156 | | - if( $x == 'rc_title' && isset( $y->rc_namespace ) ) $namespace = $y->rc_namespace; |
| 154 | + if ( $x == 'page_title' && isset( $y->page_namespace ) ) $namespace = $y->page_namespace; |
| 155 | + if ( $x == 'rc_title' && isset( $y->rc_namespace ) ) $namespace = $y->rc_namespace; |
157 | 156 | $title =& Title::makeTitle( $namespace, $o ); |
158 | 157 | $o = "<a href=\"" . $title->escapeLocalUrl() . "\" class='internal'>" . |
159 | 158 | htmlspecialchars( $y->$x ) . '</a>' ; |
— | — | @@ -172,7 +171,7 @@ |
173 | 172 | |
174 | 173 | function logQuery( $q ) { |
175 | 174 | global $wgSqlLogFile, $wgLogQueries, $wgUser; |
176 | | - if(!$wgLogQueries) return; |
| 175 | + if ( !$wgLogQueries ) return; |
177 | 176 | |
178 | 177 | $f = fopen( $wgSqlLogFile, 'a' ); |
179 | 178 | fputs( $f, "\n\n" . wfTimestampNow() . |
— | — | @@ -184,7 +183,7 @@ |
185 | 184 | |
186 | 185 | function logFinishedQuery() { |
187 | 186 | global $wgSqlLogFile, $wgLogQueries; |
188 | | - if(!$wgLogQueries) return; |
| 187 | + if ( !$wgLogQueries ) return; |
189 | 188 | |
190 | 189 | $interval = wfTime() - $this->starttime; |
191 | 190 | |
Index: trunk/extensions/Asksql/Asksql.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @addtogroup SpecialPage |
13 | 13 | */ |
14 | 14 | |
15 | | -if (!defined('MEDIAWIKI')) |
| 15 | +if ( !defined( 'MEDIAWIKI' ) ) |
16 | 16 | exit; |
17 | 17 | |
18 | 18 | $wgExtensionCredits['specialpage'][] = array( |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | $wgSqlLogFile = "{$wgUploadDirectory}/sqllog_mFhyRe6"; |
38 | 38 | $wgAvailableRights[] = 'asksql'; |
39 | 39 | |
40 | | -$dir = dirname(__FILE__) . '/'; |
| 40 | +$dir = dirname( __FILE__ ) . '/'; |
41 | 41 | $wgExtensionMessagesFiles['Asksql'] = $dir . 'Asksql.i18n.php'; |
42 | 42 | $wgExtensionAliasesFiles['Asksql'] = $dir . 'Asksql.alias.php'; |
43 | 43 | $wgAutoloadClasses['SpecialAsksql'] = $dir . 'Asksql_body.php'; |