Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,146
  • Joined

  • Last visited

  • Days Won

    150

Everything posted by Magictallguy

  1. May write that up, sounds like something I'd use
  2. I know, but I was basically stating, in so many words, that you can have the entire auto credit shiz with the standard MC Craps
  3. Getting back to the Donator with IPN request... You do realise, right, that "IPN" stands for "Instant Payment Notification" - that part is enabled on your PayPal itself. You can set up your system to automatically credit the donator pack/will potions using an IPN, but the IPN itself is *not* the auto-credit.. Screenshots on how to set up IPN http://screencast.com/t/ki1OQNPeP8I http://screencast.com/t/8p2fIggjOI http://screencast.com/t/ugF0Jf9jVP http://screencast.com/t/bKV6arHtRsTr - change to your own site
  4. Fixed, I'll read the message now :P
  5. I have details to around 15 sites.. Which one was yours? :P Edit: Nevermind, just noticed the file path
  6. Tested for parse errors only Provided there are no more errors. This code has been completely fixed, and a little security has been put in place, alongside preventing E_WARNING | E_NOTICE errors ^.^ <?php include "globals.php"; ?><center><font size='4' face='Arial, Helvetica, sans-serif'>User images</font> <hr width='90%'><?php $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'view': view_image(); break; default: user_images(); break; } function user_images() { global $db, $ir, $h; $_GET['delete'] = isset($_GET['delete']) && ctype_digit($_GET['delete']) ? abs(@intval($_GET['delete'])) : null; if(!empty($_GET['delete'])) { $select = $db->query(sprintf("SELECT `imgID` FROM `userimages` WHERE ((`imgUSER` = %u) AND (`imgID` = %u))", $ir['userid'], $_GET['delete'])); if(!$db->num_rows($select)) { echo "Either that image doesn't exist, or it's not yours"; $h->endpage(); exit; } $db->query(sprintf("DELETE FROM `userimages` WHERE (`imgID` = %u)", $_GET['delete'])); echo "Image deleted from gallery.<hr width='90%'>"; } $_GET['set'] = isset($_GET['set']) && ctype_digit($_GET['set']) ? abs(@intval($_GET['set'])) : null; if(!empty($_GET['set'])) { $image = $db->query(sprintf("SELECT `imgURL` FROM `userimages` WHERE ((`imgID` = %u) AND (`imgUSER` = %u))", $ir['userid'], $_GET['set'])); if(!$db->num_rows($image)) { echo "Either that image doesn't exist, or it's not yours"; $h->endpage(); exit; } $db->query(sprintf("UPDATE `users` SET `display_pic` = '%s' WHERE (`userid` = %u)", $db->fetch_single($image), $ir['userid'])); echo "New display image set.<hr width='90%'>"; } $_GET['XID'] = isset($_GET['XID']) && ctype_digit($_GET['XID']) ? abs(@intval($_GET['XID'])) : null; if(empty($_GET['XID'])) { echo "No user submitted<hr width='90%'>> <a href='explore.php'>Back to city</a><hr width='90%'>"; $h->endpage(); exit; } $select = $db->query(sprintf("SELECT `ui`.`imgUSER`, `u`.`username` " . "FROM `userimages` AS `ui` " . "LEFT JOIN `users` AS `u` ON (`ui`.`imgUSER` = `u`.`userid`) " . "WHERE (`ui`.`imgUSER` = %u) ", $_GET['XID'])); if(!$db->num_rows($select)) { echo "Either that player doesn't exist, or they haven't uploaded any images"; $h->endpage(); exit; } $player = $db->fetch_row($select); echo "<strong>",stripslashes(htmlspecialchars($player['username'])),"'s uploaded images</strong>"; if(!$db->num_rows($q)) { ?><table width='90%' bgcolor=#DFDFDF><tr><td><center>This user has no uploaded images</center></td></tr></table><hr width='90%'>> <a href='viewuser.php?u=<?php echo $y['userid']; ?>'>Back to profile</a><hr width='90%'><?php $h->endpage(); exit; } echo "<table width='90%' bgcolor=#DFDFDF cellpadding='3'><tr>"; $br = 0; $cn = 0; $div = ''; while($row = $db->fetch_row($select)) { if($br == 3) { $div = "</tr><tr>"; $br* = 0; } echo "<td align='center'><strong>#$cn Profile image</strong><a href='userimages.php?action=view&ID=",$row['imgUSER'],"'>View</a>"; if($_GET['XID'] == $ir['userid']) { echo "[<a href='userimages.php?XID=",$row['imgUSER'],"'>Delete</a>] [<a href='userimages.php?XID=",$row['imgUSER'],"'>Set Image</a>]"; } echo "</td>",$div; ++$br; ++$cn; } echo "</tr></table><hr width='90%'>> <a href='viewuser.php?u=",$player['imgUSER'],"'>Back to profile</a><hr width='90%'>"; } function view_image() { global $db, $ir, $h; $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $e = $db->query(sprintf("SELECT `imgURL` FROM `userimages` WHERE (`imgID` = %u)", $_GET['ID'])); if(!$db->num_rows($e)) { echo "Either that player doesn't exist, or they have no images"; $h->endpage(); exit; } echo "<img src=",stripslashes($db->fetch_single($e))," /><hr width='90%'>> <a href='userimages.php?XID=",$_GET['ID'],">Back to images</a><hr width='90%'>"; } $h->endpage(); ?>
  7. Working on it now.. Just really struggling with a 5 month old boy who's just found his voice -.-
  8. Untested Replace the gang_kidnap() function in yourgang.php with this: function cleanKill($msg = 'Something happened..') { global $h; ?><div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><?php echo $msg; $h->endpage(); exit; } function gang_event_add($gangID, $event) { global $db; $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '%s')", $gangID, time(), $db->escape($event))); } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function player($id, $escape = 0) { global $db; $selectPlayer = $db->query(sprintf("SELECT `username` FROM `users` WHERE (`userid` = %u)", $id)); return sprintf("<a href='viewuser.php?u=%u'>%s</a> [%s]", $id, format($db->fetch_single($selectPlayer)), format($id)); } function gang_kidnap() { global $db, $ir, $h, $gangdata; $_GET['u'] = isset($_GET['u']) && ctype_digit($_GET['u']) ? abs(@intval($_GET['u'])) : null; if(empty($_GET['u'])) cleanKill("You didn't select a valid gang member"); if(!$ir['gang']) cleanKill("You're not in a gang, you can't do this"); if($ir['gang'] == $gangdata['gangID']) cleanKill("You can't kidnap your own members..."); $select = $db->query(sprintf("SELECT `gangID` FROM `gangs` WHERE ((`gangPRESIDENT` = %1\$u) OR (`gangVICEPRES` = %1\$u))", $ir['userid'])); if(!$db->num_rows($select)) cleanKill("You're not the President or Vice President of your gang. You can't do that"); if(in_array($_GET['u'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) cleanKill("You can't kidnap the President or Vice President"); $select = $db->query(sprintf("SELECT `gang` FROM `users` WHERE (`userid` = %u)", $_GET['u'])); if(!$db->num_rows($select)) cleanKill("That player doesn't exist"); if($db->fetch_single($select) != $gangdata['gangID']) cleanKill(player($_GET['u'])." isn't in that gang"); $selectRansoms = $db->query(sprintf("SELECT `gkID` FROM `gangKidnaps` WHERE (`gkUser` = %u)", $_GET['u'])); if($db->num_rows($selectRansom)) cleanKill(player($_GET['u'])." is already being held ransom"); if(!isset($_POST['submit'])) { echo "<h3>Kidnapping ",player($_GET['u'])," from ",format($gangdata['gangNAME']),"</h3>"; ?><form action='gangs.php?action=view&ID=<? echo $gangdata['gangID']; ?>&u=<? echo $_GET['u']; ?>' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Ransom</th> <td width='55%'>$<input type='number' name='ransom' value='2000' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Kidnap' /></td> </tr> </table> </form><? } else { $_POST['ransom'] = isset($_POST['ransom']) && ctype_digit($_POST['ransom']) ? abs(@intval($_POST['ransom'])) : null; if(empty($_POST['ransom'])) cleanKill("You didn't enter a valid ransom"); $chance = mt_rand(1, 5); if(in_array($chance, array(1, 3))) { $db->query(sprintf("INSERT INTO `gangKidnaps` VALUES ('', %u, %u, %u, %s, %u)", $ir['gang'], $gangdata['gangID'], $_GET['u'], time(), $_POST['ransom'])); $gEventTheirs = sprintf("%s has kidnapped %s from %s. You have 1 hour to pay the ransom", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); $gEventMine = sprintf("%s has kidnapped %s from %s. They have 1 hour to pay the ransom", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); echo "You've kidnapped ",player($_GET['u'])," from ",format($gangdata['gangNAME']); } else if(in_array($chance, array(2, 4))) { $getAnother = $db->query(sprintf("SELECT `userid` FROM `users` WHERE ((`gang` = %u) AND (`userid` != %u)) ORDER BY RAND() LIMIT 1", $gangdata['gangID'], $_GET['u'])); if(!$db->num_rows($getAnother)) echo "You failed to kidnap ",player($_GET['u']); else { $another = $db->fetch_single($getAnother); $db->query(sprintf("INSERT INTO `gangKidnaps` VALUES ('', %u, %u, %u, %s, %u)", $ir['gang'], $ir['gang'], $another, time(), $_POST['ransom'])); $gEventTheirs = sprintf("%s attempted to kidnap %s from %s but failed. Instead, they got %s", player($ir['userid']), player($_GET['u']), player($another)); $gEventMine = sprintf("%s attempted to kidnap %s from %s but failed. Instead, they got %s", player($ir['userid']), player($_GET['u']), player($another)); echo "You failed to kidnap ",player($_GET['u']),", but you managed to get ",player($another)," instead"; } } else { $gEventTheirs = sprintf("%s attempted to kidnap %s from %s, but failed", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); $gEventMine = sprintf("%s attempted to kidnap %s from %s, but failed", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); } gang_event_add($gangdata['gangID'], $gEventTheirs); gang_event_add($ir['gang'], $gEventMine); } }   Any bugs, post here   Thank you :)
  9. 100% currently, I can easily modify it to have the chance effect if you'd like?
  10. Perhaps he likes the v1 code structure (why, I don't know..), and also likes the features of v2. Those 3 column additions to the users table really isn't that much, and the conversion was simple enough.. There's enough of v2 floating around to grab a copy
  11. I offer no guarantee that the code I've posted below will work as expected.. v1 attack from v2, with multiple bug/security/HTML fixes.. <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $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 exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); 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); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; if(!$_GET['ID']) { echo "*** you doing, bro?<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if($_GET['ID'] == $userid) { echo "Only the crazy attack themselves.<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if($ir['hp'] <= 1) { echo "Only the crazy attack when their unconscious.<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if(isset($_SESSION['attacklost'])) { echo "Only the losers of all their EXP attack when they've already lost.<br /><a href='index.php'>Back</a>"; $_SESSION['attacklost'] = 0; $h->endpage(); exit; } //get player data $q = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($q)) { echo "That player doesn't exist"; $h->endpage(); exit; } $them = mysql_fetch_assoc($q); $myabbr = ($ir['gender'] == "Male") ? "his" : "her"; $oabbr = ($ir['gender'] == "Male") ? "his" : "her"; if($ir['attacking'] && $ir['attacking'] != $_GET['ID']) { echo "Bad, bad, bad girl.<br /><a href='index.php'>Back</a>"; $_SESSION['attacklost'] = 0; $h->endpage(); exit; } if($them['hp'] == 1) { echo "This player is unconscious.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['hospital']) { echo "This player is in hospital.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($ir['hospital']) { echo "While in hospital you can't attack.<br /><a href='hospital.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['jail']) { echo "This player is in jail.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($ir['jail']) { echo "While in jail you can't attack.<br /><a href='jail.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['travelling']) { echo "That player is travelling.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } echo "<table width='100%'><tr><td colspan='2' align='center'>"; if(isset($_GET['wepid'])) { if(!isset($_SESSION['attacking']) && $ir['attacking'] == 0) { if($ir['energy'] >= $ir['maxenergy'] / 2) { $ir['energy'] -= floor($ir['maxenergy'] / 2); mysql_query(sprintf("UPDATE `users` SET `energy` = `energy` - %u WHERE (`userid` = %u)", floor($ir['maxenergy'] / 2), $userid), $c) or exit(mysql_error()); $_SESSION['attacklog'] = ""; $_SESSION['attackdmg'] = 0; } else { echo "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } } $_SESSION['attacking'] = 1; $ir['attacking'] = $them['userid']; mysql_query("UPDATE `users` SET `attacking` = " . $ir['attacking'] . " WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $_GET['wepid'] = isset($_GET['wepid']) && ctype_digit($_GET['wepid']) ? abs(@intval($_GET['wepid'])) : null; $_GET['nextstep'] = isset($_GET['nextstep']) && ctype_digit($_GET['nextstep']) ? abs(@intval($_GET['nextstep'])) : null; //damage if($_GET['wepid'] != $ir['equip_primary'] && $_GET['wepid'] != $ir['equip_secondary']) { echo "Stop trying to abuse a game bug. You can lose all your EXP for that.<br /><a href='index.php'>> Home</a>"; mysql_query("UPDATE `users` SET `exp` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $h->endpage(); exit; } $qo = mysql_query("SELECT * FROM `items` WHERE (`itmid` = " . $_GET['wepid'] . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($qo)) { echo "That item doesn't exist"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } $r1 = mysql_fetch_assoc($qo); $mydamage = (int) (($r1['weapon'] * $ir['strength'] / ($them['guard'] / 1.5)) * (mt_rand(8000, 12000) / 10000)); $hitratio = max(10, min(60 * $ir['agility'] / $them['agility'], 95)); if(mt_rand(1, 100) <= $hitratio) { $q3 = mysql_query("SELECT `armor` FROM `items` WHERE (`itmid` = " . $them['equip_armor'] . ") ORDER BY RAND()"); if(mysql_num_rows($q3)) { $mydamage -= mysql_result($q3, 0, 0); } $mydamage = ($mydamage < -100000) ? abs($mydamage) : 1; $crit = mt_rand(1, 40); if($crit == 17) { $mydamage *= rand(20, 40) / 10; } else if($crit == 25 or $crit == 8) { $mydamage /= (mt_rand(20, 40) / 10); } $mydamage = round($mydamage); $them['hp'] -= $mydamage; if($them['hp'] == 1) { $them['hp'] = 0; $mydamage += 1; } mysql_query("UPDATE `users` SET `hp` = `hp` - $mydamage WHERE (`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); echo "<span style='color:red;'>", $_GET['nextstep'], ". Using your ", format($r1['itmname']), " you hit ", format($them['username']), " doing ", format($mydamage), " damage (", format($them['hp']), ")</span><br />\n"; $_SESSION['attackdmg'] += $mydamage; $_SESSION['attacklog'] .= "<span style='color:red;'>" . $_GET['nextstep'] . ". Using " . $myabbr . " " . format($r1['itmname']) . ". " . format($ir['username']) . " hit " . format($them['username']) . " doing " . format($mydamage) . " damage (" . format($them['hp']) . ")</span><br />\n"; } else { echo "<span style='color:red;'>", $_GET['nextstep'], ". You tried to hit ", format($them['username']), " but missed (", format($them['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:red;'>" . $_GET['nextstep'] . ". " . format($ir['username']) . " tried to hit " . format($them['username']) . " but missed (" . format($them['hp']) . ")</span><br />\n"; } if($them['hp'] <= 0) { $them['hp'] = 0; $_SESSION['attackwon'] = $_GET['ID']; mysql_query("UPDATE `users` SET `hp` = 0 WHERE (`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); echo "<br /><strong>What do you want to do with ", format($them['username']), " now?</strong><br /> <form action='attackwon.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Mug Them' /></form> <form action='attackbeat.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Hospitalize Them' /></form> <form action='attacktake.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Leave Them' /></form>"; } else { //choose opp gun $eq = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u))", $them['equip_primary'], $them['equip_secondary']), $c) or exit(mysql_error()); if(!mysql_num_rows($eq)) { $wep = "Fists"; $dam = (int) ((((int) ($them['strength'] / $ir['guard'] / 100)) + 1) * (mt_rand(8000, 12000) / 10000)); } else { $cnt = 0; while($r = mysql_fetch_assoc($eq)) { $enweps[] = $r; $cnt++; } $weptouse = mt_rand(0, $cnt - 1); $wep = $enweps[$weptouse]['itmname']; $dam = (int) (($enweps[$weptouse]['weapon'] * $them['strength'] / ($ir['guard'] / 1.5)) * (mt_rand(8000, 12000) / 10000)); } $hitratio = max(10, min(60 * $them['agility'] / $ir['agility'], 95)); if(mt_rand(1, 100) <= $hitratio) { $q3 = mysql_query("SELECT `armor` FROM `items` WHERE (`itmid` = " . $ir['equip_armor'] . ") ORDER BY RAND()"); if(mysql_num_rows($q3)) { $dam -= mysql_result($q3); } if($dam < -100000) { $dam = abs($dam); } else if($dam < 1) { $dam = 1; } $crit = rand(1, 40); if($crit == 17) { $dam *= rand(20, 40) / 10; } else if($crit == 25 or $crit == 8) { $dam /= (mt_rand(20, 40) / 10); } $dam = round($dam); $ir['hp'] -= $dam; if($ir['hp'] == 1) { $dam += 1; $ir['hp'] = 0; } mysql_query("UPDATE `users` SET `hp` = `hp` - " . $dam . " WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $ns = $_GET['nextstep'] + 1; echo "<span style='color:blue;'>", $ns, ". Using ", $oabbr, " ", format($wep), " ", format($them['username']), " hit you doing ", format($dam), " damage (", format($ir['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:blue;'>" . $ns . ". Using " . $oabbr . " " . format($wep) . " " . format($them['username']) . " hit " . format($ir['username']) . " doing " . format($dam) . " damage (" . format($ir['hp']) . ")</span><br />\n"; } else { $ns = $_GET['nextstep'] + 1; echo "<span style='color:red;'>", $ns, ". ", format($them['username']), " tried to hit you but missed (", format($ir['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:blue;'>" . $ns . ". " . format($them['username']) . " tried to hit " . format($ir['username']) . " but missed (" . format($ir['hp']) . ")</span><br />\n"; } if($ir['hp'] <= 0) { $ir['hp'] = 0; $_SESSION['attacklost'] = 1; mysql_query("UPDATE `users` SET `hp` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); echo "<form action='attacklost.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Continue' />"; } } } else if($them['hp'] < 5) { echo "You can only attack those who have health"; $h->endpage(); exit; } else if($ir['gang'] == $them['gang'] && $ir['gang'] > 0) { echo "You are in the same gang as ", format($them['username']), "! What are you smoking today dude!"; $h->endpage(); exit; } else if($ir['energy'] < $ir['maxenergy'] / 2) { echo "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } else if($ir['location'] != $them['location']) { echo "You can only attack someone in the same location!"; $h->endpage(); exit; } echo "</td></tr>"; if($ir['hp'] <= 0 || $them['hp'] <= 0) { echo "</table>"; } else { $vars['hpperc'] = round($ir['hp'] / $ir['maxhp'] * 100); $vars['hpopp'] = 100 - $vars['hpperc']; $vars2['hpperc'] = round($them['hp'] / $them['maxhp'] * 100); $vars2['hpopp'] = 100 - $vars2['hpperc']; $mw = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u)", $ir['equip_primary'], $ir['equip_secondary']), $c) or exit(mysql_error()); echo "<tr><td colspan='2' align='center'>Attack with:<br />"; if(mysql_num_rows($mw)) { while($r = mysql_fetch_assoc($mw)) { $ns = (!$_GET['nextstep']) ? 1 : $_GET['nextstep'] + 2; if($r['itmid'] == $ir['equip_primary']) { echo "<strong>Primary Weapon:</strong> "; } if($r['itmid'] == $ir['equip_secondary']) { echo "<strong>Secondary Weapon:</strong> "; } echo "<a href='attack.php?nextstep=", $ns, "&ID=", $_GET['ID'], "&wepid=", $r['itmid'], "'>", format($r['itmname']), "</a><br />"; } } else { echo "You have nothing to fight with."; } echo "</table>"; echo "<table width='50%' align='center'> <tr> <td align='right'>Your Health:</td> <td><img src='greenbar.png' width='", $vars['hpperc'], "' height='10' /><img src='redbar.png' width='", $vars['hpopp'], "' height='10' /></td> </tr> <tr> <td align='right'>Opponents Health:</td> <td><img src='greenbar.png' width='", $vars2['hpperc'], " height='10' /><img src='redbar.png' width='", $vars2['hpopp'], "' height='10' /></td> </tr> </table>"; } $h->endpage(); ?>   inventory.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $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 exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); 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(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $equp = array(); $q = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u, %u))", $ir['equip_primary'], $ir['equip_secondary'], $ir['equip_armor']), $c) or exit(mysql_error()); echo "<h3>Equipped Items</h3><hr />"; while($r = mysql_fetch_assoc($q)) { $equip[$r['itmid']] = $r; } echo "<table width='75%' cellspacing='1' class='table'> <tr> <th>Primary Weapon</th> <td>"; if($equip[$ir['equip_primary']]['itmid']) { echo format($equip[$ir['equip_primary']]['itmname']) , "</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Secondary Weapon</th> <td>"; if($equip[$ir['equip_secondary']]['itmid']) { echo format($equip[$ir['equip_secondary']]['itmname']) , "</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Armor</th> <td>"; if($equip[$ir['equip_armor']]['itmid']) { echo format($equip[$ir['equip_armor']]['itmname']) , "</td><td><a href='unequip.php?type=equip_armor'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> </table><hr /> <h3>Inventory</h3><hr />"; $inv = mysql_query("SELECT `iv`.*, `i`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `i` ON (`iv`.`inv_itemid` = `i`.`itmid`) " . "LEFT JOIN `itemtypes` AS `it` ON (`i`.`itmtype` = `it`.`itmtypeid`) " . "WHERE (`iv`.`inv_userid` = ".$userid.") " . "ORDER BY `i`.`itmtype` ASC, `i`.`itmname` ASC", $c) or exit(mysql_error()); if(!mysql_num_rows($inv)) { echo "<strong>You have no items!</strong>"; $h->endpage(); exit; } echo "<strong>Your items are listed below.</strong><br /> <table width='100%' class='table' border='0' cellspacing='1'> <tr> <td class='h'>Item</td> <td class='h'>Sell Value</td> <td class='h'>Total Sell Value</td> <td class='h'>Links</td> </tr>"; $lt = ""; while($i = mysql_fetch_assoc($inv)) { if($lt != $i['itmtypename']) { $lt = $i['itmtypename']; echo "\n<tr><td colspan=4><strong>",format($lt),"</strong></td></tr>"; } if($i['weapon']) { $i['itmname'] = "<span style='color:red;'>*</span>" . format($i['itmname']); } if($i['armor']) { $i['itmname'] = "<span style='color:green;'>*</span>" . format($i['itmname']); } echo "<tr><td>{$i['itmname']}"; if($i['inv_qty'] > 1) { echo " x",format($i['inv_qty']); } echo "</td><td>\$",format($i['itmsellprice']),"</td><td>"; echo "$" . format($i['itmsellprice'] * $i['inv_qty']); echo "</td><td>[<a href='iteminfo.php?ID=",$i['itmid'],"'>Info</a>] [<a href='itemsend.php?ID=",$i['inv_id'],"'>Send</a>] [<a href='itemsell.php?ID=",$i['inv_id'],"'>Sell</a>] [<a href='imadd.php?ID=",$i['inv_id'],"'>Add To Market</a>]"; if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { echo " [<a href='itemuse.php?ID=",$i['inv_id'],"'>Use</a>]"; } if($i['weapon']) { echo " [<a href='equip_weapon.php?ID=",$i['inv_id'],"'>Equip as Weapon</a>]"; } if($i['armor']) { echo " [<a href='equip_armor.php?ID=",$i['inv_id'],"'>Equip as Armor</a>]"; } echo "</td></tr>"; } echo "</table><small><strong>NB:</strong> Items with a small red </small><span style='color:red;'>*</span><small> next to their name can be used as weapons in combat.<br />Items with a small green </small><span style='color:green;'>*</span><small> next to their name can be used as armor in combat.</small>"; $h->endpage(); ?>   equip_armor.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $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 exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); 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(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $id = mysql_query("SELECT `iv`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `it` ON (`iv`.`inv_itemid` = `it`.`itmid`) " . "WHERE ((`iv`.`inv_id` = ".$_GET['ID'].") AND (`iv`.`inv_userid` = ".$userid.")) LIMIT 1", $c) or exit(mysql_error()); if(!mysql_num_rows($id)) { echo "Invalid item ID"; $h->endpage(); exit; } $r = mysql_fetch_assoc($id); if(!$r['armor']) { echo "This item cannot be equipped to this slot."; $h->endpage(); exit; } if(isset($_GET['type'])) { if($_GET['type'] != 'equip_armor') { echo "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); mysql_query("UPDATE `users` SET `".$_GET['type']."` = ".$r['itmid']." WHERE (`userid` = ".$userid.")", $c) or exit(mysql_error()); echo "Your ",format($r['itmname'])," has been equipped successfully."; } else { echo "<h3>Equip Armor</h3><hr /> <form action='equip_armor.php' method='get'> <input type='hidden' name='ID' value='",$_GET['ID'],"' /> Click Equip Armor to equip ",format($r['itmname'])," as your armor, if you currently have any armor equipped it will be removed back to your inventory.<br /> <input type='hidden' name='type' value='equip_armor' /> <input type='submit' value='Equip Armor' /></form>"; } $h->endpage(); ?>   equip_weapon.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $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 exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); 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(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $id = mysql_query("SELECT `iv`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `it` ON (`iv`.`inv_itemid` = `it`.`itmid`) " . "WHERE ((`iv`.`inv_id` = ".$_GET['ID'].") AND (`iv`.`inv_userid` = ".$userid.")) LIMIT 1", $c) or exit(mysql_error()); if(!mysql_num_rows($id)) { echo "Invalid item ID"; $h->endpage(); exit; } $r = mysql_fetch_assoc($id); if(!$r['weapon']) { echo "This item cannot be equipped to this slot."; $h->endpage(); exit; } if(isset($_GET['type'])) { if(!in_array($_GET['type'], array('equip_primary', 'equip_secondary'))) { echo "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); mysql_query("UPDATE `users` SET `".$_GET['type']."` = ".$r['itmid']." WHERE (`userid` = ".$userid.")", $c) or exit(mysql_error()); echo "Your ",format($r['itmname'])," has been equipped successfully."; } else { echo "<h3>Equip Weapon</h3><hr /> <form action='equip_weapon.php' method='get'> <input type='hidden' name='ID' value='",$_GET['ID'],"' /> Please choose the slot to equip ",format($r['itmname'])," to, if there is already a weapon in that slot, it will be removed back to your inventory.<br /> <input type='radio' name='type' value='equip_primary' checked='checked' /> Primary<br /> <input type='radio' name='type' value='equip_secondary' /> Secondary<br /> <input type='submit' value='Equip Weapon' /></form>"; } $h->endpage(); ?>   I don't know what v1 SQLs exist.. So I'll stick the SQLs needed here anyway ALTER TABLE `users` ADD ( `equip_primary` INT( 11 ) NOT NULL DEFAULT 0, `equip_secondary` INT( 11 ) NOT NULL DEFAULT 0, `equip_armor` INT( 11 ) NOT NULL DEFAULT 0 );
  12. 1 plug and play announcements <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $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 exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); 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(); $ac = $ir['new_announcements']; $q = mysql_query("SELECT * FROM `announcements` ORDER BY `a_time` DESC", $c) or exit(mysql_error()); ?><table width='80%' cellspacing='1' class='table'> <tr> <th width='30%'>Time</th> <th width='70%'>Announcement</th> </tr><?php if(!mysql_num_rows($q)) { ?><tr><td colspan='2' style='text-align:center;'>There are no announcements</td></tr><?php } else { while($r = mysql_fetch_assoc($q)) { if($ac > 0) { $ac--; $new = '<br /><strong>New!</strong>'; } else { $new = ''; } ?><tr style='vertical-align:top;'> <td><?php echo date('F j Y, g:i:s a', $r['a_time']), $new; ?></td> <td><?php echo nl2br(stripslashes($r['a_text'])); ?></td> </tr><?php } } echo "</table>"; if($ir['new_announcements']) { mysql_query("UPDATE `users` SET `new_announcements` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); } $h->endpage(); ?>   Staff side (based on the v1 I "grew up" with): Edit admin.php Add function announcements() { global $ir, $c, $h; if($ir['user_level'] != 2) { echo "You don't have access to this"; $h->endpage(); exit; } if(isset($_POST['text']) && !empty($_POST['text'])) { mysql_query(sprintf("INSERT INTO `announcements` VALUES('%s', %s)", mysql_real_escape_string($_POST['text'], $c), time()), $c) or exit(mysql_error()); mysql_query("UPDATE `users` SET `new_announcements` = `new_announcements` + 1", $c) or exit(mysql_error()); echo "Announcement added!<br />> <a href='admin.php'>Back</a>"; } else { ?>Adding an announcement...<br /> Please try to make sure the announcement is concise and covers everything you want it to. <form action='staff.php?action=announce' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Announcement text</th> <td width='55%'><textarea name='text' rows='10' cols='70'></textarea></td> </tr> <tr> <td colspan='2' style='text-align:center;'><input type='submit' value='Add Announcement' /></td> </tr> </table> </form><?php } }   SQLs CREATE TABLE IF NOT EXISTS `announcements` ( `a_text` TEXT NOT NULL, `a_time` INT( 11 ) NOT NULL DEFAULT 0 ); ALTER TABLE `users` ADD `new_announcements` INT( 11 ) NOT NULL DEFAULT 0;
  13. . Looking around, he
  14. With a name of "The Coder", I do believe a simple conversion should be easy for you ;) View this topic for a short How To. Be sure to copy over the SQL structure too ;)
  15. garage.php <?php include(__DIR__ . '/globals.php'); echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'buy': buyGarage(); break; case 'upgradegarage': upgradeGarage(); break; case 'upgrade': upgradeCar(); break; case 'sell': sellCar(); break; default: carIndex(); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function carIndex() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); $selectCars = $db->query(sprintf("SELECT `pc`.*, `c`.`cName`, `c`.`cDesc` " . "FROM `playerCars` AS `pc` " . "LEFT JOIN `cars` AS `c` ON (`c`.`cID` = `pc`.`pcCarID`) " . "WHERE (`pc`.`pcUser` = %u) " . "ORDER BY `c`.`cName` ASC", $ir['userid'])); ?><h3>Cars: Your <? echo format($garage['gTypeName']); ?></h3> <a href='garage.php?action=upgradegarage'>Upgrade your <? echo format($garage['gTypeName']); ?></a><br /> You have <? echo format($db->num_rows($selectCars)),'/',format($garage['pgCapacity']); ?> cars<br /> <table class='table' width='100%' cellspacing='1'> <tr> <th width='45%'>Car/Description</th> <th width='45%'>Stats</th> <th width='10%'>Links</th> </tr><? if(!$db->num_rows($selectCars)) { echo "<tr><td colspan='3' class='center'>You don't have any cars<br /><a href='cardealer.php'>Go buy one</a></td></tr>"; } else { while($car = $db->fetch_row($selectCars)) { ?><tr> <td><? echo format($car['cName']); ?><br /><br /><? echo nl2br(format($car['cDesc'])); ?></td> <td><table class='table' width='100%' cellspacing='1'> <tr> <th width='20%'>Speed</th> <td width='30%'><? echo format($car['pcSpeed']); ?></td> <th width='20%'>Handling</th> <td width='30%'><? echo format($car['pcHandling']); ?></td> </tr> <tr> <th width='20%'>Acceleration</th> <td width='30%'><? echo format($car['pcAccel']); ?></td> <th width='20%'>Braking</th> <td width='30%'><? echo format($car['pcBrake']); ?></td> </tr> </table></td> <td><a href='garage.php?action=upgrade&ID=<? echo $car['pcID']; ?>'>Upgrade</a> · <a href='garage.php?action=sell&ID=<? echo $car['pcID']; ?>'>Sell</a><br /><a href='carrace.php?ID=<? echo $car['pcID']; ?>'>Race</a></td> </tr><? } } echo "</table>"; } function upgradeCar() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID` = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid'])); if(!$db->num_rows($selectMyCar)) { error("You don't own that car"); } $myCar = $db->fetch_row($selectMyCar); $selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID'])); if(!$db->num_rows($selectStandardCar)) { error("That car doesn't exist - message a staff member to inform them about this"); } $car = $db->fetch_row($selectStandardCar); ?><h3>Cars: Upgrading your <? echo format($car['cName']); ?></h3><? $tuneArray = array('speed', 'handling', 'accel', 'brake'); $_GET['tune'] = isset($_GET['tune']) && ctype_alpha($_GET['tune']) && in_array($_GET['tune'], $tuneArray) ? strtolower(trim($_GET['tune'])) : null; if(empty($_GET['tune'])) { ?><table class='table' width='75%' cellspacing='1'> <tr> <th width='20%'>Stat</th> <th width='60%'>Amount</th> <th width='20%'>Tune</th> </tr> <tr> <th>Speed</th> <td><? echo format($myCar['pcSpeed']); ?></td> <td>Cost: <? echo format($myCar['pcSpeed'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=speed'>Tune</a></td> </tr> <tr> <th>Handling</th> <td><? echo format($myCar['pcHandling']); ?></td> <td>Cost: <? echo format($myCar['pcHandling'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=handling'>Tune</a></td> </tr> <tr> <th>Acceleration</th> <td><? echo format($myCar['pcAccel']); ?></td> <td>Cost: <? echo format($myCar['pcAccel'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=accel'>Tune</a></td> </tr> <tr> <th>Braking</th> <td><? echo format($myCar['pcBrake']); ?></td> <td>Cost: <? echo format($myCar['pcBrake'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=brake'>Tune</a></td> </tr> </table><? } else { $rand = mt_rand(1, 5); $uhOh = ''; switch($_GET['tune']) { case 'speed': if(($myCar['pcSpeed'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('handling', 'accel', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcSpeed` = `pcSpeed` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcSpeed'] * 2), $ir['userid'])); success("You've upgraded your speed".$uhOh); break; case 'handling': if(($myCar['pcHandling'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'accel', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcHandling` = `pcHandling` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcHandling'] * 2), $ir['userid'])); success("You've upgraded your handling".$uhOh); break; case 'accel': if(($myCar['pcAccel'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'handling', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcAccel` = `pcAccel` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcAccel'] * 2), $ir['userid'])); success("You've upgraded your acceleration".$uhOh); break; case 'brake': if(($myCar['pcBrake'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'handling', 'accel'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcBrake` = `pcBrake` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcBrake'] * 2), $ir['userid'])); success("You've upgraded your braking".$uhOh); break; } } } function upgradeGarage() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); if(!empty($_GET['ID'])) { $select = $db->query(sprintf("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = %u)", $_GET['ID'])); if(!$db->num_rows($select)) { error("That upgrade doesn't exist"); } $gar = $db->fetch_row($select); if($gar['gTypeCost'] > $ir['money']) { error("You don't have enough money for that"); } $db->query(sprintf("UPDATE `playerGarages` SET `pgType` = %u WHERE (`pgUser` = %u)", $_GET['ID'], $ir['userid'])); success("You've bought the ".format($gar['gTypeName'])); } $getGarageUpgrades = $db->query(sprintf("SELECT * FROM `garages` WHERE (`gTypeID` > %u)", $garage['gTypeID'])); ?><h3>Cars: Upgrading your <? echo format($garage['gTypeName']); ?></h3> <table class='table' width='75%' cellspacing='1'> <tr> <th width='40%'>Upgrade</th> <th width='40%'>Cost</th> <th width='20%'>Links</th> </tr><? if(!$db->num_rows($getGarageUpgrades)) { echo "<tr><td colspan='3' class='center'>There are no upgrades available</td></tr>"; } else { while($upg = $db->fetch_row($getGarageUpgrades)) { ?><tr> <td><? echo format($upg['gTypeName']); ?></td> <td>$<? echo format($upg['gTypeCost']); ?></td> <td><? echo ($ir['money'] >= $upg['gTypeCost']) ? "<a href='garage.php?action=upgradegarage&ID=".$upg['gTypeID']."'>Buy</a>" : "<span style='color:#444;'>Buy</span>"; ?></td> </tr><? } } echo "</table>"; } function sellCar() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid'])); if(!$db->num_rows($selectMyCar)) { error("You don't own that car"); } $myCar = $db->fetch_row($selectMyCar); $selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID'])); if(!$db->num_rows($selectStandardCar)) { error("That car doesn't exist - message a staff member to inform them about this"); } $stdCar = $db->fetch_row($selectStandardCar); $myTotalStats = $myCar['pcSpeed'] + $myCar['pcHandling'] + $myCar['pcAccel'] + $myCar['pcBrake']; $stdTotalStats = $stdCar['cSpeed'] + $stdCar['cHandling'] + $stdCar['cAccel'] + $stdCar['cBrake']; if(($myTotalStats >= $stdTotalStats) && ($myTotalStats <= ($stdTotalStats + 500))) { $cost = $stdCar['cCost'] / 2; } else if(($myTotalStats >= ($stdTotalStats + 501)) && $myTotalStats <= ($stdTotalStats + 1500)) { $cost = $stdCar['cCost']; } else if(($myTotalStats >= ($stdTotalStats + 1501)) && $myTotalStats <= ($stdTotalStats * 2)) { $cost = ($stdCar['cCost'] * 2) - (($stdCar['cCost'] / 100) * 33); } else if(($myTotalStats >= ($stdTotalStats * 2) + 1) && $myTotalStats <= ($stdTotalStats * 5)) { $cost = $stdCar['cCost'] * 3; } else if(($myTotalStats >= ($stdTotalStats * 5) + 1) && $myTotalStats <= ($stdTotalStats * 10)) { $cost = $stdCar['cCost'] * 3; } else if($myTotalStats >= ($stdTotalStats * 10) + 1) { $cost = $stdCar['cCost'] * 5; } ?><h3>Cars: Selling your <? echo format($stdCar['cName']); ?></h3><? if(!isset($_GET['ans'])) { ?>If you sell your car, you will receive $<? echo format($cost); ?><br /> Are you sure you want to do this?<br /> <a href='garage.php?action=sell&ID=<? echo $_GET['ID']; ?>&ans=yes'>Yes</a> · <a href='garage.php'>No</a><? } else { $db->query(sprintf("DELETE FROM `playerCars` WHERE (`pcID` = %u)", $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` + %u WHERE (`userid` = %u)", $cost, $ir['userid'])); success("You've sold your ".format($stdCar['cName'])." for \$".format($cost)); } } function buyGarage() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if($db->num_rows($selectGarage)) { header("Location: garage.php"); exit; } $select = $db->query("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = 1)"); $gar = $db->fetch_row($select); ?><h3>Cars: Buying your first <? echo format($gar['gTypeName']); ?></h3><? if($gar['gTypeCost'] > $ir['money']) { error("You don't have enough money to do that. It costs ".format($gar['gTypeCost'])); } $db->query(sprintf("INSERT INTO `playerGarages` VALUES ('', %u, 1, 1)", $ir['userid'])); success("You've bought your ".format($gar['gTypeName'])); } $h->endpage(); ?>
  16. Indeed, such is the life of a child! xD
  17. 5 reps given elsewhere, or receive a rep from the "repped"
  18. Indeed, considering the family are now demanding time with me preventing me from doing what I want to .. again xD I'll finish up tomorrow. Coming soon: Garage Types (staff side) Upgrade Garage Upgrade Car Sell Car RacesFun Bet Pinks  
  19. cardealer.php <?php include(__DIR__ . '/globals.php'); echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; switch($_GET['action']) { case 'buy': buyCar(); break; default: carIndex(); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function carIndex() { global $db, $ir; echo "<h3>Cars: Car Dealership</h3>"; $selectGarage = $db->query(sprintf("SELECT `pgID` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { echo "<a href='garage.php'>Buy your own driveway</a>"; } ?><table class='table' width='100%' cellspacing='1'> <tr> <th width='25%'>Car/Description</th> <th width='20%'>Cost</th> <th width='50%'>Stats</th> <th width='5%'>Links</th> </tr><? $select = $db->query("SELECT * FROM `cars` ORDER BY `cCost` ASC, `cName` ASC"); if(!$db->num_rows($select)) { echo "<tr><td colspan='3' class='center'>There are no available cars</td></tr>"; } else { while($row = $db->fetch_row($select)) { ?><tr> <td><strong><? echo format($row['cName']); ?></strong><? echo nl2br(format($row['cDesc'])); ?></td> <td>$<? echo format($row['cCost']); ?></td> <td><table class='table' width='100%' cellspacing='1'> <tr> <th width='10%'>Speed</th> <td width='40%'><? echo format($row['cSpeed']); ?></td> <th width='10%'>Handling</th> <td width='40%'><? echo format($row['cHandling']); ?></td> </tr> <tr> <th width='10%'>Acceleration</th> <td width='40%'><? echo format($row['cAccel']); ?></td> <th width='10%'>Braking</th> <td width='40%'><? echo format($row['cBrake']); ?></td> </tr> </table></td> <td><? echo ($ir['money'] >= $row['cCost']) ? "<a href='cardealer.php?action=buy&ID=".$row['cID']."'>Buy</a>" : "<span style='color:#444;'><em>Buy</em></span>"; ?></td> </tr><? } } echo "</table>"; } function buyCar() { global $db, $ir; echo "<h3>Cars: Car Dealership: Buying a car</h3>"; if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $_GET['ID'])); if(!$db->num_rows($selectCar)) { error("That car doesn't exist"); } $row = $db->fetch_row($selectCar); $selectGarage = $db->query(sprintf("SELECT `pgCapacity`, `pgType` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { error("You don't have anywhere to park your car. You must buy a driveway before you can buy a car"); } $garage = $db->fetch_row($selectGarage); $selectPlayerCars = $db->query(sprintf("SELECT COUNT(`pcID`) FROM `playerCars` WHERE (`pcUser` = %u)", $ir['userid'])); $getGarageName = $db->query(sprintf("SELECT `gTypeName` FROM `garageTypes` WHERE (`gTypeID` = %u)", $garage['pgType'])); $garageName = $db->fetch_single($getGarageName); if($db->fetch_single($selectPlayerCars) >= $garage['pgCapacity']) { error("Your ".format($garageName)." is full. You must upgrade it before you can fit any more cars"); } if($ir['money'] < $row['cCost']) { error("You don't have enough money to buy the ".format($row['cName'])); } $db->query(sprintf("INSERT INTO `playerCars` VALUES ('', %u, %u, %u, %u, %u, %u)", $ir['userid'], $_GET['ID'], $row['cSpeed'], $row['cHandling'], $row['cAccel'], $row['cBrake'])); success("You've bought the ".format($row['cName'])); } $h->endpage(); ?>   I'm slowing down due to family getting in the way lol
  20. Next lot of SQL's - don't worry people, I'll release this all on one topic ;) CREATE TABLE `playerCars` ( `pcID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `pcUser` INT( 11 ) NOT NULL DEFAULT 0, `pcCarID` INT( 11 ) NOT NULL DEFAULT 0, `pcSpeed` INT( 11 ) NOT NULL DEFAULT 0, `pcHandling` INT( 11 ) NOT NULL DEFAULT 0, `pcAccel` INT( 11 ) NOT NULL DEFAULT 0, `pcBrake` INT( 11 ) NOT NULL DEFAULT 0 ); CREATE TABLE `playerGarages` ( `pgID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `pgUser` INT( 11 ) NOT NULL DEFAULT 0, `pgType`INT( 11 ) NOT NULL DEFAULT 1, `pgCapacity` INT( 11 ) NOT NULL DEFAULT 1 ); CREATE TABLE `garages` ( `gTypeID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `gTypeName` VARCHAR( 255 ) NOT NULL DEFAULT 0, `gTypeCost` INT( 11 ) NOT NULL DEFAULT 3000 ); INSERT INTO `garages` VALUES ('', 'Driveway', 3000);
  21. I'd also make it so they'd have to buy it, but the client gets what the client wants ;)
  22. Oh, Razor! Do you want players to automatically have a garage, or do you want them to buy it?   I can do that.. Could be fun ^.^
  23. Thank you kindly :) staff_cars.php - Code has been fully tested <?php include(__DIR__ . '/globals.php'); if($ir['user_level'] != 2) { error("You can't access this"); } echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'add': addCar(); break; case 'edit': editCar(); break; case 'del': deleteCar(); break; default: error("I don't know what to do.."); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function addCar() { global $db; echo "<h3>Cars: Create Car</h3>"; if(isset($_POST['submit'])) { $texts = array( 'carName' => 'name', 'carDesc' => 'description' ); $nums = array( 'carSpeed' => 'speed', 'carHandling' => 'handling', 'carAccel' => 'acceleration', 'carBrake' => 'braking', 'carCost' => 'cost' ); foreach($_POST[$texts] as $what => $value) { $_POST[$texts] = isset($_POST[$texts]) && is_string($_POST[$texts]) ? trim($_POST[$texts]) : null; if(empty($_POST[$texts])) { error("You didn't enter a valid ".$value); } } foreach($_POST[$nums] as $what => $value) { $_POST[$nums] = isset($_POST[$nums]) && ctype_digit($_POST[$texts]) ? abs(@intval($_POST[$texts])) : null; if(empty($_POST[$nums])) { error("You didn't enter a valid ".$nums." value"); } } $select = $db->query(sprintf("SELECT `cID` FROM `cars` WHERE (`cName` = '%s')", $db->escape($_POST['carName']))); if($db->num_rows($select)) { error("A car with that name already exists"); } $db->query(sprintf("INSERT INTO `cars` VALUES ('', '%s', '%s', %u, %u, %u, %u, %u)", $db->escape($_POST['carName']), $db->escape($_POST['carDesc']), $_POST['carSpeed'], $_POST['carHandling'], $_POST['carAccel'], $_POST['carBrake'], $_POST['carCost'])); stafflog_add("Created a new car: ".$_POST['carName']); success("The “".format($_POST['carName'])."” has been created"); } ?><form action='staff_cars.php?action=add' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Name</th> <td width='55%'><input type='text' name='carName' /></td> </tr> <tr> <th>Description</th> <td><textarea name='carDesc' rows='10' cols='70'></textarea></td> </tr> <tr> <th>Speed</th> <td><input type='number' name='carSpeed' /></td> </tr> <tr> <th>Handling</th> <td><input type='number' name='carHandling' /></td> </tr> <tr> <th>Acceleration</th> <td><input type='number' name='carAccel' /></td> </tr> <tr> <th>Braking</th> <td><input type='number' name='carBrake' /></td> </tr> <tr> <th>Cost</th> <td><input type='number' name='carCost' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Create' /></td> </tr> </table> </form><? } function editCar() { global $db; echo "<h3>Cars: Edit Car</h3>"; $_GET['step'] = isset($_GET['step']) && ctype_digit($_GET['step']) ? abs(@intval($_GET['step'])) : null; switch($_GET['step']) { default: $selectCars = $db->query("SELECT `cID`, `cName` FROM `cars` ORDER BY `cName` ASC"); if(!$db->num_rows($selectCars)) { error("There are no cars to edit"); } ?><form action='staff_cars.php?action=edit&step=1' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Car</th> <td width='55%'><select name='car' type='dropdown'><? while($row = $db->fetch_row($selectCars)) { printf("<option value='%u'>%s</option>", $row['cID'], format($row['cName'])); } ?></select></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Edit the selected car' /></td> </tr> </table> </form><? break; case 1: $_POST['car'] = isset($_POST['car']) && ctype_digit($_POST['car']) ? abs(@intval($_POST['car'])) : null; if(empty($_POST['car'])) { error("You didn't select a valid car"); } $select = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); if(!$db->num_rows($select)) { error("That car doesn't exist"); } $car = $db->fetch_row($select); ?><form action='staff_cars.php?action=edit&step=2' method='post'> <input type='hidden' name='carID' value='<? echo $_POST['car']; ?>' /> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Name</th> <td width='55%'><input type='text' name='carName' value='<? echo format($car['cName']); ?>' /></td> </tr> <tr> <th>Description</th> <td><textarea name='carDesc' rows='10' cols='70'><? echo format($car['cDesc']); ?></textarea></td> </tr> <tr> <th>Speed</th> <td><input type='number' name='carSpeed' value='<? echo $car['cSpeed']; ?>' /></td> </tr> <tr> <th>Handling</th> <td><input type='number' name='carHandling' value='<? echo $car['cHandling']; ?>' /></td> </tr> <tr> <th>Acceleration</th> <td><input type='number' name='carAccel' value='<? echo $car['cAccel']; ?>' /></td> </tr> <tr> <th>Braking</th> <td><input type='number' name='carBrake' value='<? echo $car['cBrake']; ?>' /></td> </tr> <tr> <th>Cost</th> <td><input type='number' name='carCost' value='<? echo $car['cCost']; ?>' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Edit' /></td> </tr> </table> </form><? break; case 2: $texts = array( 'carName' => 'name', 'carDesc' => 'description' ); $nums = array( 'carSpeed' => 'speed', 'carHandling' => 'handling', 'carAccel' => 'acceleration', 'carBrake' => 'braking', 'carCost' => 'cost', 'carID' => 'car' ); foreach($_POST[$texts] as $what => $value) { $_POST[$texts] = isset($_POST[$texts]) && is_string($_POST[$texts]) ? trim($_POST[$texts]) : null; if(empty($_POST[$texts])) { error("You didn't enter a valid ".$value); } } foreach($_POST[$nums] as $what => $value) { $_POST[$nums] = isset($_POST[$nums]) && ctype_digit($_POST[$texts]) ? abs(@intval($_POST[$texts])) : null; if(empty($_POST[$nums])) { error("You didn't enter a valid ".$nums." value"); } } $selectCar = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE (`cID` = %u)", $_POST['carID'])); if(!$db->num_rows($selectCar)) { error("That car doesn't exist"); } $selectCarName = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE ((`cName` = '%s') AND (`cID` != %u))", $db->escape($_POST['carName']), $_POST['carID'])); if($db->num_rows($selectCarName)) { error("Another car with that name already exists"); } $oldName = $db->fetch_single($selectCar); $db->query(sprintf("UPDATE `cars` SET `cName` = '%s', `cDesc` = '%s', `cSpeed` = %u, `cHandling` = %u, `cAccel` = %u, `cBrake` = %u, `cCost` = %u WHERE (`cID` = %u)", $db->escape($_POST['carName']), $db->escape($_POST['carDesc']), $_POST['carSpeed'], $_POST['carHandling'], $_POST['carAccel'], $_POST['carBrake'], $_POST['carCost'], $_POST['carID'])); $log = ($_POST['carName'] == stripslashes($oldName)) ? $_POST['carName'] : $oldName." > ".format($_POST['carName']); stafflog_add("Edited the car: ".$log); success("The “".stripslashes($log)."” has been edited"); break; } } function deleteCar() { global $db; echo "<h3>Cars: Delete Car</h3>"; if(isset($_POST['submit'])) { $_POST['car'] = isset($_POST['car']) && ctype_digit($_POST['car']) ? abs(@intval($_POST['car'])) : null; if(empty($_POST['car'])) { error("You didn't select a valid car"); } $select = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); if(!$db->num_rows($select)) { error("That car doesn't exist"); } $name = $db->fetch_single($select); $db->query(sprintf("DELETE FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); stafflog_add("Deleted the car: ".$name); success("You've deleted the car: ".format($name)); } $selectCars = $db->query("SELECT `cID`, `cName` FROM `cars` ORDER BY `cName` ASC"); if(!$db->num_rows($selectCars)) { error("There are no cars to delete"); } ?><form action='staff_cars.php?action=del' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Car</th> <td width='55%'><select name='car' type='dropdown'><? while($row = $db->fetch_row($selectCars)) { printf("<option value='%u'>%s</option>", $row['cID'], format($row['cName'])); } ?></select></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Delete the selected car' /></td> </tr> </table> </form><? } $h->endpage(); ?>   Edit your staff menu (smenu.php) Add this where you want it <hr /><strong>Cars</strong><br /> > <a href='staff_cars.php?action=add'>Add Car</a><br /> > <a href='staff_cars.php?action=edit'>Edit Car</a><br /> > <a href='staff_cars.php?action=del'>Delete Car</a><br />
  24. SQLs CREATE TABLE `cars` ( `cID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `cName` VARCHAR( 255 ) NOT NULL DEFAULT '', `cDesc` TEXT NOT NULL, `cSpeed` INT( 11 ) NOT NULL DEFAULT 0, `cHandling` INT( 11 ) NOT NULL DEFAULT 0, `cAccel` INT( 11 ) NOT NULL DEFAULT 0, `cBrake` INT( 11 ) NOT NULL DEFAULT 0, `cCost` INT( 11 ) NOT NULL DEFAULT 0 );   Get those in, I'm just finishing up the staff side so you can start creating the cars for your players ;)
×
×
  • Create New...