<?php

						/*************************************\
						
						    Handshakes Professional (3.0)
						            by DZOIC LTD
						       Copyright(c) 2005-2006
						        http://www.dzoic.com
						
						\*************************************/

						///////////////////////////////////////
							
						$action = $GLOBALS["Get"]->val("action");
								
							switch($action){								
										
								case '':									
									homepage();
									break;
									
							}//switch
							
						///////////////////////////////////////

function homepage(){
	
	admin_validate();
	
	$data["title_id"] = "18";	
	$sql_query="SELECT count(mem_id) AS total,verified
				FROM members
				WHERE mem_id > 100000
				GROUP BY verified
				ORDER BY verified";
	
	$result = $GLOBALS["DB"]->result($sql_query);
	
	$members_total = $result[0][total] + $result[1][total];
	$ar = array(0,1);
	
	while(list($i) = each($ar)){
		if(!$result[$i][verified]){
			$members_unverified = $result[$i][total];
			break;
		}//if
	}//while
	
	settype($members_unverified,"integer");	
	
	$sql_query="SELECT joined
				FROM profiles
				WHERE mem_id > 100000
				ORDER BY joined ASC
				LIMIT 0,1";
	
	$first_member=$GLOBALS["DB"]->single($sql_query);
	
	if($first_member)
		$first_member_joined = extract_date($first_member);
	
	$sql_query="SELECT joined
				FROM profiles
				WHERE mem_id > 100000
				ORDER BY joined DESC
				LIMIT 0,1";
	
	$last_member=$GLOBALS["DB"]->single($sql_query);
	
	if($last_member)
		$last_member_joined = extract_date($last_member);
		
	$sql_query = "SELECT count(*)
				  FROM photos
				  WHERE approved='0'
				  AND mem_id > 100000";
	
	$photos = $GLOBALS["DB"]->single($sql_query);
	
	$sql_query = "SELECT count(*)
				  FROM profiles
				  WHERE approved='0'
				  AND mem_id > 100000";
	
	$profiles = $GLOBALS["DB"]->single($sql_query);
	
	$sql_query = "SELECT count(*)
				  FROM classifieds";
	
	$classifieds = $GLOBALS["DB"]->single($sql_query) - 1;
	
	$sql_query = "SELECT count(*)
				  FROM events";
	
	$events = $GLOBALS["DB"]->single($sql_query) - 1;
	
	$sql_query = "SELECT count(*)
				  FROM clubs";
	
	$clubs = $GLOBALS["DB"]->single($sql_query) - 1;
	
	$layout[0] = "homepage";
	$data["title_id"] = "18";	
	$data["info"][labels] = array (	
		"Total members:",
		"First member joined:",
		"Last member joined:",
		"Photos waiting for approval:",
		"Profiles waiting for approval:",
		"Total classifieds:",
		"Total events",
		"Total clubs:"
	);
	
	$data["info"][content] = array (
		$members_total." (".$members_unverified." unverified)",
		$first_member_joined,
		$last_member_joined,
		$photos,
		$profiles,
		$classifieds,
		$events,
		$clubs
	);
	
	admin_output($layout,$data);
	
}//homepage


?>