Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,140
  • Joined

  • Last visited

  • Days Won

    148

Everything posted by Magictallguy

  1. Well, I've tested my security with every method I know, and my beta members have tested it with ways I didn't, and so far, not a hitch ^.^
  2. Ah ha, cheek! :P For its time, my security was one of the best MC Craps had seen xD I've brought myself up to date with PHP 5.4 though, so we're all good :)
  3. I'm absolute sh*te with layouts..
  4. I am soooooo glad to be back :D
  5. It's Notepad++'s Indent Guide - I use it so I can see where I've tabbed a little easier.
  6. I've basically ripped the layout from MC Craps (as I can't design for sh*t), but the code is mine ;) - though, with an idea of mine (yeah, they happen, 'tis rare! :P), I've made it so it'd be compatible (with a few edits) with MC Craps v2 scripts. Snippet can be found here - I will post up more if need be
  7. For those wanting to keep up to date my activity; MTG Codes is now open for beta testing. http://magictallguy.tk/mtgCodes
  8. I meant -->this<--, but still. I may re-create the in game I used to have.
  9. If you would like some help installing, send me a message :)
  10. Thank you. You've given me an idea for my gallery too ;)
  11. For us non-moderators, there's a quote function that'll help ;)
  12. I've just tested the code and it works fine, make sure you copy the entire code (this forum's syntax highlighter appears to be a little .. odd)
  13. Good to see yours too :D
  14. Sounds fair enough. I'll update now. It's not I was only trying to give someone else a script to use on MC Craps with their style or anything :P Thanks for the pointers though, I didn't know filter_input existed! *updates all codes to reflect new knowledge*
  15. I have absolutely no idea whether this has been done before, so here's my version of a Game Rules overhaul. Keep in mind, I did develop this originally for MTG Codes, figured it may be useful to someone, and converted it to MC Craps v2 - any errors, give me a shout. The usage is simple: Upload this gamerules.php, (be sure to make a copy of your current rules), run the SQL, continue as normal. gamerules.php <?php require_once __DIR__ . '/globals.php'; ?> <h1><?php echo stripslashes($set['game_name']); ?>: Rules and Regulations</h1> <?php $_GET['ID'] = array_key_exists('ID', $_GET) && is_numeric($_GET['ID']) && (int)$_GET['ID'] > 0 ? (int)$_GET['ID'] : null; $_GET['action'] = array_key_exists('action', $_GET) ? $_GET['action'] : null; switch ($_GET['action']) { case 'add': rule_add($db, $ir, $set, $h); break; case 'edit': rule_edit($db, $ir, $set, $h); break; case 'delete': rule_delete($db, $ir, $set, $h); break; default: rule_index($db, $ir, $set); break; } /** * @param database $db * @param array $ir * @param array $set * @return void */ function rule_index($db, $ir, $set) { $count = 0; $width = (2 == $ir['user_level']) ? 85 : 95; $colspan = (2 == $ir['user_level']) ? 3 : 2; $select = $db->query('SELECT * FROM game_rules ORDER BY ruleID'); ?> <table class="table" style="width:100%;"> <thead> <tr> <th scope="col" style="width:5%;">#</th> <th scope="col" style="width:<?php echo $width; ?>;%">Rule</th> <?php if (2 == $ir['user_level']) { ?> <th style="width:10%;">Links &middot; <a href="gamerules.php?action=add"><img src="/silk/add.png" title="Add Rule" alt="Add" /></a></th> <?php } ?> </tr> </thead> <tbody> <?php if (!$db->num_rows($select)) { ?> <tr> <td colspan="<?php echo $colspan; ?>" style="text-align:center;">No rules have been set. Tell an admin to get their ass to it!</td> </tr> <?php } else { $playerName = $db->fetch_single($db->query('SELECT username FROM users WHERE (userid = 1)')); // Assuming that main admin is ID 1. Change to reflect your game $findReplace = [ '{name}' => $set['game_name'], '{owner}' => '<a href=\'viewuser.php?u=1\'>' . $playerName . '</a>', ]; while ($row = $db->fetch_row($select)) { ++$count; ?> <tr> <td><?php echo $count; ?></td> <td><?php echo strtr(stripslashes($row['ruleText']), $findReplace); ?></td> <?php if (2 == $ir['user_level']) { ?> <td> <a href="gamerules.php?action=edit&amp;ID=<?php echo $row['ruleID']; ?>">Edit</a> &middot; <a href="gamerules.php?action=delete&amp;ID=<?php echo $row['ruleID']; ?>">Delete</a> </td> <?php } ?> </tr> <?php } } ?> </tbody> </table> <?php } /** * @param database $db * @param array $ir * @param array $set * @param header $h * @return void */ function rule_add($db, $ir, $set, $h) { if (2 != $ir['user_level']) { echo 'You don\'t have access to this'; $h->endpage(); exit; } if (array_key_exists('submit', $_POST)) { $_POST['newRule'] = array_key_exists('newRule', $_POST) && is_string($_POST['newRule']) && strlen($_POST['newRule']) > 0 ? strip_tags(trim($_POST['newRule'])) : null; if (!empty($_POST['newRule'])) { $selectDup = $db->query('SELECT COUNT(ruleID) FROM game_rules WHERE LOWER(ruleText) = \'' . strtolower($db->escape($_POST['newRule'])) . '\''); if (!$db->fetch_single($selectDup)) { $db->query('INSERT INTO game_rules (ruleText) VALUES (\'' . $db->escape($_POST['newRule']) . '\')'); echo 'Your new rule has been added'; } else { echo 'That rule already exists'; } } else { echo 'You didn\'t enter a valid rule'; } } ?> <form action="gamerules.php?action=add" method="post"> <div class="form-group"> <label for="newRule">Rule</label> <textarea name="newRule" id="newRule" class="form-control" rows="7" autofocus required></textarea> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Add Rule </button> </form> <?php rule_index($db, $ir, $set); } /** * @param database $db * @param array $ir * @param array $set * @param header $h * @return void */ function rule_edit($db, $ir, $set, $h) { if (2 != $ir['user_level']) { echo 'You don\'t have access to this'; $h->endpage(); exit; } if (empty($_GET['ID'])) { echo 'You didn\'t select a rule to modify'; $h->endpage(); exit; } $select = $db->query('SELECT ruleText FROM game_rules WHERE ruleID = ' . $_GET['ID']); if (!$db->num_rows($select)) { echo 'That rule doesn\'t exist'; $h->endpage(); exit; } $row = $db->fetch_row($select); if (array_key_exists('submit', $_POST)) { $_POST['ruleText'] = array_key_exists('ruleText', $_POST) && is_string($_POST['ruleText']) && $_POST['ruleText'] !== '' ? strip_tags(trim($_POST['ruleText'])) : null; if (!empty($_POST['ruleText'])) { $selectDup = $db->query('SELECT COUNT(ruleID) FROM game_rules WHERE LOWER(ruleText) = \'' . $db->escape($_POST['ruleText']) . '\' AND ruleID <> ' . $_GET['ID']); if (!$db->fetch_single($selectDup)) { $db->query('UPDATE game_rules SET ruleText = \'' . $db->escape($_POST['ruleText']) . '\' WHERE ruleID = ' . $_GET['ID']); echo 'Rule edited'; rule_index($db, $ir, $set); $h->endpage(); exit; } else { echo 'That rule already exists'; } } else { echo 'You didn\'t enter a valid rule'; } } ?> <form action="gamerules.php?action=edit&amp;ID=<?php echo $_GET['ID']; ?>" method="post"> <div class="form-group"> <label for="ruleText">Rule</label> <textarea name="ruleText" id="ruleText" class="form-control" rows="10" autofocus required><?php echo stripslashes(htmlspecialchars($row['ruleText'])); ?></textarea> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Edit Rule </button> </form> <?php rule_index($db, $ir, $set); } /** * @param database $db * @param array $ir * @param array $set * @param header $h * @return void */ function rule_delete($db, $ir, $set, $h) { if (2 != $ir['user_level']) { echo 'You don\'t have access to this'; $h->endpage(); exit; } if (empty($_GET['ID'])) { echo 'You didn\'t select a rule to delete'; $h->endpage(); exit; } $select = $db->query('SELECT ruleID FROM game_rules WHERE ruleID = ' . $_GET['ID']); if (!$db->num_rows($select)) { echo 'That rule doesn\'t exist'; $h->endpage(); exit; } $db->query('DELETE FROM game_rules WHERE ruleID = ' . $_GET['ID']); echo 'Rule deleted'; rule_index($db, $ir, $set); } $h->endpage(); SQL CREATE TABLE IF NOT EXISTS `game_rules` ( `ruleID` int(11) NOT NULL AUTO_INCREMENT, `ruleText` text NOT NULL, PRIMARY KEY (`ruleID`) ); Now, for those of you using the bog standard rules, simply run this SQL *AFTER* running the previous one to create the table to insert the standard rules. INSERT INTO `game_rules` (`ruleID`, `ruleText`) VALUES (1, 'Players are only allowed to have one account, owning two or more accounts will result in all accounts being jailed,'), (2, 'if you are on the same IP as another player, mail staff and let them know.'), (3, 'You are responsible for whatever happens on your account, don\'t give out your password to anyone.'), (4, 'Children play this game, so keep it PG-13. Mild swearing will be permitted, but F-bombing, sexual vulgarities or excessive swearing will result in some time in Fed until you clean up your act.'), (6, 'Profile images with nudity, profanity, or otherwise offensive images will be removed, and may result in jail time.'), (7, 'We understand that you play other games, but do not advertise them here. You get 1 warning, afterwards its Fed time.'), (8, 'Do not spam the staff\'s mailbox, if you have a problem, message one of us once. They will deal with your problem in a timely manner, but do not mail them repeatedly, or mail multiple staff members.'), (9, 'Do not harass other players, use common sense on this one, if you don\'t know when your crossing the line from fantasy into'), (10, 'harassment, assume that you are harassing the other player. This will not be tolerated and will result in a stiff punishment.'), (11, 'Scamming will not be tolerated in any manner. Any attempt to scam anyone will result in being jailed for a long long time.'), (12, 'If a member of staff is bothering you for any unfair or just plain, weird reason, mail {owner}'), (13, 'Common sense rules are not posted here, if you can\'t determine the difference between what is ok, and what is not, you should consider not interacting with other people until you do understand.'), (14, 'These rules are subject to change without notice, check them from time to time, as ignorance will not be accepted as an excuse.');
  16. Just read your topic title again and this happened:
  17. He must be shown the path to righteous awesomeness! >:D
  18. Nicely done. For those of us who don't like the error_log filling up: Add: $_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : null; above (line 7): switch($_GET['action'])   Add: $_POST['step'] = isset($_POST['step']) && is_numeric($_POST['step']) && in_array($_POST['step'], array(0, 1, 2)) ? abs(@intval($_POST['step'])) : null; above (line 106): switch($_POST['step'])   Change (line 210): if($_POST['course']) to: if(isset($_POST['course']))   There are multiple other things that may throw errors, but you can tackle those yourself ;) Great mod illusions, nicely done :)
  19. Deprecated people? Now that's interesting...
  20. That's obviously because we are amazing ^.^
  21. (8) Since you've been gone, I can feel for the first time (8)... I be pretty good. I'm a family man now (never thought I'd say that lol)
  22. Hahaha, I still use it, just not as excessively. Definitely my favourite string function
  23. Wow, I'm looking back at my old codes and wondering to myself: What the hell was I doing?! xD I may recode this shortly
×
×
  • Create New...