3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Copyright © 2014, Anthony Jordan (Magictallguy) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Magictallguy. Neither the name of Magictallguy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY ANTHONY JORDAN (MAGICTALLGUY) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANTHONY JORDAN (MAGICTALLGUY) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ function emote($source) { $source = preg_replace('/(\:\))|(\:\=\))|(\:\-\))/', 'smile', $source); $source = preg_replace('/(\:\()|(\:\=\()|(\:\-\()/', 'sadsmile', $source); $source = preg_replace('/(\:D)|(\:\=D)|(\:\-D)/i', 'bigsmile', $source); $source = preg_replace('/(8\))|(8\=\))|(8\-\))|(B\))|(B\=\))|(B\-\))|(\(cool\))/i', 'cool', $source); $source = preg_replace('/(\:o)|(\:\=o)|(\:\-o)/i', 'wink', $source); $source = preg_replace('/(\;\()|(\;\-\()|(\;\=\()/', 'crying', $source); $source = preg_replace('/(\(sweat\))|(\(\:\|)/i', 'sweating', $source); $source = preg_replace('/(\:\|)|(\:\=\|)|(\:\-\|)/', 'speechless', $source); $source = preg_replace('/(\:\*)|(\:\=\*)|(\:\-\*)/', 'kiss', $source); $source = preg_replace('/:P:=P:-P/i', 'tongueout', $source); $source = preg_replace('/(\(blush\))|(\:\$)|(\:\-\$)|(\:\=\$)|(\:\"\>)/i', 'blush', $source); $source = preg_replace('/(\:\^\))/', 'wondering', $source); $source = preg_replace('/(\|\-\))|(\I\-\))|(\I\=\))|(\(snooze\))/i', 'sleepy', $source); $source = preg_replace('/(\|\()|(\|\-\()|(\|\=\()/', 'dull', $source); $source = preg_replace('/(\(inlove\)/i', 'inlove', $source); $source = preg_replace('/(\]\:\))|(>\:\))|(\(grin\))/i', 'evilgrin', $source); $source = preg_replace('/(\(talk\))/i', 'talking', $source); $source = preg_replace('/(\(yawn\))|(\|\-\(\))/i', 'yawn', $source); $source = preg_replace('/(\(puke\))|(\:\&)|(\:\-\&)|(\:\=\&)/i', 'puke', $source); $source = preg_replace('/(\(doh\))/i', 'doh', $source); $source = preg_replace('/(\:\@)|(\:\-\@)|(\:\=\@)|(\x\()|(\x\-\()|(\x\=\()/i', 'angry', $source); $source = preg_replace('/(\(wasntme\))/i', 'wasntme', $source); $source = preg_replace('/(\(party\))/i', 'party', $source); $source = preg_replace('/(\:S)|(\:\-S)|(\:\=S)/i', 'worried', $source); $source = preg_replace('/(\(mm\))|(\(mmm\))/i', 'mmm', $source); $source = preg_replace('/(8\-\|)|(B\-\|)|(8\|)|(B\|)|(8\=\|)|(B\=\|)|(\(nerd\))/i', 'nerd', $source); $source = preg_replace('/(\:x)|(\:\-x)|(\:\=x)|(\:\#)|(\:\-\#)|(\:\=\#)/i', 'lipssealed', $source); $source = preg_replace('/(\(hi\))/i', 'hi', $source); $source = preg_replace('/(\(call\))/i', 'call', $source); $source = preg_replace('/(\(devil\))/i', 'devil', $source); $source = preg_replace('/(\(angel\))/i', 'angel', $source); $source = preg_replace('/(\(envy\))/i', 'envy', $source); $source = preg_replace('/(\(wait\))/i', 'wait', $source); $source = preg_replace('/(\(bear\))|(\(hug\))/i', 'bear', $source); $source = preg_replace('/(\(makeup\))|(\(kate\))/i', 'makeup', $source); $source = preg_replace('/(\(giggle\))|(\(chuckle\))/i', 'coveredlaugh', $source); $source = preg_replace('/(\(clap\))|(\(applaud\))|(\(applause\))/i', 'clapping', $source); $source = preg_replace('/(\(think\))|(\:\?)|(\:\-\?)|(\:\=\?)/i', 'thinking', $source); $source = preg_replace('/(\(bow\))/i', 'bow', $source); $source = preg_replace('/(rofl)|(\(rofl\))/i', 'rofl', $source); $source = preg_replace('/(\(whew\))|(\(phew\))/i', 'whew', $source); $source = preg_replace('/(\(happy\))/i', 'happy', $source); $source = preg_replace('/(\(smirk\))/i', 'smirking', $source); $source = preg_replace('/(\(nod\))/i', 'nodding', $source); $source = preg_replace('/(\(shake\))/i', 'shaking', $source); $source = preg_replace('/(\(punch\))/i', 'punch', $source); $source = preg_replace('/(\(emo\))/i', 'emo', $source); $source = preg_replace('/(\(y\))|(\(ok\))/i', 'yes', $source); $source = preg_replace('/(\(n\))/i', 'no', $source); $source = preg_replace('/(\(handshake\))/i', 'handshake', $source); $source = preg_replace('/(\(skype\))|(\(ss\))/i', 'skype', $source); $source = preg_replace('/(\(h\))|(\(l\))/i', 'heart', $source); $source = preg_replace('/(\(u\))/i', 'brokenheart', $source); $source = preg_replace('/(\(e\))|(\(m\))/i', 'mail', $source); $source = preg_replace('/(\(f\))/i', 'flower', $source); $source = preg_replace('/(\(rain\))|(\(london\))|(\(st\))/i', 'rain', $source); $source = preg_replace('/(\(sun\))/i', 'sun', $source); $source = preg_replace('/(\(o\))|(\(time\))|(\(clock\))/i', 'clock', $source); $source = preg_replace('/(\(8\))|(\(music\))/i', 'music', $source); $source = preg_replace('/(\(\~\))|(\(film\))|(\(movie\))/i', 'movie', $source); $source = preg_replace('/(\(mp\))|(\(ph\))|(\(phone\))|(\(mobile\))|(\(cell\))/i', 'phone', $source); $source = preg_replace('/(\(coffee\))/i', 'coffee', $source); $source = preg_replace('/(\(pizza\))|(\(pi\))|(\(za\))/i', 'pizza', $source); $source = preg_replace('/(\(cash\))|(\(mo\))|(\(\$\))/i', 'cash', $source); $source = preg_replace('/(\(muscle\))|(\(flex\))/i', 'muscle', $source); $source = preg_replace('/(\(\^\))|(\(cake\))/i', 'cake', $source); $source = preg_replace('/(\(beer\))/i', 'beer', $source); $source = preg_replace('/(\(d\))/i', 'drink', $source); $source = preg_replace('/(\(dance\))|(\\\o\/)|(\\\:D\/)/i', 'dance', $source); $source = preg_replace('/(\(ninja\))/i', 'ninja', $source); $source = preg_replace('/(\(\*\))|(\(star\))/i', 'star', $source); $source = preg_replace('/(\(mooning\))/i', 'mooning', $source); $source = preg_replace('/(\(finger\))/i', 'finger', $source); $source = preg_replace('/(\(smoking\))|(\(smoke\))|(\(ci\))|(\(cig\))/i', 'smoking', $source); $source = preg_replace('/(\(drunk\))/i', 'drunk', $source); $source = preg_replace('/(\(bandit\))/i', 'bandit', $source); $source = preg_replace('/(\(toivo\))/i', 'toivo', $source); $source = preg_replace('/(\(rock\))/i', 'rock', $source); $source = preg_replace('/(\(headbang\))|(\(banghead\))/i', 'headbang', $source); $source = preg_replace('/(\(bug\))/i', 'bug', $source); $source = preg_replace('/(\(fubar\))/i', 'fubar', $source); $source = preg_replace('/(\(poolparty\))/i', 'poolparty', $source); $source = preg_replace('/(\(swear\))/i', 'swear', $source); $source = preg_replace('/(\(tmi\))/i', 'tmi', $source); $source = preg_replace('/(\(heidy\))/i', 'heidy', $source); $source = preg_replace('/(\(malthe\))/i', 'malthe', $source); $source = preg_replace('/(\(tauri\))/i', 'tauri', $source); $source = preg_replace('/(\(priidu\))/i', 'priidu', $source); // foreach($emotes as $command => $image) // $source = preg_replace($command, '[emote]images/smilies/skype/'.$image.'.gif[/emote]', $source); return $source; } function show_emoticons() { $emotes = array( ':)' => 'smile', ':(' => 'sadsmile', ':D' => 'bigsmile', '8)' => 'cool', ':O' => 'wink', ';(' => 'crying', '(sweat)' => 'sweating', ':|' => 'speechless', ':*' => 'kiss', ':P' => 'tongueout', ':$' => 'blush', ':^' => 'wondering', '|-\\' => 'sleepy', '|(' => 'dull', '(inlove)' => 'inlove', '>:)' => 'evilgrin', '(talk)' => 'talking', '(yawn)' => 'yawn', ':&' => 'puke', '(doh)' => 'doh', ':@' => 'angry', '(wasntme)' => 'wasntme', '(party)' => 'party', ':S' => 'worried', '(mmm)' => 'mmm', '8-|' => 'nerd', ':X' => 'lipssealed', '(hi)' => 'hi', '(call)' => 'call', '(devil)' => 'devil', '(angel))' => 'angel', '(envy)' => 'envy', '(wait)' => 'wait', '(bear)' => 'bear', '(makeup)' => 'makeup', '(giggle)' => 'coveredlaugh', '(clap)' => 'clapping', ':?' => 'thinking', '(bow)' => 'bow', '(rofl)' => 'rofl', '(phew)' => 'whew', '(happy)' => 'happy', '(smirk)' => 'smirking', '(nod)' => 'nodding', '(shake)' => 'shaking', '(punch)' => 'punch', '(emo)' => 'emo', '(y)' => 'yes', '(n)' => 'no', '(handshake)' => 'handshake', '(skype)' => 'skype', '(h)' => 'heart', '(u)' => 'brokenheart', '(e)' => 'mail', '(f)' => 'flower', '(rain)' => 'rain', '(sun)' => 'sun', '(clock)' => 'clock', '(8)' => 'music', '(movie)' => 'movie', '(phone)' => 'phone', '(coffee)' => 'coffee', '(pizza)' => 'pizza', '(cash)' => 'cash', '(muscle)' => 'muscle', '(cake)' => 'cake', '(beer)' => 'beer', '(d)' => 'drink', '(dance)' => 'dance', '(ninja)' => 'ninja', '(*)' => 'star', '(mooning)' => 'mooning', '(finger)' => 'finger', '(smoking)' => 'smoking', '(drunk)' => 'drunk', '(bandit)' => 'bandit', '(toivo)' => 'toivo', '(rock)' => 'rock', '(headbang)' => 'headbang', '(bug)' => 'bug', '(fubar)' => 'fubar', '(poolparty)' => 'poolparty', '(swear)' => 'swear', '(tmi)' => 'tmi', '(heidy)' => 'heidy', '(malthe)' => 'malthe', '(tauri)' => 'tauri', '(priidu)' => 'priidu' ); $html = '<a href="#" name="emotes" id="showhide">Toggle Emotes</a><br /><div class="emoticon-list" id="emotes" style="display:none;">'; foreach($emoticons as $short_code => $short_html) $html .= '<img src="images/smilies/skype/' . $short_html . '.gif" data-short-code="' . $short_code . '" />&nbsp;'; $html .= '</div><br /><a href="bbcode.php">Chat Commands</a>'; $js1 = "<script language=\"JavaScript\" type=\"text/javascript\"> <!-- function insertTextAtCursor(el, text) { var val = el.value, endIndex, range, doc = el.ownerDocument; if (typeof el.selectionStart == 'number' && typeof el.selectionEnd == 'number') { endIndex = el.selectionEnd; el.value = val.slice(0, endIndex) + text + val.slice(endIndex); el.selectionStart = el.selectionEnd = endIndex + text.length; } else if (doc.selection != 'undefined' && doc.selection.createRange) { el.focus(); range = doc.selection.createRange(); range.collapse(false); range.text = text; range.select(); } } //--> </script>"; $js2 = "<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.8.3.min.js\"></script>"; $js3 = "<script type=\"text/javascript\"> jQuery(document).ready(function() { jQuery('div.emoticon-list img').click(function() { var jThis = jQuery(this), jMessage = jQuery('input#message'); jMessage.val(jMessage.val() + ' ' + jThis.attr('data-short-code')); }); }); </script>"; $js4 = "<script> var iframeWin = document.getElementById('message').contentWindow; var textObj = iframeWin.document.getElementById('message'); insertTextAtCursor(textObj, jThis.attr('data-short-code')); </script>"; $js5 = "<script> $(document).ready(function(){ $('#showhide').click(function(){ $('#emotes').toggle('slow'); }); }); </script>"; $css = '<style type="text/css"> div.emoticon-list { padding: 5px; border: none; } div.emoticon-list img { cursor: pointer; margin-right: 3px; border: none; width: 20px; height: 20px; } div.emoticon-list img:hover { border: 1px solid #003F87; } </style>'; echo $js5, $html, $css, $js1, $js2, $js3, $js4; } ?> <?php $complete = 1; ?> <?php echo emote(":)");

preferences:
65 ms | 402 KiB | 5 Q