Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,142
  • Joined

  • Last visited

  • Days Won

    148

Everything posted by Magictallguy

  1. Profile Comments
  2. Profile Comments! TESTED - Please respond with any bugs Run SQL: CREATE TABLE users_comments ( id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, profile_id INT(11) NOT NULL DEFAULT 0, poster_id INT(11) NOT NULL DEFAULT 0, flagged TINYINT(4) NOT NULL DEFAULT 0, content TEXT NOT NULL, time_added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX(profile_id) ) THIS STEP IS OPTIONAL - YOU ONLY NEED TO DO THIS IF YOU INTEND TO USE JBBCODE Find: require_once('globals.php'); Add below: require_once __DIR__ . '/path/to/JBBCode/Parser.php'; Find (default: above "Profile for x user"): $db->free_result($ref_q); Add below <?php // added for syntax highlighting. Remove this line before pasting $delSuccess = false; $flagSuccess = false; $commentPosted = false; $_GET['flagcom'] = array_key_exists('flagcom', $_GET) && ctype_digit($_GET['flagcom']) && $_GET['flagcom'] > 0 ? $_GET['flagcom'] : null; $_GET['delcom'] = array_key_exists('delcom', $_GET) && ctype_digit($_GET['delcom']) && $_GET['delcom'] > 0 ? $_GET['delcom'] : null; if (!empty($_GET['flagcom'])) { $selectComment = $db->query('SELECT id, profile_id, poster_id, flagged FROM users_comments WHERE id = '.$_GET['flagcom']); if ($db->num_rows($selectComment)) { $com = $db->fetch_row($selectComment); if (!$com['flagged']) { $db->query('UPDATE users_comments SET flagged = 1 WHERE id = '.$_GET['flagcom']); $flagSuccess = true; } else { echo 'This comment has already been flagged'; } $db->free_result($com); } else { echo 'The comment you selected doesn\'t exist'; } } elseif (!empty($_GET['delcom'])) { $selectComment = $db->query('SELECT id, profile_id, poster_id FROM users_comments WHERE id = '.$_GET['delcom']); if ($db->num_rows($selectComment)) { $com = $db->fetch_row($selectComment); if (in_array($ir['userid'], [$com['profile_id'], $com['poster_id']]) && !$ir['staff_rank']) { $db->query('DELETE FROM users_comments WHERE id = '.$_GET['delcom']); $delSuccess = true; } else { echo 'You don\'t have access'; } $db->free_result($com); } else { echo 'The comment you selected doesn\'t exist'; } } if (array_key_exists('comment', $_POST)) { $_POST['comment'] = is_string($_POST['comment']) && strlen($_POST['comment']) > 0 ? strip_tags(trim($_POST['comment'])) : null; if (!empty($_POST['comment'])) { $selectDupCom = $db->query('SELECT COUNT(id) FROM users_comments WHERE profile_id = '.$r['userid'].' AND poster_id = '.$ir['userid'].' AND content = "'.$db->escape($_POST['comment']).'"'); if (!$db->fetch_single($selectDupCom)) { $db->query(sprintf('INSERT INTO users_comments (profile_id, poster_id, content) VALUES (%u, %u, "%s")', $r['userid'], $ir['userid'], $db->escape($_POST['comment']))); if ($ir['userid'] != $r['userid']) { $myname = function_exists('username') ? username($ir['userid']) : '<a href="viewuser.php?u='.$ir['userid'].'">'.stripslashes($ir['username']).'</a>'; event_add($r['userid'], $myname.' left a comment on your profile'); } $commentPosted = true; } $db->free_result($selectDupCom); } } Find (default: just above function checkblank() { [...] }): echo ' </tr> </table> '; Replace with: <?php // added for syntax highlighting. Remove this line before pasting echo '</tr>'; $successExists = function_exists('success'); $selectComments = $db->query('SELECT id, poster_id, flagged, content, time_added, username FROM users_comments INNER JOIN users ON poster_id = userid WHERE profile_id = '.$r['userid'].' ORDER BY time_added DESC LIMIT 10' );?> <tr> <td colspan="2" valign="top"> <?php echo $commentPosted ? ($successExists ? success('Your comment has been posted!') : 'Your comment has been posted!<br />') : ''; echo $delSuccess ? ($successExists ? success('You\'ve deleted the comment') : 'You\'ve deleted the comment<br />') : ''; echo $flagSuccess ? ($successExists ? success('You\'ve flagged the comment') : 'You\'ve flagged the comment<br />') : ''; ?> <form action="viewuser.php?u=<?php echo $r['userid'];?>" method="post"> <div class="form-group"> <label for="comment">Comment</label> <textarea name="comment" id="comment" rows="5%" cols="40%" class="form-control"></textarea> </div> <button type="submit" class="btn btn-primary"> <i class="fas fa-thumbs-up" aria-hidden="true"></i> Post Comment </button> </form> <table class="table table-dark table-hover" width="100%"> <thead> <tr> <th scope="col" style="width:25%;">Poster</th> <th scope="col" style="width:75%;">Comment</th> </tr> </thead> <tfoot> <tr> <th>Poster</th> <th>Comment</th> </tr> </tfoot> <tbody> <?php if(!$db->num_rows($selectComments)) { ?> <tr> <td colspan="2" class="center">There are no comments on this profile</td> </tr><?php } else { $usernameExists = function_exists('username'); while($row = $db->fetch_row($selectComments)) { $comment = trim(nl2br(stripslashes(htmlentities($row['content'], ENT_QUOTES, 'UTF-8')))); if(class_exists('JBBCode\Parser')) { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $comment = $parser->getAsHTML($parser->parse($comment)); } ?> <tr<?php echo $row['flagged'] ? ' style="-webkit-filter: grayscale(1);filter: grayscale(1);"' : '';?>> <td> <?php echo $usernameExists ? username($row['poster_id']) : '<a href="viewuser.php?u='.$row['profile_id'].'">'.stripslashes(htmlspecialchars($row['username'])).'</a>';?> </td> <td> <?php echo $comment;?><br /> <span style="font-size:.8em;font-style:italic;float:right;"><?php if(in_array($ir['userid'], [$row['poster_id'], $r['userid']]) || $ir['user_level'] == 2) { ?> [<a href="viewuser.php?u=<?php echo $r['userid'];?>&amp;delcom=<?php echo $row['id'];?>">Delete</a>]<?php } else if(!in_array($ir['userid'], [$row['poster_id'], $r['userid']])) { ?> [<a href="viewuser.php?u=<?php echo $r['userid'];?>&amp;flagcom=<?php echo $row['id'];?>">Flag</a>]<?php } ?> </span> </td> </tr><?php } } ?> </tbody> </table> </td> </tr> <?php $db->free_result($selectComments);
  3. I'm afraid I haven't released them to the public yet - mostly because they're for custom builds. I'll write up a stock MC Codes version for you
  4. if(my['userid'] == returned['userid']) { show name } else { show 'unknown'; }
  5. Nah, just about clinging to life xD
  6. 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?
  7. Want any collab code [uSER=67703]adamhull[/uSER]? If so, give me a shout :) Feel free to decline, no offense will be taken :P
  8. 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.
  9. Wait.. So who actually owns MWG now? Who are the staff?
  10. 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..
  11. 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..
  12. 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';
  13. Adding this for notification to other developers this and this
  14. Use my stuff as you wish - all published under the DBAD license
  15. Based on the limited information given, I have responded the best I can.
  16. <?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
  17. *is staying out of this*
  18. 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
  19. UPDATE `users` SET `pass_salt` = '' WHERE `userid` = INSERT USERID HERE
  20. 1. Gravedig! 2. http://php.net/array_slice - RTFM!
  21. 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.')');
  22. 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()
  23. '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; }
  24. My tests show no error with my code..
×
×
  • Create New...