Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,124
  • Joined

  • Last visited

  • Days Won

    144

Everything posted by Magictallguy

  1. My code was a fork from KyleMassacre's 1min cron replacement.. I've just evolved it from there to mark in for the other crons. Dependant on server, it can cause more strain, it can have a negligible impact. As far as I'm aware though, because the crontab is part of a different system, my Cronless Crons will *always* cause more strain. Though, as previously mentioned, impact my be negligible assuming you have a decent enough webserv.. I've since evolved my Cronless Crons further and my server barely notices the different - it now runs 1min, 5min, 15min, 60min, 12hour, 24hour, 7day and not a single complaint from each - though I believe that may have something to do with the fact that I make sure *nothing* fires at the same time.. Imagine all of those firing at once? Goodbye less-than-adequate server!
  2. Oh, forgot to mention.. ```SQL ALTER TABLE `users` ADD `fed_lock` TINYINT(2) NOT NULL DEFAULT 0; ```
  3. An error function is required.. function error($msg) { global $h; echo "<h3>Error</h3>",$msg; exit($h->endpage()); }   So is a confirmation() function.. function confirmation($msg) { echo $msg; // Add in whatever formatting.. }
  4. Yeah, I got it working at one points.. Took me feckin' weeks to do so (kept getting sidetracked/nerd-ragey)
  5. Original code updated. The main issue was the return null . I've removed that call and used a sort of hacky workaround for it. Tested and fully working :)
  6. Added some basic formatting Changed the abs((int) [...]) to .. well, look at line 4 Added a stripslashes() and htmlspecialchars() to the usernames Re-wrote both queries, stripping the call to the clans table from the second query as there was nothing using it Minor changes to the for() loop Brought it down from 61 lines of code to 45   <?php include(__DIR__ . '/includes/globals.php'); echo '<h3><u>Hospital</u></h3>'; $st = array_key_exists('st', $_GET) && ctype_digit($_GET['st']) ? $_GET['st'] : 0; $query = $db->query('SELECT COUNT(`userid`) FROM `users` WHERE `hospital` > 0'); $members = $db->fetch_single($query); $pages = ceil($members / 25) + 0; for($i = 1; $i <= $pages; ++$i) { $s = $i * 25; echo $s == $st ? 'Pages: <strong>' . $i . '</strong> ' : '<a href="hospital.php?&st=' . $s . '">' . $i . '</a> '; } ?><hr width='50%' /> Welcome to the Hospital. Unlucky to be placed here. Medical Bill: <?php echo money_formatter($ir['hosp_bill']); ?><hr width='50%' /> <hr width='85%' /> <table width='85%' class='table' border='0' cellspacing='1'> <tr> <th>Name</th> <th>Level</th> <th>Time</th> <th>Reason</th> <th>Links</th> </tr><?php $q = $db->query("SELECT `userid`, `username`, `level`, `hospital`, `hospreason` FROM `users` WHERE `hospital` > 0 ORDER BY `hospital` DESC LIMIT " . $st . ", 25"); if (!$db->num_rows($q)) echo '<tr><td colspan="5">There is no one in hospital</td></tr>'; while ($r = $db->fetch_row($q)) { $time = $r['hospital']; $t4 = floor($time / 60 / 24); $t1 = floor($time / 60) % 24; $t2 = $time % 60; $t3 = $t2 < 10 ? '0' . $t2 : $t2; $t5 = $t4 ? $t4 . ' days, ' : ''; $t1 = $t1 ? $t1 . ' hours, ' : ''; $t2 = $t2 . ' minute' . ($t2 == 1 ? '' : 's'); ?><tr> <td><a href='viewuser.php?u=<?php echo $r['userid']; ?>'><?php echo stripslashes(htmlspecialchars($r['username'])); ?></a> [<?php echo $r['userid']; ?>]</td> <td><?php echo number_format($r['level']); ?></td> <td><?php echo $t5, ' ', $t1, ' ', $t2; ?></td> <td><?php echo stripslashes($r['hospreason']); ?></td> <td><a href='healer.php'>[Hire Healer]</td> </tr><?php } ?></table><hr width='85%' /><hr width='50%' /><a href='index.php'>>Go Home</a><hr width='50%' /><?php $h->endpage();   Would recommend using ctype_digit() over is_numeric() in this case. is_numeric() allows negative and decimal input, ctype_digit() does not. However, there are 2 slight drawbacks to this - is_numeric() is marginally faster, and the int/float must be passed (or typecasted) to a string. Luckily, with it being getdata, it's automatically casted internally as a string even though a var_dump() will say otherwise
  7. v1 -> v2 Find: mysql_ Replace with: $db-> Find: fetch_array Find: fetch_assoc Replace with: fetch_row Find: real_escape_string Replace with: escape Make sure you globally define the $db variable in created functions if it hasn't been done. Most conversions are as simple as that, some others require a change of method
  8. attackbeat, attacklost, attacktake, attackwon
  9. Guest? I love you ^.^ Your comments are always helpful in some way - even if it just makes me smile :P Marry me pl0x? ^,^
  10. Give us lines 8 - 10
  11. Tis my pleasure :)
  12. In gangs.php and yourgang.php, find the query responsible for populating the $gangdata array. (Default: starts with $gc = $db->query("SELECT [...] FROM `gangs`[...]"); ) Make sure that, if it's not selecting everything "*", that it is selecting the `gangPIC` column. Also, make sure that the `gangPIC` column actually exists. If it doesn't, add it! ALTER TABLE `gangs` ADD `gangPIC` VARCHAR( 255 ) NOT NULL DEFAULT 'images/defaultclan.png'; # Change the "default" to whatever you want, or leave it blank, etc.
  13. Custom coded, originally with MC Craps, then to MTG Codes, then to whatever they've done to it. Most of the systems, however, should respond as usual. If you haven't changed the class files, then simply changing $db to $mtgdb should work for you Ibraheem :)
  14. You've got my attention. Previous statements are agreed with :)
  15. I'd do it.. But I don't even open my FTP for less than $100 any more..
  16. My custom ROM built based on CyanogenMod - I was, and am still happy with my phone (even though I hate phones and, therefore, barely ever use it!)
  17. Wow, that is old work there! Here's the re-recode for v1 (directly based on OP) NOTE! This code has only been tested for parse errors <?php /*----------------------------------------------------- -- Mono Country v1.0 BETA -- A product of DBS-entertainment -- Copyright held 2005 by Dabomstew -- mailbox.php -- --------------------- -- Re-recoded by Magictallguy -----------------------------------------------------*/ 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; 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, $current_row; 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=smilies/biggrin.gif]', '[img=smilies/cool.gif]', '[img=smilies/blink.gif]', '[img=smilies/dry.gif]', '[img=smilies/angry.gif]', '[img=smilies/huh.gif]', '[img=smilies/laugh.gif]', '[img=smilies/mellow.gif]', '[img=smilies/ohmy.gif]', '[img=smilies/sad.gif]', '[img=smilies/ph34r.gif]', '[img=smilies/rolleyes.gif]', '[img=smilies/sleep.gif]', '[img=smilies/smile.gif]', '[img=smilies/tongue.gif]', '[img=smilies/unsure.gif]', '[img=smilies/wacko.gif]', '[img=smilies/wink.gif]', '[img=smilies/wub.gif]', '[img=smilies/XD.gif]', ); $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();   And here's the re-recode for v2 NOTE! This code has only been tested for parse errors <?php /*----------------------------------------------------- -- Mono Country v1.0 BETA -- A product of DBS-entertainment -- Copyright held 2005 by Dabomstew -- mailbox.php -- --------------------- -- Re-recoded and converted to v2 by Magictallguy -----------------------------------------------------*/ 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; } include(__DIR__ . '/globals.php'); 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; default: mail_home(); break; } function mail_home() { global $db, $ir, $userid, $hurrent_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 = $db->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'); if(!$db->num_rows($q)) echo '<tr><td colspan="4" class="center">You have no messages</td></tr>'; else while($r = $db->fetch_row($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 $db, $ir, $userid, $h; $q = $db->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(!$db->num_rows($q)) kill('Either that message doesn\'t exist, or it\'s not yours to read!'); $db->query('UPDATE `mail` SET `mail_read` = 1 WHERE `mail_id` = '.$_GET['ID']); $r = $db->fetch_row($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 $db, $ir, $userid, $h; $q = $db->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(!$db->num_rows($q)) kill('Either that message doesn\'t exist, or it\'s not yours to read!'); $r = $db->fetch_row($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 $db, $ir, $userid, $hurrent_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 = $db->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'); if(!$db->num_rows($q)) echo '<tr><td colspan="4" class="center">You have no messages</td></tr>'; else while($r = $db->fetch_row($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 $db, $ir, $userid, $hurrent_row; 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 = $db->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'); if(!$db->num_rows($q)) echo "<tr><td colspan='2' class='center'>None found</td></tr>"; else while($r = $db->fetch_row($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 = $db->query("SELECT `userid` FROM `users` WHERE `userid` = ".$_POST['userid']); if(!$db->num_rows($selectUser)) kill("That player doesn't exist!"); $subj = str_replace("\n", '', strip_tags($db->real_escape_string($_POST['subject']))); $msg = str_replace("\n", '', strip_tags($db->real_escape_string($_POST['message']))); $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=smilies/biggrin.gif]', '[img=smilies/cool.gif]', '[img=smilies/blink.gif]', '[img=smilies/dry.gif]', '[img=smilies/angry.gif]', '[img=smilies/huh.gif]', '[img=smilies/laugh.gif]', '[img=smilies/mellow.gif]', '[img=smilies/ohmy.gif]', '[img=smilies/sad.gif]', '[img=smilies/ph34r.gif]', '[img=smilies/rolleyes.gif]', '[img=smilies/sleep.gif]', '[img=smilies/smile.gif]', '[img=smilies/tongue.gif]', '[img=smilies/unsure.gif]', '[img=smilies/wacko.gif]', '[img=smilies/wink.gif]', '[img=smilies/wub.gif]', '[img=smilies/XD.gif]', ); $newmsg = str_replace($codes, $images, $msg); $db->query("INSERT INTO `mail` VALUES ('', 0, ".$userid.", ".$to.", ".time().", '".$subj."', '".$newmsg."')"); echo "Your Message has been sent.<gbr /><a href='mailbox.php'>> Back</a>"; } } function mail_delete() { global $db, $ir, $userid, $h; if(empty($_GET['ID'])) kill("You didn't select a valid message"); $select = $db->query("SELECT `mail_id` FROM `mail` WHERE `mail_id` = ".$_GET['ID']." AND `mail_to` = ".$userid); if(!$db->num_rows($select)) kill("Either that message doesn't exist, or it's not yours to delete"); $db->query("DELETE FROM `mail` WHERE `mail_id` = ".$_GET['ID']); echo "Message deleted.<br /><a href='mailbox.php'>> Back</a>"; } function mail_delall() { global $db, $ir, $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 { $db->query("DELETE FROM `mail` WHERE `mail_to` = ".$userid); echo format($db->affected_rows())." message".s($db->affected_rows())." ".($db->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();
  18. Whozits? I got a mention? Yay! Free fame! *spreads fame around like butter* But yeah, I can always re-recode it and post up again if wanted
  19. It wouldn't be anything spectacular. It'd be a MySQLi (or PDO, haven't decided yet (most likely MySQLi, due to being able to work OOTB without having to change every other file)) class designed to handle PHP<->database relations.
  20. Find the first instance of: <?php Add below: if(!isset($_SESSION['playerid']) || empty($_SESSION['playerid']) || !is_int($_SESSION['playerid'])) exit;   Find: $q_ry = "SELECT `e_id` FROM `member_events` WHERE `e_playerid` = '".mysql_real_escape_string($_SESSION['playerid'])."' AND `e_read` = '0'"; Replace with: $q_ry = "SELECT `e_id` FROM `member_events` WHERE `e_read` = 0 AND `e_playerid` = ".$_SESSION['playerid'];   Find and remove: $evs = array();   Find: $evs = mysql_query($q_ry); Replace with: $evs = mysql_query($q_ry) or exit(mysql_error());   Optional edits: Find: if(mysql_num_rows($evs)){echo "$sound"; } Replace with: if(mysql_num_rows($q_ry)) echo $sound;   Find (around line 942): if($_SESSION['attacking']) { header('location:run.php'); } Replace with: if(isset($_SESSION['attacking'])) { header('Location: run.php'); exit; }   Find any instance of: mysql_real_escape_string($_SESSION['playerid']) Replace all with: $_SESSION['playerid']   Also: Test all queries! If it's failing, you want it to fail so you can debug it (and prevent it from failing again)   And, of course, it should go without saying.. Upgrade yourself to MySQLi at the very least!
  21. Grab yourself a copy of v1, I'll write up a class that'd work for (but better than) v2 - and I'll host you
  22. Agreed and seconded!
  23. Teh Fuzzeh Manz! Magictallguy1, feel free :) I've got 91 games, so I can't be arsed to list them all - instead, watch this video haha
  24. Kung Fu is a collection of martial arts styles. (technically speaking, it's a Chinese term referring to any form of study, learning or practise that requires patience, energy and time. (also know as Wushu)) Wing Chun, for example, is a form of Kung Fu. 'tis also one of the most famous styles as Bruce Lee used it. Shaolin being another. Believe me when I say, it's not the same ;)
×
×
  • Create New...