Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,124
  • Joined

  • Last visited

  • Days Won

    144

Everything posted by Magictallguy

  1. This can also be done as just the query $db->query('DELETE FROM `table` WHERE `timestamp` <= (unix_timestamp() - 86400)');
  2. I've tested this myself, it does work. I'd have to see your setup before I can diagnose further - feel free to shoot me a PM
  3. When coding late at night with all the lights off around you for 13 years almost non-stop, your eyes tend to hurt (or, at least, mine do!) So I've wrote up a dark CSS theme for MakeWebGames using the browser addon Stylish (Chrome/Firefox). It's easier on the eyes, I'll give it that much, but it's fugly as hell - still, it's a darker theme that makes my time on MWG easier for me. If anyone would like to chuck over updates/suggestions, please feel free! I can add them as options for customisation before installing the theme MakeWebGames Dark
  4. Indeed. We can therefore assume that the stock jQuery packaged with MC Craps is no good. Try using the latest jQuery found here
  5. Here's an example of it in a form designed to send an event to a user. <?php require_once __DIR__ . '/globals.php'; // If the form has been submitted if(array_key_exists('submit', $_POST)) { // Basic sanitation $_POST['user'] = array_key_exists('user', $_POST) && is_string($_POST['user']) ? $db->escape(trim($_POST['user'])) : null; $_POST['event'] = array_key_exists('event', $_POST) && is_string($_POST['event']) ? trim($_POST['event']) : null; // Basic validation if(empty($_POST['user'])) { echo 'You didn\'t select a valid user'; exit($h->endpage()); } if(empty($_POST['event'])) { echo 'You didn\'t enter a valid event text'; exit($h->endpage()); } // Get the user $select = $db->query('SELECT `userid` FROM `users` WHERE `username` = "'.$_POST['user'].'"'); // Does the user exist? if(!$db->num_rows($select)) { echo 'The user you selected doesn\'t exist'; exit($h->endpage()); } // Return the userid $user = $db->fetch_single($select); // Send the event event_add($user, $_POST['event']); echo 'The event has been sent<br />'; } // Display the form ?><form action="send_event.php" method="post"> <table class="table" width="100%"> <tr> <th width="25%">User</th> <td width="75%"><?php echo getList('user');?></td> </tr> <tr> <th>Event</th> <td><input type="text" name="event" /></td> </tr> <tr> <td colspan="2" class="center"><input type="submit" name="submit" value="Send Event" /></td> </tr> </table> </form><?php // Page footer $h->endpage();   If you were to stick that in a file called send_event.php, you'd be able to simply start typing a name to select a user. With the way the getList() function works, it'll return a username as the value so, we select the user based on the username entered. If the user doesn't exist, end the page. If the user does exist, return their respective userid and continue. Long story short; getList() returns a username as a value. Do with it as you wish ;)
  6. and http://makewebgames.io/forum/game-engines/mccode-development-support/engine-support/377702-sql-errors I'm gonna say no. Thanks though
  7. Do the same - restructure the query to have column name declarations $db->query('INSERT INTO `mail` (`mail_from`, `mail_to`, `mail_time`, `mail_subject`, `mail_text`) VALUES ('.$userid.', '.$to.', '.time().', "'.$subj.'", "'.$msg.'")');
  8. The MC Craps version of jQuery *should* suffice. As for the UI, https://code.jquery.com/ui/1.11.4/jquery-ui.min.js is what you're after
  9. Change if($ir['timecard'] = 1) to if($ir['timecard'] == 1)
  10. Whoops, sorry, that's my fault. Previous post updated
  11. Run this query on the database (CLI, phpMyAdmin, SQLBuddy, Adminer, etc.) ALTER TABLE `work` MODIFY `workId` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT   My only guess now is that the `workId` hasn't been correctly set
  12. Right, you'll need to restructure your query to include column name declarations. This is based on stock MC Craps $db->query('INSERT INTO `items` (`itmtype`, `itmbuyprice`, `itmsellprice`, `itmbuyable`, `weapon`, `armor`, `effect1_on`, `effect2_on`, `effect3_on`, `effect1`, `effect2`, `effect3`, `itmname`, `itmdesc`) VALUES ('.$_POST['itmtype'].', '.$_POST['itmbuyprice'].', '.$_POST['itmsellprice'].', '.$itmbuy.', '.$weapon.', '.$armor.', '.$_POST['effect1on'].', '.$_POST['effect2on'].', '.$_POST['effect3on'].', "'.$efx1.'", "'.$efx2.'", "'.$efx3.'", "'.$itmname.'", "'.$itmdesc.'")');
  13. Your HTML was pointing GETDATA to job, not id or ID. $_GET['job'] = array_key_exists('job', $_GET) && ctype_digit($_GET['job']) ? $_GET['job'] : null; if(empty($_GET['job'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); } $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['job']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql);  
  14. Chances are you're trying to insert a string into your INT field. Please provide the line of code generating this error, along with 5 lines above and 5 lines below (11 lines in total).
  15. Use the code I've provided. The fact that it returns null suggests that whatever you're specifying in the GETDATA isn't a valid job rank. Also, make sure you're sanitizing anything coming from the user. Assuming you haven't already, add this above the SELECT query. $_GET['ID'] = array_key_exists('ID', $_GET) && ctype_digit($_GET['ID']) ? $_GET['ID'] : null; if(empty($_GET['ID'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); }   So, the full sanitation and select should look like this: $_GET['job'] = array_key_exists('job', $_GET) && ctype_digit($_GET['job']) ? $_GET['job'] : null; if(empty($_GET['job'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); } $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['job']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql);
  16. Do you have an .htaccess in your public_html/www/htdocs directory? If so, what is the content of it?
  17. As Coly said, not that code. However, I will ask anyway.. Why are you quoting an int? $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['id']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql);  
  18. Just beat me to it [uSER=65530]Coly010[/uSER] :P [uSER=72582]boionfire81[/uSER], what is the content of $r?
  19. It ain't much at the moment, but this might get you started
  20. You'll need to import the jquery-ui.css and a jquery.js   function getList($var = false, $value = false) { global $db; $selectUsers = $db->query('SELECT `username` FROM `users` ORDER BY `username` ASC'); $users = []; while($row = $db->fetch_row()) $users[] = $row['username']; ?><script> $(function() { var availableUsers = <?php echo json_encode($users);?>; $( "#users" ).autocomplete({ source: availableUsers }); }); </script><?php if($var) { $ret = '<div class="ui-widget">'; $ret .= '<input id="users"'; $ret .= ' name="'.$var.'"'; if($value) $ret .= ' value="'.$value.'"'; $ret .= ' autofocus />'; return $ret; } }   Usage (as part of a form): Returns an input box with a list of all users, with a $_REQUEST (_POST/_GET) named data_name_for_form. echo getList('data_name_for_form'); Returns an input box with a list of all users, request data named user, automatically filled with $value //Assuming getdata has been sanitized $selectUser = $db->query('SELECT `username` FROM `users` WHERE `userid` = '.$_GET['id']); $value = $db->num_rows($selectUser) ? $db->fetch_single($selectUser) : null; echo getList('user', $value);   I'll take that $50, if that's still going, thanks.
  21. This is assuming you've sanitized the getdata $q = $db->query('SELECT `inv_userid`, `inv_itemid`, `itmname`, `itmtype` FROM `inventory` INNER JOIN `items` ON `inv_itemid` = `itmid` WHERE `inv_userid` = '.$ir['userid'].' AND `itmid` = '.$_GET['ID']); if(!$db->num_rows($q)) { echo 'Either that item doesn\'t exist or it\'s not yours'; exit($h->endpage()); } $r = $db->fetch_row($q); if($r['itmtype'] != 15) { echo 'You can\'t buy ammo for the '.$r['itmname']; exit($h->endpage()); }
  22. Change form action="staff_userlogs.php?action=viewlogs" to form action="staff_userlogs.php?action=whatever_goes_here_to_access_the_original_form_function"
  23. Untested.. function view_user_logs() { global $db, $ir, $sa; $_GET['user'] = array_key_exists('user', $_GET) && ctype_digit($_GET['user']) ? $_GET['user'] : null; ?>Select the user which you want to view their log. <form action="staff_userlogs.php?action=viewlogs" method="get"> User: <?php echo userlogged_dropdown(NULL, 'user', $_GET['user']);?><br /> <input type="submit" value="Submit" /> </form><?php if(!empty($_GET['user'])) { $st = array_key_exists('st', $_GET) && ctype_digit($_GET['st']) ? $_GET['st'] : 0; $app = 100; if(empty($_GET['user'])) error('Invalid user.'); $query = $db->query('SELECT COUNT(`uUSERID`) FROM `user_logs` WHERE `uUSERID` = '.$_GET['user']); $logs = $db->fetch_single($query); $db->free_result($query); if ($logs == 0) error('There have been no logs yet from this user.'); $pages = ceil($logs / $app); $q = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_GET['user']); if ($db->num_rows($q) == 0) { $db->free_result($q); error('User doesn\'t seem to exist, Please go back and try again.'); } $query = $db->query('SELECT `uID`, `uUSERID`, `uADDRESS`, `uTIME` FROM `user_logs` WHERE `uUSERID` = '.$_GET['user'].' ORDER BY `uTIME` DESC LIMIT '.$st.', '.$app); ?><hr width="75%"><table width="75%" cellpadding="1" cellspacing="1" class="table"> <tr> <th>User</th> <th>Address</th> <th>Time</th> </tr><?php if(!$db->num_rows($query)) echo '<tr><td colspan="3" class="center">There are no logs available</td></tr>'; else while($r = $db->fetch_row($query)) { ?><tr> <td><?php echo $sa->username_nonformat($r['uUSERID'], true);?></td> <td><?php echo $r['uADDRESS'];?></td> <td><?php echo date("F j, Y, g:i:s a", $r['uTIME']);?></td> </tr><?php } ?></table><hr width="75%"> Pages: <?php for($i = 1; $i <= $pages; ++$i) { $s = ($i - 1) * $app; echo ($s == $st) ? '<b>' . $i . '</b> ' : '<a href="staff_userlogs.php?action=viewlogs&st=' . $s . '&user='.$_GET['user'].'">' . $i . '</a> '; echo ($i % 25 == 0) ? '<br />' : ''; } $mypage = floor($_GET['st'] / 100) + 1; stafflog_add('Viewed ' . $sa->username_nonformat($_GET['user'], true) . ' user logs. (Page: '.$mypage.')'); } }
  24. The code snippet you posted is broken in multiple areas. Also, to handle your undefined index notice; in this case, simply wrap it in isset() if(isset($equip[$ir['equip_helmet']]['itmid']))
  25. Jeez.. 6 year gravedig much.. Still, updated code: $ids = []; $queryGangs = $db->query('SELECT `gangID` FROM `gangs` WHERE `gangRESPECT` < 1'); if($db->num_rows($queryGangs)) while($row = $db->fetch_row($queryGangs)) $ids[] = $row['gangID']; if(count($ids)) { $targets = implode(',', $ids); $db->query('DELETE FROM `gangs` WHERE `gangID` IN ('.$targets.')'); $db->query('DELETE FROM `gangwars` WHERE `warDECLARER` IN ('.$targets.') OR `warDECLARED` IN ('.$targets.')'); $db->query('UPDATE `users` SET `gang` = 0 WHERE `gang` IN ('.$targets.')'); }
×
×
  • Create New...