session_start(); $server = 'localhost'; $user = 'ewieser'; $passwort = 'kowalski'; $db = 'db_nsf'; $connect = mysql_connect($server,$user,$passwort); $db_selected = mysql_select_db('db_nsf'); if (!$db_selected) { die ('Kann DB nicht benutzen : ' . mysql_error()); } //a8393058e7f0735a5578a6f288c388dc ECKI PW ?> class chat{ function __construct($id) { if (is_numeric($id)) { $sql="SELECT * FROM nsf_chat WHERE (id='$id') LIMIT 1"; $result = mysql_query($sql) OR die(mysql_error()); if($row = mysql_fetch_assoc($result)){ $this->Id=$row['id']; $this->Userid=$row['userid']; $this->Nachricht=$row['nachricht']; $this->Created=$row['created']; } } elseif ($id=="new") { $sql="INSERT INTO nsf_chat () VALUES ()"; mysql_query($sql); $sql="SELECT id FROM nsf_chat ORDER BY id DESC LIMIT 1"; $result = mysql_query($sql) OR die(mysql_error()); if ($row = mysql_fetch_assoc($result)){ $id=$row['id']; } return $this->__construct($id); } } ///////////////////////////////////////////// // GET METHODEN ////////////////////////////////////////////// function get_id() { return $this->Id; } function get_userid() { return $this->Userid; } function get_nachricht() { return $this->Nachricht; } function get_created() { return $this->Created; } ////////////////////////////////////////////// // SET METHODEN ////////////////////////////////////////////// function set_id($Id) { $this->Id=$Id; } function set_userid($Userid) { $this->Userid=$Userid; } function set_nachricht($Nachricht) { $this->Nachricht=$Nachricht; } function set_created($Created) { $this->Created=$Created; } ////////////////////////////////////////////// // ALLGEMEINE METHODEN ////////////////////////////////////////////// function save() { $id= $this->get_id(); $userid = $this->get_userid(); $nachricht = $this->get_nachricht(); $time=time(); $sql="UPDATE nsf_chat SET userid='$userid',nachricht='$nachricht',created='$time' WHERE (id='$id')"; if (mysql_query($sql)) {return true;}; } function set_smileys() { $msg = $this->get_nachricht(); $msg = str_ireplace(":-)","",$msg); $msg = str_ireplace(":-(","",$msg); $msg = str_ireplace("8-)","",$msg); $msg = str_ireplace(":-D","",$msg); $msg = str_ireplace(":-P","",$msg); $msg = str_ireplace(":-O","",$msg); $msg = str_ireplace(";-)","",$msg); $msg = str_ireplace(":´-(","",$msg); $msg = str_ireplace(":-X","",$msg); $this->set_nachricht($msg); } } ?> class login { function __construct($id) { if (is_numeric($id)) { $sql="SELECT * FROM nsf_login WHERE id='$id' LIMIT 1"; $result = mysql_query($sql) OR die(mysql_error()); if($row = mysql_fetch_assoc($result)){ $this->id=$row['id']; $this->username=$row['username']; $this->datum=$row['created']; } } } function get_username() { return $this->username; } function get_datum() { return $this->datum; } function get_id() { return $this->id; } } ?> $last_id; $chat_id; echo ""; echo '
'; echo ''; $messages = get_chat_messages(20);// WIEVIELE MSG ANGEZEIGT WERDEN if (is_array($messages) and sizeof($messages)>0) { echo "".$chat_user->get_username()." ( ".date("d.m.y H:i:s",$msg->get_created())." ) | "; echo "
".$msg->get_nachricht()." | "; echo "