<?php
include 'icl/reauth.inc.php';

function deluser(){
	$userid=GETVAL('userid');
	global $db;
	
	$user=userinfo();
	$gsid=$user['gsid']+0;
	
	if (!$user['groups']['accounts']) die('Access denied');
	
	checkgskey('deluser_'.$userid);
		
	$query="select * from ".TABLENAME_USERS." where userid=? and gsid=?";
	$rs=sql_prep($query,$db,array($userid,$gsid));
	if (!$myrow=sql_fetch_array($rs)) die('Invalid user record');
	
	$login=$myrow['login'];
	
	$query="delete from ".TABLENAME_USERS." where userid=? and gsid=?";
	sql_prep($query,$db,array($userid,$gsid));
	
	logaction("deleted User #$userid $login",array('userid'=>$userid,'login'=>"$login"),array('rectype'=>'reauth','recid'=>$userid));
	reauth();
}
