Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,146
  • Joined

  • Last visited

  • Days Won

    150

Everything posted by Magictallguy

  1. include(DIRNAME(DIRNAME(__FILE__)) . '/includes/functions.php');
  2. Magictallguy

    Users online

    <?php include(DIRNAME(__FILE__) . '/globals.php'); $_GET['time'] = isset($_GET['time']) && is_string($_GET['time']) ? strtolower(trim($_GET['time'])) : false; if($_GET['time'] == 'fiveminutes') { $time = 300; } else if($_GET['time'] == 'thirtyminutes') { $time = 1800; } else if($_GET['time'] == 'onehour') { $time = 3600; } else { $time = 86400; } echo "<table width='90%' border='1' height='20' class='table'> <tr> <th><u>[url='usersonline.php?online=fiveminutes']Five Minutes[/url]</u></th> <th><u>[url='usersonline.php?online=thirtyminutes']Thirty Minutes[/url]</u></th> <th><u>[url='usersonline.php?online=onehour']One Hour[/url]</u></th> <th><u>[url='usersonline.php?online=oneday']One Day[/url]</u></th> </tr> </table>"; echo "<table width='90%' border='1' height='20' class='table'> <tr style='text-decoration:underline;'> <th height='6'>Order</th> <th>Name</th> <th>ID</th> <th>Level</th> <th>Gender</th> <th>Last Action</th> <th>Money</th> <th>Attack</th> </tr>"; $q = $db->query("SELECT `username`,`userid`,`laston`,`gender`,`money`,`level` FROM users WHERE laston > (unix_timestamp() - ".$time.") ORDER BY laston DESC"); while($r = $db->fetch_row($q)) { $la = time() - $r['laston']; $unit = "secs"; if($la >= 60) { $la = (int) ($la / 60); $unit = "mins"; } if($la >= 60) { $la = (int) ($la / 60); $unit = "hours"; if($la >= 24) { $la = (int) ($la / 24); $unit = "days"; } } if($r['laston'] > 0) { $unit = "seconds"; if($la >= 60) { $la = (int) ($la / 60); $unit = "minutes"; } if($la >= 60) { $la = (int) ($la / 60); $unit = "hours"; if($la >= 24) { $la = (int) ($la / 24); $unit = "days"; } } $str = $la." ".$unit." ago"; } else { $str = "--"; } if($r['last_login'] > 0) { $ll = time() - $r['last_login']; $unit2 = "seconds"; if($ll >= 60) { $ll = (int) ($ll / 60); $unit2 = "minutes"; } if($ll >= 60) { $ll = (int) ($ll / 60); $unit2 = "hours"; if($ll >= 24) { $ll = (int) ($ll / 24); $unit2 = "days"; } } $str2 = $ll." ".$unit2." ago"; } else { $str2 = "--"; } $cn++; echo "<tr> <th>".$cn."</th> <th>[url='viewuser.php?u=".$r[']".rasheed($r['username'])."[/url]</th> <th>".rasheed($r['userid'])."</th> <th>".rasheed($r['level'])."</th> <th>".$r['gender']."</th> <th>".$str."</th> <th>\$".rasheed($r['money'])."</th> <th><a href='attack.php?ID=".$r['userid']."'>Attack "; echo ($r['gender'] == 'Female') ? "her" : "him"; echo "</a></th> </tr>"; } echo "</table>"; $h->endpage(); ?>   Untested, but should work fine
  3. You are welcome to do some yourself if you want ;)
  4. Source for the JavaScript http://www.dynamicdrive.com/dynamicindex11/arrowtitle.htm And it does work on the login/register
  5. Ah, my Bank PIN mod. Haven't seen that for a while.. I should really update that sometime lol
  6. Looks like Karlos' code ;)
  7. Hey John, welcome to Make Web Games :) Got any questions, just give me a shout
  8. Revisited this thread after randomly searching my name and noticed I hadn't updated the code in a while.. Here's my update - functionality is very similar, it just runs slightly faster (and obviously has no errors lol) <?php include(DIRNAME(__FILE__) . '/globals.php'); echo "<h3>Crystal Bank</h3>"; if($ir['crystalbank'] > -1) { $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : false; switch($_GET['action']) { case "deposit": deposit(); break; case "withdraw": withdraw(); break; default: index(); break; } } else { $cost = 25000; #Change this to the price you would like $s = ($cost == 1) ? '' : 's'; #Do not change this line $currency = 'money'; #Change money to crystals if you would prefer to charge crystals for a crystal bank account $display = ($currency == 'money') ? '$'.number_format($cost) : number_format($cost).'crystal'.$s; #Do not change this line if(isset($_GET['buy'])) { if($ir[$currency] > $cost) { echo "Congratulations, you bought a crystal bank account for ".$what."! [url='crystalbank.php']Start using my account[/url]"; $db->query("UPDATE users SET ".$currency." = ".$currency." - ".$cost.", crystalbank = 0 WHERE (userid = ".$userid.")"); } else { echo "You do not have enough ".$currency." to open an account. [url='explore.php']Back to town...[/url]"; } } else { echo "Open a crystal bank account today, just ".$display."! [url='crystalbank.php?buy']> Yes, sign me up![/url]"; } } function index() { global $db, $ir,$c,$userid,$h; $s = ($ir['crystalbank'] == 1) ? '' : 's'; echo "[b]You currently have ".number_format($ir['crystalbank'])." crystal".$s." in your Crystal bank.[/b] <table width='75%' cellspacing='1' class='table'> <tr> <td width='50%'>[b]Deposit Crystals[/b] <form action='crystalbank.php?action=deposit' method='post'> Amount: <input type='text' name='deposit' value='".number_format($ir['crystals'])."' /> <input type='submit' value='Deposit' /> </form></td> <td>[b]Withdraw Crystals[/b] <form action='crystalbank.php?action=withdraw' method='post'> Amount: <input type='text' name='withdraw' value='".number_format($ir['crystalbank'])."' /> <input type='submit' value='Withdraw' /> </form></td> </tr> </table>"; } function deposit() { global $db, $ir, $userid, $h; $_POST['deposit'] = str_replace(',', '', $_POST['deposit']); $_POST['deposit'] = abs(@floatval($_POST['deposit'])); if($_POST['deposit'] > $ir['crystals']) { echo "You do not have enough crystals to deposit in the bank."; $h->endpage(); exit; } $gain = $_POST['deposit'] - $fee; $ir['crystals'] += $gain; $db->query("UPDATE users SET crystalbank = crystalbank + ".$gain.", crystals = crystals - ".$_POST['deposit']." WHERE (userid = ".$userid.")"); $s = ($_POST['deposit'] == 1) ? '' : 's'; $s2 = ($ir['crystalbank'] == 1) ? '' : 's'; echo "You hand over ".number_format($_POST['deposit'])." crystal".$s." to be deposited, ".number_format($gain)." crystal".$s." are added to your account. [b]You now have ".number_format($ir['crystalbank'])." crystal".$s2." in the crystal bank.[/b] [url='crystalbank.php']> Back[/url]"; } function withdraw() { global $db, $ir, $userid, $h; $_POST['withdraw'] = str_replace(',', '', $_POST['withdraw']); $_POST['withdraw'] = abs(@floatval($_POST['withdraw'])); if($_POST['withdraw'] > $ir['crystalbank']) { echo "You do not have enough crystals to withdraw from the bank."; $h->endpage(); exit; } $gain = $_POST['withdraw']; $ir['crystalbank'] -= $gain; $db->query("UPDATE users SET crystalbank = crystalbank - ".$gain.", crystals = crystals + ".$gain." WHERE (userid = ".$userid.")"); $s = ($gain == 1) ? '' : 's'; $s2 = ($ir['crystalbank'] == 1) ? '' : 's'; echo "You ask to withdraw ".number_format($gain)." crystal".$s.", the banking lady grudgingly hands it over. [b]You now have ".number_format($ir['crystalbank'])." crystal".$s2." in the bank.[/b] [url='crystalbank.php']> Back[/url]"; } $h->endpage(); ?>
  9. Remove the print from that code. It'll error if you don't
  10. 1 question, why would you use mysql_real_escape_string() on a numerical value. It is designed to add backslashes (binary safe) to strings that contain apostrophies and quote marks.   $_POST['someText'] = mysql_real_escape_string($_POST['someText']); mysql_query("INSERT INTO `table` VALUES ('".$_POST['someText']."')") or die(mysql_error());   It has no effect on numbers, and therefore is a waste of space in that use ;)
  11. Happy to help :)
  12. Oh baby! Sam, Jordan? 3-some? :D
  13. He's got me to fall back on if he's stuck, don't worry Jordan :P
  14. Thanks, but it was your idea -.-
  15. Right, well.. You have my messenger, contct me whenever ;)
  16. Sorry guys, code modified..
  17. Maybe so, but is it secure?
  18. Original post updated, you can now choose which one you want *mutters under his breath: annoying little {censored} so bothered a less than a millisecond of parsing speed* *angel icon*
  19. If you're really so bothered about speed, I'm happy to "convert" my code out of sprintf() -.-
  20. Magictallguy

    Meta tags

    strip_tags(), htmlspecialchars()/htmlentities(), and str_replace() can help you here
  21. UPDATE: The ability to notify the players friends (in their friendslist) has been added - suggested by cjholder. I've left it off by default, simply change $notifyFriends = 0; to $notifyFriends = 1; Simple stuff. Here you go :) [mysql]CREATE TABLE `username_requests` ( `req_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `req_time` INT( 11 ) NOT NULL DEFAULT 0, `req_user` INT( 11 ) NOT NULL DEFAULT 0, `req_name` VARCHAR( 255 ) NOT NULL DEFAULT 'n/a' ) ENGINE = MyISAM;[/mysql] Edit smenu.php Add this link: [url='staff_requests.php?action=view']View Username Requests[/url]   For those of you bothered about a few milliseconds of speed, use the codes posted in the SECOND (2ND) expander [expander=Slightly slower method (by a few milliseconds)]Edit: preferences.php Replace the entire name_change() function with this: function name_change() { global $ir, $db, $userid, $h; echo "<h3>Changing your username</h3>"; $select = sprintf("SELECT req_id FROM username_requests WHERE (req_user = %u)", $userid); $query = $db->query($select); if($db->num_rows($query)) { echo "You have already requested a username change. Please wait until your current request is dealt with. [url='preferences.php']Back[/url]"; $h->endpage(); exit; } if(!isset($_POST['submit'])) { echo "<form action='preferences.php?action=namechange' method='post'>"; echo "<table class='table' width='50%' style='text-align:center;'>"; echo "<tr>"; echo "<th>New Name</th>"; echo sprintf("<td><input type='text' name='newName' value=\"%s\" /></td>", stripslashes(htmlspecialchars($ir['username']))); echo "</tr>"; echo "<tr>"; echo "<td colspan='2'><input type='submit' name='submit' value='Request Name Change' /></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; } else { if(empty($_POST['newName']) OR trim($_POST['newName']) == '') { echo "You cannot request a blank name"; $h->endpage(); exit; } $_POST['newName'] = $db->escape($_POST['newName']); $insert = sprintf("INSERT INTO username_requests VALUES ('', %u, %u, '%s')", time(), $userid, $_POST['newName']); $db->query($insert); echo "You username request has been successfully submitted"; } }   Create file: staff_requests.php <?php include(DIRNAME(__FILE__) . '/sglobals.php'); if($ir['user_level'] != 2) { echo "Access denied"; $h->endpage(); exit; } $notifyFriends = 0; $_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : false; switch($_GET['action']) { case 'view': viewRequests(); break; case 'accept': acceptRequest(); break; case 'decline': declineRequest(); break; default: echo "Action not specified"; break; } function viewRequests() { global $db; echo "<h3>Viewing Username Change Requests</h3>"; $select = $db->query( "SELECT r.*, u.username " . "FROM username_requests r " . "LEFT JOIN users u ON (r.req_user = u.userid) " . "ORDER BY r.req_time ASC"); echo "<table class='table' width='75%'>"; echo "<tr>"; echo "<th>User</th>"; echo "<th>Time</th>"; echo "<th>Request</th>"; echo "<th>Actions</th>"; echo "</tr>"; if(!$db->num_rows($select)) { echo "<tr>"; echo "<td colspan='3' style='text-align:center;'>There are currently no requests</td>"; echo "</tr>"; } else { while($row = $db->fetch_row($select)) { echo "<tr>"; echo sprintf("<td>[url='viewuser.php?u=%u']%s[/url] [%s]</a></td>", $row['req_user'], stripslashes(htmlspecialchars($row['username'])), number_format($row['userid'])); echo sprintf("<td>%s</td>", date('H:i:s d/m/y', $row['req_time'])); echo sprintf("<td>%s</td>", stripslashes(htmlspecialchars($row['req_name']))); echo sprintf("<td>[[url='staff_requests.php?action=accept&ID=%u']Accept[/url]] [[url='staff_requests.php?action=decline&ID=%u']Decline[/url]]</td>", $row['req_id'], $row['req_id']); echo "</tr>"; } echo "</table>"; stafflog_add("View the username change requests"); } } function acceptRequest() { global $db, $h, $notifyFriends; echo "<h3>Accepting a username change request</h3>"; $_GET['ID'] = abs(@intval($_GET['ID'])); if(!$_GET['ID']) { echo "No ID specified"; $h->endpage(); exit; } $select = sprintf("SELECT * FROM username_requests WHERE (req_id = %u)", $_GET['ID']); $query = $db->query($select); if(!$db->num_rows($query)) { echo "This request does not exist"; $h->endpage(); exit; } $row = $db->fetch_row($query); $oldName = $db->fetch_single($db->query(sprintf("SELECT username FROM users WHERE (userid = %u)", $row['req_user']))); $updateUser = sprintf("UPDATE users SET username = '%s' WHERE (userid = %u)", $row['req_name'], $row['req_user']); $deleteReq = sprintf("DELETE FROM username_requests WHERE (req_id = %u)", $row['req_id']); $db->query($updateUser); $db->query($deleteReq); event_add($row['req_user'], sprintf("Your username change request that was requested on %s has been accepted.", date('H:i:s, d/m/y', $row['req_time'])); if($notifyFriends) { $selectFriends = sprintf("SELECT fl_ADDED FROM friendslist WHERE (fl_ADDER = %u)", $row['req_user']); $queryFriends = $db->query($selectFriends); if($db->num_rows($queryFriends)) { while($friend = $db->fetch_row($queryFriends)) { event_add($friend['fl_ADDED'], sprintf("[url='viewuser.php?u=%u']%s[/url] [%s] has changed their name to “%s”", $row['req_user'], $oldName, number_format($row['req_user']), $row['req_name'])); } } } stafflog_add(sprintf("Accepted the username change request from %s - now known as %s", $oldName, $row['req_name'])); echo "You have accepted the request"; } function declineRequest() { global $db, $h; echo "<h3>Declining a username change request</h3>"; $_GET['ID'] = abs(@intval($_GET['ID'])); if(!$_GET['ID']) { echo "No ID specified"; $h->endpage(); exit; } $select = sprintf("SELECT * FROM username_requests WHERE (req_id = %u)", $_GET['ID']); $query = $db->query($select); if(!$db->num_rows($query)) { echo "This request does not exist"; $h->endpage(); exit; } $row = $db->fetch_row($query); $currentName = $db->fetch_single($db->query(sprintf("SELECT username FROM users WHERE (userid = %u)", $row['req_user']))); $deleteReq = sprintf("DELETE FROM username_requests WHERE (req_id = %u)", $row['req_id']); $db->query($deleteReq); event_add($row['req_user'], sprintf("Your username change request that was requested on %s has been declined.", date('H:i:s, d/m/y', $row['req_time'])); stafflog_add(sprintf("Declined the username change request from %s", $currentName); echo "You have declined the request"; } $h->endpage(); ?> [/expander] [expander=Slightly faster method]preferences.php edit function name_change() { global $ir, $db, $userid, $h; echo "<h3>Changing your username</h3>"; $query = $db->query("SELECT req_id FROM username_requests WHERE (req_user = ".$userid.")"); if($db->num_rows($query)) { echo "You have already requested a username change. Please wait until your current request is dealt with. [url='preferences.php']Back[/url]"; $h->endpage(); exit; } if(!isset($_POST['submit'])) { echo "<form action='preferences.php?action=namechange' method='post'> <table class='table' width='50%' style='text-align:center;'> <tr> <th>New Name</th> <td><input type='text' name='newName' value=\"".stripslashes(htmlspecialchars($ir['username']))."\" /></td> </tr> <tr> <td colspan='2'><input type='submit' name='submit' value='Request Name Change' /></td> </tr> </table> </form>"; } else { if(empty($_POST['newName']) OR trim($_POST['newName']) == '') { echo "You cannot request a blank name"; $h->endpage(); exit; } $db->query("INSERT INTO username_requests VALUES ('', ".time().", ".$userid.", '".$db->escape($_POST['newName'])."')"); echo "You username request has been successfully submitted"; } }   staff_requests.php <?php include(DIRNAME(__FILE__) . '/sglobals.php'); if($ir['user_level'] != 2) { echo "Access denied"; $h->endpage(); exit; } $notifyFriends = 0; $_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : false; switch($_GET['action']) { case 'view': viewRequests(); break; case 'accept': acceptRequest(); break; case 'decline': declineRequest(); break; default: echo "Action not specified"; break; } function viewRequests() { global $db; echo "<h3>Viewing Username Change Requests</h3>"; $select = $db->query( "SELECT r.*, u.username " . "FROM username_requests r " . "LEFT JOIN users u ON (r.req_user = u.userid) " . "ORDER BY r.req_time ASC"); echo "<table class='table' width='75%'> <tr> <th>User</th> <th>Time</th> <th>Request</th> <th>Actions</th> </tr>"; if(!$db->num_rows($select)) { echo "<tr> <td colspan='3' style='text-align:center;'>There are currently no requests</td> </tr>"; } else { while($row = $db->fetch_row($select)) { echo "<tr> <td>[url='viewuser.php?u=".$row[']".stripslashes(htmlspecialchars($row['username']))."[/url] [".number_format($row['userid'])."]</a></td> <td>".date('H:i:s d/m/y', $row['req_time'])."</td> <td>".stripslashes(htmlspecialchars($row['req_name']))."</td> <td>[[url='staff_requests.php?action=accept&ID=".$row[']Accept[/url]] [[url='staff_requests.php?action=decline&ID=".$row[']Decline[/url]]</td> </tr>"; } echo "</table>"; stafflog_add("View the username change requests"); } } function acceptRequest() { global $db, $h, $notifyFriends; echo "<h3>Accepting a username change request</h3>"; $_GET['ID'] = abs(@intval($_GET['ID'])); if(!$_GET['ID']) { echo "No ID specified"; $h->endpage(); exit; } $query = $db->query("SELECT * FROM username_requests WHERE (req_id = ".$_GET['ID'].")"); if(!$db->num_rows($query)) { echo "This request does not exist"; $h->endpage(); exit; } $row = $db->fetch_row($query); $oldName = $db->fetch_single($db->query("SELECT username FROM users WHERE (userid = ".$row['req_user'].")")); $db->query("UPDATE users SET username = '".$row['req_name']."' WHERE (userid = ".$row['req_user'].")"); $db->query("DELETE FROM username_requests WHERE (req_id = ".$row['req_id'].")"); event_add($row['req_user'], "Your username change request that was requested on ".date('H:i:sd/m/y', $row['req_time'])." has been accepted."); if($notifyFriends) { $queryFriends = $db->query("SELECT fl_ADDED FROM friendslist WHERE (fl_ADDER = ".$row['req_user'].")"); if($db->num_rows($queryFriends)) { while($friend = $db->fetch_row($queryFriends)) { event_add($friend['fl_ADDED'], "[url='viewuser.php?u=".$row[']".$oldName."[/url] [".number_format($row['req_user'])."] has changed their name to “".$row['req_name']."”"); } } } stafflog_add("Accepted the username change request from ".$oldName." - now known as ".$row['req_name']); echo "You have accepted the request"; } function declineRequest() { global $db, $h; echo "<h3>Declining a username change request</h3>"; $_GET['ID'] = abs(@intval($_GET['ID'])); if(!$_GET['ID']) { echo "No ID specified"; $h->endpage(); exit; } $query = $db->query("SELECT * FROM username_requests WHERE (req_id = ".$_GET['ID'].")"); if(!$db->num_rows($query)) { echo "This request does not exist"; $h->endpage(); exit; } $row = $db->fetch_row($query); $currentName = $db->fetch_single($db->query("SELECT username FROM users WHERE (userid = ".$row['req_user'].")")); $db->query("DELETE FROM username_requests WHERE (req_id = ".$row['req_id'].")"); event_add($row['req_user'], "Your username change request that was requested on ".date('H:i:sd/m/y', $row['req_time'])." has been declined."); stafflog_add("Declined the username change request from ".$currentName); echo "You have declined the request"; } $h->endpage(); ?> [/expander] Code is tested, and works fine
  22.   What you fail to realise is my ship is dragging mines! Sorry, your post reminded me of Galaxy Quest (the film) xD
  23. Reasons why I hate Wotlabb.. They need to send out a patch, or MWG admins need to fix it :P
  24. <?php include(DIRNAME(__FILE__) . '/globals.php'); echo "<font size='4' face='Arial, Helvetica, sans-serif'>Your Attack Logs</font> <hr width='75%'> "; switch($_GET['step']) { case 'ayw': ayw(); break; case 'ayl': ayl(); break; default; index(); break; } function index() { echo "So you want to see you attack logs huh? Please choose a section. "; echo "• [url='pal.php?step=ayw']Attacks you've won[/url]. • [url='pal.php?step=ayl']Attacks you've lost[/url]."; echo " <hr width='75%'>> [url='index.php']Home[/url]<hr width='75%'>"; } function ayw() { global $db,$userid; $atks = $db->query( "SELECT a.*, u1.username AS attackern, u2.username AS attackedn " . "FROM attacklogs a " . "LEFT JOIN users u1 ON (a.attacker = u1.userid) " . "LEFT JOIN users u2 ON (a.attacked = u2.userid) " . "WHERE ((u1.userid = $userid) AND (result = 'won')) " . "ORDER BY time DESC LIMIT 100"); echo "The last 100 players you have killed. <table width='75%' cellspacing='1' class='table' style='text-align:center;'> <tr style='background-color:#999;'> <th>Time</th> <th>Attacked</th> </tr>"; while($r = $db->fetch_row($atks)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $d = date('F j, Y, g:i:s a', $r['time']); echo "<tr style='background-color:$bgcolor;'> <td>$d</td> <td>[url='viewuser.php?u={$r[']{$r['attackedn']}[/url]</td> </tr>"; } echo "</table>"; echo " <hr width='75%'>> [url='pal.php']Back[/url]<hr width='75%'>"; } function ayl() { global $db, $userid; $atks = $db->query( "SELECT a.*, u1.username AS attackern, u2.username AS attackedn " . "FROM attacklogs a " . "LEFT JOIN users u1 ON (a.attacker = u1.userid) " . "LEFT JOIN users u2 ON (a.attacked = u2.userid) " . "WHERE ((u2.userid = $userid) AND (result = 'won')) " . "ORDER BY time DESC LIMIT 100"); echo "The last 100 players that killed you. <table width='75%' cellspacing='1' class='table' style='text-align:center;'> <tr style='background-color:#999;'> <th>Time</th> <th>Attacker</th> </tr>"; while($r = $db->fetch_row($atks)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $d = date('F j, Y, g:i:s a', $r['time']); echo "<tr style='background-color:$bgcolor;'> <td>$d</td> <td>[url='viewuser.php?u={$r[']{$r['attackern']}[/url]</td> </tr>"; } echo "</table>"; echo " <hr width='75%'>> [url='pal.php']Back[/url]<hr width='75%'>"; } $h->endpage(); ?>   Works fine for me
×
×
  • Create New...