plugins/SpecialAdmin.php
changeset 102 d807dcd7aed7
parent 89 fea81844b9a5
child 103 a8891e108c95
equal deleted inserted replaced
101:bb4e677a4da9 102:d807dcd7aed7
   791   }
   791   }
   792   
   792   
   793   if(isset($_POST['go']))
   793   if(isset($_POST['go']))
   794   {
   794   {
   795     // We need the user ID before we can do anything
   795     // We need the user ID before we can do anything
   796     $q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level FROM '.table_prefix.'users WHERE username=\'' . $db->escape($_POST['username']) . '\'');
   796     $q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level,account_active FROM '.table_prefix.'users WHERE username=\'' . $db->escape($_POST['username']) . '\'');
   797     if ( !$q )
   797     if ( !$q )
   798     {
   798     {
   799       die('Error selecting user ID: '.mysql_error());
   799       die('Error selecting user ID: '.mysql_error());
   800     }
   800     }
   801     if ( $db->numrows() < 1 )
   801     if ( $db->numrows() < 1 )
   846           {
   846           {
   847             $session->add_user_to_group($user_id, GROUP_ID_MOD, false);
   847             $session->add_user_to_group($user_id, GROUP_ID_MOD, false);
   848           }
   848           }
   849         }
   849         }
   850         
   850         
       
   851         // update account activation
       
   852         if ( isset($_POST['account_active']) )
       
   853         {
       
   854           // activate account
       
   855           $q = $db->sql_query('UPDATE '.table_prefix.'users SET account_active=1 WHERE user_id=' . intval($r['user_id']) . ';');
       
   856           if ( !$q )
       
   857             $db->_die();
       
   858         }
       
   859         else
       
   860         {
       
   861           // deactivate account and throw away the old key
       
   862           $actkey = sha1 ( microtime() . mt_rand() );
       
   863           $q = $db->sql_query('UPDATE '.table_prefix.'users SET account_active=0,activation_key=\'' . $actkey . '\' WHERE user_id=' . intval($r['user_id']) . ';');
       
   864           if ( !$q )
       
   865             $db->_die();
       
   866         }
       
   867         
   851         echo('<div class="info-box">Your changes have been saved.</div>');
   868         echo('<div class="info-box">Your changes have been saved.</div>');
   852       }
   869       }
   853       else
   870       else
   854       {
   871       {
   855         echo('<div class="error-box">Error saving changes: '.implode('<br />', $re).'</div>');
   872         echo('<div class="error-box">Error saving changes: '.implode('<br />', $re).'</div>');
   856       }
   873       }
   857       $q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['username']).'\'');
   874       $q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level,account_active FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['username']).'\'');
   858       if ( !$q )
   875       if ( !$q )
   859       {
   876       {
   860         die('Error selecting user ID: '.mysql_error());
   877         die('Error selecting user ID: '.mysql_error());
   861       }
   878       }
   862       if($db->numrows($q) < 1)
   879       if($db->numrows($q) < 1)
   896           <tr><td>New Password:</td><td><input ' . $disabled . ' type="password" name="new_pass" /></td></tr>
   913           <tr><td>New Password:</td><td><input ' . $disabled . ' type="password" name="new_pass" /></td></tr>
   897           <tr><td>E-mail:</td><td><input ' . $disabled . ' type="text" name="email" value="'.$r['email'].'" /></td></tr>
   914           <tr><td>E-mail:</td><td><input ' . $disabled . ' type="text" name="email" value="'.$r['email'].'" /></td></tr>
   898           <tr><td>Real Name:</td><td><input ' . $disabled . ' type="text" name="real_name" value="'.$r['real_name'].'" /></td></tr>
   915           <tr><td>Real Name:</td><td><input ' . $disabled . ' type="text" name="real_name" value="'.$r['real_name'].'" /></td></tr>
   899           ' . ( ( !empty($disabled) ) ? '<tr><td colspan="2"><small>To change your e-mail address, password, or real name, please use the user control panel.</small></td></tr>' : '' ) . '
   916           ' . ( ( !empty($disabled) ) ? '<tr><td colspan="2"><small>To change your e-mail address, password, or real name, please use the user control panel.</small></td></tr>' : '' ) . '
   900           <tr><td>User level:</td><td><select name="level"><option '); if($r['user_level']==USER_LEVEL_CHPREF) echo('SELECTED'); echo(' value="'.USER_LEVEL_CHPREF.'">Regular User</option><option '); if($r['user_level']==USER_LEVEL_MOD) echo('SELECTED'); echo(' value="'.USER_LEVEL_MOD.'">Moderator</option><option '); if($r['user_level']==USER_LEVEL_ADMIN) echo('SELECTED'); echo(' value="'.USER_LEVEL_ADMIN.'">Administrator</option></select></td></tr>
   917           <tr><td>User level:</td><td><select name="level"><option '); if($r['user_level']==USER_LEVEL_CHPREF) echo('SELECTED'); echo(' value="'.USER_LEVEL_CHPREF.'">Regular User</option><option '); if($r['user_level']==USER_LEVEL_MOD) echo('SELECTED'); echo(' value="'.USER_LEVEL_MOD.'">Moderator</option><option '); if($r['user_level']==USER_LEVEL_ADMIN) echo('SELECTED'); echo(' value="'.USER_LEVEL_ADMIN.'">Administrator</option></select></td></tr>
       
   918           <tr><td></td><td><label><input type="checkbox" name="account_active"' . ( $r['account_active'] == '1' ? ' checked="checked"' : '' ) . ' /> Account is active</label><br /><small>If this is unchecked, the activation key will be reset, meaning that any activation e-mails sent will be invalidated.</small></td></tr>
   901           <tr><td>Delete user:</td><td><input type="hidden" name="go" /><input type="hidden" name="username" value="'.$r['username'].'" /><input onclick="return confirm(\'This is your last warning.\n\nAre you sure you want to delete this user account? Even if you delete this user account, the username will be shown in page edit history, comments, and other areas of the site.\n\nDeleting a user account CANNOT BE UNDONE and should only be done in extreme circumstances.\n\nIf the user has violated the site policy, deleting the account will not prevent him from using the site, for that you need to add a new ban rule.\n\nContinue deleting this user account?\')" type="submit" name="deleteme" value="Delete this user" style="color: red;" /> <label><input type="checkbox" name="delete_conf" /> I\'m absolutely sure</label>
   919           <tr><td>Delete user:</td><td><input type="hidden" name="go" /><input type="hidden" name="username" value="'.$r['username'].'" /><input onclick="return confirm(\'This is your last warning.\n\nAre you sure you want to delete this user account? Even if you delete this user account, the username will be shown in page edit history, comments, and other areas of the site.\n\nDeleting a user account CANNOT BE UNDONE and should only be done in extreme circumstances.\n\nIf the user has violated the site policy, deleting the account will not prevent him from using the site, for that you need to add a new ban rule.\n\nContinue deleting this user account?\')" type="submit" name="deleteme" value="Delete this user" style="color: red;" /> <label><input type="checkbox" name="delete_conf" /> I\'m absolutely sure</label>
   902           <tr><td align="center" colspan="2">
   920           <tr><td align="center" colspan="2">
   903           <input type="submit" name="save" value="Save Changes" /></td></tr>
   921           <input type="submit" name="save" value="Save Changes" /></td></tr>
   904         </table>
   922         </table>
   905       </form>
   923       </form>