!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/chat.css" /> <script type="text/javascript" src="js/jquery-1.9.1.js"></script> <script type="text/javascript" src="js/jquery.cookie.js"></script> <script type="text/javascript" src="js/script.js"></script> <title>HTML5/jQuery chatbox with sound & save to file</title> </head> <body> <div id='container'> <div id='chatbox'> <div id='messages'> <div class='message'> <img src="img/avatar.png"/> <span class='cname'>user01234</span> <span class='date'><img src='img/date.png' alt='posted' /><?php echo date("d-n-Y @ H:i",time())?></span> <span class='text'>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.</span> </div> <div class='message'> <img src="img/avatar.png"/> <span class='cname'>user012345</span> <span class='date'><img src='img/date.png' alt='posted' /><?php echo date("d-n-Y @ H:i",time())?></span> <span class='text'>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.</span> </div> <?php if(file_exists("chats.txt")){ $lines = file("chats.txt",FILE_IGNORE_NEW_LINES); foreach($lines as $l){ $a=explode("|||",$l); echo "<div class='message'> <img src='img/avatar.png'/> <span class='cname'>".$a[0]."</span> <span class='date'><img src='img/date.png' alt='posted' />".$a[2]."</span> <span class='text'>".$a[1]."</span> </div>"; } } ?> </div> <input type="text" id="input" placeholder="Type your message..." /> <input type="submit" value="Post" id="submit" /> <center> <input type=button style='width:130px; height:40px; background: #555; border: 1px solid #333; border-radius: 5px; color: #fff; ' value=Смайлы onClick=window.open('smiles/smiles.html','','width=300,height=80,status=no,menubar=no,toolbar=no,scrollbars=yes') onfocus=if(msg.value=='Сообщение')msg.value='' > </center> </div> </div> </body> </html> Помогите вставить и заменить в сообщениях код на смайлы....
Код (PHP): function smiles($var) { $array = array( '{*SHIELD*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/25.png">', '{*SWORDS*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/24.png">', '{*GOLD*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/23.png">', '{*THUMBS UP*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/22.png">', '{*THUMBS DOWN*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/21.png">', '{%)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/20.png">', '{>:o}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/19.png">', '{*IN LOVE*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/18.png">', '{=-O}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/17.png">', '{:[}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/16.png">', '{:)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/15.png">', '{]:)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/14.png">', '{:'(}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/13.png">', '{*HI*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/12.png">', '{@]->--}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/11.png">', '{;)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/10.png">', '{:D}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/9.png">', '{8)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/8.png">', '{:*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/7.png">', '{:-P}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/6.png">', '{*HEART*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/5.png">', '{:(}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/4.png">', '{]:->}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/3.png">', '{*DRINK*}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/2.png">', '{O:)}' => '<img src="http://'. SITE_URL .'/forum/include/images/smiles/1.png">' ); return strtr($var, $array); }