Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,130
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by Magictallguy

  1. 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 🙂
  2. A couple of syntax issues (parsing) and a small miscount for table headings/rows, but you're on the right path 🙂
  3. 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
  4. 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 😉
  5. 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. 🙂
  6. 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 😉
  7. 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"); }
  8. 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.
  9. 'fraid not. Both v1 and v2 hard-code the logo.jpg into the .. uh .. template.
  10. 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 😄
  11. Oh, yeah, lemme get riiiiiight on that!
  12. 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!
  13. Load up the webpage in question and attempt to carry out the process you've written
  14. PHP versions! mysql_* functions were deprecated and removed. Use the mysqli_* functions - so, for you, alter your config.php and change "mysql" to "mysqli"
  15. Welcome aboard! 😄
  16. It's one of the IPNs I wrote - attempting to load the file directly will result in this error as there's no POSTDATA being sent on a standard GET request for loading a page in browser. Use PayPal's Dev Sandbox to simulate real-world payments
  17. More information required. What is the error message it spits at you? (If you haven't already and your script supports it, enable debug mode)
  18. More information required. An HTTP Error 500 is generic Check your error_log
  19. 1 table, 3 columns; id, parent_id, name. We can make some guesses at what the data might actually be, based on what we see. For example, I see that `id` (the first column) is likely a primary key that auto-increments. Again, based on the data we've got and the explanation given with it, the parent_id relates to another row in the table if parent_id is greater than 0, or otherwise has no direct relation (and therefore is the parent category). Your instructions are to write a function that'll display this breadcrumb-style, based on parameters given to said function. As the question says, assume you've already got a function named getCategory() and it takes 1 parameter; the id. Can you write, say, showBreadcrumbs()? If you have a PHP-capable webserver and a DB server available to you, then start playing around (suggested only as I'm aware you're familiar with this)! Create the table with the 3 columns and insert the data as displayed - then query it. If not, or if you'd like to run this in a php sandbox online for free (hint hint), then write an array of the data instead; <?php $categories = [ [ 'id' => 1, 'parent_id' => 0, 'name' => 'Clothing', ], [ 'id' => 2, 'parent_id' => 0, 'name' => 'Accessories', ], // ... ]; There's a couple of "oh, duuuhhh" moments in this exercise. Remember; keep it simple!
  20. * * * * * php path/to/file code=thecode arg=wutever arg3=..
  21. Currently running AlmaLinux here for multiple purposes including the usual webserver setup. Beautiful OS, familiar CLI, no complaints!
  22. Check that the result of the guard / 1.5 is above 0 before using it as part of the equation <?php // Check that the user's guard is above 0 and get the guard division result, otherwise it's 0 $guardResult = $youdata['guard'] > 0 ? $youdata['guard'] / 1.5 : 0; // Begin the damage calculation $dam = $enweps[$weptouse]['weapon'] * $odata['strength']; // If we've got something to divide by .. if ($guardResult > 0) { // .. divide it $dam /= $guardResult; } // Add the randomisation back in $dam *= rand(8000, 12000) / 10000; // And cast it to an integer $dam = (int)$dam; /** * Original line for reference * $dam = (int) (($enweps[$weptouse]['weapon'] * $odata['strength'] / ($youdata['guard'] / 1.5)) * (rand(8000, 12000) / 10000)); */
  23. Enable Debug Mode - edit lib/basic_error_handler.php and set the DEBUG constant to true (line 31 by default)
  24. And all of this is beside the point - if it doesn't make sense to you, that's fine. Ask, don't attack. Stay on topic, please
×
×
  • Create New...