<?php
	date_default_timezone_set('America/New_York');
	class UtilitiesAdmin
	{
		var $username;     //Username given on sign-up

		function UtilitiesAdmin(){

		}
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		function showAllUsers(){
		   global $database;
		   $q = "SELECT 
				username,
				CASE WHEN userlevel = '1' THEN 'USER'
					 WHEN userlevel = '9' THEN 'ADMINISTRATOR' END AS userlevel,
				
				email,
				timestamp "
			   ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username";
		   $result = $database->query($q);
		   /* Error occurred, return given name by default */
		   $num_rows = mysql_numrows($result);
		   if(!$result || ($num_rows < 0)){
			  echo "Error displaying info";
			  return;
		   }
		   if($num_rows == 0){
			  echo "Database table empty";
			  return;
		   }
		   /* Display table contents */

							
							
	
		   for($i=0; $i<$num_rows; $i++){
			  $uname  = mysql_result($result,$i,"username");
			  $ulevel = mysql_result($result,$i,"userlevel");
			  $email  = mysql_result($result,$i,"email");
			  $time   = mysql_result($result,$i,"timestamp");

			  echo "<tr><td>".$uname."</td><td>".$ulevel."</td><td>".$email."</td><td >".$time."</td></tr>";
		   }
		   //echo "</table>";
		}
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
		function getUsernames(){
		   global $database;
		   $q = "SELECT username,userlevel,email,timestamp "
			   ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username";
		   $result = $database->query($q);
		   /* Error occurred, return given name by default */
		   $num_rows = mysql_numrows($result);
		   if(!$result || ($num_rows < 0)){
			  echo "Error displaying info";
			  return;
		   }
		   if($num_rows == 0){
			  echo "Database table empty";
			  return;
		   }
			
	
		   for($i=0; $i<$num_rows; $i++){
			  $uname  = mysql_result($result,$i,"username");
			  
			  $usernameList = " " . $uname . " ";
				echo $usernameList;
		   }
		   
		}
		
	};

	$admin = new UtilitiesAdmin;
?>