<!--
Copyright 2007 Martin Remisch
This file is part of "Babylon 5: Upheaval".
"Babylon 5: Upheaval" is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
"Babylon 5: Upheaval" 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with "Babylon 5: Upheaval". If not, see <http://www.gnu.org/licenses/>.
-->
<html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../format.css">
<ul id="Navigation">
Navigation
<a href="sternenkarte.php">Sternenkarte</a>
<a href="display_own_planets.php">Planeten</a>
<a href="manage_planets.php">Baumenü</a>
</ul>
<?php
@session_start();
error_reporting(E_ALL);
include('/var/www/localhost/htdocs/alpha/db_include.inc');
mysql_connect(HOST,USER,PASS)or die(mysql_error());
mysql_select_db(DATABASE) or die(mysql_error());
function direction($dir) // setzt das $_GET für aufsteigende/absteigende sortierung
{
if($dir == "asc")
{
return "desc";
}else
{
return "asc";
}
}
$name = $_SESSION['name']; // spielername
$planeten_namen = "planeten"."_".$name; // datenbankname
$dir = direction(@$_GET['dir']); // sortierung -> aufsteigend/absteigend
$sortierung = array('name','x','y','credits','mineral','bio','gas','population','energy','moral','research','economy'); // spaltennamen
if ((isset($_POST["set"]) && $_POST["set"] == 'go')) // abfrage des submit -> aktualisieren der planetennamen
{
$res = mysql_result(mysql_query("SELECT COUNT(id) FROM ".$planeten_namen),0)or die(mysql_error());
for($i=1; $i <= $res; $i++)
{
$index = "name".$i;
$sql = "UPDATE ".$planeten_namen." SET name='".$_POST[$index]."' WHERE id='".$i."'";
mysql_query($sql);
if (@$_POST['check'] == 'checked'.$i) // aktivierte checkbox für manage_planets.php als $_SESSION exportieren
{ // abfangen nicht vorhandener checkboxen durch @$_POST
unset($_SESSION['auswahl']); // ohne unset ist "auswahl" eingefroren
$_SESSION['auswahl'] = $i;
}
}
}
//table header | ?sort= & dir | sort -> pos. im array $sortierung; dir -> funktion setzt absteigend/aufsteigend
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<table>\n";
echo "<tr>\n";
echo "<th>Sprung<br/>zu</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=0&dir=$dir\">Name</th>\n";
echo "<th width=\"35\"><a href=\"".$_SERVER['PHP_SELF']."?sort=1&dir=$dir\">X</th>\n";
echo "<th width=\"35\"><a href=\"".$_SERVER['PHP_SELF']."?sort=2&dir=$dir\">Y</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=3&dir=$dir\">Credits</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=4&dir=$dir\">Festelement-<br/>abbau</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=5&dir=$dir\">Bio-<br/>kapazität</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=6&dir=$dir\">Gas-<br/>förderung</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=7&dir=$dir\">Population</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=8&dir=$dir\">Energie</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=9&dir=$dir\">Moral/</br>Produktivität</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=10&dir=$dir\">Forschungs-<br/>quotient</th>\n";
echo "<th><a href=\"".$_SERVER['PHP_SELF']."?sort=11&dir=$dir\">Gesinnung</th>\n";
echo "</tr><tr>\n";
if (isset($_GET['sort'])) // sortierung setzen
{
$sql = "SELECT * FROM ".$planeten_namen." ORDER BY ".$sortierung[$_GET['sort']]." ".$_GET['dir'];
}
else
{
$sql = "SELECT * FROM ".$planeten_namen." ORDER BY x ASC";
}
$query = mysql_query($sql);
while($planeten = mysql_fetch_array($query)) // werte ausgeben; erst checkbox, dann input zum edit, dann n-rows
{
echo "<td><input type=\"radio\" name=\"check\" value=\"checked".$planeten[0]."\"></td>\n";
echo "<td><input type=\"text\" name=\"name".$planeten[0]."\" value=\"$planeten[name]\"></td>\n";
for ($i=1; $i < count($sortierung); $i++)
{
echo "<td>".$planeten[$sortierung[$i]]."</td>\n";
}
echo "</tr>";
}
?>
</table>
<input type="hidden" name="set" value="go"> <!-- siehe submitabfrage -->
<br/><input type="submit" value="Ok" />
</form>
</html>