3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*----------------------------------------------------- -- Mono Country v1.0 BETA -- A product of DBS-entertainment -- Copyright held 2005 by Dabomstew -- INDEX.php -----------------------------------------------------*/ function file_check($file) { if(!file_exists(__DIR__ . '/' . $file.'.php')) exit('You\'re missing a major file!'); require(__DIR__ . '/' . $file.'.php'); } function s($num) { return $num == 1 ? '' : 's'; } function format($str, $dec = 0) { return is_numeric($str) ? number_format($str, $dec) : stripslashes(htmlentities($str, ENT_COMPAT, 'UTF-8')); } function kill($msg) { global $h; echo "<font size='4' face='Arial, Helvetica, sans-serif'>Error</font><br /><br />",$msg; $h->endpage(); exit; } if(!isset($_SESSION)) session_start(); file_check('global_func'); if(!isset($_SESSION['loggedin']) || empty($_SESSION['loggedin']) || !isset($_SESSION['userid']) || empty($_SESSION['userid']) || !is_int($_SESSION['userid'])) { header('Location: login.php'); exit; } $userid = $_SESSION['userid']; file_check('header'); $h = new headers; $h->startheaders(); file_check('mysql'); global $c; if(!is_resource($c)) exit('You\'re not connected to the database'); $is = mysql_query('SELECT `u`.*, `us`.* ' . 'FROM `users` AS `u` ' . 'LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) ' . 'WHERE `u`.`userid` = '.$userid, $c) or kill(mysql_error()); if(!mysql_num_rows($is)) { session_unset(); session_destroy(); exit('There appears to be an issue with your account'); } $ir = mysql_fetch_assoc($is); $current_row = 0; check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'],''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); if($ir['mailban']) kill("<center><font color=red>You have been mail banned for ".format($ir['mailban'])." day".s($ir['mailban']).".<br /> <strong>Reason: ".format($ir['mb_reason'])."</font></strong>"); $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; ?><center><font size='4' face='Arial, Helvetica, sans-serif'>Mail Box</font><hr width=90%><table width=90% border=0><tr> <td width='20%' class='center'>&gt; <a href='mailbox.php?action=compose'> Compose</a></td> <td width='20%' class='center'>&gt; <a href='mailbox.php?action=outbox'> Outbox</a></td> <td width='20%' class='center'>&gt; <a href='mailbox.php?action=archive'> Save</a></td> <td width='20%' class='center'>&gt; <a href='mailbox.php?action=delall'> Delete All</a></td> <td width='20%' class='center'>&gt; <a href='mailbox.php?action=mailhome'> Inbox</a></td> </tr></table><hr width=90%><?php $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'inbox': mail_inbox(); break;  case 'outbox': mail_outbox(); break;  case 'compose': mail_compose(); break;  case 'delete': mail_delete(); break;  case 'delall': mail_delall(); break;  case 'archive': mail_archive(); break;  case 'read': mail_view(); break;  case 'readmail': mail_view_outbox(); break;  case 'mailhome': mail_home(); break;   default: mail_home(); break; } function mail_home() { global $ir, $c, $userid, $h, $current_row; ?>Below are the Last 10 Messages Sent to You<hr width='90%'> <table width='90%' cellpadding='2'> <tr bgcolor='AAAAAA'> <th width='30%'>From</th> <th width='40%'>Subject</th> <th width='15%'>Status</th> <th width='15%'>Manage</th> </tr><?php $q = mysql_query('SELECT `m`.*, `u`.* ' . 'FROM `mail` AS `m` ' . 'LEFT JOIN `users` AS `u` ON (`m`.`mail_from` = `u`.`userid`) ' . 'WHERE `m`.`mail_to` = '.$userid.' ORDER BY `mail_time` DESC LIMIT 10', $c); if(!mysql_num_rows($q)) echo '<tr><td colspan="4" class="center">You have no messages</td></tr>'; else while($r = mysql_fetch_assoc($q)) { echo '<tr class="row',$current_row,'"> <td>',($r['userid'] ? '<a href="viewuser.php?u='.$r['userid'].'">'.format($r['username']).'</a> ['.format($r['userid']).']' : 'SYSTEM'),'</td> <td><strong>Subject:</strong> <a href="mailbox.php?action=read&amp;ID=',$r['mail_id'],'">',format($r['mail_subject']),'</a> <em>Sent at: ',date('F j, Y, g:i:s a', $r['mail_time']),'</em></td> <td class="center">',(!$r['mail_read'] ? '<span style="color:red;">Unread</span>' : '<span style="color:green;">Read</span>'),'</td> <td class="center">[<a href="mailbox.php?action=delete&amp;ID=',$r['mail_id'],'">Delete</a>] [<a href="mailbox.php?action=read&amp;ID=',$r['mail_id'],'">Read</a>]</td> </tr>'; --$current_row; } ?></table><?php } function mail_view() { global $ir, $c, $userid, $h; $q = mysql_query('SELECT `m`.*, `u`.* ' . 'FROM `mail` AS `m` ' . 'LEFT JOIN `users` AS `u` ON (`m`.`mail_from` = `u`.`userid`) ' . 'WHERE `m`.`mail_id` = '.$_GET['ID'].' AND `m`.`mail_to` = '.$userid); if(!mysql_num_rows($q)) kill('Either that message doesn\'t exist, or it\'s not yours to read!'); mysql_query('UPDATE `mail` SET `mail_read` = 1 WHERE `mail_id` = '.$_GET['ID'], $c) or kill(mysql_error()); $r = mysql_fetch_assoc($q); $from = ($r['userid']) ? '<strong>Mail From:</strong> <a href="viewuser.php?u='.$r['userid'].'">'.format($r['username']).'</a> ['.format($r['userid']).']' : 'SYSTEM'; ?><table width='90%' cellpadding='2'> <tr class='row1'> <th bgcolor='#AAAAAA' width='75%'><strong>Subject:</strong> <?php echo format($r['mail_subject']);?></th> </tr> <tr> <td>Sent at: <?php echo date('F j, Y, g:i:s a', $r['mail_time']);?> <a href='mailbox.php?action=compose&amp;ID=<?php echo $r['mail_from'];?>'>Reply</a> <a href='mailbox.php?action=delete&amp;ID=<?php echo $r['mail_id'];?>'>Delete</a> <a href='preport.php?ID=<?php echo $r['mail_from'];?>'>Report</a></td> <td><?php echo format($r['mail_text']);?></td> </tr> </table> <form action='mailbox.php?action=send' method='post'> <table width='90%' cellpadding='2'> <tr> <th colspan='2' bgcolor='#AAAAAA'><strong>Reply To This Message</strong></th> </tr> <tr class='row1'> <td>User's ID:</td> <td><input type='text' name='userid' value='<?php echo isset($r['userid']) ? $r['userid'] : '';?>' size='5' maxlength='10' /> <i><font size='1.9'>(E.g. 123456)</font></i></td> </tr> <tr> <td>Subject:</td> <td><input type='text' name='subject' size='50' maxlength='50' value='' /> <i><font size='1.9'>(E.g. Hello there)</font></i></td> </tr> <tr> <td>Message:</td> <td><textarea rows='10' cols='75%' name='message'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' value='Send' /></td> </tr> </table> </form><?php  } function mail_view_outbox() { global $ir, $c, $userid, $h; $q = mysql_query('SELECT `m`.*, `u`.* ' . 'FROM `mail` AS `m` ' . 'LEFT JOIN `users` AS `u` ON (`m`.`mail_to` = `u`.`userid`) ' . 'WHERE `m`.`mail_id` = '.$_GET['ID'].' AND `m`.`mail_from` = '.$userid); if(!mysql_num_rows($q)) kill('Either that message doesn\'t exist, or it\'s not yours to read!'); $r = mysql_fetch_assoc($q); $from = ($r['userid']) ? '<strong>Mail To:</strong> <a href="viewuser.php?u='.$r['userid'].'">'.format($r['username']).'</a> ['.format($r['userid']).']' : 'SYSTEM'; ?><table width='90%' cellpadding='2'> <tr class='row1'> <th bgcolor='#AAAAAA' width='75%'><strong>Subject:</strong> <?php echo format($r['mail_subject']);?></th> </tr> <tr> <td>Sent at: <?php echo date('F j, Y, g:i:s a', $r['mail_time']);?> <a href='mailbox.php?action=compose&amp;ID=<?php echo $r['mail_to'];?>'>Compose</a> <a href='mailbox.php?action=delete&amp;ID=<?php echo $r['mail_id'];?>'>Delete</a></td> <td><?php echo format($r['mail_text']);?></td> </tr> </table> <form action='mailbox.php?action=send' method='post'> <table width='90%' cellpadding='2'> <tr> <th colspan='2' bgcolor='#AAAAAA'><strong>Compose Another Message</strong></th> </tr> <tr class='row1'> <td>User's ID:</td> <td><input type='text' name='userid' value='<?php echo isset($r['userid']) ? $r['userid'] : '';?>' size='5' maxlength='10' /> <i><font size='1.9'>(E.g. 123456)</font></i></td> </tr> <tr> <td>Subject:</td> <td><input type='text' name='subject' size='50' maxlength='50' value='' /> <i><font size='1.9'>(E.g. Hello there)</font></i></td> </tr> <tr> <td>Message:</td> <td><textarea rows='10' cols='75%' name='message'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' value='Send' /></td> </tr> </table> </form><?php  } function mail_outbox() { global $ir, $c, $userid, $h, $current_row; ?>Below are the Last 10 Messages You've Sent<hr width='90%'> <table width='90%' cellpadding='2'> <tr bgcolor='AAAAAA'> <th width='30%'>To</th> <th width='40%'>Subject</th> <th width='15%'>Status</th> <th width='15%'>Manage</th> </tr><?php $q = mysql_query('SELECT `m`.*, `u`.* ' . 'FROM `mail` AS `m` ' . 'LEFT JOIN `users` AS `u` ON (`m`.`mail_to` = `u`.`userid`) ' . 'WHERE `m`.`mail_from` = '.$userid.' ORDER BY `mail_time` DESC LIMIT 10', $c); if(!mysql_num_rows($q)) echo '<tr><td colspan="4" class="center">You have no messages</td></tr>'; else while($r = mysql_fetch_assoc($q)) { echo '<tr class="row',$current_row,'"> <td>',($r['userid'] ? '<a href="viewuser.php?u='.$r['userid'].'">'.format($r['username']).'</a> ['.format($r['userid']).']' : 'SYSTEM'),'</td> <td><strong>Subject:</strong> <a href="mailbox.php?action=read&amp;ID=',$r['mail_id'],'">',format($r['mail_subject']),'</a> <em>Sent at: ',date('F j, Y, g:i:s a', $r['mail_time']),'</em></td> <td class="center">',(!$r['mail_read'] ? '<span style="color:red;">Unread</span>' : '<span style="color:green;">Read</span>'),'</td> <td class="center">[<a href="mailbox.php?action=delete&amp;ID=',$r['mail_id'],'">Delete</a>] [<a href="mailbox.php?action=read&amp;ID=',$r['mail_id'],'">Read</a>]</td> </tr>'; --$current_row; } ?></table><?php } function mail_compose() { global $ir, $c, $userid, $h; if(!array_key_exists('submit', $_POST)) { ?><form action='mailbox.php?action=compose' method='post'> <table width='90%' cellpadding='2'> <tr> <td colspan='3' bgcolor='#AAAAAA'><strong>Send a Message</strong></td> </tr> <tr> <td>User's ID:</td> <td><input type='text' name='userid' value='<?php echo $_GET['ID'];?>' size='5' maxlength='10' /> <i><font size='1.9'>(E.g. 123456)</font></i></td> </tr> <tr> <td>Subject:</td> <td><input type='text' name='subject' size='50' maxlength='50' value='' /> <i><font size='1.9'>(E.g. Hello there)</font></i></td> </tr> <tr> <td>Message:</td> <td><textarea rows='10' cols='75%' name='message'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Send' /></td> </tr> </table> </form> <hr width='90%'>&gt; <a href='mailbox.php'>Back to Messages</a><hr width='90%'><?php if(!empty($_GET['ID'])) { ?><table width='90%' cellpadding='2'> <tr> <td colspan='2' bgcolor='#AAAAAA'><strong>Your last 5 mails to/from this person:</strong></td> </tr><?php $q = mysql_query('SELECT `m`.*, `u1`.`username` AS `sender` ' . 'FROM `mail` AS `m` ' . 'LEFT JOIN `users` AS `u1` ON (`m`.`mail_from` = `u1`.`userid`) ' . 'WHERE (`m`.`mail_from` = '.$userid.' AND `m`.`mail_to` = '.$_GET['ID'].') OR (`m`.`mail_to` = '.$userid.' AND `m`.`mail_from` = '.$_GET['ID'].') ' . 'ORDER BY `m`.`mail_time` DESC LIMIT 5', $c) or kill(mysql_error()); if(!mysql_num_rows($q)) echo "<tr><td colspan='2' class='center'>None found</td></tr>"; else while($r = mysql_fetch_assoc($q)) { ?><tr class='row<?php echo $current_row;?>'> <td><?php echo date('F j, Y, g:i:s a', $r['mail_time']);?></td> <td><strong><?php echo format($r['sender']);?> wrote:</strong> <?php echo format($r['mail_text']);?></td> </tr><?php --$current_row; } ?></table><?php } } else { $_POST['userid'] = isset($_POST['userid']) && ctype_digit($_POST['userid']) ? abs(@intval($_POST['userid'])) : null; if(empty($_POST['userid'])) kill("You didn't enter a valid player's ID"); $selectUser = mysql_query("SELECT `userid` FROM `users` WHERE `userid` = ".$_POST['userid'], $c) or kill(mysql_error()); if(!mysql_num_rows($selectUser)) kill("That player doesn't exist!"); $subj = str_replace("\n", '', strip_tags(mysql_real_escape_string($_POST['subject'], $c))); $msg = str_replace("\n", '', strip_tags(mysql_real_escape_string($_POST['message'], $c))); $codes = array( ':]', '<img src="images/smilies/biggrin.png" border="0" alt="" title="Big Grin" class="inlineimg" />', '<img src="images/smilies/redface.png" border="0" alt="" title="Embarrassment" class="inlineimg" />o:', 'O.o', ':/', ':angry:', ':?:', ':lol:', ':-:', ':O', '<img src="images/smilies/frown.png" border="0" alt="" title="Frown" class="inlineimg" />', 'O.O', ':roll:', ':zzz:', '<img src="images/smilies/smile.png" border="0" alt="" title="Smile" class="inlineimg" />', ':P', ':S', ':nut:', '<img src="images/smilies/wink.png" border="0" alt="" title="Wink" class="inlineimg" />', ':heart:', 'XD', ); $images  = array( '[img]smilies/happy.gif[/img]', '[img]smilies/biggrin.gif[/img]', '[img]smilies/cool.gif[/img]', '[img]smilies/blink.gif[/img]', '[img]smilies/dry.gif[/img]', '[img]smilies/angry.gif[/img]', '[img]smilies/huh.gif[/img]', '[img]smilies/laugh.gif[/img]', '[img]smilies/mellow.gif[/img]', '[img]smilies/ohmy.gif[/img]', '[img]smilies/sad.gif[/img]', '[img]smilies/ph34r.gif[/img]', '[img]smilies/rolleyes.gif[/img]', '[img]smilies/sleep.gif[/img]', '[img]smilies/smile.gif[/img]', '[img]smilies/tongue.gif[/img]', '[img]smilies/unsure.gif[/img]', '[img]smilies/wacko.gif[/img]', '[img]smilies/wink.gif[/img]', '[img]smilies/wub.gif[/img]', '[img]smilies/XD.gif[/img]', ); $newmsg = str_replace($codes, $images, $msg); mysql_query("INSERT INTO `mail` VALUES ('', 0, ".$userid.", ".$to.", ".time().", '".$subj."', '".$newmsg."')", $c) or kill(mysql_error()); echo "Your Message has been sent.<gbr /><a href='mailbox.php'>&gt; Back</a>"; } } function mail_delete() { global $ir, $c, $userid, $h; if(empty($_GET['ID'])) kill("You didn't select a valid message"); $select = mysql_query("SELECT `mail_id` FROM `mail` WHERE `mail_id` = ".$_GET['ID']." AND `mail_to` = ".$userid, $c) or kill(mysql_error()); if(!mysql_num_rows($select)) kill("Either that message doesn't exist, or it's not yours to delete"); mysql_query("DELETE FROM `mail` WHERE `mail_id` = ".$_GET['ID'], $c) or kill(mysql_error()); echo "Message deleted.<br /><a href='mailbox.php'>&gt; Back</a>"; } function mail_delall() { global $ir, $c, $userid, $h; if(!array_key_exists('answer', $_GET)) { ?>This will delete all the messages in your inbox.<br /> There is <strong>NO</strong> undo, so be sure.<br /> <a href='mailbox.php?action=delall&amp;answer=yes'>&gt; Yes, delete all messages</a> &middot; <a href='mailbox.php'>&gt; No, go back</a><?php } else { mysql_query("DELETE FROM `mail` WHERE `mail_to` = ".$userid, $c) or kill(mysql_error()); echo format(mysql_affected_rows())." message".s(mysql_affected_rows())." ".(mysql_affected_rows() == 1 ? 'has' : 'have')." been deleted.<br /> <a href='mailbox.php'>&gt; Back</a>"; } } function mail_archive() { ?>This tool will download an archive of all your messages.<br /> <a href='dlarchive.php?a=inbox'>&gt; Download Inbox</a><br /> <a href='dlarchive.php?a=outbox'>&gt; Download Outbox</a><?php } $h->endpage();

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.300.0090.04912.54
5.4.290.0130.05412.54
5.4.280.0100.05212.44
5.4.270.0090.05212.44
5.4.260.0150.05112.44
5.4.250.0150.04912.44
5.4.240.0090.05612.44
5.4.230.0130.04912.43
5.4.220.0110.03912.43
5.4.210.0070.03912.43
5.4.200.0100.03712.43
5.4.190.0140.04712.43
5.4.180.0140.05712.43
5.4.170.0140.05412.43
5.4.160.0180.04612.43
5.4.150.0140.04912.43
5.4.140.0150.04812.12
5.4.130.0090.05012.09
5.4.120.0080.05112.06
5.4.110.0110.04212.06
5.4.100.0080.04812.06
5.4.90.0060.06212.05
5.4.80.0090.08412.05
5.4.70.0160.11912.05
5.4.60.0070.08612.05
5.4.50.0070.05512.05
5.4.40.0130.05712.04
5.4.30.0110.06012.04
5.4.20.0110.06112.03
5.4.10.0070.05112.04
5.4.00.0170.05811.53
5.3.280.0140.06812.71
5.3.270.0110.06812.73
5.3.260.0120.06612.71
5.3.250.0110.04812.72
5.3.240.0120.06612.72
5.3.230.0100.05412.71
5.3.220.0190.09712.68
5.3.210.0160.07212.68
5.3.200.0100.05512.68
5.3.190.0080.05012.68
5.3.180.0120.05012.68
5.3.170.0130.06012.68
5.3.160.0080.06112.68
5.3.150.0180.04812.68
5.3.140.0090.05412.68
5.3.130.0130.05412.66
5.3.120.0130.05712.66
5.3.110.0100.05712.66
5.3.100.0170.04612.17
5.3.90.0190.05212.13
5.3.80.0070.06212.13
5.3.70.0150.05012.12
5.3.60.0110.05212.11
5.3.50.0130.05312.06
5.3.40.0070.06012.05
5.3.30.0150.05112.02
5.3.20.0120.06011.80
5.3.10.0090.06311.76
5.3.00.0100.06211.75

preferences:
136.57 ms | 1394 KiB | 7 Q