|
|
Line 7: |
Line 7: |
| ::::How do you find out who made the most edits?--[[User:Zhen lin|Zhen lin]] 23:03, January 22, 2010 (UTC) | | ::::How do you find out who made the most edits?--[[User:Zhen lin|Zhen lin]] 23:03, January 22, 2010 (UTC) |
| Either use their contributions page and count how many they have had or write the edit count before and after the month and workout the amount in between.--[[User:Sgtcook|Sgtcook]] ([[User Talk:Sgtcook|My Talk Page]]) 23:05, January 22, 2010 (UTC) | | Either use their contributions page and count how many they have had or write the edit count before and after the month and workout the amount in between.--[[User:Sgtcook|Sgtcook]] ([[User Talk:Sgtcook|My Talk Page]]) 23:05, January 22, 2010 (UTC) |
− | :It would be impossible to do that for every user--[[User:Zhen lin|Zhen lin]] 23:06, January 22, 2010 (UTC)
| |
− | ::That could be a different page, e.g. Wikisimpsons:Top Contributors of the Month--[[User:Smiley12|Smiley]][[User talk:Smiley12|12]] was here at 23:09, January 22, 2010 (UTC)
| |
− | :::Also, we could use this script to find out the top contributors--[[User:Smiley12|Smiley]][[User talk:Smiley12|12]] was here at 23:14, January 22, 2010 (UTC)
| |
− | <pre style="font-size:90%; height:200px; overflow-y:scroll;"><nowiki>
| |
− | <?php
| |
− | header('Content-Type: text/html; charset=utf-8');
| |
− | $db = mysql_connect('localhost', ' username ', ' password');
| |
− |
| |
− | mysql_select_db(' database ');
| |
− |
| |
− | if (!$db)
| |
− | {
| |
− | trigger_error('MySQL error #' . mysql_errno() . ': ' . mysql_error(), E_USER_ERROR);
| |
− | }
| |
− |
| |
− | mysql_query("SET NAMES 'utf8'");
| |
− |
| |
− | function requestVar($name, $default = '')
| |
− | {
| |
− | if (isset($_GET[$name]))
| |
− | {
| |
− | return $_GET[$name];
| |
− | }
| |
− | if (isset($_POST[$name]))
| |
− | {
| |
− | return $_POST[$name];
| |
− | }
| |
− | return $default;
| |
− | }
| |
− |
| |
− | $starttime = requestVar('starttime', '00000000000000');
| |
− |
| |
− | // HINT: set here, for example: requestVar('starttime', mktime (0,0,0, $month, 1, 2008) );
| |
− |
| |
− | $endtime = requestVar('endtime', '99999999999999');
| |
− | $limit = requestVar('limit', 100);
| |
− |
| |
− | $query = 'SELECT COUNT(*) AS x
| |
− | FROM page
| |
− | LEFT JOIN revision ON rev_page = page_id
| |
− | LEFT JOIN user ON rev_user = user_id
| |
− | WHERE page_namespace = 0
| |
− | AND page_is_redirect = 0
| |
− | AND rev_timestamp >= ' . "'${starttime}'" . '
| |
− | AND rev_timestamp <= ' . "'${endtime}'";
| |
− |
| |
− | $result = mysql_query($query);
| |
− | $row = mysql_fetch_row($result);
| |
− | $totaledits = $row[0];
| |
− |
| |
− | print '<p>There have been ' . number_format($totaledits) . ' edits to the main namespace, excluding the pages which are currently redirects.</p>';
| |
− |
| |
− | flush();
| |
− |
| |
− | $query = 'SELECT COUNT(*) AS x, user_name
| |
− | FROM page
| |
− | LEFT JOIN revision ON rev_page = page_id
| |
− | LEFT JOIN user ON rev_user = user_id
| |
− | WHERE page_namespace = 0
| |
− | AND page_is_redirect = 0
| |
− | AND rev_timestamp >= ' . "'${starttime}'" . '
| |
− | AND rev_timestamp <= ' . "'${endtime}'" . '
| |
− | GROUP BY user_id
| |
− | ORDER BY x DESC, user_id ASC';
| |
− |
| |
− | if ($limit > 0)
| |
− | $query .= ' LIMIT 0, ' . $limit;
| |
− |
| |
− | $result = mysql_query($query);
| |
− |
| |
− | $topeditlist = array();
| |
− |
| |
− | while ($row = mysql_fetch_row($result))
| |
− | {
| |
− | $topeditlist[] = array($row[1], intval($row[0]));
| |
− | }
| |
− |
| |
− |
| |
− | $cumulative = 0.0;
| |
− |
| |
− | if ($topeditlist[0][0] == 'BulbaBot')
| |
− | echo '<ol start="0">';
| |
− | else
| |
− | echo '<ol>';
| |
− |
| |
− | foreach($topeditlist as $data)
| |
− | {
| |
− | $user = $data[0];
| |
− | $user1 = htmlspecialchars(urlencode(str_replace(' ', '_', $user)));
| |
− | $count = $data[1];
| |
− |
| |
− | $fraction = floatval($count) / $totaledits;
| |
− | $cumulative += $fraction;
| |
− |
| |
− | echo '<li>';
| |
− | echo '<a href="http://bulbapedia.bulbagarden.net/wiki/User:' . $user1 .'">';
| |
− | echo $user;
| |
− | echo '</a> has made ';
| |
− | echo '<a href="http://bulbapedia.bulbagarden.net/w/index.php?title=Special:Contributions&target=' . $user1 .'">';
| |
− | echo $count;
| |
− | if ($count == 1)
| |
− | echo ' edit</a>. <small>(';
| |
− | else
| |
− | echo ' edits</a>. <small>(';
| |
− | echo round($fraction, 3) * 100.0;
| |
− | echo '%, ';
| |
− | echo round($cumulative, 3) * 100.0;
| |
− | echo '% cumulative)</small></li>';
| |
− | echo "\n";
| |
− | }
| |
− | echo '</ol>';
| |
− |
| |
− | $cutoff = 21;
| |
− |
| |
− | echo '<pre>';
| |
− | foreach($topeditlist as $data)
| |
− | {
| |
− | $user = $data[0];
| |
− | $count = $data[1];
| |
− |
| |
− | if ($cutoff == 0)
| |
− | break;
| |
− | $cutoff--;
| |
− | if ($count < $minedits)
| |
− | break;
| |
− | echo '# ';
| |
− | echo '{{u|' . $user . '}}';
| |
− | echo ' <small>(';
| |
− | echo $count;
| |
− | if ($count == 1)
| |
− | echo ' Edit';
| |
− | else
| |
− | echo ' Edits';
| |
− | echo ")</small>\n";
| |
− | }
| |
− |
| |
− | ?>
| |
− |
| |
− | </nowiki></pre>
| |
− | For example, set the times like this:
| |
− |
| |
− | $starttime = mktime (0,0,0, 8, 1, 2008) ; // from 8 = august, 1st, 0:00:00
| |
− |
| |
− | $endtime = mktime (0,0,0, 9, 1, 2008) ; // to 9 = september, 1st, 0:00:00
| |
− |
| |
− | :And how would one use this script?--[[User:Zhen lin|Zhen lin]] 23:16, January 22, 2010 (UTC)
| |
− | ::Well... I havn't actually tested this but it should work for every wiki. It's PHP, so it'd work by creating a new file on the server with that content. Then one would just need to open that file in the browser--[[User:Smiley12|Smiley]][[User talk:Smiley12|12]] was here at 23:34, January 22, 2010 (UTC)
| |
Either use their contributions page and count how many they have had or write the edit count before and after the month and workout the amount in between.--Sgtcook (My Talk Page) 23:05, January 22, 2010 (UTC)