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();
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'case' (T_CASE) in /in/GHCTv on line 73
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_CASE in /in/GHCTv on line 73
Process exited with code 255.

preferences:
181.59 ms | 1399 KiB | 67 Q