db = new PDO('mysql:host=localhost;dbname='.database.';charset=utf8',username_db, passwod_db); } function minecraft_join(){ $curent_time = time(); $curent_minf = $curent_time - 300; $sql = 'SELECT * FROM playerlogger where showed_screen=0 and time >= "'.$curent_minf.'" ORDER BY time DESC limit 1'; foreach ($this->db->query($sql) as $row) { $data['header'] = $row['playername']; $data['message'] = $this->type_chat($row['type'],$row['data']); if($row['playername'] !=""){ $data['show'] ="true"; $sql1 = 'update playerlogger set showed_screen = 1 where playername=:name'; $update_db =$this->db->prepare($sql1); $update_db->bindParam(':name', $row['playername'], PDO::PARAM_STR); $update_db->execute(); } else{ $data['show'] ="false"; } } return $data; } function type_chat($typ,$chat){ switch($typ){ case "join": $text = "has connected"; break; case "quit": $text = "has Quit"; break; case "chat": $text ="Chat: ".$chat; break; case "death": $text ="died"; break; case "killedby": $text ="killed by ".$chat; break; case "kill": $text ="killed by ".$chat; break; case "enchant": $text ="encaned a thing"; break; } return $text; } } ?>