Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,124
  • Joined

  • Last visited

  • Days Won

    144

Everything posted by Magictallguy

  1. 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
  2. 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 );
  3. 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;
  4. . Looking around, he
  5. 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 ;)
  6. 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(); ?>
  7. Indeed, such is the life of a child! xD
  8. 5 reps given elsewhere, or receive a rep from the "repped"
  9. 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  
  10. 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
  11. 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);
  12. I'd also make it so they'd have to buy it, but the client gets what the client wants ;)
  13. 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 ^.^
  14. 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 />
  15. 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 ;)
  16. Good stuff, writing up the staff side now :)
  17. Not what I asked lol. You wanted cars, do you also want car brands?
  18. Right, before I continue, do you want car brands (Mercedes, BMW, etc. (obviously, for legal reasons, you'd have to invent your own or get permission from each company to use their name)
  19. Any specific time limit on how many times a player can race said car(s)? Is there a limit on the amount of races by x amount of time? Limit on how many cars a player can have/win/lose?   Again, limits? Do you want the players to be able to nickname their cars?   Similar to the Item Market, I assume?   How much money per upgrade? Does the upgrade count for all car "stats" or just one specifically per upgrade purchase? Would the car have a "car level"? If so, would this level limit the amount a car can be upgraded?   Upgrading a garage gives you how many more parking spots? Do you want the garage to be upgraded into something different per "garage level"? (i.e. Garage -> Sheltered Garage -> Showroom -> Complex, etc..)
  20. Want to stop cheating? As "Nyna" once said.. The best way is this: <tt>Site Offline</tt>
  21. Is that 100,000 per player, or 100,000 in total? As that is what Dave was saying
  22. Continuing on from my original post.. * You will need my time2readable() function found in one of my gang mods SQLs ALTER TABLE `guildAlliances` ADD `gaTime` INT( 11 ) NOT NULL DEFAULT 0;   Edit yourgang.php In the gang_staff_alliance_decide() function Find $db->query(sprintf("INSERT INTO `gangAlliances` VALUES ('', %u, %u)", $gangdata['gangID'], $req['gangID'])); Replace with $db->query(sprintf("INSERT INTO `gangAlliances` VALUES ('', %u, %u, %s)", $gangdata['gangID'], $req['gangID'], time()));   In the gang_staff_alliance_view() Find <th width='80%'>Gang</th> <th width='20%'>Action</th> Replace with <th width='60%'>Gang</th> <th width='20%'>Time Left</th> <th width='20%'>Action</th>   Find echo "<tr><td colspan='2' class='center'>You don't have any Allies</td></tr>"; Replace with echo "<tr><td colspan='3' class='center'>You don't have any Allies</td></tr>";   Find printf("<td class='center'><a href='yourgang.php?action=staff&act2=allianceb&ID=%u'><img src='/silk/link_break.png' title='Break this alliance' alt='Break' /></a></td>", $yellow['gaID']); Add above printf("<td class='center'>%s</td>", time2readable(($yellow['gaTime'] + 2592000) - time()));   Edit your five minute cron [Default setup - cron_fivemins.php] At the bottom of the file Add $selectAlliances = $db->query("SELECT * FROM `guildAlliances` WHERE ((`gaTime` + 2592000) > unix_timestamp())"); while($row = $db->fetch_row($select)) { $getName1 = $db->fetch_single($db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $row['gaGuild1']))); $getName2 = $db->fetch_single($db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $row['gaGuild2']))); $db->query(sprintf("DELETE FROM `guildAlliances` WHERE (`gaID` = %u)", $row['gaID'])); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, 'The alliance between <a href=\'gangs.php?action=view&ID=%u\'>%s</a> and <a href=\'gangs.php?action=view&ID=%u\'>%s</a> has come to an end')", $row['gaGuild1'], time(), $row['gaGuild1'], $getName1, $row['gaGuild2'], $getName2)); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, 'The alliance between <a href=\'gangs.php?action=view&ID=%u\'>%s</a> and <a href=\'gangs.php?action=view&ID=%u\'>%s</a> has come to an end')", $row['gaGuild2'], time(), $row['gaGuild1'], $getName1, $row['gaGuild2'], $getName2)); }
  23. This mod was requested by Bennyh789 on this topic. PHP5.6 complaint Staff Gang Delete Add the following code into staff_gangs.php case 'gdelete': admin_gang_delete($db, $ir); break /** * @param database $db * @param array $ir * @return void */ function admin_gang_delete($db, $ir) { if (2 != $ir['user_level']) { clean_kill('You can\'t do that'); } ?> <h3>Gang Management: Deletion</h3> <?php $select = $db->query('SELECT gangID, gangNAME FROM gangs ORDER BY gangNAME'); if (!$db->num_rows($select)) { clean_kill('There are no gangs to delete'); } if (!array_key_exists('submit', $_POST)) { ?> <form action="staff_gangs.php?action=gdelete" method="post"> <div class="form-control"> <label for="gang">Gang</label> <select name="gang" id="gang" class="form-control"> <?php while ($row = $db->fetch_row($select)) { printf('<option value="%u">%s</option>', $row['gangID'], stripslashes(htmlspecialchars($row['gangNAME']))); } ?> </select> </div> <div class="form-control"> <label for="reason">Reason</label> <input type="text" name="reason" id="reason" class="form-control"> </div> <div class="form-check"> <input type="checkbox" name="notify" id="notify" value="1" class="form-check-input" checked> <label for="notify" class="form-check-label">Notify members</label> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Delete the selected gang </button> </form> <?php } else { $_POST['gang'] = array_key_exists('gang', $_POST) && is_numeric($_POST['gang']) && (int)$_POST['gang'] > 0 ? (int)$_POST['gang'] : null; $_POST['reason'] = array_key_exists('reason', $_POST) && is_string($_POST['reason']) && strlen($_POST['reason']) > 0 ? strip_tags(trim($_POST['reason'])) : null; if (empty($_POST['gang'])) { clean_kill('You didn\'t select a valid gang'); } if (empty($_POST['reason'])) { clean_kill('You didn\'t enter a valid reason'); } $select = $db->query('SELECT gangNAME FROM gangs WHERE gangID = ' . $_POST['gang']); if (!$db->num_rows($select)) { clean_kill('That gang doesn\'t exist'); } $gangName = $db->fetch_single($select); if (isset($_POST['notify']) && $_POST['notify']) { $selectMembers = $db->query('SELECT userid FROM users WHERE gang = ' . $_POST['gang']); if ($db->num_rows($selectMembers)) { while ($row = $db->fetch_row($selectMembers)) { event_add($row['userid'], 'Your gang has been disbanded by the Administration'); } } } $db->query('DELETE FROM gangs WHERE gangID = ' . $_POST['gang']); $db->query('DELETE FROM gangwars WHERE ' . $_POST['gang'] . ' IN (warDECLARED, warDECLARER)'); $db->query('DELETE FROM gangevents WHERE gevGANG = ' . $_POST['gang']); $checkForMTGsGangArmoury = $db->query('SHOW COLUMNS FROM inventory WHERE (field = "inv_borrowed")'); if ($db->num_rows($checkForMTGsGangArmoury)) { $db->query('DELETE FROM inventory WHERE (inv_borrowed = \'Yes\')'); $db->query('DELETE FROM gang_armoury WHERE gang = ' . $_POST['gang']); $db->query('DELETE FROM gang_armoury_loans WHERE gang = ' . $_POST['gang']); $db->query( 'UPDATE users SET IF(equip_primary_loaned = \'Yes\', (equip_primary_loaned = \'No\', equip_primary = 0), equip_primary_loaned = \'No\'), IF(equip_secondary_loaned = \'Yes\', (equip_secondary_loaned = \'No\', equip_secondary = 0), equip_secondary_loaned = \'No\'), IF(equip_armor_loaned = \'Yes\', (equip_armor_loaned = \'No\', equip_armor = 0), equip_armor_loaned = \'No\') WHERE gang = ' . $_POST['gang'] ); } $db->query('UPDATE users SET gang = 0 WHERE gang = ' . $_POST['gang']); stafflog_add('Deleted the gang named &ldquo;' . $gangName . '&rdquo; with the reason: ' . $_POST['reason']); echo 'You\'ve deleted the gang &ldquo;' . $gangName . '&rdquo;'; } } Add your link to the staff menu (smenu.php by default) staff_gangs.php?action=gdelete
  24. This mod was requested by Bennyh789 on this topic Gang Alliance PHP 5.6 compliant Edit yourgang.php, add to the bottom (above the endpage..) /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } /** * Applies stripslashes() and htmlspecialchars() to strings, and number_format() to integers/floats. * @param int|float|string $str * @return string */ function format($str) { return is_numeric($str) ? number_format($str) : stripslashes(htmlspecialchars($str)); } /** * Adds an event to the gangevents table. * @param database $db * @param int $gangID * @param string $event * @return void */ function gang_event_add($db, $gangID, $event) { $db->query('INSERT INTO gangevents (gevGANG, gevTIME, gevTEXT) VALUES (' . $gangID . ', ' . time() . ', \'' . $db->escape($event) . '\')'); } $_GET['ID'] = array_key_exists('ID', $_GET) && is_numeric($_GET['ID']) && (int)$_GET['ID'] > 0 ? (int)$_GET['ID'] : null; /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_request($db, $gangdata) { if (!array_key_exists('submit', $_POST)) { $pikachu = $db->query('SELECT gangID, gangNAME FROM gangs WHERE gangID <> ' . $gangdata['gangID']); ?> <h3>Request an Alliance</h3> <form action="yourgang.php?action=staff&amp;act2=alliancer" method="post"> <div class="form-group"> <label for="gang">Gang</label> <select name="gang" id="gang" class="form-control"> <?php if (!$db->num_rows($pikachu)) { ?> <option value="0">There are no gangs</option> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { printf('<option value="%u">%s</option>', $yellow['gangID'], format($yellow['gangNAME'])); } } ?> </select> </div> <div class="form-group"> <label for="message">Message</label> <textarea name="message" id="message" rows="10" cols="70" placeholder="Enter a reason as to why you want to become allies"></textarea> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Request Alliance </button> </form> <?php } else { $_POST['gang'] = array_key_exists('gang', $_POST) && ctype_digit($_POST['gang']) && $_POST['gang'] > 0 ? $_POST['gang'] : null; $_POST['message'] = array_key_exists('message', $_POST) && is_string($_POST['message']) && strlen($_POST['message']) > 0 ? strip_tags(trim($_POST['message'])) : null; if ($_POST['gang'] === null) { clean_kill('You didn\'t select a valid gang'); } if ($_POST['message'] === null) { clean_kill('You didn\'t enter a valid message'); } $blue = $db->query('SELECT gangID, gangNAME FROM gangs WHERE gangID = ' . $_POST['gang']); if (!$db->num_rows($blue)) { clean_kill('That gang doesn\'t exist'); } $row = $db->fetch_row($blue); $froob = $db->query('SELECT gaID FROM gangs_alliances WHERE (gaGuild1 = ' . $_POST['gang'] . ' AND gaGuild2 = ' . $gangdata['gangID'] . ') OR (gaGuild2 = ' . $_POST['gang'] . ' AND gaGuild1 = ' . $gangdata['gangID'] . ')'); if ($db->num_rows($froob)) { clean_kill('You\'re already allied with ' . format($row['gangNAME'])); } if ($_POST['gang'] == $gangdata['gangID']) { clean_kill('You can\'t ally with yourself!'); } $selectRequest = $db->query('SELECT garID FROM gangs_alliances_requests WHERE (garGuildFrom = ' . $_POST['gang'] . ' AND garGuildTo = ' . $gangdata['gangID'] . ') OR (garGuildTo = ' . $_POST['gang'] . ' AND garGuildFrom = ' . $gangdata['gangID'] . ')'); if ($db->num_rows($selectRequest)) { clean_kill('You\'ve already sent an alliance request'); } $db->query('INSERT INTO gangs_alliances_requests VALUES (NULL, ' . time() . ', ' . $gangdata['gangID'] . ', ' . $_POST['gang'] . ', \'' . $db->escape($_POST['message']) . '\')'); $eventText = '<a href="gangs.php?action=view&amp;ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has sent an alliance request to <a href="gangs.php?action=view&amp;ID=' . $_POST['gang'] . '">' . $row['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $_POST['gang'], $eventText); echo 'You\'ve requested to become allied with ' . format($row['gangNAME']); } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_decide($db, $gangdata) { if ($_GET['ID'] === null) { clean_kill('You didn\'t select a valid alliance request to decide on'); } $select = $db->query('SELECT gar.*, g.gangID, g.gangNAME FROM gangs_alliances_requests AS gar INNER JOIN gangs AS g ON g.gangID = gar.garGuildFrom WHERE gar.garGuildTo = ' . $gangdata['gangID'] . ' AND gar.garID = ' . $_GET['ID'] . ' LIMIT 1' ); if (!$db->num_rows($select)) { clean_kill('That request doesn\'t exist'); } $_GET['what'] = array_key_exists('what', $_GET) && in_array($_GET['what'], ['accept', 'decline']) ? $_GET['what'] : null; if ($_GET['what'] === null) { clean_kill('You didn\'t select a valid decision'); } $req = $db->fetch_row($select); if ('accept' == $_GET['what']) { $db->query('INSERT INTO gangs_alliances VALUES (NULL, ' . $gangdata['gangID'] . ', ' . $req['gangID'] . ')'); $db->query('DELETE FROM gangs_alliances_requests WHERE garID = ' . $_GET['ID']); $eventText = '<a href="gangs.php?action=view&amp;ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has accepted the alliance request from <a href="gangs.php?action=view&amp;ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $req['gangID'], $eventText); echo 'You\'ve accepted the alliance request from <a href="gangs.php?action=view&amp;ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; } else { $eventText = '<a href="gangs.php?action=view&amp;ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> have declined the alliance request from <a href="gangs.php?action=view&amp;ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; $db->query('DELETE FROM gangs_alliances_requests WHERE garID = ' . $_GET['ID']); gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $req['gangID'], $eventText); echo 'You\'ve declined the alliance request from <a href="gangs.php?action=view&amp;ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_break($db, $gangdata) { if (!array_key_exists('submit', $_POST)) { $pikachu = $db->query('SELECT gi.gaID, g.gangID, g.gangNAME FROM gangs_alliances AS gi INNER JOIN gangs AS g ON g.gangID = gi.gaGuild2 WHERE ' . $gangdata['gangID'] . ' IN (gi.gaGuild1, gi.gaGuild2)' ); ?> <h3>Break an Alliance</h3> <form action="yourgang.php?action=staff&amp;act2=allianceb" method="post"> <div class="form-group"> <label for="alliance">Gang</label> <select name="alliance" id="alliance" class="form-control"> <?php if (!$db->num_rows($pikachu)) { ?> <option value="0">You have no allies</option> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { printf('<option value="%u"%s>%s</option>', $yellow['gaID'], $yellow['gaID'] == $_GET['ID'] ? ' selected' : '', format($yellow['gangNAME'])); } } ?> </select> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Break Alliance </button> </form> <?php } else { $_POST['alliance'] = array_key_exists('alliance', $_POST) && ctype_digit($_POST['alliance']) && $_POST['alliance'] > 0 ? $_POST['alliance'] : null; if ($_POST['alliance'] === null) { clean_kill('You didn\'t select a valid alliance'); } $blue = $db->query('SELECT ga.gaID, g.gangID, g.gangNAME FROM gangs_alliances AS ga INNER JOIN gangs AS g ON g.gangID = ga.gaGuild2 WHERE (ga.gaID = ' . $_POST['alliance'] . ' AND ga.gaGuild1 = ' . $gangdata['gangID'] . ') OR ga.gaGuild2 = ' . $gangdata['gangID'] ); if (!$db->num_rows($blue)) { clean_kill('Either that alliance doesn\'t exist, or it\'s not yours!'); } $row = $db->fetch_row($blue); $db->query('DELETE FROM gangs_alliances WHERE gaID = ' . $_POST['alliance']); $eventText = '<a href="gangs.php?action=view&amp;ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has broken the alliance with <a href="gangs.php?action=view&amp;ID=' . $row['gangID'] . '">' . $row['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $row['gangID'], $eventText); echo 'You have broken the alliance'; } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_view($db, $gangdata) { $pikachu = $db->query('SELECT ga.*, g.gangID, g.gangNAME FROM gangs_alliances AS ga INNER JOIN gangs AS g ON g.gangID = ga.gaGuild2 WHERE ga.gaGuild1 = ' . $gangdata['gangID'] . ' OR ga.gaGuild2 = ' . $gangdata['gangID'] ); $froob = $db->query('SELECT gar.*, g.gangID, g.gangNAME FROM gangs_alliances_requests AS gar INNER JOIN gangs AS g ON gar.garGuildFrom = g.gangID WHERE gar.garGuildTo = ' . $gangdata['gangID'] . ' ORDER BY gar.garTime' ); ?> <table class="table w-100"> <thead> <tr> <th class="w-80">Gang</th> <th class="w-20">Action</th> </tr> </thead> <tfoot> <tr> <th>Gang</th> <th>Action</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($pikachu)) { ?> <tr> <td colspan="2" class="text-center">You do not have any Allies</td> </tr> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { ?> <tr> <td><a href="gangs.php?action=view&amp;ID=<?php echo $yellow['gaGuild2']; ?>"><?php echo format($yellow['gangNAME']); ?></a></td> <td class="text-center"> <a href="yourgang.php?action=staff&amp;act2=allianceb&amp;ID=<?php echo $yellow['gaID']; ?>"> <img src="/silk/link_break.png" alt="Break" /> Break this alliance </a> </td> </tr> <?php } } ?> </tbody> </table><br /><br /> <h3>Alliance Requests</h3> <table class="table w-100"> <thead> <tr> <th class="w-40">Gang</th> <th class="w-40">Message</th> <th class="w-20">Links</th> </tr> </thead> <tfoot> <tr> <th>Gang</th> <th>Message</th> <th>Links</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($froob)) { ?> <tr> <td colspan="3" class="text-center">You do not have any alliance requests</td> </tr> <?php } else { while ($blue = $db->fetch_row($froob)) { ?> <tr> <td><a href="gangs.php?action=view&amp;ID=<?php echo $blue['gangID']; ?>"><?php echo format($blue['gangNAME']); ?></a></td> <td><?php echo format($blue['garMessage']); ?></td> <td> <a href="yourgang.php?action=staff&amp;act2=alliance&amp;ID=<?php echo $blue['garID']; ?>&amp;what=accept"> <img src="/silk/accept.png" alt="Accept"> Accept this request </a> <a href="yourgang.php?action=staff&amp;act2=alliance&amp;ID=<?php echo $blue['garID']; ?>&amp;what=decline"> <img src="/silk/delete.png" alt="Decline"> Decline this request </a> </td> </tr> <?php } } ?> </tbody> </table> <?php } Edit the function gang_staff_wardeclare() Find if ($_POST['gang'] == $gangdata['gangID']) { echo "You can't declare war on your own gang.<br /> > <a href='yourgang.php?action=staff&act2=declare'>Go back</a>"; $h->endpage(); exit; } Add below $selectGangAlliance = $db->query('SELECT gaID FROM gangs_alliances WHERE ' . $gangdata['gangID'] . ' IN (gaGuild1, gaGuild2) AND ' . $_POST['gang'] . ' IN (gaGuild1, gaGuild2)'); if ($db->num_rows($selectGangAlliance)) { ?> Your gang is currently allied with that gang. You cannot attack them<br /> &gt; <a href="yourgang.php?action=staff&amp;act2=declare">Go back</a> <?php $h->endpage(); exit; } Still in gang_staff_wardeclare() Find $db->query( "INSERT INTO `gangwars` VALUES(NULL, {$gangdata['gangID']}, {$_POST['gang']}, " . time() . ")"); Add above $time = time(); $query = ''; $selectAllies1 = $db->query('SELECT gaGuild2 FROM gangs_alliances WHERE gaGuild1 = ' . $_POST['gang']); if ($db->num_rows($selectAllies1)) { while ($row = $db->fetch_row($selectAllies1)) { $query .= '(' . $gangdata['gangID'] . ', ' . $row['gaGuild2'] . ', ' . $time . '), '; } } $selectAllies2 = $db->query('SELECT gaGuild1 FROM gangs_alliances WHERE gaGuild2 = ' . $_POST['gang']); if ($db->num_rows($selectAllies2)) { while ($row = $db->fetch_row($selectAllies2)) { $query .= '(' . $gangdata['gangID'] . ', ' . $row['gaGuild1'] . ', ' . $time . '), '; } } if ('' != $query) { $db->query('INSERT INTO gangwars (warDECLARER, warDECLARED, warTIME) VALUES ' . substr($query, -2)); } Add the gang staff cases case 'alliancer': guild_staff_alliance_request($db, $gangdata); break; case 'alliancea': guild_staff_alliance_decide($db, $gangdata); break; case 'alliancev': guild_staff_alliance_view($db, $gangdata); break; case 'allianceb': guild_staff_alliance_break($db, $gangdata); break; SQLs CREATE TABLE `gangs_alliances_requests` ( `garID` int NOT NULL auto_increment, `garTime` int NOT NULL default '0', `garGuildFrom` int NOT NULL default '0', `garGuildTo` int NOT NULL default '0', `garMessage` text NOT NULL, PRIMARY KEY (`garID`) ); CREATE TABLE `gangs_alliances` ( `gaID` int NOT NULL auto_increment, `gaGuild1` int NOT NULL default '0', `gaGuild2` int NOT NULL default '0', PRIMARY KEY (`gaID`) ); Edit attack.php, add this where the rest of the if() statements are (towards the top of the file) if ($odata['gang'] > 0) { $selectGangAlliance = $db->query('SELECT COUNT(gaID) FROM gangs_lliances WHERE ' . $ir['gang'] . ' IN (gaGuild1, gaGuild2) AND ' . $odata['gang'] . ' IN (gaGuild1, gaGuild2)'); if ($db->fetch_single($selectGangAlliance)) { echo 'Your gang is currently allied with ' . $odata['username'] . '\'s gang. You can\'t attack ' . (('Male' === $odata['gender']) ? 'him' : 'her'); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; $h->endpage(); exit; } } And finally, the CSS; .w-20 { width: 20%; } .w-40 { width: 40%; } .w-80 { width: 80%; } .w-100 { width: 100%; } .text-center { text-align: center; }
  25. This mod was requested by Bennyh789 on this topic This can also be found on my site here: http://magictallguy.tk/mods.php?mod=13 Edit yourgang.php Find case "masspayment": gang_staff_masspayment(); break; Add below case 'delete': gang_staff_delete($db, $gangdata, $ir); break; Find <br /> <a href='yourgang.php?action=staff&act2=tag'>Change Gang Tag</a> Add below <br /> <a href='yourgang.php?action=staff&amp;act2=delete'>Disband Gang</a> Find the closing brace at the end of the gang_staff_apps() function Add below if (!function_exists('clean_kill')) { /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } } function gang_staff_delete($db, $gangdata, $ir) { if ($gangdata['gangPRESIDENT'] != $ir['userid']) { clean_kill('You don\'t have access to this'); } if (!array_key_exists('ans', $_GET)) { ?> Once you have disbanded your gang, it is permanent. This can <strong>not</strong> be reversed.<br> Are you sure you want to do this? <a href="yourgang.php?action=staff&amp;act2=delete&amp;ans=yes">Yes</a> ยท <a href="yourgang.php">No</a> <?php } else { $select = $db->query('SELECT userid FROM users WHERE gang = ' . $gangdata['gangID']); while ($row = $db->fetch_row($select)) { event_add($row['userid'], 'Your gang has been disbanded'); } $db->query('DELETE FROM gangs WHERE gangID = ' . $gangdata['gangID']); $db->query('DELETE FROM gangwars WHERE ' . $gangdata['gangID'] . ' IN (warDECLARED, warDECLARER)'); $db->query('DELETE FROM gangevents WHERE gevGANG = ' . $gangdata['gangID']); $checkForMTGsGangArmoury = $db->query('SHOW COLUMNS FROM inventory WHERE (Field = \'inv_borrowed\')'); if ($db->num_rows($checkForMTGsGangArmoury)) { $db->query('DELETE FROM inventory WHERE (inv_borrowed = \'Yes\')'); $db->query('DELETE FROM gang_armoury WHERE gang = ' . $_POST['gang']); $db->query('DELETE FROM gang_armoury_loans WHERE gang = ' . $_POST['gang']); $db->query( 'UPDATE users SET IF(equip_primary_loaned = \'Yes\', (equip_primary_loaned = \'No\', equip_primary = 0), equip_primary_loaned = \'No\'), IF(equip_secondary_loaned = \'Yes\', (equip_secondary_loaned = \'No\', equip_secondary = 0), equip_secondary_loaned = \'No\'), IF(equip_armor_loaned = \'Yes\', (equip_armor_loaned = \'No\', equip_armor = 0), equip_armor_loaned = \'No\') WHERE gang = ' . $gangdata['gangID'] ); } $db->query('UPDATE users SET gang = 0 WHERE gang = ' . $gangdata['gangID']); echo 'Your gang has been disbanded.<br><a href="index.php">Home</a>'; } }
×
×
  • Create New...