Location: PHPKode > projects > SiteX > admin/user_manager.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsUsersEdit']))  loginError($sxLang['LoginRequired']);

// Setup sort value
if(!$sort)
	$sort = 'user_asc';

if($delete)
{
	if($delete != $_SESSION['userid'])
	{
		deleteUser($delete);
		$message = $sxLang['MessageUserDeleted'];
	}
	else
		$message = $sxLang['MessageUserDeleteSelf'];
}

if($activate)
{
	$query = "UPDATE $DB_Users SET active='1' WHERE id='$activate'";
	$result = mysql_query($query, $Link);
	
	$query = "SELECT * FROM $DB_Users WHERE id='$activate' LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("24", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	mail($ROW->email, $sxLangMail['SubjectUserActivated'], $sxLangMail['UserActivated'], "From: ".$sxSetup['AdminEmail']);
	$message = $sxLang['MessageUserActivated'];
}

if($deactivate)
{
	$query = "UPDATE $DB_Users SET active='0' WHERE id='$deactivate'";
	$result = mysql_query($query, $Link) or queryError("221", mysql_error());
	$message = $sxLang['MessageUserDeactivated'];
}

if($validate)
{
	$query = "UPDATE $DB_Users SET validated='1', validation_code='' WHERE id='$validate'";
	$result = mysql_query($query, $Link) or queryError("135", mysql_error());
	$message = $sxLang['MessageUserValidatedAdmin'];
}

$sxQueryConditions = "";

if (($sxShowInactive) OR ($filter) OR ($sxUserGroup))
{
	$sxQueryConditions = " WHERE ";
	$sxQueryConditionsArray = array();

	// Inactive users
	if($sxShowInactive)
		 array_push($sxQueryConditionsArray, "$DB_Users.active='0'");
	
	// Alpha filter
	if($filter)
		 array_push($sxQueryConditionsArray, "$DB_Users.username LIKE '$filter%'");
	
	// Type filter
	if($sxUserGroup)
		 array_push($sxQueryConditionsArray, "$DB_Users.id = $DB_Users_Assoc.userid AND $DB_Users_Assoc.typeid='$sxUserGroup'");
		
	// Form final query conditions
	foreach($sxQueryConditionsArray as $value)
		$sxQueryConditions .= $value." AND ";
	$sxQueryConditions = substr($sxQueryConditions, 0, strlen($sxQueryConditions)-4);
}

// Sort queries
$sxQueryOrder = " ORDER BY ";
switch($sort)
{
	case 'user_asc' : 
		$sxQueryOrder .= "$DB_Users.username ASC";
		break;
		
	case 'user_desc' : 
		$sxQueryOrder .= "$DB_Users.username DESC";
		break;

	case 'email_asc' : 
		$sxQueryOrder .= "$DB_Users.email ASC";
		break;

	case 'email_desc' : 
		$sxQueryOrder .= "$DB_Users.email DESC";
		break;

	case 'lastname_asc' : 
		$sxQueryOrder .= "$DB_Users.lastname ASC";
		break;

	case 'lastname_desc' : 
		$sxQueryOrder .= "$DB_Users.lastname DESC";
		break;
		
	case 'validated_asc' : 
		$sxQueryOrder .= "$DB_Users.validated ASC";
		break;

	case 'validated_desc' : 
		$sxQueryOrder .= "$DB_Users.validated DESC";
		break;
	
	default :
		$sxQueryOrder .= "$DB_Users.username ASC";
}


// Filter by user group
if($sxUserGroup)
{
	$sxExtendedQuery = ", $DB_Users_Assoc" . $sxQueryConditions . $sxQueryOrder;
	$query = "SELECT DISTINCT $DB_Users.username FROM $DB_Users" . $sxExtendedQuery;
	$result = mysql_query($query, $Link) or queryError("551", mysql_error());
	$totalElements = mysql_num_rows($result);
}
else
{
	$sxExtendedQuery = $sxQueryConditions . $sxQueryOrder;
	$query = "SELECT * FROM $DB_Users" . $sxExtendedQuery;
	$result = mysql_query($query, $Link) or queryError("552", mysql_error());
	$totalElements = mysql_num_rows($result);
}

$elements_per_page = $sxThemeConfig['AdminUsersPerPage'];
if(!$page)
	$page = 1;
$start = ($page - 1)*$elements_per_page;

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['UserJSUserDelete']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
		window.location='<?PHP print $PHP_SELF."?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&page=$page&delete="; ?>'+theID;
	}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function changeState(object_check, object){
	if(object_check.checked == false){
		document.all[object].disabled = true;
	}else{
		document.all[object].disabled = false;
		document.all[object].select();
	}
}
//-->
</script>     
<div class="bodyWrapper">
<h1 class="sxAdminHeading"><?PHP echo $sxLang['UserHeadingManager']; ?></h1>
<div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['UserHeadingManager']; ?></div>
<?PHP echoMessage($message); ?>
<?PHP
if(!$sxShowInactive)
{
	$query = "SELECT * FROM $DB_Users WHERE active='0'";
	$result = mysql_query($query, $Link) or queryError("24", mysql_error());
	
	if(mysql_num_rows($result))
		echo '<div class="message">' . $sxLang['MessageUserInactive1'] . ' ' . mysql_num_rows($result) . ' <a href="' . $PHP_SELF . '?sxShowInactive=true">' . $sxLang['MessageUserInactive2'] . '</a>.</div>';
}
?>
<table align="center" border="0" cellspacing="2" cellpadding="5">
  <tr>
	<td colspan="6"><div width="50%" style="float:left"><?PHP echo $sxLang['UserItemDisplay']; ?>:
	<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
	<option value=<?PHP echo '"'."$PHP_SELF?sort=$sort&filter=$filter&page=$page".'"'; if(!$sxUserGroup) echo ' selected="selected"'; ?>><?PHP echo $sxLang['UserOptionAllTypes']; ?></option>
	  <?PHP
		$query = "SELECT * FROM $DB_Users_Types ORDER BY name ASC";
		$result = mysql_query($query, $Link) or queryError("46", mysql_error());
		while($ROW = mysql_fetch_object($result))
		{
			if($sxUserGroup == $ROW->id)
				$selected = " selected";
			else
				$selected = "";
			echo '<option value="' . "$PHP_SELF?sxUserGroup=$ROW->id&sort=$sort&filter=$filter&page=$page".'"'.$selected.'>'.$ROW->name.'</option>';
		}
		?>
	</select><span style="padding-left: 10px;"><?PHP echo $sxLang['MaintenanceUsers']; ?>: <?PHP echo $totalElements; ?></span></div>
	<div align="right">
	<input name="AddUser" style="width:150px;" type="button" value="<?PHP echo $sxLang['UserButtonAddNew']; ?>" onclick="window.location='user_add.php'" />
	</div>
	<div>
	  <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
	  <td class="pageTurns" colspan="2">
		<?PHP
		foreach ($sxLangChars as $key => $value)
		{	
			$query2 = "SELECT * FROM $DB_Users, $DB_Users_Assoc WHERE $DB_Users.username LIKE '$value%'";
			if($sxUserGroup)
				$query2 .= " AND $DB_Users.id = $DB_Users_Assoc.userid AND $DB_Users_Assoc.typeid='$sxUserGroup'";
			$result2 = mysql_query($query2, $Link) or queryError("24", mysql_error());
			if (mysql_num_rows($result2))
				echo '<a href="user_manager.php?sxUserGroup='.$sxUserGroup.'&sort=' . $sort . '&filter=' . $value . '">';
			echo $value;
			if (mysql_num_rows($result2))
				echo '</a>';
			echo ' ';
		}
		echo '<a href="user_manager.php?sxUserGroup='.$sxUserGroup.'&sort=' . $sort . '">' . $sxLang['All'] . '</a>';
		?>
	  </td>
	  </tr>
	  <tr>
		<td class="pageTurns">
		<?PHP pageTurns("$PHP_SELF?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&", $totalElements, $page, $elements_per_page); ?>
		</td>
	  </tr>
	  </table>
	  </div>
	</td>
  </tr>
  <tr class="tableColumn">
	  <td nowrap="nowrap" class="tableColumn" style="color:<?PHP echo $sxTheme['ColorTextTable']; ?>;"><?PHP echo $sxLang['GeneralItemActive']; ?></td>
<?PHP
	// Validated column
	echo '	  <td nowrap="nowrap">';
	
	if ($sort == 'validated_asc')
	{
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=validated_desc".'" title="' . $sxLang['SortDesc'] . '" >';
		echo '<img alt="' . $sxLang['SortDesc'] . '" src="../images/down.gif" style="border: 0;" /> ';
	}
	else
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=validated_asc".'" title="' . $sxLang['SortAsc'] . '" >';
	
	if ($sort == 'validated_desc')
		echo '<img alt="' . $sxLang['SortAsc'] . '" src="../images/up.gif" style="border: 0;" /> ';
		
	echo $sxLang['GeneralItemValidation'];
	echo '</a></td>';

	// Name column
	echo '	  <td nowrap="nowrap">';
	
	if ($sort == 'lastname_asc')
	{
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=lastname_desc".'" title="' . $sxLang['SortDesc'] . '" >';
		echo '<img alt="' . $sxLang['SortDesc'] . '" src="../images/down.gif" style="border: 0;" /> ';
	}
	else
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=lastname_asc".'" title="' . $sxLang['SortAsc'] . '" >';
	
	if ($sort == 'lastname_desc')
		echo '<img alt="' . $sxLang['SortAsc'] . '" src="../images/up.gif" style="border: 0;" /> ';
		
	echo $sxLang['GeneralItemName'];
	echo '</a></td>';
	
	// Username column	
	echo '	  <td nowrap="nowrap">';
	
	if ($sort == 'user_asc')
	{
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=user_desc".'" title="' . $sxLang['SortDesc'] . '" >';
		echo '<img alt="' . $sxLang['SortDesc'] . '" src="../images/down.gif" style="border: 0;" /> ';
	}
	else
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=user_asc".'" title="' . $sxLang['SortAsc'] . '" >';
	
	if ($sort == 'user_desc')
		echo '<img alt="' . $sxLang['SortAsc'] . '" src="../images/up.gif" style="border: 0;" /> ';
		
	echo $sxLang['UserItemUsername'];
	echo '</a></td>';
	
	// Email column
	echo '	  <td nowrap="nowrap">';
	
	if ($sort == 'email_asc')
	{
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=email_desc".'" title="' . $sxLang['SortDesc'] . '" >';
		echo '<img alt="' . $sxLang['SortDesc'] . '" src="../images/down.gif" style="border: 0;" /> ';
	}
	else
		echo '<a class="tableColumn" href="'.$PHP_SELF."?sxUserGroup=$sxUserGroup&page=$page&filter=$filter&sort=email_asc".'" title="' . $sxLang['SortAsc'] . '" >';
	
	if ($sort == 'email_desc')
		echo '<img alt="' . $sxLang['SortAsc'] . '" src="../images/up.gif" style="border: 0;" /> ';
		
	echo $sxLang['UserItemEmail'];
	echo '</a></td>';

?>	  
	  <td nowrap="nowrap" class="tableColumn" style="color:<?PHP echo $sxTheme['ColorTextTable']; ?>;"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
  </tr>
<?PHP
$query3 = "SELECT $DB_Users.id, $DB_Users.email, $DB_Users.username, $DB_Users.active, $DB_Users.validated, $DB_Users.lastname, $DB_Users.firstname, $DB_Users.email
          FROM $DB_Users $sxExtendedQuery LIMIT $start, $elements_per_page";
$result3 = mysql_query($query3, $Link) or queryError("2419374", mysql_error());


while($ROW3 = mysql_fetch_object($result3))
{
	//if($DB_Users_Assoc.typeid !=1)
	echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
	
	if(($ROW3->active)AND(userAdmin())) {
	 echo '<td><a href="' . $PHP_SELF . "?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&page=$page&deactivate=" . $ROW3->id . '" title="' . $sxLang['ImgAltDeactivate'] . '"><img alt="' . $sxLang['ImgAltDeactivate'] . '" src="../images/check.gif" style="border: 0;" /></a></td>';
	}
	if((!$ROW3->active)AND(userAdmin())) {
	 echo '<td><a href="' . $PHP_SELF . "?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&page=$page&activate=" . $ROW3->id . '" title="' . $sxLang['ImgAltActivate'] . '"><img alt="' . $sxLang['ImgAltActivate'] . '" src="../images/x.gif" style="border: 0;" /></a></td>';
	}
	if(($ROW3->active)AND(userEditor())) {
	 echo '<td><img alt="' . $sxLang['ImgAltDeactivated'] . '" src="../images/check.gif" style="border: 0;" /></td>';
	}
	if((!$ROW3->active)AND(userEditor())) {
	 echo '<td><img alt="' . $sxLang['ImgAltActivated'] . '" src="../images/x.gif" style="border: 0;" /></td>';
	}
	if($ROW3->validated)
		echo '<td title="' . $sxLang['MessageUserTooltipValidated'] . '"><img alt="' . $sxLang['MessageUserTooltipValidated'] . '" src="../images/admin_validated.gif" style="border: 0;" /></td>';
	else
		echo '<td><a href="' . $PHP_SELF . "?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&page=$page&validate=" . $ROW3->id . '" title="' . $sxLang['MessageUserTooltipAwaiting'] . '"><img alt="' . $sxLang['MessageUserTooltipAwaiting'] . '" src="../images/admin_unvalidated.gif" style="border: 0;" /></a></td>';
	
	echo '     <td><a href="user_edit.php?edit_userid=' . $ROW3->id . '">' . htmlspecialchars($ROW3->lastname) . ', ' . htmlspecialchars($ROW3->firstname) . '</a></td>';
	echo '     <td>' . htmlspecialchars($ROW3->username) . '</td>';
	echo '     <td><a href="mailto:' .  htmlspecialchars($ROW3->email) . '"><span class="sxSmallText">' . limitStringForce(htmlspecialchars($ROW3->email), 20) . '</span></a></td>';
	echo '     <td nowrap="nowrap">';
	echo '                <a href="profile_view.php?user=' . $ROW3->username . '" title="' . $sxLang['ButtonProfile'] . '"><img src="../images/admin_preview.gif" style="border: 0;" alt="' . $sxLang['ButtonProfile'] . '" /></a> ';
	echo '                <a href="user_edit.php?edit_userid=' . $ROW3->id . '" title="' . $sxLang['ButtonEdit'] . '"><img src="../images/admin_edit.gif" style="border: 0;" alt="' . $sxLang['ButtonEdit'] . '" /></a> ';
	if (!userEditor()) echo '                <a href="#" onclick="confirmDelete(' . $ROW3->id . ',\'' . htmlspecialchars(addslashes($ROW3->username)) . '\')" title="' . $sxLang['ButtonDelete'] . '"><img src="../images/admin_delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a></td>';
	echo '  </tr>';
}

?><tr>
	<td colspan="6"><div class="pageTurns"><?PHP pageTurns("$PHP_SELF?sxUserGroup=$sxUserGroup&sort=$sort&filter=$filter&", $totalElements, $page, $elements_per_page); ?></div></td>
  </tr>
  <tr>
  <td colspan="6"><?php echo $sxLang['GeneralItemValidation']; ?>: <img alt="<?php echo $sxLang['UserStatusUnvalidated']; ?> " src="../images/admin_unvalidated.gif" style="border: 0;" /> = <?php echo $sxLang['UserStatusUnvalidated']; ?>&nbsp;(<?php echo $sxLang['MessageUserTooltipAwaiting']; ?>)&nbsp;&nbsp;<img alt="<?php echo $sxLang['UserStatusValidated']; ?> " src="../images/admin_validated.gif" style="border: 0;" /> = <?php echo $sxLang['UserStatusValidated']; ?></td>
  </tr> 
</table></div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX