darkfreaks Posted November 24, 2007 Share Posted November 24, 2007 ok so im trying to get it so my game works instead of allowing you to do a job for a day it will let ya do it by a selected amount of hours. will the current mods ive made work? the code is: <?php /*************************************************************************** * adr_jobs.php * ------------------------ * begin : 09/11/2004 * copyright : Seteo-Bloke * * ***************************************************************************/ define('IN_PHPBB', true); define('IN_ADR_CHARACTER', true); define('IN_ADR_SHOPS', true); $phpbb_root_path = './'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); include_once($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx); include_once($phpbb_root_path . 'adr/includes/adr_functions_jobs.'.$phpEx); include_once($phpbb_root_path . 'adr/language/lang_english/lang_adr_jobs.'.$phpEx); $loc = 'town'; $sub_loc = 'adr_town'; // // Start session management $userdata = session_pagestart($user_ip, PAGE_INDEX); init_userprefs($userdata); // End session management // adr_template_file('adr_jobs_body.tpl'); include($phpbb_root_path . 'includes/page_header.'.$phpEx); // Sorry , only logged users ... if(!$userdata['session_logged_in']){ $redirect = "adr_jobs.$phpEx"; $redirect .= (isset($user_id)) ? '&user_id=' . $user_id : ''; header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true)); } $user_id = $userdata['user_id']; // Get the general config $adr_general = adr_get_general_config(); // Standard checks adr_enable_check(); adr_ban_check($user_id); adr_character_created_check($user_id); // Check jobs are enabled by admin if($adr_general['job_salary_enable'] != '1') adr_previous(Adr_job_closed, adr_town, ''); // Fix values $apply = isset($HTTP_POST_VARS['apply']); $quit = isset($HTTP_POST_VARS['quit']); $show_only_mine = intval($HTTP_GET_VARS['show_only_mine']); // Grab character details $character = adr_get_user_infos($user_id); if($apply) { $apply_id = intval($HTTP_POST_VARS['apply_select']); // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$apply_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job = $db->sql_fetchrow($result); if($job['job_enabled'] != '1') adr_previous(Adr_job_job_disabled_error, 'adr_jobs', ''); // is job enabled? if(($job['job_max_per_user'] == '1') && (in_array($job['job_id'], explode(', ', $character['character_job_completed_id'])))) adr_previous(Adr_job_too_many_applies, 'adr_jobs', ''); // One time jobs only check // Check more than 1 slot available to use if($job['job_slots_available'] < '1'){ $message = sprintf($lang['Adr_job_none_left'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } if((!in_array('0', explode('-', $job['job_race_id']))) && (!in_array($character['character_race'], explode('-', $job['job_race_id'])))) adr_previous(Adr_job_wrong_race, 'adr_jobs', ''); // check race restriction if((!in_array('0', explode('-', $job['job_class_id']))) && (!in_array($character['character_class'], explode('-', $job['job_class_id'])))) adr_previous( Adr_job_wrong_class, 'adr_jobs', '');// check class restriction if((!in_array('0', explode('-', $job['job_alignment_id']))) && (!in_array($character['character_alignment'], explode('-', $job['job_alignment_id'])))) adr_previous( Adr_job_wrong_alignment, 'adr_jobs', '');// check alignment restriction if((!in_array('0', explode('-', $job['job_element_id']))) && (!in_array($character['character_element'], explode('-', $job['job_element_id'])))) adr_previous( Adr_job_wrong_element, 'adr_jobs', '');// check element restriction if(($job['job_level'] > '0') && ($job['job_level'] > $character['character_level'])) adr_previous(Adr_job_wrong_level, 'adr_jobs', ''); // check level restriction if(($job['job_mon_total'] > '0') && ($job['job_mon_total'] > ($character['character_victories'] + $character['character_flees'] + $character['character_defeats']))) adr_previous(Adr_job_mon_total_error, 'adr_jobs', ''); // check total monster battle restriction if(($job['job_mon_won'] > '0') && ($job['job_mon_won'] > $character['character_victories'])) adr_previous(Adr_job_mon_won_error, 'adr_jobs', ''); // check won monster battle restriction // Remove a job slot $dsql = "UPDATE " . ADR_JOB_TABLE . " SET job_slots_available = (job_slots_available - 1) WHERE job_id = '$apply_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Failed updating the job slots' , "", __LINE__, __FILE__, $csql);} // Work out job duration $current_time = time(); //if selected time equal an hour set the time if ($job['job_duration']=='1 hour' ) { $set_time = time()+3200;} // if selected job time is equal or greater then the set time if ($job['job_duration']=>$set_time){ $end_hours= time(); } else {echo 'you are not allowed to battle or upgrade your defense or attacks during this time';} // Update the job to the character $dsql = "UPDATE " . ADR_CHARACTERS_TABLE . " SET character_job_id = $apply_id, character_job_start = $current_time, character_job_end = $end_hours, character_job_last_paid = $current_time, character_job_times_employed = (character_job_times_employed + 1) WHERE character_id = '$user_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Failed updating job to character table' , "", __LINE__, __FILE__, $csql);} $message = sprintf($lang['Adr_job_accept'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } if($quit) { $quit_id = $character['character_job_id']; // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$quit_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job = $db->sql_fetchrow($result); $job_slots = (($job['job_slots_available'] + 1) > $job['job_slots_max']) ? $job['job_slots_max'] : ($job['job_slots_available'] + 1); // Add job slot back $dsql = "UPDATE " . ADR_JOB_TABLE . " SET job_slots_available = '$job_slots' WHERE job_id = '$quit_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Error updating job slots' , "", __LINE__, __FILE__, $csql);} // Update the job to the character $dsql = "UPDATE " . ADR_CHARACTERS_TABLE . " SET character_job_id = 0, character_job_start = 0, character_job_end = 0, character_job_incomplete = (character_job_incomplete + 1) WHERE character_id = '$user_id'"; if ( !($dresult = $db->sql_query($dsql)) ){ message_die(GENERAL_ERROR, 'Error updating character table' , "", __LINE__, __FILE__, $csql);} $message = sprintf($lang['Adr_job_quit'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } // Check if user is currently employed & show stats if($character['character_job_id'] != '0'){ $job_id = $character['character_job_id']; // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$job_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job_details = $db->sql_fetchrow($result); $image = ($job_details['job_img'] != '') ? '<img src="adr/images/jobs/'.$job_details['job_img'].'">' : ''; $days_remaining = ceil(($character['character_job_end'] - time()) /86400); $template->assign_block_vars('employed', array( 'EMPLOYED' => $job_details['job_name'], 'EMPLOYED_SALARY' => number_format($job_details['job_salary']), 'EMPLOYED_EARNED' => number_format($character['character_job_earned']), 'EMPLOYED_IMG' => $image, 'EMPLOYED_DAYS_LEFT' => $days_remaining, 'JOB_ID' => $job_id, 'L_EMPLOYED_TIMES' => sprintf($lang['Adr_job_times_employed'] , $character['character_job_times_employed']), )); } else{ $template->assign_block_vars('non_employed', array()); } // Check auth level of user if($userdata['user_level'] == ADMIN) $sql_level = ''; elseif($userdata['user_level'] == MOD) $sql_level = 'AND job_auth_level != 1'; else $sql_level = 'AND job_auth_level = 0'; // START categories & pagination $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; if ( isset($HTTP_GET_VARS['mode2']) || isset($HTTP_POST_VARS['mode2']) ) { $mode2 = ( isset($HTTP_POST_VARS['mode2']) ) ? htmlspecialchars($HTTP_POST_VARS['mode2']) : htmlspecialchars($HTTP_GET_VARS['mode2']); } else { $mode2 = 'itemname'; } if(isset($HTTP_POST_VARS['order'])) { $sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC'; } else if(isset($HTTP_GET_VARS['order'])) { $sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC'; } else { $sort_order = 'ASC'; } if ( isset($HTTP_GET_VARS['cat']) || isset($HTTP_POST_VARS['cat']) ) { $cat = ( isset($HTTP_POST_VARS['cat']) ) ? htmlspecialchars($HTTP_POST_VARS['cat']) : htmlspecialchars( $HTTP_GET_VARS['cat']); } else { $cat = 0; } $cat_sql = ( $cat ) ? 'AND job_name = '.$cat : ''; $mode_types_text = array($lang['Adr_job_name'], $lang['Adr_job_level'], $lang['Adr_job_slots'], $lang['Adr_job_salary']); $mode_types = array('name', 'level', 'job_slots_available', 'job_salary'); $select_sort_mode = '<select name="mode2">'; for($i = 0; $i < count($mode_types_text); $i++) { $selected = ( $mode2 == $mode_types[$i] ) ? ' selected="selected"' : ''; $select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>'; } $select_sort_mode .= '</select>'; $select_sort_order = '<select name="order">'; if($sort_order == 'ASC') { $select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>'; } else { $select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>'; } $select_sort_order .= '</select>'; switch( $mode2 ) { case 'name': $order_by = "job_name $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'level': $order_by = "job_level $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'job_slots_available': $order_by = "job_slots_available $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'job_salary': $order_by = "job_salary $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; default: $order_by = "job_level $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; } if($show_only_mine == '1'){ // Make sure finished job ids is never empty otherwise == sql error $character['character_job_completed_id'] = ($character['character_job_completed_id'] == '') ? '0' : $character['character_job_completed_id']; $sql = "SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_enabled = '1' AND (job_alignment_id LIKE '%".$character['character_alignment']."%' OR job_alignment_id = '0') AND (job_class_id LIKE '%".$character['character_class']."%' OR job_class_id = '0') AND (job_element_id LIKE '%".$character['character_element']."%' OR job_element_id = '0') AND (job_race_id LIKE '%".$character['character_race']."%' OR job_race_id = '0') AND job_level <= '".$character['character_level']."' AND job_mon_total <= '".($character['character_victories'] + $character['character_defeats'] + $character['character_flees'])."' AND job_mon_won <= '".$character['character_victories']."' AND job_slots_available > '0' AND (job_id NOT IN (".$character['character_job_completed_id'].") OR job_max_per_user = '0') $sql_level $cat_sql ORDER BY $order_by"; } else{ $sql = "SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_enabled = '1' $sql_level $cat_sql ORDER BY $order_by"; } if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Error showing all job list' , "", __LINE__, __FILE__, $sql);} $jobs = $db->sql_fetchrowset($result); for($i = 0; $i < count($jobs); $i++) { $row_color = (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2']; $row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2']; $image = ($jobs[$i]['job_img'] != '') ? '<img src="adr/images/jobs/'.$jobs[$i]['job_img'].'">' : '' ; $interval_lang = ($jobs[$i]['job_payment_intervals'] > '1') ? $lang['Adr_job_days'] : $lang['Adr_job_day']; $duration_lang = ($jobs[$i]['job_duration'] > '1') ? $lang['Adr_job_days'] : $lang['Adr_job_day']; $template->assign_block_vars('jobs', array( 'ROW_CLASS' => $row_class, 'JOB_ID' => $jobs[$i]['job_id'], 'JOB_IMG' => $image, 'JOB_NAME' => adr_get_lang($jobs[$i]['job_name']), 'JOB_DESC' => adr_get_lang($jobs[$i]['job_desc']), 'JOB_LEVEL' => $jobs[$i]['job_level'], 'JOB_ITEM_REWARD' => adr_job_make_array_items($jobs[$i]['job_item_reward_id']), 'JOB_CLASS' => adr_job_make_array_class($jobs[$i]['job_class_id']), 'JOB_RACE' => adr_job_make_array_race($jobs[$i]['job_race_id']), 'JOB_ALIGNMENT' => adr_job_make_array_alignment($jobs[$i]['job_alignment_id']), 'JOB_ELEMENT' => adr_job_make_array_element($jobs[$i]['job_element_id']), 'JOB_SALARY' => number_format($jobs[$i]['job_salary']), 'JOB_SALARY_INT' => number_format($jobs[$i]['job_payment_intervals']), 'JOB_MON_TOTAL' => number_format($jobs[$i]['job_mon_total']), 'JOB_MON_WON' => number_format($jobs[$i]['job_mon_won']), 'JOB_DURATION' => $jobs[$i]['job_duration'], 'JOB_SLOTS' => ($jobs[$i]['job_slots_available'] < '1') ? '<font color="#FF0000">'.$jobs[$i]['job_slots_available'].'</font>' : $jobs[$i]['job_slots_available'], 'JOB_SLOTS_MAX' => $jobs[$i]['job_slots_max'], 'JOB_EXP' => number_format($jobs[$i]['job_exp']), 'JOB_SP_REWARD' => number_format($jobs[$i]['job_sp_reward']), 'L_JOB_DURA_LANG' => $duration_lang, 'L_JOB_INT_LANG' => $interval_lang, )); // Show additional restrictions, if req. if($jobs[$i]['job_mon_total'] > '0') $template->assign_block_vars('jobs.mon_total', array()); if($jobs[$i]['job_mon_won'] > '0') $template->assign_block_vars('jobs.mon_won', array()); if($jobs[$i]['job_max_per_user'] == '1') $template->assign_block_vars('jobs.one_time', array()); // Show employment block if($jobs[$i]['job_max_per_user'] === '0'){ if(($character['character_job_id'] === '0') && ($jobs[$i]['job_slots_available'] > '0')) $template->assign_block_vars('jobs.slots', array()); else $template->assign_block_vars('jobs.no_slots', array()); } else{ if(($character['character_job_id'] === '0') && ($jobs[$i]['job_slots_available'] > '0') && (!in_array($jobs[$i]['job_id'], explode('-', $character['character_job_completed_id'])))) $template->assign_block_vars('jobs.slots', array()); else $template->assign_block_vars('jobs.no_slots', array()); } } // If no results then say so to user to stop confusion if(count($jobs) < '1') $template->assign_block_vars('oh_crap_nothing', array());; // Show apply if not employed if($character['character_job_id'] === '0') $template->assign_block_vars('apply', array()); // Check auth level of user if($userdata['user_level'] == ADMIN) $sql_total_level = ''; elseif($userdata['user_level'] == MOD) $sql_total_level = 'WHERE job_auth_level != 1'; else $sql_total_level = 'WHERE job_auth_level = 0'; // START pagination $sql = "SELECT count(*) AS total FROM " . ADR_JOB_TABLE . " $sql_total_level"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);} if($total = $db->sql_fetchrow($result)){ $total_items = $total['total']; $pagination = generate_pagination("adr_jobs.$phpEx?mode2=$mode2&order=$sort_order&cat=$cat", $total_items, $board_config['topics_per_page'], $start). ' '; } // END pagination // Show all? $show_all = ($show_only_mine == '1') ? $lang['Adr_job_show_all'] : $lang['Adr_job_show_mine']; $template->assign_vars(array( 'POINTS' => $board_config['points_name'], 'EMPLOYED_TOTAL' => number_format($character['character_job_total_earned']), 'EMPLOYED_TIMES' => $character['character_job_times_employed'], 'EMPLOYED_COMPLETED' => $character['character_job_completed'], 'EMPLOYED_INCOMPLETE' => $character['character_job_incomplete'], 'L_JOBS_OFFICE' => $lang['Adr_job_office'], 'L_JOBS_LIST' => $lang['Adr_job_list'], 'L_EMPLOYED_DAYS_LEFT' => $lang['Adr_job_days_remaining'], 'L_EMPLOYED_TIMES' => $lang['Adr_job_times_employed'], 'L_PERSONAL_STATS' => $lang['Adr_job_personal_stats'], 'L_NON_EMPLOYED' => $lang['Adr_job_non_employed'], 'L_EMPLOYED' => $lang['Adr_job_employed'], 'L_EMPLOYED_TOTAL' => $lang['Adr_job_employed_total_earned'], 'L_EMPLOYED_SALARY' => $lang['Adr_job_employed_salary'], 'L_EMPLOYED_EARNED' => $lang['Adr_job_employed_total'], 'L_EMPLOYED_COMPLETED' => $lang['Adr_job_employed_completed'], 'L_EMPLOYED_INCOMPLETE' => $lang['Adr_job_employed_incomplete'], 'L_JOB_TITLE' => $lang['Adr_job_title'], 'L_JOB_NAME' => $lang['Adr_job_name'], 'L_JOB_DESC' => $lang['Adr_job_desc'], 'L_JOB_LEVEL' => $lang['Adr_job_level'], 'L_JOB_RACE' => $lang['Adr_job_race'], 'L_JOB_CLASS' => $lang['Adr_job_class'], 'L_JOB_ALIGNMENT' => $lang['Adr_job_alignment'], 'L_JOB_ELEMENT' => $lang['Adr_character_element'], 'L_JOB_SALARY' => $lang['Adr_job_salary'], 'L_JOB_SALARY_INTERVALS' => $lang['Adr_job_salary_intervals'], 'L_JOB_DURATION' => $lang['Adr_job_duration'], 'L_JOB_SLOTS' => $lang['Adr_job_slots'], 'L_JOB_SLOTS_MAX' => $lang['Adr_job_slots_max'], 'L_JOB_EXP' => $lang['Adr_job_exp'], 'L_JOB_ITEM_REWARD' => $lang['Adr_job_item_reward'], 'L_JOB_SP_REWARD' => $lang['Adr_job_sp_reward'], 'L_JOB_SHOW_MINE' => $show_all, 'L_JOB_MON_TOTAL' => $lang['Adr_job_mon_total'], 'L_JOB_MON_WON' => $lang['Adr_job_mon_won'], 'L_JOB_ONE_TIME' => $lang['Adr_job_once'], 'L_OH_CRAP_NOTHING' => $lang['Adr_job_nothing_to_show'], 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_SORT_SUBMIT' => $lang['Sort'], 'L_SELECT_CAT' => $lang['Adr_items_select'], 'L_GOTO_PAGE' => $lang['Goto_page'], 'SELECT_CAT' => $select_category, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], (floor($start /$board_config['topics_per_page']) + 1), ceil( $total_items /$board_config['topics_per_page'])), 'S_MODE_SELECT' => $select_sort_mode, 'S_ORDER_SELECT' => $select_sort_order, 'S_JOB_ACTION' => append_sid("adr_jobs.$phpEx"), 'U_JOBS_OFFICE' => append_sid("adr_jobs.$phpEx"), 'U_JOBS_LIST' => append_sid("adr_character_jobs.$phpEx"), 'U_JOB_SHOW_MINE' => ($show_only_mine == '1') ? append_sid("adr_jobs.$phpEx") : append_sid("adr_jobs.$phpEx?show_only_mine=1"), )); include($phpbb_root_path . 'adr/includes/adr_header.'.$phpEx); $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 25, 2007 Author Share Posted November 25, 2007 i need someone to tell me how i would change it right now it calculated jobs by 1 day but if i wanted to change it to 1 hour? <?php /*************************************************************************** * adr_jobs.php * ------------------------ * begin : 09/11/2004 * copyright : Seteo-Bloke * * ***************************************************************************/ define('IN_PHPBB', true); define('IN_ADR_CHARACTER', true); define('IN_ADR_SHOPS', true); $phpbb_root_path = './'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); include_once($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx); include_once($phpbb_root_path . 'adr/includes/adr_functions_jobs.'.$phpEx); include_once($phpbb_root_path . 'adr/language/lang_english/lang_adr_jobs.'.$phpEx); $loc = 'town'; $sub_loc = 'adr_town'; // // Start session management $userdata = session_pagestart($user_ip, PAGE_INDEX); init_userprefs($userdata); // End session management // adr_template_file('adr_jobs_body.tpl'); include($phpbb_root_path . 'includes/page_header.'.$phpEx); // Sorry , only logged users ... if(!$userdata['session_logged_in']){ $redirect = "adr_jobs.$phpEx"; $redirect .= (isset($user_id)) ? '&user_id=' . $user_id : ''; header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true)); } $user_id = $userdata['user_id']; // Get the general config $adr_general = adr_get_general_config(); // Standard checks adr_enable_check(); adr_ban_check($user_id); adr_character_created_check($user_id); // Check jobs are enabled by admin if($adr_general['job_salary_enable'] != '1') adr_previous(Adr_job_closed, adr_town, ''); // Fix values $apply = isset($HTTP_POST_VARS['apply']); $quit = isset($HTTP_POST_VARS['quit']); $show_only_mine = intval($HTTP_GET_VARS['show_only_mine']); // Grab character details $character = adr_get_user_infos($user_id); if($apply) { $apply_id = intval($HTTP_POST_VARS['apply_select']); // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$apply_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job = $db->sql_fetchrow($result); if($job['job_enabled'] != '1') adr_previous(Adr_job_job_disabled_error, 'adr_jobs', ''); // is job enabled? if(($job['job_max_per_user'] == '1') && (in_array($job['job_id'], explode(', ', $character['character_job_completed_id'])))) adr_previous(Adr_job_too_many_applies, 'adr_jobs', ''); // One time jobs only check // Check more than 1 slot available to use if($job['job_slots_available'] < '1'){ $message = sprintf($lang['Adr_job_none_left'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } if((!in_array('0', explode('-', $job['job_race_id']))) && (!in_array($character['character_race'], explode('-', $job['job_race_id'])))) adr_previous(Adr_job_wrong_race, 'adr_jobs', ''); // check race restriction if((!in_array('0', explode('-', $job['job_class_id']))) && (!in_array($character['character_class'], explode('-', $job['job_class_id'])))) adr_previous( Adr_job_wrong_class, 'adr_jobs', '');// check class restriction if((!in_array('0', explode('-', $job['job_alignment_id']))) && (!in_array($character['character_alignment'], explode('-', $job['job_alignment_id'])))) adr_previous( Adr_job_wrong_alignment, 'adr_jobs', '');// check alignment restriction if((!in_array('0', explode('-', $job['job_element_id']))) && (!in_array($character['character_element'], explode('-', $job['job_element_id'])))) adr_previous( Adr_job_wrong_element, 'adr_jobs', '');// check element restriction if(($job['job_level'] > '0') && ($job['job_level'] > $character['character_level'])) adr_previous(Adr_job_wrong_level, 'adr_jobs', ''); // check level restriction if(($job['job_mon_total'] > '0') && ($job['job_mon_total'] > ($character['character_victories'] + $character['character_flees'] + $character['character_defeats']))) adr_previous(Adr_job_mon_total_error, 'adr_jobs', ''); // check total monster battle restriction if(($job['job_mon_won'] > '0') && ($job['job_mon_won'] > $character['character_victories'])) adr_previous(Adr_job_mon_won_error, 'adr_jobs', ''); // check won monster battle restriction // Remove a job slot $dsql = "UPDATE " . ADR_JOB_TABLE . " SET job_slots_available = (job_slots_available - 1) WHERE job_id = '$apply_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Failed updating the job slots' , "", __LINE__, __FILE__, $csql);} // Work out job duration $current_time = time(); $end_days = ($current_time + ($job['job_duration'] *86400)); // Update the job to the character $dsql = "UPDATE " . ADR_CHARACTERS_TABLE . " SET character_job_id = $apply_id, character_job_start = $current_time, character_job_end = $end_days, character_job_last_paid = $current_time, character_job_times_employed = (character_job_times_employed + 1) WHERE character_id = '$user_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Failed updating job to character table' , "", __LINE__, __FILE__, $csql);} $message = sprintf($lang['Adr_job_accept'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } if($quit) { $quit_id = $character['character_job_id']; // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$quit_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job = $db->sql_fetchrow($result); $job_slots = (($job['job_slots_available'] + 1) > $job['job_slots_max']) ? $job['job_slots_max'] : ($job['job_slots_available'] + 1); // Add job slot back $dsql = "UPDATE " . ADR_JOB_TABLE . " SET job_slots_available = '$job_slots' WHERE job_id = '$quit_id'"; if(!($dresult = $db->sql_query($dsql))){ message_die(GENERAL_ERROR, 'Error updating job slots' , "", __LINE__, __FILE__, $csql);} // Update the job to the character $dsql = "UPDATE " . ADR_CHARACTERS_TABLE . " SET character_job_id = 0, character_job_start = 0, character_job_end = 0, character_job_incomplete = (character_job_incomplete + 1) WHERE character_id = '$user_id'"; if ( !($dresult = $db->sql_query($dsql)) ){ message_die(GENERAL_ERROR, 'Error updating character table' , "", __LINE__, __FILE__, $csql);} $message = sprintf($lang['Adr_job_quit'], $job['job_name']); $message .= '<br /><br />'.sprintf($lang['Adr_job_return'], "<a href=\"" . 'adr_jobs.'.$phpEx . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } // Check if user is currently employed & show stats if($character['character_job_id'] != '0'){ $job_id = $character['character_job_id']; // Grab job details $sql = " SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_id = '$job_id'"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);} $job_details = $db->sql_fetchrow($result); $image = ($job_details['job_img'] != '') ? '<img src="adr/images/jobs/'.$job_details['job_img'].'">' : ''; $days_remaining = ceil(($character['character_job_end'] - time()) /86400); $template->assign_block_vars('employed', array( 'EMPLOYED' => $job_details['job_name'], 'EMPLOYED_SALARY' => number_format($job_details['job_salary']), 'EMPLOYED_EARNED' => number_format($character['character_job_earned']), 'EMPLOYED_IMG' => $image, 'EMPLOYED_DAYS_LEFT' => $days_remaining, 'JOB_ID' => $job_id, 'L_EMPLOYED_TIMES' => sprintf($lang['Adr_job_times_employed'] , $character['character_job_times_employed']), )); } else{ $template->assign_block_vars('non_employed', array()); } // Check auth level of user if($userdata['user_level'] == ADMIN) $sql_level = ''; elseif($userdata['user_level'] == MOD) $sql_level = 'AND job_auth_level != 1'; else $sql_level = 'AND job_auth_level = 0'; // START categories & pagination $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; if ( isset($HTTP_GET_VARS['mode2']) || isset($HTTP_POST_VARS['mode2']) ) { $mode2 = ( isset($HTTP_POST_VARS['mode2']) ) ? htmlspecialchars($HTTP_POST_VARS['mode2']) : htmlspecialchars($HTTP_GET_VARS['mode2']); } else { $mode2 = 'itemname'; } if(isset($HTTP_POST_VARS['order'])) { $sort_order = ($HTTP_POST_VARS['order'] == 'ASC') ? 'ASC' : 'DESC'; } else if(isset($HTTP_GET_VARS['order'])) { $sort_order = ($HTTP_GET_VARS['order'] == 'ASC') ? 'ASC' : 'DESC'; } else { $sort_order = 'ASC'; } if ( isset($HTTP_GET_VARS['cat']) || isset($HTTP_POST_VARS['cat']) ) { $cat = ( isset($HTTP_POST_VARS['cat']) ) ? htmlspecialchars($HTTP_POST_VARS['cat']) : htmlspecialchars( $HTTP_GET_VARS['cat']); } else { $cat = 0; } $cat_sql = ( $cat ) ? 'AND job_name = '.$cat : ''; $mode_types_text = array($lang['Adr_job_name'], $lang['Adr_job_level'], $lang['Adr_job_slots'], $lang['Adr_job_salary']); $mode_types = array('name', 'level', 'job_slots_available', 'job_salary'); $select_sort_mode = '<select name="mode2">'; for($i = 0; $i < count($mode_types_text); $i++) { $selected = ( $mode2 == $mode_types[$i] ) ? ' selected="selected"' : ''; $select_sort_mode .= '<option value="' . $mode_types[$i] . '"' . $selected . '>' . $mode_types_text[$i] . '</option>'; } $select_sort_mode .= '</select>'; $select_sort_order = '<select name="order">'; if($sort_order == 'ASC') { $select_sort_order .= '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>'; } else { $select_sort_order .= '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>'; } $select_sort_order .= '</select>'; switch( $mode2 ) { case 'name': $order_by = "job_name $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'level': $order_by = "job_level $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'job_slots_available': $order_by = "job_slots_available $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; case 'job_salary': $order_by = "job_salary $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; default: $order_by = "job_level $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; } if($show_only_mine == '1'){ // Make sure finished job ids is never empty otherwise == sql error $character['character_job_completed_id'] = ($character['character_job_completed_id'] == '') ? '0' : $character['character_job_completed_id']; $sql = "SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_enabled = '1' AND (job_alignment_id LIKE '%".$character['character_alignment']."%' OR job_alignment_id = '0') AND (job_class_id LIKE '%".$character['character_class']."%' OR job_class_id = '0') AND (job_element_id LIKE '%".$character['character_element']."%' OR job_element_id = '0') AND (job_race_id LIKE '%".$character['character_race']."%' OR job_race_id = '0') AND job_level <= '".$character['character_level']."' AND job_mon_total <= '".($character['character_victories'] + $character['character_defeats'] + $character['character_flees'])."' AND job_mon_won <= '".$character['character_victories']."' AND job_slots_available > '0' AND (job_id NOT IN (".$character['character_job_completed_id'].") OR job_max_per_user = '0') $sql_level $cat_sql ORDER BY $order_by"; } else{ $sql = "SELECT * FROM " . ADR_JOB_TABLE . " WHERE job_enabled = '1' $sql_level $cat_sql ORDER BY $order_by"; } if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Error showing all job list' , "", __LINE__, __FILE__, $sql);} $jobs = $db->sql_fetchrowset($result); for($i = 0; $i < count($jobs); $i++) { $row_color = (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2']; $row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2']; $image = ($jobs[$i]['job_img'] != '') ? '<img src="adr/images/jobs/'.$jobs[$i]['job_img'].'">' : '' ; $interval_lang = ($jobs[$i]['job_payment_intervals'] > '1') ? $lang['Adr_job_days'] : $lang['Adr_job_day']; $duration_lang = ($jobs[$i]['job_duration'] > '1') ? $lang['Adr_job_days'] : $lang['Adr_job_day']; $template->assign_block_vars('jobs', array( 'ROW_CLASS' => $row_class, 'JOB_ID' => $jobs[$i]['job_id'], 'JOB_IMG' => $image, 'JOB_NAME' => adr_get_lang($jobs[$i]['job_name']), 'JOB_DESC' => adr_get_lang($jobs[$i]['job_desc']), 'JOB_LEVEL' => $jobs[$i]['job_level'], 'JOB_ITEM_REWARD' => adr_job_make_array_items($jobs[$i]['job_item_reward_id']), 'JOB_CLASS' => adr_job_make_array_class($jobs[$i]['job_class_id']), 'JOB_RACE' => adr_job_make_array_race($jobs[$i]['job_race_id']), 'JOB_ALIGNMENT' => adr_job_make_array_alignment($jobs[$i]['job_alignment_id']), 'JOB_ELEMENT' => adr_job_make_array_element($jobs[$i]['job_element_id']), 'JOB_SALARY' => number_format($jobs[$i]['job_salary']), 'JOB_SALARY_INT' => number_format($jobs[$i]['job_payment_intervals']), 'JOB_MON_TOTAL' => number_format($jobs[$i]['job_mon_total']), 'JOB_MON_WON' => number_format($jobs[$i]['job_mon_won']), 'JOB_DURATION' => $jobs[$i]['job_duration'], 'JOB_SLOTS' => ($jobs[$i]['job_slots_available'] < '1') ? '<font color="#FF0000">'.$jobs[$i]['job_slots_available'].'</font>' : $jobs[$i]['job_slots_available'], 'JOB_SLOTS_MAX' => $jobs[$i]['job_slots_max'], 'JOB_EXP' => number_format($jobs[$i]['job_exp']), 'JOB_SP_REWARD' => number_format($jobs[$i]['job_sp_reward']), 'L_JOB_DURA_LANG' => $duration_lang, 'L_JOB_INT_LANG' => $interval_lang, )); // Show additional restrictions, if req. if($jobs[$i]['job_mon_total'] > '0') $template->assign_block_vars('jobs.mon_total', array()); if($jobs[$i]['job_mon_won'] > '0') $template->assign_block_vars('jobs.mon_won', array()); if($jobs[$i]['job_max_per_user'] == '1') $template->assign_block_vars('jobs.one_time', array()); // Show employment block if($jobs[$i]['job_max_per_user'] === '0'){ if(($character['character_job_id'] === '0') && ($jobs[$i]['job_slots_available'] > '0')) $template->assign_block_vars('jobs.slots', array()); else $template->assign_block_vars('jobs.no_slots', array()); } else{ if(($character['character_job_id'] === '0') && ($jobs[$i]['job_slots_available'] > '0') && (!in_array($jobs[$i]['job_id'], explode('-', $character['character_job_completed_id'])))) $template->assign_block_vars('jobs.slots', array()); else $template->assign_block_vars('jobs.no_slots', array()); } } // If no results then say so to user to stop confusion if(count($jobs) < '1') $template->assign_block_vars('oh_crap_nothing', array());; // Show apply if not employed if($character['character_job_id'] === '0') $template->assign_block_vars('apply', array()); // Check auth level of user if($userdata['user_level'] == ADMIN) $sql_total_level = ''; elseif($userdata['user_level'] == MOD) $sql_total_level = 'WHERE job_auth_level != 1'; else $sql_total_level = 'WHERE job_auth_level = 0'; // START pagination $sql = "SELECT count(*) AS total FROM " . ADR_JOB_TABLE . " $sql_total_level"; if(!($result = $db->sql_query($sql))){ message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);} if($total = $db->sql_fetchrow($result)){ $total_items = $total['total']; $pagination = generate_pagination("adr_jobs.$phpEx?mode2=$mode2&order=$sort_order&cat=$cat", $total_items, $board_config['topics_per_page'], $start). ' '; } // END pagination // Show all? $show_all = ($show_only_mine == '1') ? $lang['Adr_job_show_all'] : $lang['Adr_job_show_mine']; $template->assign_vars(array( 'POINTS' => $board_config['points_name'], 'EMPLOYED_TOTAL' => number_format($character['character_job_total_earned']), 'EMPLOYED_TIMES' => $character['character_job_times_employed'], 'EMPLOYED_COMPLETED' => $character['character_job_completed'], 'EMPLOYED_INCOMPLETE' => $character['character_job_incomplete'], 'L_JOBS_OFFICE' => $lang['Adr_job_office'], 'L_JOBS_LIST' => $lang['Adr_job_list'], 'L_EMPLOYED_DAYS_LEFT' => $lang['Adr_job_days_remaining'], 'L_EMPLOYED_TIMES' => $lang['Adr_job_times_employed'], 'L_PERSONAL_STATS' => $lang['Adr_job_personal_stats'], 'L_NON_EMPLOYED' => $lang['Adr_job_non_employed'], 'L_EMPLOYED' => $lang['Adr_job_employed'], 'L_EMPLOYED_TOTAL' => $lang['Adr_job_employed_total_earned'], 'L_EMPLOYED_SALARY' => $lang['Adr_job_employed_salary'], 'L_EMPLOYED_EARNED' => $lang['Adr_job_employed_total'], 'L_EMPLOYED_COMPLETED' => $lang['Adr_job_employed_completed'], 'L_EMPLOYED_INCOMPLETE' => $lang['Adr_job_employed_incomplete'], 'L_JOB_TITLE' => $lang['Adr_job_title'], 'L_JOB_NAME' => $lang['Adr_job_name'], 'L_JOB_DESC' => $lang['Adr_job_desc'], 'L_JOB_LEVEL' => $lang['Adr_job_level'], 'L_JOB_RACE' => $lang['Adr_job_race'], 'L_JOB_CLASS' => $lang['Adr_job_class'], 'L_JOB_ALIGNMENT' => $lang['Adr_job_alignment'], 'L_JOB_ELEMENT' => $lang['Adr_character_element'], 'L_JOB_SALARY' => $lang['Adr_job_salary'], 'L_JOB_SALARY_INTERVALS' => $lang['Adr_job_salary_intervals'], 'L_JOB_DURATION' => $lang['Adr_job_duration'], 'L_JOB_SLOTS' => $lang['Adr_job_slots'], 'L_JOB_SLOTS_MAX' => $lang['Adr_job_slots_max'], 'L_JOB_EXP' => $lang['Adr_job_exp'], 'L_JOB_ITEM_REWARD' => $lang['Adr_job_item_reward'], 'L_JOB_SP_REWARD' => $lang['Adr_job_sp_reward'], 'L_JOB_SHOW_MINE' => $show_all, 'L_JOB_MON_TOTAL' => $lang['Adr_job_mon_total'], 'L_JOB_MON_WON' => $lang['Adr_job_mon_won'], 'L_JOB_ONE_TIME' => $lang['Adr_job_once'], 'L_OH_CRAP_NOTHING' => $lang['Adr_job_nothing_to_show'], 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_SORT_SUBMIT' => $lang['Sort'], 'L_SELECT_CAT' => $lang['Adr_items_select'], 'L_GOTO_PAGE' => $lang['Goto_page'], 'SELECT_CAT' => $select_category, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], (floor($start /$board_config['topics_per_page']) + 1), ceil( $total_items /$board_config['topics_per_page'])), 'S_MODE_SELECT' => $select_sort_mode, 'S_ORDER_SELECT' => $select_sort_order, 'S_JOB_ACTION' => append_sid("adr_jobs.$phpEx"), 'U_JOBS_OFFICE' => append_sid("adr_jobs.$phpEx"), 'U_JOBS_LIST' => append_sid("adr_character_jobs.$phpEx"), 'U_JOB_SHOW_MINE' => ($show_only_mine == '1') ? append_sid("adr_jobs.$phpEx") : append_sid("adr_jobs.$phpEx?show_only_mine=1"), )); include($phpbb_root_path . 'adr/includes/adr_header.'.$phpEx); $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 25, 2007 Author Share Posted November 25, 2007 if anyone can change this from remaining days to remaining hours id be glad the zip file is below. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.