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) { $emotes = array( '/(\:\))|(\:\=\))|(\:\-\))/' => 'smile', '/(\:\()|(\:\=\()|(\:\-\()/' => 'sadsmile', '/(\:D)|(\:\=D)|(\:\-D)/i' => 'bigsmile', '/(8\))|(8\=\))|(8\-\))|(B\))|(B\=\))|(B\-\))|(\(cool\))' => 'cool', '/(\:o)|(\:\=o)|(\:\-o)/i' => 'wink', '/(\;\()|(\;\-\()|(\;\=\()/' => 'crying', '/(\(sweat\))|(\(\:\|)/i' => 'sweating', '/(\:\|)|(\:\=\|)|(\:\-\|)/' => 'speechless', '/(\:\*)|(\:\=\*)|(\:\-\*)/' => 'kiss', '/:P:=P:-P/i' => 'tongueout', '(\(blush\))|(\:\$)|(\:\-\$)|(\:\=\$)|(\:\"\>)/i' => 'blush', '/(\:\^\))/' => 'wondering', '/(\|\-\))|(\I\-\))|(\I\=\))|(\(snooze\))/i' => 'sleepy', '/(\|\()|(\|\-\()|(\|\=\()/' => 'dull', '/(\(inlove\)/i' => 'inlove', '/(\]\:\))|(>\:\))|(\(grin\))/i' => 'evilgrin', '/(\(talk\))/i' => 'talking', '/(\(yawn\))|(\|\-\(\))/i' => 'yawn', '/(\(puke\))|(\:\&)|(\:\-\&)|(\:\=\&)/i' => 'puke', '/(\(doh\))/i' => 'doh', '/(\:\@)|(\:\-\@)|(\:\=\@)|(\x\()|(\x\-\()|(\x\=\()/i' => 'angry', '/(\(wasntme\))/i' => 'wasntme', '/(\(party\))/i' => 'party', '/(\:S)|(\:\-S)|(\:\=S)/i' => 'worried', '/(\(mm\))|(\(mmm\))/i' => 'mmm', '/(8\-\|)|(B\-\|)|(8\|)|(B\|)|(8\=\|)|(B\=\|)|(\(nerd\))/i' => 'nerd', '/(\:x)|(\:\-x)|(\:\=x)|(\:\#)|(\:\-\#)|(\:\=\#)/i' => 'lipssealed', '/(\(hi\))/i' => 'hi', '/(\(call\))/i' => 'call', '/(\(devil\))/i' => 'devil', '/(\(angel\))/i' => 'angel', '/(\(envy\))/i' => 'envy', '/(\(wait\))/i' => 'wait', '/(\(bear\))|(\(hug\))/i' => 'bear', '/(\(makeup\))|(\(kate\))/i' => 'makeup', '/(\(giggle\))|(\(chuckle\))/i' => 'coveredlaugh', '/(\(clap\))|(\(applaud\))|(\(applause\))/i' => 'clapping', '/(\(think\))|(\:\?)|(\:\-\?)|(\:\=\?)/i' => 'thinking', '/(\(bow\)/i' => 'bow', '/(rofl)|(\(rofl\))/i' => 'rofl', '/(\(whew\))|(\(phew\))/i' => 'whew', '/(\(happy\))/i' => 'happy', '/(\(smirk\))/i' => 'smirking', '/(\(nod\))/i' => 'nodding', '/(\(shake\))/i' => 'shaking', '/(\(punch\))/i' => 'punch', '/(\(emo\))/i' => 'emo', '/(\(y\))|(\(ok\))/i' => 'yes', '/(\(n\)))/i' => 'no', '/(\(handshake\))/i' => 'handshake', '/(\(skype\))|(\(ss\))/i' => 'skype', '/(\(h\))|(\(l\))/i' => 'heart', '/(\(u\))/i' => 'brokenheart', '/(\(e\))|(\(m\))/i' => 'mail', '/(\(f\))/i' => 'flower', '/(\(rain\))|(\(london\))|(\(st\))/i' => 'rain', '/(\(sun\))/i' => 'sun', '/(\(o\))|(\(time\))|(\(clock\))/i' => 'clock', '/(\(8\))|(\(music\))/i' => 'music', '/(\(\~\))|(\(film\))|(\(movie\))/i' => 'movie', '/(\(mp\))|(\(ph\))|(\(phone\))|(\(mobile\))|(\(cell\))/i' => 'phone', '/(\(coffee\))/i' => 'coffee', '/(\(pizza\))|(\(pi\))|(\(za\))/i' => 'pizza', '/(\(cash\))|(\(mo\))|(\(\$\))/i' => 'cash', '/(\(muscle\))|(\(flex\))/i' => 'muscle', '/(\(\^\))|(\(cake\))/i' => 'cake', '/(\(beer\))/i' => 'beer', '/(\(d\))/i' => 'drink', '/(\(dance\))|(\\\o\/)|(\\\:D\/)/i' => 'dance', '/(\(ninja\))/i' => 'ninja', '/(\(\*\))|(\(star\))/i' => 'star', '/(\(mooning\))/i' => 'mooning', '/(\(finger\))/i' => 'finger', '/(\(smoking\))|(\(smoke\))|(\(ci\))|(\(cig\))/i' => 'smoking', '/(\(drunk\))/i' => 'drunk', '/(\(bandit\))/i' => 'bandit', '/(\(toivo\))/i' => 'toivo', '/(\(rock\))/i' => 'rock', '/(\(headbang\))|(\(banghead\))/i' => 'headbang', '/(\(bug\))/i' => 'bug', '/(\(fubar\))/i' => 'fubar', '/(\(poolparty\))/i' => 'poolparty', '/(\(swear\))/i' => 'swear', '/(\(tmi\))/i' => 'tmi', '/(\(heidy\))/i' => 'heidy', '/(\(malthe\))/i' => 'malthe', '/(\(tauri\))/i' => 'tauri', '/(\(priidu\))/i' => 'priidu' ); 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(":)");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sg2GZ
function name:  (null)
number of ops:  7
compiled vars:  !0 = $complete
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  265     0  E >   ASSIGN                                                   !0, 1
  266     1        ECHO                                                     '%0A'
  268     2        INIT_FCALL                                               'emote'
          3        SEND_VAL                                                 '%3A%29'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > RETURN                                                   1

Function emote:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/sg2GZ
function name:  emote
number of ops:  17
compiled vars:  !0 = $source, !1 = $emotes, !2 = $image, !3 = $command
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN                                                   !1, <array>
  104     2      > FE_RESET_R                                       $5      !1, ->14
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->14
          4    >   ASSIGN                                                   !3, ~6
  105     5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAR                                                 !3
          7        CONCAT                                           ~8      '%5Bemote%5Dimages%2Fsmilies%2Fskype%2F', !2
          8        CONCAT                                           ~9      ~8, '.gif%5B%2Femote%5D'
          9        SEND_VAL                                                 ~9
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !0, $10
  104    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $5
  106    15      > RETURN                                                   !0
  107    16*     > RETURN                                                   null

End of function emote

Function show_emoticons:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/sg2GZ
function name:  show_emoticons
number of ops:  27
compiled vars:  !0 = $emotes, !1 = $html, !2 = $emoticons, !3 = $short_html, !4 = $short_code, !5 = $js1, !6 = $js2, !7 = $js3, !8 = $js4, !9 = $js5, !10 = $css
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  110     0  E >   ASSIGN                                                   !0, <array>
  200     1        ASSIGN                                                   !1, '%3Ca+href%3D%22%23%22+name%3D%22emotes%22+id%3D%22showhide%22%3EToggle+Emotes%3C%2Fa%3E%3Cbr+%2F%3E%3Cdiv+class%3D%22emoticon-list%22+id%3D%22emotes%22+style%3D%22display%3Anone%3B%22%3E'
  201     2      > FE_RESET_R                                       $13     !2, ->11
          3    > > FE_FETCH_R                                       ~14     $13, !3, ->11
          4    >   ASSIGN                                                   !4, ~14
  202     5        CONCAT                                           ~16     '%3Cimg+src%3D%22images%2Fsmilies%2Fskype%2F', !3
          6        CONCAT                                           ~17     ~16, '.gif%22+data-short-code%3D%22'
          7        CONCAT                                           ~18     ~17, !4
          8        CONCAT                                           ~19     ~18, '%22+%2F%3E%26nbsp%3B'
          9        ASSIGN_OP                                     8          !1, ~19
  201    10      > JMP                                                      ->3
         11    >   FE_FREE                                                  $13
  203    12        ASSIGN_OP                                     8          !1, '%3C%2Fdiv%3E%3Cbr+%2F%3E%3Ca+href%3D%22bbcode.php%22%3EChat+Commands%3C%2Fa%3E'
  204    13        ASSIGN                                                   !5, '%3Cscript+language%3D%22JavaScript%22+type%3D%22text%2Fjavascript%22%3E+%0A%09%3C%21--%0A%09function+insertTextAtCursor%28el%2C+text%29+%7B%0A%09%09var+val+%3D+el.value%2C+endIndex%2C+range%2C+doc+%3D+el.ownerDocument%3B%0A%09%09if+%28typeof+el.selectionStart+%3D%3D+%27number%27%0A%09%09%09%09%26%26+typeof+el.selectionEnd+%3D%3D+%27number%27%29+%7B%0A%09%09%09endIndex+%3D+el.selectionEnd%3B%0A%09%09%09el.value+%3D+val.slice%280%2C+endIndex%29+%2B+text+%2B+val.slice%28endIndex%29%3B%0A%09%09%09el.selectionStart+%3D+el.selectionEnd+%3D+endIndex+%2B+text.length%3B%0A%09%09%7D+else+if+%28doc.selection+%21%3D+%27undefined%27+%26%26+doc.selection.createRange%29+%7B%0A%09%09%09el.focus%28%29%3B%0A%09%09%09range+%3D+doc.selection.createRange%28%29%3B%0A%09%09%09range.collapse%28false%29%3B%0A%09%09%09range.text+%3D+text%3B%0A%09%09%09range.select%28%29%3B%0A%09%09%7D%0A%09%7D%0A%09%2F%2F--%3E%0A%09%3C%2Fscript%3E'
  223    14        ASSIGN                                                   !6, '%3Cscript+type%3D%22text%2Fjavascript%22+src%3D%22http%3A%2F%2Fcode.jquery.com%2Fjquery-1.8.3.min.js%22%3E%3C%2Fscript%3E'
  224    15        ASSIGN                                                   !7, '%3Cscript+type%3D%22text%2Fjavascript%22%3E%0A%09%09jQuery%28document%29.ready%28function%28%29+%7B%0A%09%09jQuery%28%27div.emoticon-list+img%27%29.click%28function%28%29+%7B%0A%09%09%09var+jThis+%3D+jQuery%28this%29%2C+jMessage+%3D+jQuery%28%27input%23message%27%29%3B%0A%09%09%09jMessage.val%28jMessage.val%28%29+%2B+%27+%27+%2B+jThis.attr%28%27data-short-code%27%29%29%3B%0A%09%09%7D%29%3B%0A%09%09%7D%29%3B%0A%09%3C%2Fscript%3E'
  232    16        ASSIGN                                                   !8, '%3Cscript%3E%0A%09var+iframeWin+%3D+document.getElementById%28%27message%27%29.contentWindow%3B%0A%09var+textObj+%3D+iframeWin.document.getElementById%28%27message%27%29%3B%0A%09insertTextAtCursor%28textObj%2C+jThis.attr%28%27data-short-code%27%29%29%3B%0A%09%3C%2Fscript%3E'
  237    17        ASSIGN                                                   !9, '%3Cscript%3E%0A%09%24%28document%29.ready%28function%28%29%7B%0A%09%09%24%28%27%23showhide%27%29.click%28function%28%29%7B%0A%09%09%24%28%27%23emotes%27%29.toggle%28%27slow%27%29%3B%0A%09%09%7D%29%3B%0A%09%7D%29%3B%0A%09%3C%2Fscript%3E'
  244    18        ASSIGN                                                   !10, '%3Cstyle+type%3D%22text%2Fcss%22%3E%0A%09div.emoticon-list+%7B%0A%09%09padding%3A+5px%3B%0A%09%09border%3A+none%3B%0A%09%7D%0A%0A%09div.emoticon-list+img+%7B%0A%09%09cursor%3A+pointer%3B%0A%09%09margin-right%3A+3px%3B%0A%09%09border%3A+none%3B%0A%09%09width%3A+20px%3B%0A%09%09height%3A+20px%3B%0A%09%7D%0A%0A%09div.emoticon-list+img%3Ahover+%7B%0A%09%09border%3A+1px+solid+%23003F87%3B%0A%09%7D%0A%09%3C%2Fstyle%3E'
  262    19        ECHO                                                     !9
         20        ECHO                                                     !1
         21        ECHO                                                     !10
         22        ECHO                                                     !5
         23        ECHO                                                     !6
         24        ECHO                                                     !7
         25        ECHO                                                     !8
  263    26      > RETURN                                                   null

End of function show_emoticons

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.19 ms | 1406 KiB | 16 Q