Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,140
  • Joined

  • Last visited

  • Days Won

    148

Everything posted by Magictallguy

  1. You're too kind 🙂 So, to get us back on topic, here's an update to MCCv2. I turned the rewards into a config array at the top of the file. Be sure to update the bonus_items to the id=>quantity you want to give! You're no longer limited to 2 items either. Set as many or as few as you wish - at least 1 required. PHP 7.4-friendly <?php declare(strict_types=1); global $db, $ir, $h, $set; include __DIR__ . '/globals.php'; // bonus_items = [item id => quantity, ...] $rewards = [ 'money' => 500, 'crystals' => 500, 'donatordays' => 10, 'bonus_items' => [ 2 => 100, 4 => 100, ] ]; // If the bonus item id is not set if (empty($rewards['bonus_items'])) { basic_error('The welcome pack hasn\'t been set up. Please notify an administrator.'); } // If the bonus item is set, but doesn't exist $getItems = $db->query( 'SELECT itmid, itmname FROM items WHERE itmid IN (' . implode(', ', array_keys($rewards['bonus_items'])) . ')' ); // If there's no result at all if (!$db->num_rows($getItems)) { basic_error('The items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // Get the items into an array. [item id => name, ...] $items = []; while ($row = $db->fetch_row($getItems)) { $items[$row['itmid']] = $row['itmname']; } // If the amount of items in our array doesn't match the number of items set in the Bonus Pack if (count($items) !== count($rewards['bonus_items'])) { basic_error('Some of the items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // If the user has already claimed their Bonus Pack if ($ir['bonus'] > 1) { basic_error('You\'ve already claimed your Bonus Pack.'); } // Ok! Looks like we're clear. Grant the Bonus Pack! // Update the user $db->query( 'UPDATE users SET money = money + ' . $rewards['money'] . ', crystals = crystals + ' . $rewards['crystals'] . ', donatordays = donatordays + ' . $rewards['donatordays'] . ', bonus = 2 WHERE userid = ' . $ir['userid'] ); // Give 'em the items foreach ($rewards['bonus_items'] as $id => $quantity) { item_add($ir['userid'], $id, $quantity); } ?> Your welcome pack has been credited successfully.<br><br> You have gained 500 game money.<br> You have gained 500 crystals.<br> You have gained 10 days donators status.<br> <?php // Dynamically output the items, meaning we can change them at any time without having to update this foreach ($items as $id => $name) { echo 'x' . $rewards['bonus_items'][$id] . ' <a href="iteminfo.php?ID=' . $id . '">' . $name . '</a><br>'; } ?> The donator status given here will give you the following benefits:<br><br> <ul> <li> Red name + cross next to your name.</li> <li> Friends and Enemies List.</li> <li> 17% Energy every 5 minutes instead of 8%.</li> <li> 25% Stats gain in the donator gym.</li> <li> Unlocking of enhanced features.</li> <li> 25 street steps instead of 10 per day.</li> </ul> This is a complementary welcome pack.<br> Just a way to say thank you for joining <?php echo $set['game_name']; ?>. <?php // End $h->endpage(); /** * A simple "error and exit" function, which keeps the output styling Dragon Blade originally wrote for this script. * @param string $msg * @return void */ function basic_error(string $msg) { global $h; ?> <hr style="width: 50%;"> <h3>ERROR</h3> <?php echo $msg; ?><br><br> <hr style="width: 50%;"> <a href="index.php">&gt; Go Back</a> <hr style="width: 50%;"> <?php $h->endpage(); exit; } And here's the same script, updated to PHP 8.2 - which, in all honesty, merely adds the return typehinting for the basic_error() function. <?php declare(strict_types=1); global $db, $ir, $h, $set; include __DIR__ . '/globals.php'; // bonus_items = [item id => quantity, ...] $rewards = [ 'money' => 500, 'crystals' => 500, 'donatordays' => 10, 'bonus_items' => [ 2 => 100, 4 => 100, ] ]; // If the bonus item id is not set if (empty($rewards['bonus_items'])) { basic_error('The welcome pack hasn\'t been set up. Please notify an administrator.'); } // If the bonus item is set, but doesn't exist $getItems = $db->query( 'SELECT itmid, itmname FROM items WHERE itmid IN (' . implode(', ', array_keys($rewards['bonus_items'])) . ')' ); // If there's no result at all if (!$db->num_rows($getItems)) { basic_error('The items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // Get the items into an array. [item id => name, ...] $items = []; while ($row = $db->fetch_row($getItems)) { $items[$row['itmid']] = $row['itmname']; } // If the amount of items in our array doesn't match the number of items set in the Bonus Pack if (count($items) !== count($rewards['bonus_items'])) { basic_error('Some of the items set in the Bonus Pack don\'t exist. Please notify an administrator'); } // If the user has already claimed their Bonus Pack if ($ir['bonus'] > 1) { basic_error('You\'ve already claimed your Bonus Pack.'); } // Ok! Looks like we're clear. Grant the Bonus Pack! // Update the user $db->query( 'UPDATE users SET money = money + ' . $rewards['money'] . ', crystals = crystals + ' . $rewards['crystals'] . ', donatordays = donatordays + ' . $rewards['donatordays'] . ', bonus = 2 WHERE userid = ' . $ir['userid'] ); // Give 'em the items foreach ($rewards['bonus_items'] as $id => $quantity) { item_add($ir['userid'], $id, $quantity); } ?> Your welcome pack has been credited successfully.<br><br> You have gained 500 game money.<br> You have gained 500 crystals.<br> You have gained 10 days donators status.<br> <?php // Dynamically output the items, meaning we can change them at any time without having to update this foreach ($items as $id => $name) { echo 'x' . $rewards['bonus_items'][$id] . ' <a href="iteminfo.php?ID=' . $id . '">' . $name . '</a><br>'; } ?> The donator status given here will give you the following benefits:<br><br> <ul> <li> Red name + cross next to your name.</li> <li> Friends and Enemies List.</li> <li> 17% Energy every 5 minutes instead of 8%.</li> <li> 25% Stats gain in the donator gym.</li> <li> Unlocking of enhanced features.</li> <li> 25 street steps instead of 10 per day.</li> </ul> This is a complementary welcome pack.<br> Just a way to say thank you for joining <?php echo $set['game_name']; ?>. <?php // End $h->endpage(); /** * A simple "error and exit" function, which keeps the output styling Dragon Blade originally wrote for this script. * @param string $msg * @return void */ function basic_error(string $msg): void { global $h; ?> <hr style="width: 50%;"> <h3>ERROR</h3> <?php echo $msg; ?><br><br> <hr style="width: 50%;"> <a href="index.php">&gt; Go Back</a> <hr style="width: 50%;"> <?php $h->endpage(); exit; }
  2. Keep the flaming out of this topic please. A blow-up over genuine support is not how we do things here.
  3. Here's SRB's PHP-flavoured generator as pure HTML/CSS/JS. <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Kitten Generator</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.1.4/tailwind.min.css"> </head> <body> <div class="antialiased w-screen min-h-screen bg-gray-900 pb-12"> <form action="" method="post" id="kitten-form"> <div> <div class="max-w-6xl mx-auto flex pt-12"> <div class="w-1/2 p-4"> <h1 class="text-white text-3xl">Mother</h1> </div> <div class="w-1/2 p-4"> <h1 class="text-white text-3xl">Father</h1> </div> </div> <div class="max-w-6xl mx-auto flex"> <div class="w-1/2 p-4 border-r border-gray-500"> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Body Size</span> <input type="text" name="mother-body-size" id="mother-body-size" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded px-2" tabindex="1" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Build</span> <input type="text" name="mother-build" id="mother-build" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="3" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Ears</span> <input type="text" name="mother-ears" id="mother-ears" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="5" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Eye Color</span> <input type="text" name="mother-eye-color" id="mother-eye-color" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="7" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Nose / Paw Pads</span> <input type="text" name="mother-nose-paw-pads" id="mother-nose-paw-pads" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="9" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Length</span> <input type="text" name="mother-pelt-length" id="mother-pelt-length" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="11" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Color</span> <input type="text" name="mother-pelt-color" id="mother-pelt-color" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="13" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Markings</span> <input type="text" name="mother-pelt-markings" id="mother-pelt-markings" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="15" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Mutation</span> <input type="text" name="mother-mutation" id="mother-mutation" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="17" /> </label> </div> </div> <div class="w-1/2 p-4"> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Body Size</span> <input type="text" name="father-body-size" id="father-body-size" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="2" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Build</span> <input type="text" name="father-build" id="father-build" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="4" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Ears</span> <input type="text" name="father-ears" id="father-ears" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="6" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Eye Color</span> <input type="text" name="father-eye-color" id="father-eye-color" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="8" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Nose / Paw Pads</span> <input type="text" name="father-nose-paw-pads" id="father-nose-paw-pads" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="10" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Length</span> <input type="text" name="father-pelt-length" id="father-pelt-length" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="12" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Color</span> <input type="text" name="father-pelt-color" id="father-pelt-color" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="14" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Pelt Markings</span> <input type="text" name="father-pelt-markings" id="father-pelt-markings" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="16" /> </label> </div> <div class="block mb-4"> <label> <span class="block text-gray-300 text-sm">Mutation</span> <input type="text" name="father-mutation" id="father-mutation" value="" class="mt-1 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md px-2" tabindex="18" /> </label> </div> </div> </div> <div class="max-w-4xl mx-auto flex justify-center mt-8"> <button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">Randomize</button> </div> </div> </form> <div class="max-w-6xl mx-auto flex justify-center flex-wrap mt-6 border-t pt-6" id="kitten-result"></div> </div> <script> let kittenCount = 0; const getOpts = () => { return ['body-size', 'build', 'ears', 'eye-color', 'nose-paw-pads', 'pelt-length', 'pelt-color', 'pelt-markings', 'mutation']; }; const generateKittens = () => { const opts = getOpts(); let output = []; for (let opt of opts) { const fatherOpt = `father-${opt}`; const motherOpt = `mother-${opt}`; let motherInput = document.getElementById(motherOpt).value ?? ''; let fatherInput = document.getElementById(fatherOpt).value ?? ''; console.log(`${opt}: ${motherInput} :: ${fatherInput}`); const items = [motherInput, fatherInput]; let selectedOpt = items[Math.floor(Math.random() * 2)]; let color = "#838383"; if (selectedOpt === '') { selectedOpt = (motherInput ?? fatherInput) ?? 'none'; } if (motherInput === fatherInput) { color = "#5bf132"; } else if (selectedOpt === motherInput) { color = "#ee6acb"; } else if (selectedOpt === fatherInput) { color = "#32aef1"; } output[opt] = `<span style="color: ${color};">${selectedOpt}</span>`; } const kittenCard = ` <div class="inline text-left box-border p-3 w-1/4"> <div class="border box-border p-2"> <h3 class="text-gray-300 font-bold border-b pb-1 mb-1"> Random Kitten #${++kittenCount} </h3> <div class="text-gray-300 body-size"> <span class="font-semibold">Body Size : </span> <span class="float-right">${output['body-size']}</span> </div> <div class="text-gray-300 build"> <span class="font-semibold">Build : </span> <span class="float-right">${output['build']}</span> </div> <div class="text-gray-300 ears"> <span class="font-semibold">Ears : </span> <span class="float-right">${output['ears']}</span> </div> <div class="text-gray-300 eye-color"> <span class="font-semibold">Eye Color : </span> <span class="float-right">${output['eye-color']}</span> </div> <div class="text-gray-300 nose-paw-color"> <span class="font-semibold">Nose / Paw Color : </span> <span class="float-right">${output['nose-paw-pads']}</span> </div> <div class="text-gray-300 pelt-length"> <span class="font-semibold">Pelt Length : </span> <span class="float-right">${output['pelt-length']}</span> </div> <div class="text-gray-300 pelt-color"> <span class="font-semibold">Pelt Color : </span> <span class="float-right">${output['pelt-color']}</span> </div> <div class="text-gray-300 pelt-markings"> <span class="font-semibold">Pelt Markings : </span> <span class="float-right">${output['pelt-markings']}</span> </div> <div class="text-gray-300 mutation"> <span class="font-semibold">Mutation : </span> <span class="float-right">${output['mutation']}</span> </div> </div> </div>`; document.getElementById('kitten-result').innerHTML += kittenCard; }; let formElem = document.getElementById('kitten-form'); formElem.addEventListener("submit", (e) => { e.preventDefault(); e.stopPropagation(); generateKittens(); }); </script> </body> </html> Fair note that this has never heard of "security". Blue: trait from father Pink: trait from mother Green: trait from both (matching trait) Grey: no trait 2023-08-23 15-44-43.mp4
  4. Here's a PHP 8 version, because why not? <?php declare(strict_types=1); global $db, $h, $set, $userid; include 'globals.php'; $question = strtolower($_POST['question']); ?> <h2 class="fontface"><span class="green">T</span>utorial</h2> <hr /><br /><br /> <table style="border:none;width:650px;"> <tr> <td> <p>Welcome to the Tutorial, we hope that this guide will help you to better understand the game. <p><br /> <p> You are free to choose your own path. You can protect the weak, or exploit their weakness. Spend your money to help your friends, or horde it, they can take care of themselves. Buy a gang and become the most respected group of players in the land. Declare war on an enemy, or an innocent bystander, the choice is yours. </p><br /> <h3 class="fontface"> <?php echo $set['game_name']; ?> Help Bot </h3> <small>(Ask the Bot a question below and let's see if we can get you going.)</small><br /><br /> <form action="help.php" method="POST"> Question: <input type="text" name="question" size="70" placeholder="What would you like to know? why not try typing in training, gangs or rules"> <input type="submit" value="Ask"> </form> <?php if (empty($question)) { $h->endpage(); exit; } $answer = match ($question) { 'x' => 'x', 'help' => 'What do you need help with?', 'hello', 'helo', 'hi', 'hey' => 'Hello how are you?', 'gym', 'the gym' => 'The gym is where you use energy,gold and some will potions to train your stats up.<Br />Stats help you beat up players and protect yourself as well from attacks.', 'good' => 'Im glad to hear your good.', 'strength' => 'This stat is used to calculate how much damage a weapon does.', 'agility' => 'This stat is used for dodging attacks.', 'labour' => 'This stat is used for getting promoted in jobs.', 'IQ' => 'This stat is stat is gained from courses and used for promotions.', 'crystal', 'crystals' => 'Crystals are used for various things under <a href="crystaltemple.php">Crystal Temple</a>', 'cash' => 'Cash is used to buy stuff all over the game', 'energy' => 'This is used mainly for training and attacking', 'brave' => 'This is used for doing crimes', 'health' => 'How much health you have in a fight', 'mine', 'mines' => 'Mining a great way to earn gold', 'job' => 'Nice way to earn cash and stats', 'education' => 'Used for gaining IQ', 'mail' => 'Your own personal mail system', 'events' => 'What happens to you is recorded here', 'logout' => 'Used to logout of the game, duh.', 'explore' => 'Where the main links are listed', 'search' => 'Search for other players!', 'friend list' => 'Record your friends', 'black list' => 'Record your enemies', 'missions' => 'This is where you can use some of your brave to earn some cash.', 'preferences' => 'Used to change your account around', 'donate' => 'Donate to the game and be awarded donator features', 'vote' => 'Voting earns you rewards and it helps the game grow', 'item', 'items' => 'Items are a main part of the game and used for doing lots of things', 'church' => 'Used for getting married', 'stats' => 'Stats are what determines your account and how good you are', 'travel' => 'Travel around the game', 'casino' => 'Casino, play various games earning you some cash', 'quests' => 'Quests do various tasks to earn rewards', 'banned' => 'Users banned are listed in dungeon', 'war' => 'War is when 2 gangs fight each other', 'staff' => 'Main staff can be listed under Staff, ID 1 is the overall owner', 'prison' => 'Sent here when failing crimes', 'hospital', 'hosp' => 'Sent here when attacked', 'noob', 'n00b' => 'Who you calling a noob?', 'fuck', 'shit', 'prick', 'cunt', 'bitch' => 'Please do not swear', 'robot', 'bot' => 'Who you calling a bot!', 'who are you' => 'I am the ' . $set['game_name'] . ' Bot', 'weather' => 'The weather effects your training at the gym and your mining rates when at the mines.<br />You can also visit the weather page and ask the gods for better weather.', 'money' => 'Please Explain? e.g: how to get money or what should i save for', 'how to get money' => 'The best way to get money is by going into the mines and mine for gold and sell it. You could also take a risk and put it into the stock exchange.', 'what should i save for' => 'Well that\'s upto you but personally I would save up for a better house as that will help improve your stats and player.', 'users online' => 'This is where you see who is online', 'attacking' => 'Attacking is a good way to get experience, and exert your superiority over those weaker than you. In order to attack you need 1 energy, and should have a weapon. When you win a fight you will get a percentage of experience depending on how much stronger you are compared to the person you are attacking. Make sure that you really want to fight the person, because once you start you can\'t stop until one of you loses. When you start a fight, you will have the option of using any weapon that you currently have in your items page.', 'gang', 'gangs' => 'Gangs are a group of players that band together to work for a common purpose, granted this may be robbing a bank, or taking down the losers in a rival gang.<br /> Gangs cost $500K to create, and once you buy it, you are the president of your gang.<br /> Your gang will initially be able to hold 5 members, but will be able to upgrade to more as time goes on.<br /> The President will be able to assign a Vice-President to the gang. Gangs are able to do Organised Crimes for money and respect.<br /> The president can also select to go to war with another gang. One should be careful about doing this though, as it may come back to haunt you.', 'training' => '<b>Gym: </b>To use the gym, type in the number of times you want to train, select the stat to train and click ok.<br /> The next screen will tell you how much of that stat you gained, and what your total in that stat is.<br /><br /> <b>Missions: </b>Go to the mission screen and select the mission you want to do. <br />Remember that trying a mission that is to hard may land you in jail, and lose the experience you\'ve worked so hard to get.<br /><br /> <b>School: </b>School offers courses that will raise your stats over a certain period of time<br /><br /> <b>Your Job: </b>A job will provide you with money at 5:00PM every day, as well as raising your job stats every day. <br />Some jobs have requirements before you can do them, so make sure to keep an eye out for that.<br /><br /> <b>Attacking: </b>Attacking will gain you experience when you win, but you lose experience if you lose.<br /> The amount of experience depends on the comparative strength of your enemy, if they are much weaker, you won\'t get much experience.', 'rules' => 'Rules are important, They make sure that everyone gets a chance and the games is fair and fun for all. For all the rules please check out the game rules section.', 'profile', 'profiles' => 'This is where you can look at yours and other players profiles. Very informative ', 'rucksack' => 'this is where you find your items to use within the game, you also find your weapons and armour here.<br />', 'referrals', 'referral' => 'This is where you give friends a link to the game to earn rewards.', 'lucky', 'box', 'lucky box' => 'This is your reward for logging in every hour.', default => 'Sorry, I don\'t know the answer. <br />I\'ve logged it and should have an answer for you soon.', }; ?> <br /> <span class="blue"><b>You asked the Bot:</b></span> <?php echo $question; ?><br /> <span class="gold"><b>The Bot replied:</b></span> <?php echo $answer; if (empty($answer)) { $db->query('INSERT INTO `bot` (`submitted` ,`question` )VALUES (' . $userid . ', \'' . $db->escape($question) . '\')'); ?> Sorry, I don't know the answer. <br />It has been submitted to the database. <?php $h->endpage(); exit; } ?> </td> </tr> </table> <?php $h->endpage();
  5. No worries! And no, I don't believe so. Updating it, I imagine, wouldn't be such a massive undertaking - it's a pretty small engine, and good practice! 😄
  6. It will not run on PHP 8 without minor edits (primarily removals of magic_quotes calls in a couple of core files and a removal/tweak of the gethostbyaddr() calls in viewuser.php). After those minor fixes, it seems to run ok on my localhost and a public-facing webserver, though it will fill up the error log depending on your error reporting setting. PHP 7 seems to be a little more forgiving, it's less-restrictive rulesets allow MCCv2.0.5b to run. Again, however, it will generate a few notices/warnings for the error log. PHP 5.6 doesn't seems to give a rats butt - it runs fine. MySQL, all major versions since (and including) version 5 seem to take it fine. I'd advise a number of optimisations - both to the code and the database - but that'd be another topic for another time.
  7. About that.. It's an interesting choice to throw your toys out of the pram about asking questions while on a forum absolutely full of them. Advise re-reading this topic. The answers are here 😉
  8. Aye, they're not bad at all. Well reputed, long-standing, experienced. Do you already have a domain? (example.com, example.net, example.tld) If so, contact wherever you bought it for that code. If not, consider creating a new one for your project. Edit; responded to DM. This isn't the correct context for the desire
  9. Your second attempt is much closer! 😄 I've edited your post to wrap your code in code tags, with PHP selected as the language. Not only does this make the post look a little cleaner, it's less abuse on my scrollwheel 😛 Now it has "syntax highlighting", which changes the colour of the text, visually breaking things up a little in an attempt to make it easier to follow. Lets take the first line after the opening PHP tag -- this bit: require_once('globals.php'); It uses 3 colours: White to denote a function (or variable (see further down your code)), off-yellow to show special characters, and green to show a string. Syntactically, this is correct. Assuming there is a file named "globals.php" in the same directory (folder) as whatever file's running this, it will parse (see this StackOverflow answer for multiple explanations on what "parsing" is). So, strings are green. Noted. See the example snippet @corruptcity || skalman just posted? Notice how variables are green and some of the strings are white? Eek! Something's wrong here! The colours have flipped - perhaps a string has been closed before it should've been. It's easy to mix up " (quotation mark) and '' (double apostrophe) 😉 Example snippets from your code: That's absolutely correct! The function (I use the term loosely as echo is not a function but a language construct.) is white and the string is green. That should run fine. It starts fine, but wait! The string becomes white, yellow and blue. Somewhere here's one of your problems. 😉 You're also going to run into an additional "gotcha!" too with this one; variables within strings encased in ' (apostrophe) won't parse and will print as plain text. You'll need to break it out of the string and concatenate it instead. At the risk of a temporary topic change; I strongly recommend using an IDE, preferably tailored the languages you intend to write. Personally, I use solutions from the JetBrains Toolbox as I have full access to everything the toolbox provides at (thankfully) no cost to me. However, it is payware under the usual circumstances. Notepad++ (albeit not actually an IDE, but can become one) is great for quick 30-second edits and VSCode is a highly-extensive free alternative to the JetBrains products I use. Final note: Keep at it. You're getting there 🙂
  10. A couple of syntax issues (parsing) and a small miscount for table headings/rows, but you're on the right path 🙂
  11. Chromebook's Developer Mode is for allowing the user to install apps not found in the Play Store, amongst other things. However; these ones are! Here's VSCode Mobile, and here's CodeSandbox which even supports importing directly from GitHub and has its own version of VSCode interface - all in-browser! Also, here's KSWEB: web developer kit, which allows you to turn your Android/Chromium device into an Apache webserver with MySQL database for localhost testing
  12. Free coding courses in various language available here: CodeCademy, FreeCodeCamp, The Odin Project Free courses available on Udacity: Tech Requirements, Intro to HTML and CSS, JavaScript Basics, Intro to jQuery Intro to AJAX, Object-Oriented JavaScript, Intro to Relational Databases (such as MySQL), Web Development, Full Stack Foundations, Responsive Web Design Fundamentals, Mobile Web Development, HTML5 Game Development, Intro to Computer Science, Programming Foundations with Python, Programming Languages, HTML5 Canvas, Responsive Images. If you need to pay for it, you're probably doing it wrong 😉
  13. The installer hook did not want to fire for me - though that could be due to running on localhost in a subdirectory. After extracting the db structure from the code and generating a .sql for it, I was able to create an account and log in. I quite like your approach to this. That cron management system is niiiice! Overall, I'd say this is a great basis for a game. Pretty easy to extend too. I'll continue exploring the code and see if I can come up with some mods for it. 🙂
  14. If you wish to continue your dispute, please take it to DMs. We're not resuming the flaming threads of old if we can help it 😉
  15. Seeing as this was tagged as v2, suggest making use of MCCv2's `database` class. At the very least, it offers a MySQLi wrapper. Here's the snippet, converted to use v2: function mass_give_item() { global $db, $ir, $c, $h; if ($ir['user_level'] != 2) { print "<hr width='50%'>Please read the error message.<hr width='50%'><h3>! ERROR</h3>Admin Only<br/><br/> <hr width='50%'><a href='../index.php'>> Go Home</a><hr width='50%'><br />"; $h->endpage(); exit; } print "<h3>Giving Item To All Users</h3> <form action='staff_users.php?action=massitemgivesub' method='post'> Item: " . item_dropdown($c, 'item') . " Quantity: <input type='text' name='qty' value='1' /> Event: <input type='text' name='event' value='Event Words Here' /> <input type='submit' value='Mass Send' /></form>"; } function mass_give_item_sub() { global $db, $ir, $c; $q = $db->query("SELECT * FROM users WHERE fedjail=0"); while ($r = $db->fetch_row($q)) { $qty = abs(intval($_POST['qty'])); $item = abs(intval($_POST['item'])); $event = ($_POST['event']); item_add($r['userid'], $item, $qty); event_add($r['userid'], "$event", $c); print "Item Sent To {$r['username']}</br>"; } print "Mass item sending complete!</br>"; stafflog_add("Gave {$_POST['qty']} of item ID {$_POST['item']} to all users"); }
  16. Learn how to patch 'em! 😉 It's directly thanks to MCC that I learned as much as I did about security (or the distinct lack thereof) in my first year as a developer. I would strongly recommend learning what attacks are applicable to your project(s) and, more importantly, how to defend against them.
  17. 'fraid not. Both v1 and v2 hard-code the logo.jpg into the .. uh .. template.
  18. function renderEditUser(database $db, array $ir, headers $h, array $column_data, ?array $user_data = null): void { // Loop through the column data foreach ($column_data as $column => $data_type) { $type = in_array($data_type, ['tinyint', 'int', 'bigint', 'float', 'double', 'decimal']) ? 'number' : 'text'; ?> <div style="padding: 0.8em 0;"> <label for="<?php echo $column; ?>"><?php echo ucwords(str_replace('_', ' ', $column)); ?></label> <?php if ($data_type === 'text') { ?> <textarea name="<?php echo $column; ?>" id="<?php echo $column; ?>" class="form-control"><?php echo $user_data[$column]; ?></textarea> <?php } else { ?> <input type="<?php echo $type; ?>" name="<?php echo $column; ?>" id="<?php echo $column; ?>" value="<?php echo $user_data[$column]; ?>" class="form-control"> <?php } ?> </div> <?php } } function editUser(): void { global $db, $ir, $h; // These should really be passed in if ($ir['user_level'] != 2) { echo '403: Forbidden'; $h->endpage(); exit; } $user_id = $_GET['user'] ?? 0; // Get column data for both users and userstats tables // .. while omitting the stuff we don't need $unneeded = implode('\', \'', ['userid', 'userpass', 'pass_salt', 'lastrest_life', 'lastrest_other']); $get_user_cols = $db->query('SHOW COLUMNS FROM users WHERE Field NOT IN (\'' . $unneeded . '\')'); $get_stats_cols = $db->query('SHOW COLUMNS FROM userstats WHERE Field NOT IN (\'' . $unneeded . '\')'); // Loop column name => type into array $cols = [ 'users' => [], 'stats' => [], ]; while ($row = $db->fetch_row($get_user_cols)) { $cols['users'][$row['Field']] = strtolower(explode('(', $row['Type'])[0]); } while ($row = $db->fetch_row($get_stats_cols)) { $cols['stats'][$row['Field']] = strtolower(explode('(', $row['Type'])[0]); } // Get the relevant user data $user_data = null; if ($user_id > 0) { $get_user_data = $db->query( 'SELECT u.*, us.* FROM users AS u INNER JOIN userstats AS us ON u.userid = us.userid WHERE u.userid = '.$user_id, ); if (!$db->num_rows($get_user_data)) { echo 'Sod off.'; $h->endpage(); exit; } $user_data = $db->fetch_row($get_user_data); }?> <form action="/staff_users.php?action=edituser" method="post"> <h4>User</h4> <?php renderEditUser($db, $ir, $h, $cols['users'], $user_data); ?> <h4>Stats</h4> <?php renderEditUser($db, $ir, $h, $cols['stats'], $user_data); ?> <div style="padding: 1em 0;"> <button type="submit" name="submit" class="btn-submit"> <span class="fas fa-check"></span> Save Changes </button> </div> </form> <?php } 5 minutes o' fun 😄
  19. Oh, yeah, lemme get riiiiiight on that!
  20. The ability to set image paths via the staff_items.php's add/edit item methods could be added. This would allow you (and your staff) to set `path/to/someImage.png` (example) when creating/editing an item directly within the staff panel, as opposed to needing to log into the database - to which, I presume, isn't something you'd normally grant your game staff access. So yeah, modify add/edit item, set image path!
  21. Load up the webpage in question and attempt to carry out the process you've written
  22. PHP versions! mysql_* functions were deprecated and removed. Use the mysqli_* functions - so, for you, alter your config.php and change "mysql" to "mysqli"
  23. Welcome aboard! 😄
×
×
  • Create New...