@ 2014-07-04T12:10:57Z <?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'>> <a href='mailbox.php?action=compose'> Compose</a></td>
<td width='20%' class='center'>> <a href='mailbox.php?action=outbox'> Outbox</a></td>
<td width='20%' class='center'>> <a href='mailbox.php?action=archive'> Save</a></td>
<td width='20%' class='center'>> <a href='mailbox.php?action=delall'> Delete All</a></td>
<td width='20%' class='center'>> <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&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&ID=',$r['mail_id'],'">Delete</a>] [<a href="mailbox.php?action=read&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&ID=<?php echo $r['mail_from'];?>'>Reply</a>
<a href='mailbox.php?action=delete&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&ID=<?php echo $r['mail_to'];?>'>Compose</a>
<a href='mailbox.php?action=delete&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&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&ID=',$r['mail_id'],'">Delete</a>] [<a href="mailbox.php?action=read&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%'>> <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'>> 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'>> 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&answer=yes'>> Yes, delete all messages</a> · <a href='mailbox.php'>> 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'>> Back</a>";
}
}
function mail_archive() {
?>This tool will download an archive of all your messages.<br />
<a href='dlarchive.php?a=inbox'>> Download Inbox</a><br />
<a href='dlarchive.php?a=outbox'>> Download Outbox</a><?php
}
$h->endpage();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 5.4.30 0.009 0.049 12.54 5.4.29 0.013 0.054 12.54 5.4.28 0.010 0.052 12.44 5.4.27 0.009 0.052 12.44 5.4.26 0.015 0.051 12.44 5.4.25 0.015 0.049 12.44 5.4.24 0.009 0.056 12.44 5.4.23 0.013 0.049 12.43 5.4.22 0.011 0.039 12.43 5.4.21 0.007 0.039 12.43 5.4.20 0.010 0.037 12.43 5.4.19 0.014 0.047 12.43 5.4.18 0.014 0.057 12.43 5.4.17 0.014 0.054 12.43 5.4.16 0.018 0.046 12.43 5.4.15 0.014 0.049 12.43 5.4.14 0.015 0.048 12.12 5.4.13 0.009 0.050 12.09 5.4.12 0.008 0.051 12.06 5.4.11 0.011 0.042 12.06 5.4.10 0.008 0.048 12.06 5.4.9 0.006 0.062 12.05 5.4.8 0.009 0.084 12.05 5.4.7 0.016 0.119 12.05 5.4.6 0.007 0.086 12.05 5.4.5 0.007 0.055 12.05 5.4.4 0.013 0.057 12.04 5.4.3 0.011 0.060 12.04 5.4.2 0.011 0.061 12.03 5.4.1 0.007 0.051 12.04 5.4.0 0.017 0.058 11.53 5.3.28 0.014 0.068 12.71 5.3.27 0.011 0.068 12.73 5.3.26 0.012 0.066 12.71 5.3.25 0.011 0.048 12.72 5.3.24 0.012 0.066 12.72 5.3.23 0.010 0.054 12.71 5.3.22 0.019 0.097 12.68 5.3.21 0.016 0.072 12.68 5.3.20 0.010 0.055 12.68 5.3.19 0.008 0.050 12.68 5.3.18 0.012 0.050 12.68 5.3.17 0.013 0.060 12.68 5.3.16 0.008 0.061 12.68 5.3.15 0.018 0.048 12.68 5.3.14 0.009 0.054 12.68 5.3.13 0.013 0.054 12.66 5.3.12 0.013 0.057 12.66 5.3.11 0.010 0.057 12.66 5.3.10 0.017 0.046 12.17 5.3.9 0.019 0.052 12.13 5.3.8 0.007 0.062 12.13 5.3.7 0.015 0.050 12.12 5.3.6 0.011 0.052 12.11 5.3.5 0.013 0.053 12.06 5.3.4 0.007 0.060 12.05 5.3.3 0.015 0.051 12.02 5.3.2 0.012 0.060 11.80 5.3.1 0.009 0.063 11.76 5.3.0 0.010 0.062 11.75
preferences:dark mode live preview
136.57 ms | 1394 KiB | 7 Q