r77390 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77389‎ | r77390 | r77391 >
Date:15:58, 28 November 2010
Author:kipcool
Status:deferred
Tags:
Comment:
no longer needed: replaced by SpecialOWStatistics.php
Modified paths:
  • /trunk/extensions/Wikidata/util/stats.php (deleted) (history)
  • /trunk/extensions/Wikidata/util/stats.png (deleted) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/util/stats.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Index: trunk/extensions/Wikidata/util/stats.php
@@ -1,141 +0,0 @@
2 -<?php
3 -die( "Unsafe script -- no error checking, may be vulnerable to attacks." );
4 -header( "Content-type: text/html; charset=UTF-8" );
5 -
6 -define( 'MEDIAWIKI', true );
7 -include_once( "../../../includes/Defines.php" );
8 -include_once( "../../../LocalSettings.php" );
9 -global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname;
10 -
11 -$db1 = $wgDBserver; # hostname
12 -$db2 = $wgDBuser; # user
13 -$db3 = $wgDBpassword; # pass
14 -$db4 = $wgDBname; # db-name
15 -
16 -$connection = MySQL_connect( $db1, $db2, $db3 );
17 -if ( !$connection )die( "Cannot connect to SQL server. Try again later." );
18 -MySQL_select_db( $db4 ) or die( "Cannot open database" );
19 -mysql_query( "SET NAMES 'utf8'" );
20 -
21 -echo "
22 -<style type=\"text/css\"><!--
23 -body {font-family:arial,sans-serif}
24 -";
25 -
26 -function stopwatch() {
27 - list( $usec, $sec ) = explode( " ", microtime() );
28 - return ( (float)$usec + (float)$sec );
29 -}
30 -
31 -$start = stopwatch();
32 -
33 -// finds the number of DMs.
34 -$defined_meanings_r = mysql_query( "SELECT COUNT(DISTINCT defined_meaning_id) FROM uw_syntrans WHERE remove_transaction_id IS NULL" );
35 -$defined_meanings_a = mysql_fetch_row( $defined_meanings_r );
36 -$defined_meanings = $defined_meanings_a[0];
37 -// The number of expressions is computed below as the sum of the number of expressions in each language, instead of a SQL query.
38 -
39 -// finds the list of languages with their English names
40 -$result = mysql_query( "SELECT *
41 -FROM language_names
42 -where name_language_id = 85
43 -" ) or die ( "error " . mysql_error() );
44 -
45 -while ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) {
46 - $lang[$row[0]] = $row[2];
47 -}
48 -
49 -
50 -// //////////////////////////////////////////////////////
51 -$result = mysql_query( "
52 -SELECT
53 -language_id, count(*) as tot
54 -FROM uw_expression
55 -WHERE expression_id IN
56 -(
57 - SELECT DISTINCT expression_id
58 - FROM uw_syntrans
59 - WHERE remove_transaction_id IS NULL
60 -)
61 -AND remove_transaction_id IS NULL
62 -group by language_id
63 -order by tot desc
64 - " ) or die ( "error " . mysql_error() );
65 -
66 -$width = 500;
67 -$limit = 500;
68 -$max = 0;
69 -$total = 0 ;
70 -$nblang = 0 ;
71 -while ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) {
72 - if ( $max < $row[1] )$max = $row[1];
73 - $wi = ceil( ( ( $row[1] / $max ) * $width ) );
74 - $per = ceil( ( ( $row[1] / $max ) * 100 ) );
75 - $total += $row[1] ;
76 - $nblang++ ;
77 - if ( $row[1] > $limit ) {
78 - $tableLang .= "<tr><td >" . $lang[$row[0]] . '</td><td align="right">' . $row[1] . "</td><td width=30></td><td><img src=sc1.png width=\"$wi\" height=20> $per %</td></tr>";
79 - } else {
80 - $tx .= $lang[$row[0]] . " (" . $row[1] . "), ";
81 - }
82 -}
83 -
84 -// now printing the table
85 -
86 -echo "<center>
87 -<h1>Number of Expressions per language</h1>
88 -<hr width=950 size=1 noshade><br />
89 -";
90 -
91 -echo "<p>\n";
92 -echo "Total <b>$defined_meanings</b> DefinedMeanings in database, linking together <b>$total</b> Expressions in <b>$nblang</b> languages:\n";
93 -echo "</p>\n";
94 -echo "<hr>\n";
95 -
96 -echo '
97 -<table cellpadding=0 width=950><tr><td width=200><b>Language</b></td><td align=right><b>Expressions</b></td><td width=30></td><td></td></tr>';
98 -
99 -echo "$tableLang" ;
100 -
101 -echo "
102 -<tr><td colspan=4>
103 -<div align=justify>
104 -
105 -<h3>Languages with less than $limit entries:</h3>
106 -$tx
107 -</div>
108 -</td>
109 -</table><center>";
110 -
111 -echo "
112 -<br />
113 -<hr size=1 noshade width=950>
114 -<table width=950><tr><td>
115 -<small>Page time: " . substr( ( stopwatch() - $start ), 0, 5 ) . " seconds</small>
116 -<td align=right>
117 -
118 -<small>Script contributed by <a href=http://www.dicts.info/>Zdenek Broz</a>
119 -</small>
120 -</td>
121 -</tr></table>
122 -<br />";
123 -
124 -
125 -function filewrite( $file, $txt ) {
126 -$fw = fopen( $file, "w+" );
127 -fwrite( $fw, $txt . "\n" );
128 -fclose( $fw );
129 -}
130 -
131 -
132 -
133 -
134 -?>
135 -</center></center>
136 -<p align="left">
137 -<h3> see also</h3>
138 -<ul>
139 -<li><a href="collections.php">Collections</a></li>
140 -<li><a href="../../..">return to Omegawiki proper</li></a>
141 -</p>

Status & tagging log