Thread: Reset Invites
View Single Post
  #1  
Old 30th October 2009, 14:35
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default Reset Invites
PHP Code:
<?php

/*******************************************\
|* Reset Invites by Alex2005 for TBDEV.NET *|
\*******************************************/

include('include/bittorrent.php');
dbconn();
loggedinorreturn();

if (
get_user_class() != UC_SYSOP)
    
stderr('Error''Access Denied!');

if (
$_GET['confirm'] != 1)
    
stderr('Sanity check!''Click <a href='.$_SERVER['PHP_SELF'].'?confirm=1>here</a> if you are sure you want to reset all users invites to 0.');
else
{
    
$res mysql_query('SELECT id FROM users WHERE invites > 0 AND enabled = \'yes\' AND status = \'confirmed\'') or sqlerr(__FILE____LINE__);
    
    if (
mysql_num_rows($res) > 0)
    {
        
$ids = array();
        
        while (
$arr mysql_fetch_assoc($res))
            
$ids[] = $arr['id'];
        
        
mysql_query('UPDATE users SET invites = 0 WHERE id IN ('.implode(' ,'$ids).')') or sqlerr(__FILE____LINE__);
        
        
stderr('Success'mysql_affected_rows().' user\'s invites reseted.');
    }
    else
        
stderr('Sorry''Nothing to reset.');
}
?>
Reply With Quote
The Following 2 Users Say Thank You to elvira For This Useful Post:
kalwin (19th January 2012), Tibys08 (29th May 2011)