2005-01-08 19:45:26 +00:00
|
|
|
<?php
|
2005-02-08 03:33:35 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
2005-01-08 19:45:26 +00:00
|
|
|
|
|
|
|
require_once("../inc/db.inc");
|
2005-02-08 03:33:35 +00:00
|
|
|
require_once("../inc/util_ops.inc");
|
2005-01-08 19:45:26 +00:00
|
|
|
|
2005-02-09 18:09:26 +00:00
|
|
|
// activate/deactivate script
|
|
|
|
if (1) {
|
|
|
|
echo "
|
|
|
|
This script needs to be activated before it can be run.
|
|
|
|
Once you understand what the script does you can change the
|
|
|
|
if (1) to if (0) at the top of the file to activate it.
|
|
|
|
Be sure to deactivate the script after using it to make sure
|
|
|
|
it is not accidentally run.
|
|
|
|
";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-01-08 19:45:26 +00:00
|
|
|
set_time_limit(0);
|
|
|
|
|
2005-02-08 03:33:35 +00:00
|
|
|
function set_nusers($credit_only) {
|
|
|
|
echo "Running set_nusers() ...<br>\n";
|
2005-01-08 19:45:26 +00:00
|
|
|
$result = mysql_query("select id, nusers from team");
|
|
|
|
while ($team = mysql_fetch_object($result)) {
|
2005-02-08 03:33:35 +00:00
|
|
|
$q = "select count(*) from user where teamid=$team->id";
|
|
|
|
if ($credit_only) $q .= " and total_credit>0";
|
|
|
|
echo $q . "<br>";
|
|
|
|
$r = mysql_query($q);
|
2005-01-08 19:45:26 +00:00
|
|
|
$x = mysql_fetch_array($r);
|
|
|
|
mysql_free_result($r);
|
|
|
|
$n = $x[0];
|
|
|
|
if ($n != $team->nusers) {
|
2005-02-08 03:33:35 +00:00
|
|
|
echo "team $team->id: old: $team->nusers new: $n<br>\n";
|
2005-01-08 19:45:26 +00:00
|
|
|
mysql_query("update team set nusers=$n where id=$team->id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
2005-02-08 03:33:35 +00:00
|
|
|
echo "set_nusers() finished!<br>";
|
2005-01-08 19:45:26 +00:00
|
|
|
}
|
|
|
|
|
2005-02-08 03:33:35 +00:00
|
|
|
db_init();
|
|
|
|
$use = $_GET['use'];
|
|
|
|
|
|
|
|
admin_page_head("Repair team nusers");
|
|
|
|
|
|
|
|
if ($use < 1 || $use >2) {
|
|
|
|
echo "<br>Script to recalculate the number of users in a team.<br>
|
|
|
|
Please choose:<br>
|
|
|
|
<a href=\"team_repair.php?use=1\">Consider every user</a><br>
|
|
|
|
<a href=\"team_repair.php?use=2\">Consider only user with total_credit>0</a><br>";
|
|
|
|
} else {
|
|
|
|
if ($use == 1) {
|
|
|
|
set_nusers(FALSE);
|
|
|
|
} else {
|
|
|
|
set_nusers(TRUE);
|
|
|
|
}
|
|
|
|
}
|
2005-01-08 19:45:26 +00:00
|
|
|
|
2005-02-08 03:33:35 +00:00
|
|
|
admin_page_tail();
|
2005-01-08 19:45:26 +00:00
|
|
|
?>
|