- <?php
- function Smiley($texttoreplace) {
- $smilies = array(
- ";)" => "<img src=\"smileys/cool.gif\">",
- ";-)" => "<img src=\"smileys/cool.gif\">",
- ":-)" => "<img src=\"smileys/smile.gif\">",
- ":)" => "<img src=\"smileys/smile.gif\">",
- ":(" => "<img src=\"smileys/frown.gif\">",
- ":-(" => "<img src=\"smileys/frown.gif\">",
- ":D" => "<img src=\"smileys/mdr.gif\">",
- ":-D" => "<img src=\"smileys/mdr.gif\">",
- "^^" => "<img src=\"smileys/^^.gif\">",
- "666*" => "<img src=\"smileys/666.gif\">",
- ":'(" => "<img src=\"smileys/cry.gif\">",
- "cry*" => "<img src=\"smileys/cry.gif\">",
- ":|" => "<img src=\"smileys/erf.gif\">",
- ":-|" => "<img src=\"smileys/erf.gif\">",
- ":o" => "<img src=\"smileys/eek.gif\">",
- ":-o" => "<img src=\"smileys/eek.gif\">",
- "fuck" => "$#$%",
- "Fuck" => "&$#@"
- );
-
- $texttoreplace = str_replace(array_keys($smilies), array_values($smilies), $texttoreplace);
- return $texttoreplace;
- }
-
- include "../connect.php";
-
- $sql = "SELECT name, message FROM chatmessages ORDER BY postime DESC LIMIT 20";
- $query = mysql_query($sql) or die(mysql_error());
-
- $data = array();
- while($row = mysql_fetch_array($query)) {
- $message = $row['message'];
- $message = Smiley($message); //Smiley faces
-
- $sql = "SELECT * FROM users WHERE username='$row['name']'";
- $query = mysql_query($sql);
- $result = mysql_fetch_assoc($result);
-
- if($result['id_privil_fk'] == "1") {
- $row['__color'] = '#ff0000';
- } elseif(!isset($result['id_privil_fk'])) {
- $row['__color'] = '#cccccc';
- } else {
- $row['__color'] = '#00ff00';
- }
- $data[] = $row;
- }
- $data = array_reverse($data);
-
- foreach($data as $row) {
- echo '<div><span style="color: '.$row['__color'].';font-weight: bold;">'.$row['name'].':</span> '.$message.'</div>';
- }
- ?>
- <script>
- setTimeout("window.location.replace('chatlog.php')",2000);
- </script>
Har ingen idé om det virker, men det kan da give dig et bedre overblik.