public function display_robbery() { // Grab some vars $action = $this->request->variable('action', ''); $id = $this->request->variable('id', 0); // Read out config data $sql_array = array('SELECT' => 'config_name, config_value', 'FROM' => array($this->points_config_table => 'c')); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $points_config[$row['config_name']] = $row['config_value']; } $this->db->sql_freeresult($result); $this->template->assign_vars(array_change_key_case($points_config, CASE_UPPER)); // Read out values data $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_values_table => 'v')); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_values = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Form key add_form_key('acp_points'); $this->template->assign_vars(array('BASE' => $this->u_action)); $submit = $this->request->variable('submit', ''); $robbery_data = $errors = array(); if ($submit) { if (!check_form_key('acp_points')) { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } // Values for phpbb_points_config $robbery_enable = $this->request->variable('robbery_enable', 0); $robbery_notify = $this->request->variable('robbery_notify', 0); // Values for phpbb_points_values $robbery_chance = round($this->request->variable('robbery_chance', 0.0), 2); $robbery_loose = round($this->request->variable('robbery_loose', 0.0), 2); $robbery_max_rob = round($this->request->variable('robbery_max_rob', 0.0), 2); // Check, if entered robbery chance is 0 or below if ($robbery_chance <= 0) { trigger_error($this->user->lang['ROBBERY_CHANCE_MINIMUM'] . adm_back_link($this->u_action), E_USER_WARNING); } // Check entered robbery chance - has to be max 100 if ($robbery_chance > 100) { trigger_error($this->user->lang['ROBBERY_CHANCE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); } // Check, if entered robbery loose is 0 or below if ($robbery_loose <= 0) { trigger_error($this->user->lang['ROBBERY_LOOSE_MINIMUM'] . adm_back_link($this->u_action), E_USER_WARNING); } // Check entered robbery loose - has to be max 100 if ($robbery_loose > 100) { trigger_error($this->user->lang['ROBBERY_LOOSE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); } // Check, if entered robbery is 0 or below if ($robbery_max_rob <= 0) { trigger_error($this->user->lang['ROBBERY_MAX_ROB_MINIMUM'] . adm_back_link($this->u_action), E_USER_WARNING); } // Check entered robbery max rob value - has to be max 100 if ($robbery_max_rob > 100) { trigger_error($this->user->lang['ROBBERY_MAX_ROB_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); } // Update values in phpbb_points_config if ($robbery_enable != $points_config['robbery_enable']) { $this->functions_points->set_points_config('robbery_enable', $robbery_enable); } if ($robbery_notify != $points_config['robbery_notify']) { $this->functions_points->set_points_config('robbery_notify', $robbery_notify); } // Update values in phpbb_points_values $this->functions_points->set_points_values('robbery_chance', $robbery_chance); $this->functions_points->set_points_values('robbery_loose', $robbery_loose); $this->functions_points->set_points_values('robbery_max_rob', $robbery_max_rob); // Add logs $this->log->add('admin', $this->user->data['user_id'], $this->user->data['user_ip'], 'LOG_MOD_POINTS_ROBBERY'); trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } $this->template->assign_vars(array('ROBBERY_CHANCE' => $points_values['robbery_chance'], 'ROBBERY_LOOSE' => $points_values['robbery_loose'], 'ROBBERY_MAX_ROB' => $points_values['robbery_max_rob'], 'S_ROBBERY_ENABLE' => $points_config['robbery_enable'] ? true : false, 'S_ROBBERY_NOTIFY' => $points_config['robbery_notify'] ? true : false, 'S_ROBBERY' => true, 'U_ACTION' => $this->u_action)); }