Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,146
  • Joined

  • Last visited

  • Days Won

    149

Everything posted by Magictallguy

  1. I've built a "Court" system for those in Federal Jail, so that could be what you're looking for. The incentive system, as we currently know it, relies on the voting site itself to send something back to the originating site (a game, for example). Unless you mean to add a staff interface so you can add/edit/delete voting sites directly from within the Staff Panel (if so, wrote that too). Profile comments are yet another thing I've written up a few times (not trying to brag..) and are pretty simple (mine even comes with BBCode!) -- What are your thoughts, Adam?
  2. Want any collab code [uSER=67703]adamhull[/uSER]? If so, give me a shout :) Feel free to decline, no offense will be taken :P
  3. You know, funnily enough, I do! I wouldn't have created this topic otherwise.. I've spent years on this site, learning from it and adding to it (not necessarily all good content, but added content all the same). Criminal Existence (now MWG) is effectively my root to how and where I started coding. Unlike some on this site (mentioning no names, and no this isn't aimed at you), I actually want to help new developers. We live in an age where it's a good skill to have.
  4. Wait.. So who actually owns MWG now? Who are the staff?
  5. Without trying to offend, but with trying to kick people up the arse and into gear.. Will the administration please get on top of and handle the friggin' spam?! Sick and tired of seeing it. Spammers are posting more content than the users - go figure Also, the session handling ain't doing so well - not even 2 minutes being logged in and I'm logged out again? This is with activity during typing posts (to ensure the session doesn't time out..) Addendum: If this topic gets closed/locked before the spam is handled, says a lot..
  6. You'll need a little JavaScript for this. <script type="text/javascript"> function insertBBCode(val, ele) { document.getElementByName(ele).innerHTML += val; } </script>   Then, for your BBCode click entry.. <a href="javascript:insertBBCode('[img][/img]', 'message');" onclick="void(0)">Insert image</a>   The secondary argument "message" may need updating to match your system - whatever the textarea on mail_compose() is called..
  7. Magictallguy

    reset

    For your setup.. <?php require_once __DIR__ . '/lib/allpage.php'; $tables = [ 'attacklogs', 'attacklogs', 'blacklist', 'blacklist', 'cashxferlogs', 'cashxferlogs', 'challengesbeaten', 'coursesdone', 'crystalmarket', 'dps_process', 'events', 'fedjail', 'fedjail', 'fight_challenges', 'fight_challenges', 'forum_forums', 'forum_forums', 'forum_posts', 'forum_posts', 'forum_topics', 'forum_topics', 'friendslist', 'friendslist', 'gymlogs', 'hitlist', 'imarketaddlogs', 'imbuylogs', 'imbuylogs', 'imremovelogs', 'imremovelogs', 'inventory', 'itembuylogs', 'itemmarket', 'itemselllogs', 'itemxferlogs', 'itemxferlogs', 'jaillogs', 'jaillogs', 'logs_staff', 'mail', 'mail', 'mugger_oth', 'mugger_oth_global', 'preports', 'preports', 'referals', 'referals', 'reports_bugs', 'reports_bugs_responses', 'review', 'rr_challenges', 'rr_challenges', 'rr_logs', 'rr_logs', 'rr_logs', 'scoment', 'staffnotelogs', 'staffnotelogs', 'status', 'syndicates', 'syndicates', 'syndicate_apps', 'syndicate_coment', 'unjaillogs', 'unjaillogs', 'users', 'userstats', 'user_imageusername', 'warnings', 'warnings', 'willplogs' ]; $db->startTrans(); foreach($tables as $table) { $db->query('TRUNCATE TABLE '.$query); $db->execute(); } $db->endTrans(); session_unset(); session_destroy(); echo 'Game reset';
  8. Adding this for notification to other developers this and this
  9. Use my stuff as you wish - all published under the DBAD license
  10. Based on the limited information given, I have responded the best I can.
  11. <?php $cnt = 0; //assuming we have results.. while($row = $db->fetch_row($select)) { ++$cnt; echo '<label id="accordion-'.$cnt.'">'; for($i = 1; $i <= 3; ++$i) echo '<span name="acc-'.$cnt.'-'.$i.'"></span>'; echo '</label>'; } Not the cleanest method, but should achieve the desired effect, if I understand correctly
  12. *is staying out of this*
  13. There are multiple reasons as to why you're getting this error. Is there any whitespace before the opening <?php tag on globals.php? Is there any whitespace before the opening <?php tag on the file in which you're including the globals.php? Have you tried to include the globals.php multiple times (for whatever reason)? Provide a little more info please
  14. UPDATE `users` SET `pass_salt` = '' WHERE `userid` = INSERT USERID HERE
  15. 1. Gravedig! 2. http://php.net/array_slice - RTFM!
  16. Suggestion, add gang requirements to their own table (easier to expand in the long run) CREATE TABLE `gangs_requirements` ( `gang` INT(11) NOT NULL UNIQUE, `level` INT(11) NOT NULL DEFAULT 0, `money` INT(11) NOT NULL DEFAULT 0, `bankmoney` INT(11) NOT NULL DEFAULT -1, `cybermoney` INT(11) NOT NULL DEFAULT -1, `crystals` INT(11) NOT NULL DEFAULT 0, `days_old` INT(11) NOT NULL DEFAULT 0, `items` VARCHAR(255) NOT NULL DEFAULT '', `items_qty` VARCHAR(255) NOT NULL DEFAULT '' ); ALTER TABLE `items` ADD `itmgangreq` TINYINT(4) NOT NULL DEFAULT 0; NOTE: This code has not been tested Please add any bugs here and I'll repair Edit yourgang.php Find: $gq = $db->query("SELECT g.*,oc.* FROM gangs g LEFT JOIN orgcrimes oc ON g.gangCRIME=oc.ocID WHERE g.gangID={$ir['gang']}"); Replace with: $gq = $db->query('SELECT g.*, oc.*, r.* FROM gangs AS g LEFT JOIN orgcrimes AS oc ON g.gangCRIME = oc.ocID LEFT JOIN gangs_requirements AS r ON r.gang = g.gangID WHERE g.gangID = '.$ir['gang']); if(!$db->num_rows($gq)) { $db->query('UPDATE users SET gang = 0 WHERE gang = '.$ir['gang']); echo 'Your gang doesn\'t exist, you\'ve automatically been set no gang'; exit($h->endpage()); } Add to second switch() statement (the $_GET['act2'] switch): case 'reqs': staff_change_requirements($db, $ir, $h, $gangdata); break; Add a link in the gang staff management panel: yourgang.php?action=staff&act2=reqs Find (end of file): $h->endpage(); Add above: if (!function_exists('error')) { function error($msg) { global $h; echo '<div class="error"><strong>Error!</strong><br />'.$msg.'</div>'; exit($h->endpage()); } } function staff_change_requirements($db, $ir, $h, $gangdata) { ?> <h3>Gang Management: Applicant Requirements</h3><?php if (!in_array($ir['userid'], [$gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']])) { error('You don\'t have access'); } if (array_key_exists('submit', $_POST)) { $nums = ['level', 'money', 'bank', 'cyber', 'crystals', 'days_old']; // Basic numeric validation foreach ($nums as $what) { $_POST[$what] = array_key_exists($what, $_POST) && ctype_digit($_POST[$what]) && $_POST[$what] > 0 ? $_POST[$what] : null; } if ($_POST['bank'] === null) { $_POST['bank'] = -1; } if ($_POST['cyber'] === null) { $_POST['cyber'] = -1; } $strs = ['items', 'quantities']; // Basic string validation and sanitation foreach ($strs as $what) { $_POST[$what] = array_key_exists($what, $_POST) && preg_match('/^\d(?:,\d)*$/', $_POST[$what]) ? $_POST[$what] : ''; } $_POST['items'] = array_unique($_POST['items']); // Handle strings first.. if (!empty($_POST['items']) && !empty($_POST['quantities'])) { $itemsStr = ''; $itemsCnt = count($_POST['items']); $itemsCntErrors = 0; $itemsCntErrorsNoUse = 0; if ($itemsCnt > 5) { error('You can add up to 5 item requirements only'); } $quants = explode(',', $_POST['quantities']); $quantsCnt = count($quants); if ($quantsCnt != $itemsCnt) { error('You didn\'t enter a matching amount of items to quantities'); } foreach ($_POST['items'] as $item) { $select = $db->query('SELECT itmname, itmgangreq FROM items WHERE itmid = '.$item); if (!$db->num_rows($select)) { ++$itemsCntErrors; } $item = $db->fetch_row($select); if (!$item['itmgangreq']) { ++$itemsCntErrorsNoUse; } } if ($itemsCntErrors) { error($itemsCntErrors.' of the item'.(1 == $itemsCntErrors ? ' doesn\'t' : 's don\'t').' exist'); } if ($itemsCntErrorsNoUse) { error((1 == $itemsCntErrorsNoUse ? 'The item' : $itemsCntErrorsNoUse.' of the items').' you selected can\'t be used'); } } $db->query('INSERT INTO gangs_requirements (gang, level, money, bankmoney, cybermoney, crystals, days_old, items, items_qty) VALUES ('.$gangdata['gangID'].', '.$_POST['level'].', '.$_POST['money'].', '.$_POST['bank'].', '.$_POST['cyber'].', '.$_POST['crystals'].', '.$_POST['days_old'].', "'.$_POST['items'].'", "'.$_POST['items_qty'].'") ON DUPLICATE KEY UPDATE level = '.$_POST['level'].', money = '.$_POST['money'].', bank = '.$_POST['bank'].', cyber = '.$_POST['cyber'].', crystals = '.$_POST['crystals'].', days_old = '.$_POST['days_old'].', items = "'.$_POST['items'].'", items_qty = "'.$_POST['items_qty'].'"'); $db->query('INSERT INTO gangevents (gevGANG, gevTIME, gevTEXT) VALUES ('.$gangdata['gangID'].', '.time().', "'.$db->escape($ir['username']).' updated the gang applicant requirements")'); ?> <div class="success"> You've updated the gang applicant requirements<br /> <a href="yourgang.php?action=staff">Back to Gang Management</a> &middot; <a href="yourgang.php">Back to Your Gang</a> </div><?php exit($h->endpage()); } $items = []; $selectUsable = $db->query('SELECT itmid, itmname FROM items WHERE itmgangreq = 1 ORDER BY itmname ASC'); while ($row = $db->fetch_row($selectUsable)) { $items[] = [$row['itmid'] => $row['itmname']]; } ?> <strong>Note:</strong> Leave blank for no requirement<br /> <form action="yourgang.php?action=staff&act2=reqs" method="post"> <table class="table" width="100%"> <tr> <th colspan="2">Basic Requirements</th> </tr> <tr> <th width="25%">Level</th> <td width="75%"><input type="number" name="level" value="<?php isset($gangdata['level']) ? $gangdata['level'] : 0; ?>" /></td> </tr> <tr> <th>Money</th> <td><input type="number" name="money" value="<?php echo isset($gangdata['money']) ? $gangdata['money'] : 0; ?>" /></td> </tr> <tr> <th>Bank</th> <td><input type="number" name="bank" value="<?php echo !isset($gangdata['bank']) || -1 == $gangdata['bank'] ? 0 : $gangdata['bank']; ?>" /></td> </tr> <tr> <th>Cyber</th> <td><input type="number" name="cyber" value="<?php echo !isset($gangdata['cyber']) || -1 == $gangdata['cyber'] ? 0 : $gangdata['cyber']; ?>" /></td> </tr> <tr> <th>Crystals</th> <td><input type="number" name="crystals" value="<?php echo isset($gangdata['crystals']) ? $gangdata['crystals'] : 0; ?>" /></td> </tr> <tr> <th>Days Old</th> <td><input type="number" name="days_old" value="<?php echo isset($gangdata['days_old']) ? $gangdata['days_old'] : 0; ?>" /></td> </tr> <tr> <th colspan="2">Item Requirements</th> </tr><?php if (!count($items)) { ?> <tr> <td colspan="2" class="centre">There are no items available</td> </tr><?php } else { for ($i = 1; $i <= 5; ++$i) { ?> <tr> <th>Item #<?php echo $i; ?></th> <td> <select name="items[]"> <option value="0" selected>--- None ---</option><?php foreach ($items as $key => $item) { printf('<option value="%u">%s</option>', $item[0], stripslashes(htmlspecialchars($item[1]))); } ?> </select> </td> </tr><?php } } ?> <tr> <td colspan="2" class="center"><input type="submit" name="submit" value="Update Applicant Requirements" /></td> </tr> </table> </form><?php } Edit gangs.php Find: include 'globals.php'; Add below: $reqNums = [ 'level' => 'level', 'money' => 'cash', 'bankmoney' => 'banked cash', 'cybermoney' => 'cyber cash', 'crystals' => 'crystals', 'days_old' => 'days old' ]; Find: case 'apply': gang_applyform(); break; case 'applys': gang_applysubmit(); break; Replace with: case 'apply': gang_apply($db, $ir, $h, $gangdata, $reqNums); break; Find: $gq = $db->query("SELECT * FROM gangs WHERE gangID={$_GET['ID']}"); Replace with: $gq = $db->query('SELECT * FROM gangs AS g LEFT JOIN gangs_requirements AS r ON g.gangID = r.gang WHERE g.gangID = '.$_GET['ID']); if (!$db->num_rows($gq)) { echo 'That gang doesn\'t exist'; exit($h->endpage()); } Find (in gang_view()): global $db, $ir, $c, $h, $gangdata; Replace with: global $db, $ir, $c, $h, $gangdata, $reqNums; Find (in gang_view()): > <a href='gangs.php?action=apply&ID={$gangdata['gangID']}'>Apply</a>"; Replace with: > <a href='gangs.php?action=apply&ID=<?php echo $gangdata['gangID']; ?>'>Apply</a><br /><br /> <h4>Requirements:</h4><br /><?php foreach ($reqNums as $col => $out) { if (isset($gangdata[$col])) { echo '<strong>',ucwords($out),':</strong> ',number_format($gangdata[$col]),'<br />'; } } if (isset($gangdata['items']) && !empty($gangdata['items'])) { ?> <h4>Items Required</h4><br /><?php $items = explode(',', $gangdata['items']); $quants = explode(',', $gangdata['items_qty']); $quantsMarker = 0; foreach ($items as $item) { $select = $db->query('SELECT itmname, inv_qty FROM items INNER JOIN inventory ON itmid = inv_itemid WHERE itmid = '.$item); if ($db->num_rows($select)) { $row = $db->fetch_row($select); $color = $row['inv_qty'] < $quants[$quantsMarker] ? 'red' : 'green'; echo $row['itmname'],' <span style="color:',$color,';">x',$quants[$quantsMarker],'</span><br />'; } ++$quantsMarker; } } Find: function gang_applyform() { global $mtg, $ir, $c, $h, $gangdata; if (!$ir['gang']) { print "<form action='gangs.php?action=applys&ID={$_GET['ID']}' method='post'> Type the reason you should be in this gang.<br /> <textarea name='application' rows='7' cols='40'></textarea><br /> <input type='submit' value='Apply' /></form>"; } else { print 'You cannot apply to join a gang when you are already in one.'; } } function gang_applysubmit() { global $db, $ir, $c, $h, $gangdata, $userid; if (!$ir['gang']) { $db->query("INSERT INTO applications VALUES('',$userid,{$_GET['ID']},'{$_POST['application']}');"); $db->query("INSERT INTO gangevents VALUES('',{$_GET['ID']},unix_timestamp(),'".$db->escape($mtg->username($ir['userid']))." sent a request to join your gang.')"); print "You sent your application to the ".$gangdata['gangNAME'])." gang."; } else { print 'You cannot apply for a gang when you are already in one.'; } } Replace with: if (!function_exists('error')) { function error($msg) { global $h; echo '<div class="error"><strong>Error!</strong><br />'.$msg.'</div>'; exit($h->endpage()); } } function gang_apply($db, $ir, $h, $data, $reqNums) { ?> <h3>Applying to join</h3><?php foreach ($reqNums as $col => $out) { if (isset($data[$col]) && $data[$col] > $ir[$col]) { error('Your '.$out.' isn\'t high enough for '.$data['gangNAME'].'\'s requirements'); } } if (isset($data['items']) && isset($data['items_qty'])) { $items = explode(',', $data['items']); $quants = explode(',', $data['items_qty']); $itemsCnt = count($items); $quantsMarker = 0; foreach ($items as $item) { $select = $db->query( 'SELECT i.itmname, inv.inv_qty FROM items AS i INNER JOIN inventory AS inv ON i.itmid = inv.inv_itemid WHERE i.itmid = '.$item ); if ($db->num_rows()) { $row = $db->fetch_row($select); if ($row['inv_qty'] < $quants[$quantsMarker]) { error('You don\'t have enough '.$row['itmname'].'\'s'); } ++$quantsMarker; } } } if (array_key_exists('submit', $_POST)) { $selectApps = $db->query('SELECT COUNT(appID) FROM applications WHERE appGANG = '.$data['gangID'].' AND appUSER = '.$ir['userid']); if ($db->fetch_single($selectApps)) { error('You\'ve already applied to be a part of '.$data['gangNAME']); } $_POST['app'] = array_key_exists('app', $_POST) && is_string($_POST['app']) ? filter_var($_POST['app'], FILTER_SANITIZE_STRING) : null; if (empty($_POST['app'])) { error('You didn\'t enter a valid application'); } $db->query('INSERT INTO applications (appUSER, appGANG, appTEXT) VALUES ('.$ir['userid'].', '.$data['gangID'].', "'.$_POST['app'].'")'); $db->query('INSERT INTO gangevents (gevGANG, gevTIME, gevTEXT) VALUES ('.$data['gangID'].', '.time().', "'.$db->escape($ir['username']).' has applied to join the gang")'); ?> <div class="success"> You've applied to join <?php echo $data['gangNAME']; ?> </div><?php exit(gang_view()); } ?> <form action="gangs.php?action=apply" method="post"> <textarea name="app" rows="50" cols="10" placeholder="Enter why you should be accepted into <?php echo $data['gangNAME']; ?>"></textarea><br /> <input type="submit" name="submit" value="Send Application" /> </form><?php } Edit staff_items.php Find (in new_item_form()): Item Buyable: <input class='textbox' type='checkbox' name='itmbuyable' checked='checked' /><br /> Add below: Item Usable as Gang Requirement: <input class='textbox' type='checkbox' name='itmgangreq' /><br /> Find (in new_item_submit()): if ($_POST['itmbuyable'] == 'on') {$itmbuy = 1;} else { $itmbuy = 0;} Add below: $itmreq = isset($_POST['itmgangreq']) ? 1 : 0; Find (in new_item_submit()): $m = $db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor)"); Replace with: $db->query('INSERT INTO items (itmname, itmdesc, itmtype, itmbuyprice, itmsellprice, itmbuyable, itmgangreq, effect1_on, effect2_on, effect3_on, effect1, effect2, effect3, weapon, armor) VALUES ("'.$itmname.'", "'.$itmdesc.'", '.$_POST['itmtype'].', '.$_POST['itmbuyprice'].', '.$_POST['itmsellprice'].', '.$itmbuyable.', '.$itmreq.', '.$_POST['effect1on'].', '.$_POST['effect2on'].', '.$_POST['effect3on'].', "'.$efx1.'", "'.$efx2.'", "'.$efx3.'", '.$weapon.', '.$armor.')'); Find (in edit_item_form()): Item Buyable: <input type='checkbox' name='itmbuyable'"; if ($itemi['itmbuyable']) {print " checked='checked'";} print " /> Add below: Item Usable as Gang Requirement: <input class='textbox' type='checkbox' name='itmgangreq'".($itemi['itmgangreq'] ? ' checked' : '')." /><br /> Find (in edit_item_sub()): if ($_POST['itmbuyable'] == 'on') {$itmbuy = 1;} else { $itmbuy = 0;} Add below: $itmreq = isset($_POST['itmgangreq']) ? 1 : 0; Find (in edit_item_sub()): $m = $db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor)"); Replace with: $db->query('INSERT INTO items (itmname, itmdesc, itmtype, itmbuyprice, itmsellprice, itmbuyable, itmgangreq, effect1_on, effect2_on, effect3_on, effect1, effect2, effect3, weapon, armor) VALUES ("'.$itmname.'", "'.$itmdesc.'", '.$_POST['itmtype'].', '.$_POST['itmbuyprice'].', '.$_POST['itmsellprice'].', '.$itmbuyable.', '.$itmreq.', '.$_POST['effect1on'].', '.$_POST['effect2on'].', '.$_POST['effect3on'].', "'.$efx1.'", "'.$efx2.'", "'.$efx3.'", '.$weapon.', '.$armor.')');
  17. URL given: "asdf" Code: <?php require_once __DIR__ . '/includes/globals.php'; function isImage($url = null) { $url = filter_var($url, FILTER_VALIDATE_URL) ? filter_var($url, FILTER_SANITIZE_URL) : null; if(empty($url)) return false; $params = ['http' => ['method' => 'HEAD']]; $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx) or false; if(!$fp) return false; // Problem with url $meta = stream_get_meta_data($fp); if ($meta === false) { fclose($fp); return false; // Problem reading data from url } $wrapper_data = $meta['wrapper_data']; if(is_array($wrapper_data)) foreach(array_keys($wrapper_data) as $hh) if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") { fclose($fp); return true; } fclose($fp); return false; } $images = [ null, '', 'http://google.com', 'http://somerandomwebsite.com/fake/url/image/watever.png', 'https://image.freepik.com/free-icon/teddy-bear_318-104767.jpg' ]; foreach($images as $image) echo (isImage($image) ? 'Yup.. <em>'.$image.'</em> is an image' : 'Nah, no image here - <em>'.($image ? $image : 'No URL given').'</em>!').'<br />'; First test (single file): Usage of code (minor update to fit my system): Second test (within [settings|preferences].php): --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Url given: https://s-media-cache-ak0.pinimg.com...1983a96c11.jpg Exact same code Output: --------------------------------------------------------------------------------------------------------------------------------------------------------------------- If it's failing in your code, your server's settings (php.ini) may not allow remote file opening via fopen()
  18. 'twas the fopen() before hitting the headers. Code updated and repiared function isImage($url = null) { $url = filter_var($url, FILTER_VALIDATE_URL) ? filter_var($url, FILTER_SANITIZE_URL) : null; if(empty($url)) return false; $params = ['http' => ['method' => 'HEAD']]; $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx) or false; if(!$fp) return false; // Problem with url $meta = stream_get_meta_data($fp); if ($meta === false) { fclose($fp); return false; // Problem reading data from url } $wrapper_data = $meta['wrapper_data']; if(is_array($wrapper_data)) foreach(array_keys($wrapper_data) as $hh) if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") { fclose($fp); return true; } fclose($fp); return false; }
  19. My tests show no error with my code..
  20. SELECT `itmid`, `itmname` FROM `items` WHERE `itmtype` IN(1, 2, 3) Alter the IN clause to whitelist the item type IDs you want to use there
  21. Why aren't you going via itemtype? Isn't that generally what it's for; easier differentiation?
  22. $fp = @fopen($url, 'rb', false, $ctx) or exit('Couldn\'t load URL'); ?
  23. I suppose you could do this: $fp = @fopen($url, 'rb', false, $ctx);
  24. Set DEBUG to false in the error handler
  25. Exactly what Hax-guy said; that URL isn't an image Edit: Just tested with a direct URL given by PhotoBucket itself (http://i871.photobucket.com/albums/ab277/ANNNNNNNNA_bucket/Animated%20Gif/Psychedelic%20Animated%20Gifs/AnimatedAura.gif), seems to work fine for me
×
×
  • Create New...