Source

Selador / allianz_frontend.inc.php

Full commit
<?php

/* allianz_frontend.inc.php - Helper functions for the "Allianz" page
 *
 * Copyright (C) 2006, 2007, 2008 Kevin Read, Simone Schaefer
 *
 * This file is part of Selador, a browser-based fantasy strategy game
 *
 * This program is distributed under the terms of the GNU Affero General Public License.
 *
 *
 *   Selador is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *
 *   Selador is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with Selador.  If not, see <http://www.gnu.org/licenses/>.
 **/

//generiert den Link zu einer Allianz
function drawAllyLink ($aid, $tag, $draw_deleted = true)
{
	if ($tag)
		return '<a href="allianz.php?a='.$aid.'">'.$tag.'</a>';
	else
	{
		if ($draw_deleted)
			return '(gel&ouml;schte Allianz)';
		else
			return '';
	}
}

//generiert den Link zu einem Spieler
function drawUserLink ($uid, $name)
{
	if ($uid)
		return '<a href="profile.php?u='.$uid.'">'.$name.'</a>';
	else
		return '(gel&ouml;schter Spieler)';
}

//zeichnet eine einfache Trennlinie
function draw_line ($colspan)
{
	global $_SESSION;
	echo '
		<tr><td colspan="'.$colspan.'"><img src="styles/'.$_SESSION['theme'].'/line_thin.gif" width="98%" height="1px"></td></tr>
		';
}

function generateOnlineIcon($icon, $title)
{
	return "<img src=\"gfx/on".$icon.".gif\" title=\"".$title."\" alt=\"".$title."\">";
}

function generateNews()
{
	echo "<img src=\"styles/".$_SESSION['theme']."/new.gif\" width=\"25px\">";

}

//diese Funktion ueberprueft, ob Einladungen fuer den Spieler vorhanden sind
function check_invitations()
{
	global $gamedb;
	global $me;
	global $ally_info_msgs;
	$query = "select A.aid, B.tag from ally_invite A, allies B where A.aid=B.aid and A.uid=".$me->uid;
	if (!($res = $gamedb->query ($query)))
		log_err ("Cannot read invitations. Query: ".$query.", ".mysql_error());
	else
	{
		if (mysql_num_rows ($res))
		{
			$invitations = "<tr><td >Zur Zeit liegen folgende Einladungen f&uuml;r dich vor</td></tr>";
			//$invitations .= "<table cellspacing=\"0\" class=\"inhalt\"><tr><th>".$ally_info_msgs[20]."</th><th>&nbsp;</th></tr>";
			while ($row = mysql_fetch_array ($res))
			{
				$invitations .= "<tr><td><a href=\"".$SERVER['PHP_SELF']."?a=".$row['aid']."\">".$row['tag']."</a>&nbsp;&nbsp;<a href=\"".$SERVER['PHP_SELF']."?accept=".$row['aid']."\">&nbsp;&nbsp;&nbsp;&nbsp annehmen</a> | <a href=\"".$SERVER['PHP_SELF']."?decline=".$row['aid']."\">ablehnen</a></td></tr>\n";
			}
			$invitations .= "</table>\n";
		}
		else
			$invitations = "<tr><td>Derzeit liegen auch keine Einladungen f&uuml;r dich vor.</td></tr>";
	}
	return $invitations;
}

//erstellen des "Allianz-gruenden"-Formulars
function setFoundForm()
{
	echo "<table class=\"border\"><form name=\"ally\" action=\"".$SERVER['PHP_SELF']."\" method=\"POST\">\n";
	echo "<tr><th colspan=\"3\">Eigene Allianz gr&uuml;nden</th></tr>";
	echo '<tr><td colspan="3">Du kannst auch eine eigene Allianz gr&uuml;nden: </td></tr>
		<tr><td>K&uuml;rzel: </td><td><input type="text" name="tag" value="" size="5"></td></tr>
		<tr><td>Name: </td><td><input type="text" name="name" value="" size="20"></td></tr>
		<tr><td align="left" colspan="2"><input type="submit" name="foundally" value="Allianz gr&uuml;nden"></td></tr>
	</form></table>';
}
?>