diff --git a/04_Misc/05_PHP_Example/index.php b/04_Misc/05_PHP_Example/index.php new file mode 100644 index 0000000..eb22f6c --- /dev/null +++ b/04_Misc/05_PHP_Example/index.php @@ -0,0 +1,183 @@ + + + + + Perun - Example of PHP Integration + + + + + + + + + +
+ connect_errno) { + printf("Connect failed: %s\n", $mysqli->connect_error); + exit(); + } + + // Some Examples + // List last 5 missions at the server + echo "

List last 5 missions at the server

"; + if ($result = $mysqli->query("SELECT * FROM `pe_DataMissionHashes` ORDER BY `pe_DataMissionHashes`.`pe_DataMissionHashes_datetime` DESC LIMIT 5")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
" . $row['pe_DataMissionHashes_id'] . "" . $row['pe_DataMissionHashes_hash'] . "" . $row['pe_DataMissionHashes_datetime'] . "
"; + + $result->close(); + } + + // List last 5 + echo "

List last 5 players known server

"; + if ($result = $mysqli->query("SELECT * FROM `pe_DataPlayers` ORDER BY `pe_DataPlayers`.`pe_DataPlayers_updated` DESC LIMIT 5")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
" . $row['pe_DataPlayers_id'] . "" . $row['pe_DataPlayers_ucid'] . "" . $row['pe_DataPlayers_lastname'] . "" . $row['pe_DataPlayers_updated'] . "
"; + + $result->close(); + } + + // List last 5 chat messages + echo "

List last 5 chat messages (note: INNER JOIN is used to pull the player's name from other table)

"; + if ($result = $mysqli->query("SELECT * FROM `pe_LogChat` INNER JOIN `pe_DataPlayers` on `pe_LogChat`.pe_LogChat_playerid = `pe_DataPlayers`.pe_DataPlayers_id ORDER BY `pe_LogChat`.`pe_LogChat_datetime` DESC LIMIT 5")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
" . $row['pe_LogChat_datetime'] . "" . $row['pe_DataPlayers_lastname'] . "" . $row['pe_LogChat_msg'] . "
"; + + $result->close(); + } + + + // List last 5 events + echo "

List last 5 events

"; + if ($result = $mysqli->query("SELECT * FROM `pe_LogEvent` ORDER BY `pe_LogEvent_datetime` DESC LIMIT 5")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
" . $row['pe_LogEvent_datetime'] . "" . $row['pe_LogEvent_content'] . "
"; + + $result->close(); + } + + // List last statistics + echo "

List last statistics (note: multiple INNER JOINs is used to pull information from other table)

"; + if ($result = $mysqli->query("SELECT * FROM `pe_LogStats` INNER JOIN `pe_DataMissionHashes` ON `pe_LogStats`.pe_LogStats_missionhash_id = `pe_DataMissionHashes`.pe_DataMissionHashes_id INNER JOIN `pe_DataPlayers` ON `pe_LogStats`.pe_LogStats_playerid = `pe_DataPlayers`.pe_DataPlayers_id INNER JOIN `pe_DataTypes` ON `pe_LogStats`.pe_LogStats_typeid = `pe_DataTypes`.pe_DataTypes_id ORDER BY pe_LogStats_datetime desc LIMIT 5")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + // TIP: See documentation there is many more counted events which can be displayed here + echo ""; + echo ""; + } + echo "
" . $row['pe_LogStats_datetime'] . "" . $row['pe_DataPlayers_lastname'] . "" . $row['pe_DataTypes_name'] . "" . $row['ps_crashes'] . "" . $row['ps_kills_planes'] . "" . $row['ps_kills_armor'] . "" . $row['pe_LogStats_mstatus'] . "
"; + + $result->close(); + } + + // Get JSON objects with actual server information including LotATC and DCS SRS information + echo "

Get JSON objects with actual server information including LotATC and DCS SRS information

"; + if ($result = $mysqli->query("SELECT * FROM `pe_DataRaw`")) { + echo ""; + while($row = mysqli_fetch_array($result)) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
" . $row['pe_dataraw_updated'] . "" . $row['pe_dataraw_payload'] . "
"; + + $result->close(); + } + + // Close database connection + $mysqli->close(); + ?> +
+ + + \ No newline at end of file