Location: PHPKode > projects > iLP System > Release 2.2/upload/events.php
<?php
/**
 * iLP System Ereignisse anzeigen
 * 
 * Autor:		Florian "ApoY2k" Peschka
 * Projekt:		iLP System
 * Paket:		apoy2k.ilp.wrynn
 * Lizenz:		CreativeCommons (by-nc-sa)
 * Kontakt:		hide@address.com
 * Version:		2.1.2
 */
// Benutzer-Login prüfen
if (isset($_SESSION['user']['login']))
{
	// Alle Ereignisse des Benutzers suchen
	if (!isset($tpl['url'][2]) || 'show' == $tpl['url'][2])
	{
		$get_events = $db->prepare("SELECT ilp_event_types.name AS type_name, ilp_event_types.icon AS type_icon, ilp_events.id AS event_id, ilp_events.date AS event_date, ilp_event_attends.value FROM ilp_event_types, ilp_event_attends, ilp_events WHERE ilp_events.id = ilp_event_attends.event_id AND ilp_events.type = ilp_event_types.id AND ilp_event_attends.user_id = ? ORDER BY ilp_events.date DESC, ilp_events.id DESC");
	
		$get_events->execute(array($_SESSION['user']['id']));
		
		// Wenn die Ereignisse gefunden wurde, deren Daten speichern.
		if (1 <= $get_events->rowCount())
		{
			
			// Zusätzliche Header laden
			$tpl['headincludes'][] = 'events.list';
			
			// Alle gefundenen Ereignisse speichern.
			while($row = $get_events->fetch(PDO::FETCH_ASSOC))
			{
				$tpl['events'][] = $row;
			}
		}
		else
		{
			$tpl['events']['error'] = true;
		}
	}
	
	// Details eines bestimmten Ereignisses anzeigen
	elseif ('detail' == $tpl['url'][2])
	{
		$get_event = $db->prepare("SELECT ilp_event_types.name AS type_name, ilp_event_types.icon AS type_icon, ilp_events.date AS event_date, ilp_events.comment FROM ilp_event_types, ilp_events WHERE ilp_events.type = ilp_event_types.id AND ilp_events.id = ?");
		$get_attends = $db->prepare("SELECT ilp_event_attends.user_id, ilp_users.char, ilp_event_attends.value FROM ilp_event_attends, ilp_users WHERE ilp_event_attends.user_id = ilp_users.id AND ilp_event_attends.event_id = ?");
		$get_loots = $db->prepare("SELECT ilp_loots.item_id, ilp_loots.looter_id, ilp_loots.value, ilp_users.char FROM ilp_loots, ilp_users, ilp_events WHERE ilp_loots.event_id = ilp_events.id AND ilp_loots.looter_id = ilp_users.id AND ilp_events.id = ? ORDER BY ilp_loots.id DESC");
		
		// Ereignis suchen
		$get_event->execute(array($tpl['url'][3]));
		
		// Wenn das Ereignis gefunden wurde, die Daten suchen und speichern.
		if (1 == $get_event->rowCount())
		{
			$tpl['event'] = $get_event->fetch(PDO::FETCH_ASSOC);
			if ('' != $tpl['event']['comment'])
			{
				$tpl['event']['comment'] = dbToHtml($tpl['event']['comment']);
			}
			else
			{
				$tpl['event']['comment'] = '&nbsp;';
			}
			
			// Alle Teilnehmer des Raids suchen
			$get_attends->execute(array($tpl['url'][3]));
			
			// Wenn Teilnehmer gefunden wurden, diese in ein Array speichern
			if (1 <= $get_attends->rowCount())
			{
				while ($row = $get_attends->fetch(PDO::FETCH_ASSOC))
				{
					// Charakterdaten auslesen und entschlüsselt übergeben.
					$row['char'] = unserialize($row['char']);
					
					$tpl['event']['attends'][] = $row;
				}
			}
			
			$tpl['event']['attends'] = sortUsers($tpl['event']['attends']);
			
			// Beute suchen
			$get_loots->execute(array($tpl['url'][3]));
			
			// Wenn Beute gefunden wurde, diese in ein Array speichern
			if (1 <= $get_loots->rowCount())
			{
				while ($row = $get_loots->fetch(PDO::FETCH_ASSOC))
				{
					// Charakterdaten auslesen und entschlüsselt übergeben.
					$row['char'] = unserialize($row['char']);
					
					$tpl['event']['loots'][] = $row;
				}
			}
		}
		else
		{
			$tpl['error']['action'] = 'Ereignis anzeigen';
			$tpl['error']['actor'] = $tpl['user']['login'].' – ID: '.$tpl['user']['id'];
			$tpl['error']['location'] = 'events.php:49';
			$tpl['error']['result'] = var_dump($get_event->errorInfo());
			$tpl['error']['level'] = '0 (base-php)';
		}
	}
}

// Wenn der Benutzer nicht eingeloggt ist, Fehlerausgabe erzeugen
else
{
	$tpl['error']['action'] = 'Seite aufrufen: Ereignisse anzeigen';
	$tpl['error']['actor'] = $_SERVER['REMOTE_ADDR'];
	$tpl['error']['location'] = 'events.php:13';
	$tpl['error']['result'] = 'Zugriff verweigert';
	$tpl['error']['level'] = '0 (base-php)';
}
?>
Return current item: iLP System