-
Posts
2,146 -
Joined
-
Last visited
-
Days Won
149
Content Type
Profiles
Forums
Events
Everything posted by Magictallguy
-
Do you have an .htaccess in your public_html/www/htdocs directory? If so, what is the content of it?
-
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);
-
Just beat me to it [uSER=65530]Coly010[/uSER] :P [uSER=72582]boionfire81[/uSER], what is the content of $r?
-
Looking to purchase a Browser/Text Based Game!
Magictallguy replied to Just Ace's topic in Game Projects
It ain't much at the moment, but this might get you started -
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
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. -
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()); }
-
Change form action="staff_userlogs.php?action=viewlogs" to form action="staff_userlogs.php?action=whatever_goes_here_to_access_the_original_form_function"
-
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.')'); } }
-
mccode-v2 New and improved inventory code sources for free!
Magictallguy replied to MDK666's topic in Free Modifications
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'])) -
mccode-v1 [mccode] delete gang after respect hit 0
Magictallguy replied to iseeyou94056's topic in Free Modifications
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.')'); } -
function create_item() { global $db, $ir, $h; $select = $db->query('SELECT *, `itmname` FROM `workshop` INNER JOIN `items` ON `wITEM` = `itmid` WHERE `wACTIVE` = 1 AND `wLEVEL` <= '.$ir['level'].' AND `wDONATOR` <= '.$ir['donatordays'].' AND `wDAYSOLD` <= '.$ir['daysold'].' ORDER BY `wITEM` ASC'); ?><table border="1" width="85%"> <tr> <th colspan="4" class="center">Here Are The Items You Can Currently Create</th> </tr> <tr> <th width="30%">Item Name</th> <th width="30%">Requirements</th> <th width="30%">Cost(s)</th> <th width="10%">---</th> </tr><?php $reqs = ''; $costs = ''; if(!$db->num_rows($select)) echo '<tr><td colspan="4" class="center">There are currently no items available for you to create</td></tr>'; else while($row = $db->fetch_row($select)) { $costs .= $row['wCOST'] ? '$'.number_format($row['wCRYSTALS']).'<br />' : ''; $costs .= $row['wCRYSTALS'] ? number_format($row['wCRYSTALS']).' crystal'.($row['wCRYSTALS'] == 1 ? '' : 's').'<br />' : ''; $reqs .= $row['wDAYSOLD'] ? number_format($row['wDAYSOLD']).' Day'.($row['wDAYSOLD'] == 1 ? '' : 's').' Old<br />' : ''; $reqs .= $row['wLEVEL'] ? 'Level '.number_format($row['wLEVEL']).'<br />' : ''; $reqs .= $row['wDONATOR'] ? number_format($row['wDONATOR']).' Donator Day'.($row['wDAYSOLD'] == 1 ? '' : 's').'<br />' : ''; ?><tr> <td><?php echo $row['itmname'];?></td> <td><?php echo substr($reqs, 0, -6); $selectRequiredCourse = $db->query('SELECT `cnCOURSE` FROM `coursesneeded` WHERE `cnID` = '.$row['wITEM']); if($db->num_rows($selectRequiredCourse)) { $selectCourse = $db->query('SELECT `crNAME` FROM `courses` WHERE `crID` = '.$db->fetch_single($selectRequiredCourse)); if($db->num_rows($selectCourse)) echo '<ul><li><a href="education.php">'.$db->fetch_single($selectCourse).'</a></li></ul>'; } ?></td> <td><?php echo substr($costs, 0, -6); $selectRequiredItem = $db->query('SELECT `nITEM` FROM `itemsneeded` WHERE `nID` = '.$row['wITEM']); if($db->num_rows($selectRequiredItem)) { $selectItem = $db->query('SELECT `itmid`, `itmname` FROM `items` WHERE `itmid` = '.$db->fetch_single($selectRequiredItem)); if($db->num_rows($selectItem)) { $item = $db->fetch_row($selectItem); echo '<ul><li><a href="iteminfo.php?ID='.$item['itmid'].'">'.$item['itmname'].'</a></li></ul>'; } } ?></td> <td class="center"><a href="workshop.php?action=cconfirm&ID=<?php echo $row['wITEM'];?>">Create This Item</a></td> </tr><?php } ?></table><?php }
-
php code check no errors found??
Magictallguy replied to boionfire81's topic in Modification Support
Also, else statement is incorrect. Change the if() statement if(!$ir['gang']) { echo 'You\'re not in a gang'; exit($h->endpage()); } -
php code check no errors found??
Magictallguy replied to boionfire81's topic in Modification Support
I know my code when I see it.. Could just ask me for help.. -
Use jQuery's Tooltip as a basis and just work the information in
-
That particular piece of code shouldn't affect the typing. Ask [uSER=52003]Dave Macaulay[/uSER] for a hand, that is his code, after all
-
Right, that's because PHP Code Checker (whilst being pretty decent), is struggling with the ternary-within-ternary statement.. The code *should* still run fine. *If* you're still bothered about that issue, try changing lines 181 to 184 to this: ?><div id="<?php echo $ir['gang']?>" class="chat_box gang<?php echo isset($_COOKIE['chat_'.$ir['gang']]) && $_COOKIE['chat_'.$ir['gang']] == 'hidden' ? ' hidden' : (!isset($_COOKIE['chat_'.$ir['gang']]) && $chan['channel_open'] == 1 ? ' hidden' : ' open');?>"<?php echo ($chat_count > 1 ? ' style="right: '.((($chat_count-1)*262)+20).'px;"' : '');?>> <div class="chat_bar"><?php echo $g_data['gangNAME'];?> Chat</div>
-
You had 2 partially opened div tags <?php if(!isset($set)) { $set = array(); $settq = $db->query("SELECT `conf_name`, `conf_value` FROM `settings`"); while($r = $db->fetch_row($settq)) $set[$r['conf_name']] = $r['conf_value']; } ?><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.chat_bar').click(function() { var this_ele = $(this); if($(this).parents('.chat_box').hasClass('hidden')) { $(this).parents('.hidden').animate({bottom: '0px'},500,function() { $('[name=' + this_ele.parents('.chat_box').attr('id') + ']').focus(); updateShoutbox(); }).addClass('open').removeClass('hidden'); c_name = 'chat_' + $(this).parents('.chat_box').attr('id'); document.cookie = c_name + "=open"; } else { $(this).parents('.open').animate({bottom: '-320px'},500,function() { updateShoutbox(); }).addClass('hidden').removeClass('open'); c_name = 'chat_' + $(this).parents('.chat_box').attr('id'); document.cookie = c_name + "=hidden"; } }); $('.chat_contents').click(function() { $('[name=' + $(this).parents('.chat_box').attr('id') + ']').focus(); }); $('.chat_form').each(function() { $(this).submit(function() { alert('test'); }); }); updateShoutbox(); }); function scrollBottom() { $('.chat_box').each(function() { $(this).children('.chat_contents').scrollTop($(this).children('.chat_contents')[0].scrollHeight); }); } function updateShoutbox() { $('.open').each(function() { var chat_box = $(this).children('.chat_contents'); $.ajax({ type: "POST", url: 'ajax_chat/chat_ajax.php', cache: false, data: "function=chat_box" + ( chat_box.parents('.open').hasClass('gang') ? '&gang=' + chat_box.parents('.open').attr('id') : '&channel=' + $(this).attr('id') ), success: function(data) { chat_box.html(data); scrollBottom(); } }); }); } function sendChat(channel_id) { var chat_field = $('[name=' + channel_id + ']'); if(chat_field.val() != '' && chat_field.val() != ' ') { chat_field.attr('disabled',true); $.ajax({ type: "POST", url: 'ajax_chat/chat_ajax.php', cache: false, data: "function=send_chat" + ( chat_field.parents('.open').hasClass('gang') ? '&gang=' + chat_field.parents('.open').attr('id') : '&channel=' + channel_id ) + "&msg= " + chat_field.val(), success: function(data) { if(data == 1) { updateShoutbox(); chat_field.val(''); chat_field.attr('disabled',false); } else { alert('You\'re trying to post in a channel that either doesn\'t exist or your account does not have access to.'); chat_field.attr('disabled',false); } } }); } } setInterval('updateShoutbox()',<?php echo $set['refresh_time']; ?>); </script> <link href="http://stillarider.com/css/game.css" type="text/css" rel="stylesheet" /> <!--[if IE]> <style type="text/css"> .chat_box chat_input { margin-bottom: -20px; } </style> <![endif]--> <!--[if lt IE 7]> <style type="text/css"> .chat_box { display: none; } </style> <![endif]--><?php // Make any changes to the system that is needed for the system to work. $fields = array('top_bar','top_bar_hover','top_bar_text','top_bar_text_hover','chat_text','main_back','input_box','input_box_text','opacity','opacity_level','round_corners','round_corners_amount','box_shadow','channel_number','refresh_time','filter_words','new_words'); $values = array('bdbdbd','afafaf','000000','000000','000000','e2e2e2','bdbdbd','000000',1,0.8,1,5,1,1,2000,'****,cunt,****','****,****,****'); $count = 0; foreach($fields as $f) { if(!isset($set[$f])) { $db->query("INSERT INTO `settings` (`conf_name`, `conf_value`) VALUES ('".$f."','".$values[$count]."')"); ++$changed; } ++$count; } $table[] = "CREATE TABLE IF NOT EXISTS `chat_box` ( `chat_id` int(11) NOT NULL AUTO_INCREMENT, `chat_user` int(11) NOT NULL, `chat_to` int(11) NOT NULL, `chat_text` varchar(255) NOT NULL, `chat_time` int(11) NOT NULL, `chat_channel` int(11) NOT NULL, `chat_gang` int(11) NOT NULL, PRIMARY KEY (`chat_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;"; $table[] = "CREATE TABLE IF NOT EXISTS `chat_channels` ( `channel_id` int(11) NOT NULL AUTO_INCREMENT, `channel_alias` varchar(255) NOT NULL, `channel_name` varchar(255) NOT NULL, `channel_open` int(1) NOT NULL, `channel_req` text NOT NULL, PRIMARY KEY (`channel_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;"; foreach($table as $t) { $db->query($t) or exit('<b>MySQL Databse insertion error:</b><p>An error has occured when the system attempted to dump the various database information into the table. Please check the error below.<br />'.$db->error()); } if(isset($changed)) exit(header("Location: ".$_SERVER['PHP_SELF'])); // Make any changes to the system that is needed for the system to work. $find_channels = $db->query("SELECT `channel_name`, `channel_id`, `channel_alias`, `channel_open`, `channel_req` FROM `chat_channels`"); if($db->num_rows($find_channels)) { $chat_count = 1; while($chan = $db->fetch_row($find_channels)) { $failed = 0; if($chan['channel_req']) { $privs = unserialize($chan['channel_req']); foreach($privs as $p) { $check_priv = $db->query("SELECT `userid` FROM `users` WHERE `".$db->escape($p[0])."` ".$db->escape($p[1])." '".$db->escape($p[2])."' AND `userid` = ".$userid); if(!$db->num_rows($check_priv)) $failed = 1; } } if($failed < 1) { ?> <div id="<?php echo $chan['channel_alias'];?>" class="chat_box<?php echo (isset($_COOKIE['chat_'.$chan['channel_alias']]) && $_COOKIE['chat_'.$chan['channel_alias']] == 'hidden' ? ' hidden' : (!isset($_COOKIE['chat_'.$chan['channel_alias']]) && $chan['channel_open'] == 1 ? ' hidden' : ' open' ) );?>"<?php echo ($chat_count > 1 ? ' style="right: '.((($chat_count-1)*262)+20).'px;"' : '');?>> <div class="chat_bar"><?php echo ($set['channel_number'] == 1 ? $chan['channel_id'].'.' : '').$chan['channel_name']; ?></div> <div class="chat_contents"></div> <div id="chat_input"> <form action="#" onsubmit="sendChat('<?php echo $chan['channel_alias'];?>');return false;"> <input type="text" name="<?php echo $chan['channel_alias'];?>" class="chat_msg" /> </form> </div> </div><?php ++$chat_count; } } } if(isset($ir['gang'])) { $gang_data = $db->query("SELECT `gangNAME` FROM `gangs` WHERE `gangID` = ".$ir['gang']); if($db->num_rows($gang_data)) { $g_data = $db->fetch_row($gang_data); ?><div id="<?php echo $ir['gang']?>" class="chat_box gang<?php echo (isset($_COOKIE['chat_'.$ir['gang']]) && $_COOKIE['chat_'.$ir['gang']] == 'hidden' ? ' hidden' : (!isset($_COOKIE['chat_'.$ir['gang']]) && $chan['channel_open'] == 1 ? ' hidden' : ' open') );?>"<?php echo ($chat_count > 1 ? ' style="right: '.((($chat_count-1)*262)+20).'px;"' : '');?>> <div class="chat_bar"><?php echo $g_data['gangNAME'];?> Chat</div> <div class="chat_contents"></div> <div id="chat_input"> <form action="#" onsubmit="sendChat('<?php echo $chan['channel_alias'];?>');return false;"> <input type="text" name="<?php echo $chan['channel_alias'];?>" class="chat_msg" /> </form> </div> </div><?php } }
-
The folder extracts as JBBCode (capital J). Either update your require path, or rename the directory $parser->parse(nl2br($r['example'])); echo $parser->getAsHTML();
-
Jee, gravedig much!
-
Lite/v1 doesn't. I'm offering a conversion service with your choice of either MySQLi or PDO (preferred). I charge $5 an hour (negotiable), I use Toggl to track all time whilst coding, and a small file that shows you to-the-second tracked time. Short report (basic detail (time tracked, cost)) Detailed report contains each time tracked - will only show for whichever "workspace" I've used (to track specifically your time)
-
Jeez, procedural style is almost alien to me after writing OO for so long.. <?php ini_set('error_reporting', E_ALL); $dbhost = "localhost"; $dbuser = "usernamehere"; $dbpass = "passwordhere"; $dbbase = "dbnamehere"; $cron_are_so_cool = "trick_is_da_bomb"; $db = "mysql_tut"; $con = mysqli_connect($dbhost, $dbuser, $dbpass, $dbbase); if(!isset($_GET['code_to_run']) || $_GET['code_to_run'] != $cron_are_so_cool) die("<center><font color=red>Fatal error!</font><br/><blink>IP logged as {$_SERVER['REMOTE_ADDR']}</blink></center>"); /*----------------------- HELPER FUNCTIONS ------------------------ */ // -- Fugly "hacky" method for implementing MySQL's mysql_result() into MySQLi function mysqli_result($result, $row = 0, $column = 0) { $count = mysqli_num_rows($result); if($count && $row <= ($count - 1) && $row >=0) { mysqli_data_seek($result, $row); $get = ctype_digit($row) ? mysqli_fetch_row($result) : mysqli_fetch_assoc($result); if(isset($get[$column])) return $get[$column]; } return false; } // -- End fugly "hacky" method function remove_staff($id) { global $con; if(!ctype_digit($id)) return false; $selectStaff = mysqli_query($con, 'SELECT `p_maids`, `p_butler`, `p_guard`, `p_doctor`, `p_pilot` FROM `members_properties` WHERE `p_id` = '.$id) or exit(mysqli_error($con)); if(!mysqli_num_rows($selectStaff)) return false; $row = mysqli_fetch_assoc($selectStaff); $happloss = 0; if($row['p_maids'] != 0) { $selectName = mysqli_query($con, 'SELECT `ps_name` FROM `property_staff` WHERE `ps_id` = '.$row['p_maids']) or exit(mysqli_error($con)); if(!mysqli_num_rows($selectName)) return false; switch(mysqli_result($selectName)) { case '5x Maid Service': $happloss += 100; break; case '3x Maid Service': $happloss += 85; break; case '2x Maid Service': $happloss += 75; break; case 'Maid Service': $happloss += 50; break; } } if($row['p_butler'] != 0) { $selectName = mysqli_query($con, 'SELECT `ps_name` FROM `property_staff` WHERE `ps_id` = '.$row['p_butler']) or exit(mysqli_error($con)); if(!mysqli_num_rows($selectName)) return false; switch(mysqli_result($selectName)) { case '3x Butler Service': $happloss += 125; break; case '2x Butler Service': $happloss += 100; break; case 'Butler Service': $happloss += 75; break; } } if($row['p_guard'] != 0) { $selectName = mysqli_query($con, 'SELECT `ps_name` FROM `property_staff` WHERE `ps_id` = '.$row['p_guard']) or exit(mysqli_error($con)); if(!mysqli_num_rows($selectName)) return false; switch(mysqli_result($selectName)) { case '10x Guard Service': $happloss += 500; break; case '5x Guard Service': $happloss += 300; break; case '3x Guard Service': $happloss += 200; break; case '2x Guard Service': $happloss += 150; break; case 'Guard Service': $happloss += 100; break; } } if($row['p_doctor'] != 0) $happloss += 25; if($row['p_pilot'] != 0) $happloss += 50; mysqli_query($con, 'UPDATE `members_properties` SET `p_happy` = GREATEST(`p_happy` - '.$happloss.', 0), `p_maids` = 0, `p_butler` = 0, `p_guard` = 0, `p_doctor` = 0, `p_pilot` = 0, `p_priceofstaff` = 0, `p_daysofstaff` = 0 WHERE `p_id` = '.$id) or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `members` SET `my_maxhappy` = my_maxhappy` - '.$happloss.' WHERE `my_property` = '.$id) or exit(mysqli_error($con)); } function in_event($player, $text, $cs_val = true) { global $con; if(!ctype_digit($player)) return false; mysqli_query($con, 'INSERT INTO `member_events` VALUES (NULL, '.$player.', "'.mysqli_real_escape_string($con, $text).'", '.time().', 0)') or exit(mysqli_error($con)); if($cs_val) mysqli_query($con, 'UPDATE `city_statistic` SET `cs_value` = `cs_value` + 1 WHERE `cs_id` = 1') or exit(mysqli_error($con)); } function stock_credit($id, $credit) { global $con; if(!ctype_digit($id) || !ctype_digit($credit)) return false; mysqli_query($con, 'UPDATE `stock_market` SET `s_profit` = GRETEST(0, `s_profit` + '.$credit.'), `s_losses` = GREATEST(0, `s_losses` - '.$credit.') WHERE `s_id` = '.$id) or exit(mysqli_error($con)); } function award_check($user, $number, $award) { global $con; if(!ctype_digit($user) || !ctype_digit($number) || !ctype_digit($award)) return false; $selectAward = mysqli_query($con, 'SELECT `ma_id`, `ma_tier` FROM `members_award` WHERE `ma_playerid` = '.$user.' AND `ma_award` = '.$award) or exit(mysqli_error($con)); if(mysqli_num_rows($selectAward)) { $row = mysqli_fetch_assoc($selectAward); if($row['ma_tier'] < $number) { mysqli_query($con, 'UPDATE `members_awards` SET `ma_viewed` = 0, `ma_time` = '.time().', `ma_tier` = '.$number.' WHERE `ma_id` = '.$row['ma_id']) or exit(mysqli_error($con)); } } else mysqli_query($con, 'INSERT INTO `members_awards` VALUES (NULL, '.$award.', '.$number.', '.$user.', 0, '.time().')') or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `members` SET `my_merits` = `my_merits` + 1 WHERE `playerid` = '.$user) or exit(mysqli_error($con)); } /* ------------------- END HELPER FUNCTIONS ----------------------- */ /*----------------------------------Start cron days--------------------------*/ mysqli_query($con, 'UPDATE `members` SET `my_mailban` = IF(`my_mailban` > 0, `my_mailban` - 1, 0), `my_forumban` = IF(`my_forumban` > 0, `my_forumban` - 1, 0), `my_dondays` = IF(`my_dondays` > 0, `my_dondays` - 1, 0), `my_maxenergy` = IF(`my_dondays` = 0, 100, `my_maxenergy`), `my_partner_days`` = IF(`my_partner` > 0, `my_partner_days` - 1, 0), `brew` = 0') or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `members_extra` SET `my_daysold` = `my_daysold` + 1, `energy_refill` = 0, `my_ctokens` = `my_ctokens_daily`.`my_cstreak` = 0') or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `none_agressive` SET `na_days` = IF(`na_days` > 0, `na_days` - 1, 0)') or exit(mysqli_error($con)); mysqli_query($con, 'DELETE FROM `none_agressive` WHERE `na_days` = 0') or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `city_shop_dogs` SET `csd_daysold` = `csd_daysold` + 1') or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `members_dogs` SET `md_daysold` = `md_daysold` + 1') or exit(mysqli_error($con)); $newones = mt_rand(1, 15); $morf = [ 1 => 'male', 2 => 'female' ]; for($i = 1; $i <= $newones; ++$i) mysqli_query($con, 'INSERT INTO `city_shop_dogs` VALUES (NULL, '.mt_rand(1, 8).', "'.$morf[mt_rand(1, 2)].'", 0)') or exit(mysqli_error($con)); $selectPlayerJobs = mysqli_query($con, 'SELECT `me`.`playerid`, `me`.`my_job`, `me`.`my_job_rank`, `sjr`.*, `m`.`mt_level` FROM `members_extra` AS `me` INNER JOIN `system_job_ranks` AS `sjr` ON `me`.`my_job_rank` = `sjr`.`r_ID` INNER JOIN `members` AS `m` ON `me`.`playerid` = `m`.`playerid` WHERE `me`.`my_job` > 0') or exit(mysqli_error($con)); if(mysqli_num_rows($selectPlayerJobs)) { $job = [ 1 => 'armypoints', 2 => 'grocpoints', 3 => 'casipoints', 4 => 'medipoints', 5 => 'educpoints', 6 => 'lawpoints' ]; while($row = mysqli_fetch_assoc($selectPlayerJobs)) { mysqli_query($con, 'UPDATE `memberstats` SET `my_labor` = `my_labor` + '.$row['r_MANUALGAIN'].', `my_intelligence` = `my_intelligence` + '.$row['r_INTELGAIN'].', `my_endurance` = `my_endurance` + '.$row['r_ENDURGAIN'].' WHERE `playerid` = '.$row['playerid']) or exit(mysqli_error($con)); $row['r_POINTS'] *= $row['my_level']; mysqli_query($con, 'UPDATE `members_extra` SET `'.$job[$row['my_job']].'` = `'.$job[$row['my_job']].'` + '.$row['r_POINTS'].' WHERE `playerid` = '.$row['playerid']) or exit(mysqli_error($con)); mysqli_query($con, 'UPDATE `members` SET `wallet` = `wallet` + '.$row['r_WAGES'].' WHERE `playerid` = '.$row['playerid']) or exit(mysqli_error($con)); } } mysqli_query($con, 'UPDATE `members_properties` SET `p_ltime` = IF(`p_leasedto` > 0, GREATEST(0, `p_ltime` - 1), 0), `p_daysofstaff` = IF(`p_priceofstaff` > 0, `p_daysofstaff` + 1, `p_daysofstaff`)') or exit(mysqli_error($con)); //Check for expired rentings $selectRents = mysqli_query($con, 'SELECT * FROM `members_properties` AS `mp` LEFT JOIN `properties` AS `h` ON `mp`.`p_property` = `h`.`house_id` WHERE `mp`.`p_leasedto` > 0 AND `mp`.`p_ltime` = 0') or exit(mysqli_error($con)); if(mysqli_num_rows($selectRents)) { while($row = mysqli_fetch_assoc($selectRents)) { // ---- THIS BIT IS FUGLY AS HELL AND NEEDS A REWRITE (Well, it all does, but this bit especially!) $getPlayer = mysqli_query($con, 'SELECT `playerid` FROM `members` WHERE `my_property` = '.$row['p_id']) or exit(mysqli_error($con)); if(mysqli_num_rows($getPlayer)) { $prop = mysqli_fetch_assoc($getPlayer); $selectProp = mysqli_query($con, 'SELECT `p_id` FROM `members_properties` WHERE `p_property` = 1 AND `p_playerid` = '.$prop['playerid']) or exit(mysqli_error($con)); $pid = mysqli_result($selectProp); mysqli_query($con, 'UPDATE `members` SET `my_property` = '.$pid.', `my_happy` = 100, `my_maxhappy` = 100 WHERE `playerid` = '.$prop['playerid']) or exit(mysqli_error($con)); } remove_staff($row['p_id']); mysqli_query($con, 'UPDATE `members_properties` SET `p_leasedto` = 0, `p_ltime` = 0 WHERE `p_id` = '.$row['p_id']) or exit(mysqli_error($con)); in_event($row['p_playerid'], 'The lease for your '.$row['house_name'].' has now ended. Your property has been returned to you.', false); in_event($row['p_leasedto'], 'The lease for the '.$row['house_name'].' has now ended. The property has been returned to its owner.', false); } } //Check for expired rentings //Charge daily upkeep $selectProps = mysqli_query($con, 'SELECT * FROM `members_properties` AS `mp` LEFT JOIN `properties` AS `h` ON `mp`.`p_property` = `h`.`house_id` WHERE `mp`.`p_property` <> 1') or exit(mysqli_error($con)); if(mysqli_num_rows($selectProps)) { while($row = mysqli_fetch_assoc($selectProps)) { $total = $row['p_priceofstaff'] + $row['house_tax']; $target = $row['p_leasedto'] ? $row['p_leasedto'] : $row['p_playerid']; $selectPlayer = mysqli_query($con, 'SELECT `wallet` FROM `members` WHERE `playerid` = '.$target) or exit(mysqli_error($con)); if(mysqli_num_rows($selectPlayer)) { //Shouldn't be necessary - failsafe check $cash = mysqli_result($selectPlayer); if($row['p_priceofstaff']) { stock_credit(5, 1); if($cash < $total) { remove_staff($row['p_id']); in_event($target, 'You didn\'t have enough to pay your staff for today. They\'ve packed up and left!'); } mysqli_query($con, 'UPDATE `members` SET `wallet` = GREATEST(0, `wallet` - '.$total.') WHERE `playerid` = '.$target) or exit(mysqli_error($con)); } } } } //Charge daily upkeep $selectAwards = mysqli_query($con, 'SELECT * FROM `award_checks` AS `ac` LEFT JOIN `awards` AS `a` ON `ac`.`ac_award_id` = `a`.`a_id`') or exit(mysqli_error($con)); if(mysqli_num_rows($selectAwards)) { while($row = mysqli_fetch_assoc($selectAwards)) { $selectAward = mysqli_query($con, 'SELECT `'.$row['ac_identify'].'`, `'.$row['ac_what'].'` FROM `'.$row['ac_table'].'` WHERE `'.$row['ac_what'].'` >= '.$row['ac_amount']) or exit(mysqli_error($con)); if(mysqli_num_rows($selectAward)) while($get = mysqli_fetch_assoc($selectAward)) award_check($get[$row['ac_identify']], $row['ac_number'], $row['ac_award_id']); } } $selectFactionPlayers = mysqli_query($con, 'SELECT `playerid` FROM `members` WHERE `my_faction` > 0') or exit(mysqli_error($con)); if(mysqli_num_rows($selectFactionPlayers)) while($row = mysqli_fetch_assoc($selectFactionPlayers)) mysqli_query($con, 'UPDATE `members_extra` SET `my_faction_days`= `my_faction_days` + 1 WHERE `playerid` = '.$row['playerid']) or exit(mysqli_error($con)); mysqli_query($con, 'DELETE FROM `votes_count` WHERE `vc_site` IN ("apex", "ultra")') or exit(mysqli_error($con)); $selectStocks = mysqli_query($con, 'SELECT * FROM `stock_holdings` WHERE `sh_saletime` > 0 AND `sh_playerid` <> 3 AND (`sh_saletime` + 1036800) <= '.time()) or exit(mysqli_error($con)); if(mysqli_num_rows($selectStocks)) { while($row = mysqli_fetch_assoc($selectStocks)) { $credit = $row['sh_nowprice'] * $row['sh_qty']; mysqli_query($con, 'UPDATE `members` SET `wallet` = `wallet` + '.$credit.' WHERE `playerid` = '.$row['sh_playerid']) or exit(mysqli_error($con)); in_event($row['sh_playerid'], 'Someome bought '.$row['sh_qty'].' of your stocks for $'.number_format($credit)); mysqli_query($con, 'UPDATE `stock_holdings` SET `sh_playerid` = 1, sh_payed` = '.$row['sh_nowprice'].', `sh_time` = '.time().', `sh_sale` = 1, `sh_saletime` = '.time().' WHERE `sh_id` = '.$row['sh_id']) or exit(mysqli_error($con)); } } $yearago = (time() - 32140800); $sixmonths = $yearago / 2; $threemonths = $sixmonths / 2; $onemonth = $sixmonths / 6; $twoweeks = $onemonth / 2; $queries = [ 'DELETE FROM `member_mail` WHERE `mm_time` <= '.$onemonth, 'DELETE FROM `members_events` WHERE `e_time` <= '.$onemonth, 'DELETE FROM`attack_logs` WHERE `time` <= '.$onemonth, 'DELETE FROM `faction_events` WHERE `fe_time` <= '.$onemonth, 'DELETE FROM `stock_history` WHERE `h_time` <= '.$sixmonth ]; foreach($queries as $query) mysqli_query($con, $query) or exit(mysqli_error($con)); From 500~ lines to 268 and does the same job. There's still a few practises in there that I'd change, but I'm not willing to do all the work for you TESTED FOR PARSE ERRORS ONLY This is now using mysqli_*() (as opposed to deprecated mysql_*()) Including another file that contains database connections or mysql_*() functions may break this. I can provide a mysql_*() version if you'd like
-
Hnng *twitch*... jQuery != Java JavaScript != Java JavaScript != jQuery .... -.-
-
Ugh.. Genuine stomach churns whilst writing this - friggin' mysql_*() bleh.. <?php session_start(); require_once __DIR__ . '/global_func.php'; $userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) ? $_SESSION['userid'] : null; if(empty($userid)) exit(header('Location: login.php')); require_once __DIR__ . '/header.php'; $h = new headers; $h->startheaders(); require_once __DIR__ . '/mysql.php'; global $c; $is = mysql_query( 'SELECT `u`.*, `us`.*, `h`.* FROM `users` AS `u` LEFT JOIN `userstats` AS `us` ON `u`.`userid` = `us`.`userid` LEFT JOIN `houses` AS `h` ON `h`.`hWILL` = `u`.`maxwill` WHERE `u`.`userid` = '.$userid, $c ) or exit(mysql_error()); if(!mysql_num_rows($is)) { session_unset(); session_destroy(); exit(header('Location: login.php')); } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); $_GET['id'] = array_key_exists('id', $_GET) && ctype_digit($_GET['id']) ? $_GET['id'] : null; if (!isset($_GET['work'])) $_GET['work'] = ''; switch ($_GET['work']){ case 'apply': apply_job($ir, $c, $h); break; case 'hired': complete_job($ir, $c); break; default: job_home($ir, $c); } function job_home($ir, $c) { ?><table bgcolor="#c4c4c4" width="75%"><?php if($ir['job']) { $select = mysql_query('SELECT `Jname`, `Jpay` FROM `jobs` WHERE `Jid` = '.$ir['job'], $c) or exit(mysql_error()); if(!mysql_num_rows($select)) { mysql_query('UPDATE `users` SET `job` = 0 WHERE `job` = '.$ir['job'], $c) or exit(mysql_error()); echo 'The job you had no longer exists..'; } else { $row = mysql_fetch_assoc($select); ?><tr> <th colspan="4" style="text-align:center">You currently work at <?php echo $row['Jname'];?> making <?php echo money_formatter($row['Jpay']);?> a day!</th> </tr><?php } } $select = mysql_query('SELECT * FROM `jobs` ORDER BY `Jid` ASC', $c) or exit(mysql_error()); ?><tr> <th>Job</th> <th>Level</th> <th>Pay</th> <th>Apply</th> </tr><?php if(!mysql_num_rows($select)) echo '<tr><td colspan="4" style="text-align:center">There are no jobs</td></tr>'; else while($row = mysql_fetch_assoc($select)) { ?><tr> <td><?php echo $row['Jname'];?></td> <td><?php echo $row['Jlevel'];?></td> <td><?php echo money_formatter($row['Jpay']);?></td> <td><?php echo $row['Jlevel'] <= $ir['level'] ? '<a href="jobs.php?work=apply&id='.$row['Jid'].'">Apply</a>':'';?></td> </tr><?php } ?></table><?php } function apply_job($ir, $h, $c) { if(empty($_GET['id'])) { echo 'You didn\'t select a valid job'; exit($h->endpage()); } $select = mysql_query('SELECT `Jname`, `Jlevel`, `Jpay` FROM `jobs` WHERE `Jid` = '.$_GET['id'], $c) or exit(mysql_error()); if(!mysql_num_rows($select)) { echo 'The job you\'ve selected doesn\'t exist'; exit($h->endpage()); } $row = mysql_fetch_assoc($select); if($row['Jlevel'] > $ir['level']) { echo 'Your level isn\'t high enough for this job - go get some experience!'; exit($h->endpage()); } if(!array_key_exists('ans', $_GET)) { ?>Are you sure you want to apply to <?php echo $row['Jname'];?>?<br /> <a href="jobs.php?work=apply&id=<?php echo $_GET['id'];?>">Aye!</a><br /> <a href="jobs.php">Nah, take me back..</a><?php } else { mysql_query('UPDATE `users` SET `job` = '.$_GET['id'].', `jobpay` = '.$row['Jpay'].' WHERE `userid` = '.$ir['userid'], $c) or exit(mysql_error()); ?>You got the job! Congratulations!<br /> You now work at <?php echo $row['Jname'];?><br /> <a href="jobs.php"><span style="color:grey;">~</span> Back</a><?php } } $h->endpage(); And cron becomes: mysql_query('UPDATE `users` SET `money` = `money` + `jobpay`', $c) or exit(mysql_error());
-
For anyone else having an issue with the lack of SQL tag support... *glares at MWG admins* CREATE TABLE `mugger_oth` ( `uid` INT(11) NOT NULL, `total_mugged` INT(11) NOT NULL DEFAULT 0, `date_start` DATETIME NOT NULL, FOREIGN KEY (`uid`) REFERENCES `users`(`userid`) ON DELETE CASCADE ) ENGINE=MyISAM; CREATE TABLE `mugger_oth_global` ( `entry_type` ENUM('top_ever', 'top_hour', 'top_24') NOT NULL DEFAULT 'top_24', `uid` INT(11) NOT NULL, `total_mugs` INT(11) NOT NULL, `total_mugged` INT(11) NOT NULL, PRIMARY KEY (`entry_type`), FOREIGN KEY (`uid`) REFERENCES `users`(`userid`) ) ENGINE=MyISAM; INSERT INTO `mugger_oth_global` (`entry_type`, `uid`, `total_mugs`, `total_mugged`) VALUES ('top_24', 1, 0, 0), ('top_hour', 1, 0, 0), ('top_ever', 1, 0, 0);