Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>SplashMC.de ChatLog</title>
- <meta charset="utf-8"/>
- <meta name="language" content="de"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
- <link rel="stylesheet" type="text/css" href="style.css"/>
- <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,300"/>
- </head>
- <body>
- <?php
- include("script/Chatlog.php");
- if(@$_GET['ID'] != null) {
- showLog($_GET['ID']);
- }
- ?>
- <div class="wrapper">
- <center>
- <h1>SplashMC | ChatLog</h1>
- <div class="wrappercontent">
- <form action="index.php" method="get">
- <input class="form-input" type="text" placeholder="ChatLog-ID" name="ID">
- <br></br>
- <input class="form-button" type="submit" value="Go">
- </form>
- </div>
- </center>
- <br></br>
- <div id="content">
- </div>
- </div>
- <div class="footer">
- <center>
- <h5>Copyright © 2016 SplashMC.de</h5>
- <h5>Created by Vinka01</h5>
- <h5><a href="http://splashmc.de/imprint.html">Impressum</a></h5>
- </center>
- </div>
- </body>
- </html>
- <?php
- $con;
- $dom;
- $div;
- function showLog($logID) {
- if($logID != null) {
- libxml_use_internal_errors(true);
- error_reporting(0);
- $con = connectDB();
- $html = file_get_contents('index.php');
- $dom = new DOMDocument();
- $dom->loadHTML($html);
- $finder = new DOMXPath($dom);
- $div = $dom->getElementById('content');
- /*addMessage("Testuser1", "Testnachricht nr1","12:45",$dom,$div);
- addMessage("Testuser2", "Testnachricht nr2","12:45",$dom,$div);
- addMessage("Testuser1", "hallo","12:45",$dom,$div);
- addMessage("Testuser2", "jo was geht?","12:45",$dom,$div);
- addMessage("Testuser1", "alles gut bei dir?","12:45",$dom,$div);
- addMessage("Testuser2", "klar","12:45",$dom,$div); */
- setChatLog(getMessage(),$dom,$div);
- echo getMessage();
- print $dom->saveHTML();
- }
- }
- function connectDB() {
- $host = "localhost";
- $user = "root";
- $pass = "vkyd6600!!!";
- $database = "splashmc_chatlog";
- $con = new mysqli($host, $user);
- mysqli_select_db($con, $database);
- $createTable = "CREATE TABLE IF NOT EXISTS ChatLog(MESSAGEID INT AUTO_INCREMENT, AUTHOR LONGTEXT, MESSAGE LONGTEXT, DATE LONGTEXT, LOGID LONGTEXT, PRIMARY KEY(MESSAGEID))";
- mysqli_query($con, $createTable) or die("Fehler beim ausführen!" . mysqli_error($con));
- }
- function getMessage() {
- for($i = 0; $i < 6; $i++) {
- if($i%2) {
- $json["Sender"] = "s1";
- } else {
- $json["Sender"] = "s2";
- }
- $json["Message"] = "Hallo";
- $json["Timestep"] = "123";
- $msg["Message"][] = $json;
- }
- return json_encode($msg);
- }
- function setChatLog($message,$dom,$div) {
- $decode = json_decode($message);
- $msgarr = $decode->{'Message'};
- for($i = 0; $i < count($msgarr); $i++) {
- $rawmsg = $msgarr[$i];
- addMessage($rawmsg->{'Sender'},$rawmsg->{'Message'},$rawmsg->{'Timestep'},$dom,$div);
- }
- }
- function addMessage($author,$message,$time,$dom,$parent) {
- $wrapper = $dom->createElement('div');
- $wrapper->setAttribute('class', 'msg');
- $parent->appendChild($wrapper);
- $author = $dom->createElement('p', $author);
- $author->setAttribute('class', 'author');
- $wrapper->appendChild($author);
- $text = $dom->createElement('p'," : " . $message);
- $author->appendChild($text);
- $timestep = $dom->createElement('p', $time);
- $timestep->setAttribute('class', 'timestep');
- $wrapper->appendChild($timestep);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement