2011-10-08 08:00:14 +00:00
< ?
if ( ! check_perms ( 'users_mod' )) { error ( 403 ); }
if ( isset ( $_REQUEST [ 'addtokens' ])) {
authorize ();
$Tokens = $_REQUEST [ 'numtokens' ];
if ( ! is_number ( $Tokens ) || ( $Tokens < 0 )) { error ( " Please enter a valid number of tokens. " ); }
$sql = " UPDATE users_main SET FLTokens = FLTokens + $Tokens WHERE Enabled = '1' " ;
if ( ! isset ( $_REQUEST [ 'leechdisabled' ])) {
$sql .= " AND can_leech = 1 " ;
}
$DB -> query ( $sql );
2011-10-27 08:00:15 +00:00
$sql = " SELECT ID FROM users_main WHERE Enabled = '1' " ;
if ( ! isset ( $_REQUEST [ 'leechdisabled' ])) {
$sql .= " AND can_leech = 1 " ;
}
$DB -> query ( $sql );
while ( list ( $UserID ) = $DB -> next_record ()) {
$Cache -> delete_value ( 'user_info_heavy_' . $UserID );
}
2011-10-08 08:00:14 +00:00
$message = " <strong> $Tokens freeleech tokens added to all enabled users " . ( ! isset ( $_REQUEST [ 'leechdisabled' ]) ? ' with enabled leeching privs' : '' ) . '.</strong><br /><br />' ;
2011-10-27 08:00:15 +00:00
} elseif ( isset ( $_REQUEST [ 'cleartokens' ])) {
authorize ();
$Tokens = $_REQUEST [ 'numtokens' ];
if ( ! is_number ( $Tokens ) || ( $Tokens < 0 )) { error ( " Please enter a valid number of tokens. " ); }
if ( isset ( $_REQUEST [ 'onlydrop' ])) {
$Where = " WHERE FLTokens > $Tokens " ;
} elseif ( ! isset ( $_REQUEST [ 'leechdisabled' ])) {
$Where = " WHERE (Enabled = '1' AND can_leech = 1) OR FLTokens > $Tokens " ;
} else {
$Where = " WHERE Enabled = '1' OR FLTokens > $Tokens " ;
}
$DB -> query ( " SELECT ID FROM users_main $Where " );
$Users = $DB -> to_array ();
$DB -> query ( " UPDATE users_main SET FLTokens = $Tokens $Where " );
foreach ( $Users as $UserID ) {
list ( $UserID ) = $UserID ;
$Cache -> delete_value ( 'user_info_heavy_' . $UserID );
}
$where = " " ;
2011-10-08 08:00:14 +00:00
}
2011-10-29 08:00:15 +00:00
2012-10-11 08:00:15 +00:00
View :: show_header ( 'Add tokens sitewide' );
2011-10-08 08:00:14 +00:00
?>
2012-08-19 08:00:19 +00:00
< div class = " header " >
< h2 > Add freeleech tokens to all enabled users </ h2 >
< div class = " linkbox " >
2012-09-09 08:00:26 +00:00
< a href = " tools.php?action=tokens&showabusers=1 " > [ Show Abusers ] </ a >
2012-08-19 08:00:19 +00:00
</ div >
</ div >
2011-10-08 08:00:14 +00:00
< div class = " box pad " style = " margin-left: auto; margin-right: auto; text-align:center; max-width: 40% " >
< ? = $message ?>
2012-09-15 08:00:25 +00:00
< form class = " add_form " name = " fltokens " action = " " method = " post " >
2011-10-08 08:00:14 +00:00
< input type = " hidden " name = " action " value = " tokens " />
< input type = " hidden " name = " auth " value = " <?= $LoggedUser['AuthKey'] ?> " />
Tokens to add : < input type = " text " name = " numtokens " size = " 5 " style = " text-align: right " value = " 0 " >< br />< br />
< label for = " leechdisabled " > Grant tokens to leech disabled users : </ label >< input type = " checkbox " id = " leechdisabled " name = " leechdisabled " value = " 1 " >< br />< br />
< input type = " submit " name = " addtokens " value = " Add tokens " >
</ form >
</ div >
2011-10-27 08:00:15 +00:00
< br />
< div class = " box pad " style = " margin-left: auto; margin-right: auto; text-align:center; max-width: 40% " >
< ? = $message ?>
2012-09-15 08:00:25 +00:00
< form class = " manage_form " name = " fltokens " action = " " method = " post " >
2011-10-27 08:00:15 +00:00
< input type = " hidden " name = " action " value = " tokens " />
< input type = " hidden " name = " auth " value = " <?= $LoggedUser['AuthKey'] ?> " />
Tokens to set : < input type = " text " name = " numtokens " size = " 5 " style = " text-align: right " value = " 0 " >< br />< br />
2012-09-20 08:00:49 +00:00
< span id = " droptokens " class = " " >< label for = " onlydrop " > Only affect users with at least this many tokens : </ label >< input type = " checkbox " id = " onlydrop " name = " onlydrop " value = " 1 " onchange = " $ ('#disabled').toggle();return true; " ></ span >< br />
< span id = " disabled " class = " " >< label for = " leechdisabled " > Also add tokens ( as needed ) to leech disabled users : </ label >< input type = " checkbox " id = " leechdisabled " name = " leechdisabled " value = " 1 " onchange = " $ ('#droptokens').toggle();return true; " ></ span >< br />< br />
2011-10-27 08:00:15 +00:00
< input type = " submit " name = " cleartokens " value = " Set token total " >
</ form >
</ div >
2011-10-08 08:00:14 +00:00
< ?
2012-10-11 08:00:15 +00:00
View :: show_footer ()
2012-09-09 08:00:26 +00:00
?>