Show sourcecode
The following files exists in this folder. Click to view.
admin.php
bilder/
checkUpdates.php
confirmPassword.php
confirmSignIn.php
createadmin.php
endScreen.php
getBoard.php
getChat.php
getHand.php
getTurnPlayer.php
lobbies.php
logIn.php
play.php
playCard.php
signIn.php
start.php
startsida.php
style.css
tables.php
update.php
updatePassword.php
waitInfo.php
waitingRoom.php
tables.php
163 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
<?php
/** @var PDO $dbconn */
include ("start.php");
if ($_COOKIE["type"] != "admin") {
header("location: logIn.php");
}
// Om en table har valts att raderas, ta bort den
if (isset($_POST["table"])) {
try {
$sql = "DROP TABLE IF EXISTS " . $_POST["table"];
$dbconn->exec($sql);
echo "Table deleted successfully";
} catch (PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$dbconn = null;
} elseif (isset($_POST["create"])) {
// Körs om tabellerna ska skapas
try {
// Skapa Players
$sql = "CREATE TABLE JassPlayers (
playerid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL,
password VARCHAR(255) NOT NULL,
type VARCHAR(30) NOT NULL,
mail VARCHAR(30) NOT NULL,
disabled BOOL NOT NULL
)";
$dbconn->exec($sql);
echo "Table created successfully <br>";
} catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br><br>";
try {
// Skapa GamePlayers
$sql = "CREATE TABLE GamePlayers (
gameplayerid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
playerid INT(16),
gameid INT(30)
)";
$dbconn->exec($sql);
echo "Table created successfully <br>";
} catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br><br>";
try {
// Skapa Games
$sql = "CREATE TABLE JassGames (
gameid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
maxplayers INT(6) NOT NULL,
trumf VARCHAR(30),
turnplayerid INT(6),
isprivate BOOLEAN NOT NULL,
ownerid INT(6) NOT NULL,
code VARCHAR(30) NOT NULL
)";
$dbconn->exec($sql);
echo "Table created successfully";
} catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br><br>";
try {
// Skapa PlayerCards
$sql = "CREATE TABLE JassPlayerCards (
cardid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
playerid INT(6) NOT NULL,
color VARCHAR(10) NOT NULL,
value VARCHAR(30) NOT NULL,
position VARCHAR(30) NOT NULL
)";
$dbconn->exec($sql);
echo "Table created successfully <br>";
} catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br><br>";
try {
// Skapa PlayedCards
$sql = "CREATE TABLE JassPlayedCards (
cardid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
gameplayerid INT(6) NOT NULL,
color VARCHAR(10) NOT NULL,
value VARCHAR(30) NOT NULL,
boardposition INT(6) NOT NULL
)";
$dbconn->exec($sql);
echo "Table created successfully <br>";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br><br>";
try {
// Skapa ChatMessages
$sql = "CREATE TABLE ChatMessages (
messageid INT(16) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
gameid INT(6) NOT NULL,
img VARCHAR(32),
text VARCHAR(64) NOT NULL
)";
$dbconn->exec($sql);
echo "Table created successfully <br>";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$dbconn = null;
}
?>
<!-- Formulär för att välja en tabell att radera -->
<form action="" method="post">
<select name="table">
<option>JassPlayers</option>
<option>GamePlayers</option>
<option>JassGames</option>
<option>JassPlayerCards</option>
<option>JassPlayedCards</option>
<option>ChatMessages</option>
</select>
<input type="submit" value="Radera">
</form>
<!-- Formulär för att skapa tabeller -->
<form action="" method="post">
<input type="submit" name="create" value="Skapa tabeller">
</form>
</body>
</html>