<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/


if ($MsgText[0][679] == '') {
	$MsgText[0][679] = 'No usernames found starting with that letter.';
}




	// ========================================================================================
	// View Members List
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_info.gif" width="21" height="20"> '.$MsgText[0][335];
	$BrowserTitle = $MsgText[0][335];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][335];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[12] == 'y') {
		
				$Link1 = 'user-asc';
				$Link2 = 'activity-desc';
				$Link3 = 'registered-desc';
				$Link4 = 'level-desc';
				$Link5 = 'posts-desc';
		
				if ($Arguments3 == 'user-asc') { $SortBy = 'Username'; $SortOrder = 'ASC'; $Link1 = 'user-desc'; }
				else if ($Arguments3 == 'user-desc') { $SortBy = 'Username'; $SortOrder = 'DESC'; }
				
				else if ($Arguments3 == 'activity-asc') { $SortBy = 'LastAction'; $SortOrder = 'ASC'; }
				else if ($Arguments3 == 'activity-desc') { $SortBy = 'LastAction'; $SortOrder = 'DESC'; $Link2 = 'activity-asc'; }
				
				else if ($Arguments3 == 'registered-asc') { $SortBy = 'RegistrationDate'; $SortOrder = 'ASC'; }
				else if ($Arguments3 == 'registered-desc') { $SortBy = 'RegistrationDate'; $SortOrder = 'DESC'; $Link3 = 'registered-asc'; }
				
				else if ($Arguments3 == 'level-asc') { $SortBy = 'Level'; $SortOrder = 'asc'; }
				else if ($Arguments3 == 'level-desc') { $SortBy = 'Level'; $SortOrder = 'desc'; $Link4 = 'level-asc'; }
				
				else if ($Arguments3 == 'posts-asc') { $SortBy = 'ForumPosts'; $SortOrder = 'asc'; }
				else if ($Arguments3 == 'posts-desc') { $SortBy = 'ForumPosts'; $SortOrder = 'desc'; $Link5 = 'posts-asc'; }
				
				else { $SortBy = 'Username'; $SortOrder = 'ASC'; $Link1 = 'user-desc'; }
				
				
				if ($Arguments5 != '') {
					$Arguments5 = strtolower(substr($Arguments5,0,1));
					
					$Link6 = '/'.$Arguments5;
										
					$OtherPart = ' where Username like \''.$Arguments5.'%\'';
				}
				
				
				$query = "select count(RecordNumber) as RecordsCount from `".$Settings['DBPrefix']."core-Users`".$OtherPart;
				$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				$RecordsCount = $row['RecordsCount'];
				
				
				if ($RecordsCount > 0) {
				
				
					$PagesCount = ceil($RecordsCount/intval($Settings['UsersPerPage']));
				
					$PageNumber = intval($Arguments4);
				
					if ($PageNumber > 0) {	
						if ($PageNumber > $PagesCount) {
							$PageNumber = $PagesCount;
						}
					}
					else {
						$PageNumber = 1;
					}
	
			
					$query69 = "select Username,DisplayName,LastAction,SessionLength,Level,RegistrationDate,ForumPosts from `".$Settings['DBPrefix']."core-Users`".$OtherPart." ORDER BY ".$SortBy." ".$SortOrder." limit ".(($PageNumber-1)*intval($Settings['UsersPerPage'])).",".intval($Settings['UsersPerPage']);
					$result69 = mysql_query($query69) or die (mysql_error());
														
					while ($row = mysql_fetch_array($result69)) { 
					
						//if ($row['DisplayName'] == '') {
						//	$row['DisplayName'] = $row['Username'];
						//}
						//else {
						//	$row['DisplayName'] = $row['Username'] . ' (' . $row['DisplayName'] . ')';
						//}
						
							
						if ($row['LastAction'] > 0) {
							if ($row['LastAction']+($row['SessionLength']*60) > GetTimestamp()) {
								$LastActivity = '['.$MsgText[0][81].']';
							}
							else if (date('F jS, Y',$row['LastAction']) == date('F jS, Y',GetTimestamp())) {
								$LastActivity = $MsgText[0][82].' @ '.date('g:i:s A',$row['LastAction']);
							}
							else if (date('Y',$row['LastAction']) == date('Y',GetTimestamp())) {
								$LastActivity = date('M jS @ g:i:s A',$row['LastAction']);
							}
							else {
								$LastActivity = date('M jS, Y @ g:i:s A',$row['LastAction']);
							}
						}
						else {
							$LastActivity = '['.$MsgText[0][83].']';
						}
						
						
						/*$LevelPrint = '';
						$Level = number_format($row['Level']/10,0);
						for ($i = 1; $i <= $Level; $i++) {
							$LevelPrint .= '=';
						}*/
						$LevelPrint = $row['Level'];
						
						
						
						if ($IM['mb'] == 'y') {
							$ForumPostsPrint = '<td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.number_format($row['ForumPosts'],0).'</td>';
						}
						else {
							$ForumPostsPrint = '';
						}
						
						
						if ($Permissions[5] == 'y' && ($row['Level'] < $UserLevel || $UserLevel == 100)) {
																	
							$PrintRows .= '<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'">[<a href="'.$MainURL.'/profile-edit/'.$row['Username'].'.html" target="_blank">'.$MsgText[0][155].'</a>]&nbsp;&nbsp;<a href="'.$MainURL.'/profile/'.$row['Username'].'.html" target="_blank">'.$row['Username'].'</a></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$LastActivity.'</td>
	  <td><font face="'.$FontFace.'" size="'.$FontSize.'">'.date('M jS, Y',$row['RegistrationDate']).'</td>
	  <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$LevelPrint.'</td>
	  '.$ForumPostsPrint.'
    </tr>';
						}
						else {
							$PrintRows .= '<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$BaseURL.'/'.$Settings['ScriptName'].'/profile/'.$row['Username'].'.html" target="_blank">'.$row['Username'].'</a></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$LastActivity.'</td>
	  <td><font face="'.$FontFace.'" size="'.$FontSize.'">'.date('M jS, Y',$row['RegistrationDate']).'</td>
	  <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$LevelPrint.'</td>
	  '.$ForumPostsPrint.'
    </tr>';		
						}
						
					
					}
				
				
				if ($PagesCount > 1 && $PageNumber > 1) {
					$PreviousPageLink = '<a href="'.$MainURL.'/admin/users/'.$Arguments3.'/'.($PageNumber-1).$Link6.'.html"><b>&lt; '.$MsgText[0][558].'</b></a>';
				}
				if ($PagesCount > 1 && $PageNumber < $PagesCount) {
					$NextPageLink = '<a href="'.$MainURL.'/admin/users/'.$Arguments3.'/'.($PageNumber+1).$Link6.'.html"><b>'.$MsgText[0][557].' &gt;</b></a>';
				}
				if ($PagesCount > 1) {
					$PageLinks = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="50%"><font face="'.$FontFace.'" size="'.($FontSize-1).'">'.$PreviousPageLink.'</font></td><td width="50%" align="right"><font face="'.$FontFace.'" size="'.($FontSize-1).'">'.$NextPageLink.'</font></td></tr></table>';
				}	
						
			
			} // end if recordscount > 0
			else {
				if ($IM['mb'] == 'y') {
					$PrintRows .= '<tr><td colspan="5" align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$MsgText[0][679].'</font></td></tr>';
				}
				else {
					$PrintRows .= '<tr><td colspan="4" align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$MsgText[0][679].'</font></td></tr>';
				}
			
			}
			
			
			if ($IM['mb'] == 'y') {
				$ForumPostsHeading = '<td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b><a href="'.$MainURL.'/admin/users/'.$Link5.'/'.$PageNumber.$Link6.'.html">'.$MsgText[0][84].'</a></b></td>';
			}
			else {
				$ForumPostsHeading = '';
			}
				
			
			if ($Arguments5 != '') {
				$LettersString = '<b><a href="'.$MainURL.'/admin/users/'.$Arguments3.'/1.html">Show All</a></b>&nbsp;&nbsp;';
			}
			else {
				$LettersString = '<b>Show All</b>&nbsp;&nbsp;';
			}
			
			for ($i = 0; $i <= 25; $i++) {
	
				if ($LettersString != '') {
					$LettersString .= ' ';
				}
				
				if ($Arguments5 == chr($i+97)) {
					$LettersString .= '<b>'.chr($i+65).'</b>';
				}
				else {
					$LettersString .= '<b><a href="'.$MainURL.'/admin/users/'.$Arguments3.'/1/'.chr($i+97).'.html">'.chr($i+65).'</a></b>';
				}

			}
			
			
			$PageContents = $MsgText[0][336].'<br><br><br><div align="center">'.$LettersString.'</div>'.$PageLinks.'<br><table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b><a href="'.$MainURL.'/admin/users/'.$Link1.'/1'.$Link6.'.html">'.$MsgText[0][337].'</a></b></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b><a href="'.$MainURL.'/admin/users/'.$Link2.'/1'.$Link6.'.html">'.$MsgText[0][338].'</a></b></td>
	  <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b><a href="'.$MainURL.'/admin/users/'.$Link3.'/1'.$Link6.'.html">'.$MsgText[0][339].'</a></b></td>
      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b><a href="'.$MainURL.'/admin/users/'.$Link4.'/1'.$Link6.'.html">'.$MsgText[0][340].'</a></b></td>
	'.$ForumPostsHeading.'
    </tr>'.$PrintRows.'</table><br>'.$PageLinks;
			

		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

	// ========================================================================================




?>
