function main($id, $mode) { global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $check_auth; $adm_points = request_var('adm_points', false); $u_id = request_var('user_id', 0); $post_id = request_var('post_id', 0); if (empty($u_id)) { $message = $user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $user_id = $u_id; add_form_key('bank_edit'); if ($adm_points != false && ($auth->acl_get('a_points') || $auth->acl_get('m_chg_bank'))) { $template->assign_block_vars('administer_bank', array()); if (isset($_POST['submit'])) { if (!check_form_key('bank_edit')) { trigger_error('FORM_INVALID'); } $new_points = round(request_var('points', 0.0), 2); set_bank($u_id, $new_points); $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $points_user = $db->sql_fetchrow($result); add_log('admin', 'LOG_MOD_BANK', $points_user['username']); $message = $post_id ? sprintf($user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>'); trigger_error(sprintf($user->lang['EDIT_POINTS_SET'], $config['points_name']) . $message); } else { $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(POINTS_BANK_TABLE => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (empty($u_id)) { $message = $user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id)); $template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf(number_format_points($row['holding'])), 'POINTS_NAME' => $config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($user->lang['EDIT_BANK_MODIFY'], $config['points_name']), 'L_P_BANK_TITLE' => sprintf($user->lang['EDIT_P_BANK_TITLE'], $config['points_name']), 'L_USERNAME' => $user->lang['USERNAME'], 'L_SET_AMOUNT' => $user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $u_id), 'S_ACTION' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit&adm_points=1"), 'S_HIDDEN_FIELDS' => $hidden_fields)); } } else { $message = $user->lang['NOT_AUTHORISED']; trigger_error($message); } // Generate the page page_header($user->lang['EDIT_POINTS_ADMIN']); // Generate the page template $template->set_filenames(array('body' => 'points/points_bank_edit.html')); page_footer(); }
function main($id, $mode) { global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $checked_user, $check_auth; print_r('test'); // Select user's bank holding $sql_array = array('SELECT' => '*', 'FROM' => array(POINTS_BANK_TABLE => 'b'), 'WHERE' => 'user_id = ' . (int) $user->data['user_id']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); // Select user's lottery tickets $viewer_total_tickets = ''; if ($user->data['user_id'] != ANONYMOUS) { $sql_array = array('SELECT' => 'COUNT(ticket_id) AS num_tickets', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 't'), 'WHERE' => 'user_id = ' . (int) $user->data['user_id']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $viewer_total_tickets = (int) $db->sql_fetchfield('num_tickets'); $db->sql_freeresult($result); } // Generate the page header page_header(sprintf($user->lang['POINTS_TITLE_MAIN'], $config['points_name'])); $user_name = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']); // Generate some language stuff, dependig on the fact, if user has a bank account or not if ($row['user_id'] != $user->data['user_id'] || $row['holding'] < 1) { $template->assign_vars(array('L_MAIN_ON_HAND' => sprintf($user->lang['MAIN_ON_HAND'], number_format_points($checked_user['user_points']), $config['points_name']), 'L_MAIN_HELLO_USERNAME' => sprintf($user->lang['MAIN_HELLO_USERNAME'], $user_name), 'L_MAIN_LOTTERY_TICKETS' => sprintf($user->lang['MAIN_LOTTERY_TICKETS'], $viewer_total_tickets))); } else { $template->assign_vars(array('L_MAIN_ON_HAND' => $auth->acl_get('u_use_points') ? sprintf($user->lang['MAIN_ON_HAND'], number_format_points($checked_user['user_points']), $config['points_name']) : '', 'L_MAIN_HELLO_USERNAME' => sprintf($user->lang['MAIN_HELLO_USERNAME'], $user_name), 'L_MAIN_LOTTERY_TICKETS' => $auth->acl_get('u_use_lottery') ? sprintf($user->lang['MAIN_LOTTERY_TICKETS'], $viewer_total_tickets) : '')); if ($auth->acl_get('u_use_bank')) { $template->assign_block_vars('has_bank_account', array('L_MAIN_BANK_HAVE' => sprintf($user->lang['MAIN_BANK_HAVE'], number_format_points($row['holding']), $config['points_name']))); } } // Generate most rich users $limit = $points_values['number_show_top_points']; $sql_array = array('SELECT' => 'user_id, username, user_colour, user_points', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_points > 0', 'ORDER_BY' => 'user_points DESC, username_clean ASC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $limit); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('points', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf(number_format_points($row['user_points'])))); } $db->sql_freeresult($result); $template->assign_vars(array('LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'S_DISPLAY_INDEX' => $points_values['number_show_top_points'] > 0 ? true : false, 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'))); // Generate the page template $template->set_filenames(array('body' => 'points/points_main.html')); page_footer(); }
} $message = $user->lang['ROBBERY_BAD'] . '<br /><br />' . $robbery_usage_info . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } } $template->assign_vars(array('USER_NAME' => get_username_string('full', $checked_user['user_id'], $points_config['username'], $points_config['user_colour']), 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $hidden_fields)); } // If Robbery PN is enabled, show option to disable for the users if ($points_config['robbery_sendpm']) { if (isset($_POST['robbery_pm'])) { if (!check_form_key('robbery_attack')) { trigger_error('FORM_INVALID'); } $user_robbery_pm = request_var('user_robbery_pm', 0); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_robbery_pm = ' . $user_robbery_pm . ' WHERE user_id = ' . (int) $user->data['user_id']; $result = $db->sql_query($sql); $redirect_url = append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"); meta_refresh(5, $redirect_url); $message = $user->lang['ROBBERY_PM_CHANGE'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); $template->assign_vars(array('USER_ROBBERY_PM' => $user->data['user_robbery_pm'], 'U_ACTION' => $this->u_action)); } } $template->assign_vars(array('S_ROBBERY_PM' => $points_config['robbery_sendpm'], 'USER_POINTS' => sprintf(number_format_points($pointsa)), 'POINTS_NAME' => $config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'L_ROBBERY_CHANCE' => sprintf($user->lang['ROBBERY_CHANCE'], number_format_points($points_values['robbery_max_rob']), number_format_points($points_values['robbery_chance'])), 'L_ROBBERY_AMOUNTLOSE' => sprintf($user->lang['ROBBERY_AMOUNTLOSE'], number_format_points($points_values['robbery_loose'])), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=searchuser&form=post&field=username&select_single=true"), 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'))); // Generate the page page_header($user->lang['POINTS_ROBBERY']); // Generate the page template $template->set_filenames(array('body' => 'points_robbery.html')); page_footer();
function main($id, $mode) { global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $checked_user, $check_auth; add_form_key('transfer_user'); // Grab the message variable $message = request_var('comment', '', true); // Check, if transferring is allowed if (!$points_config['transfer_enable']) { $message = $user->lang['TRANSFER_REASON_TRANSFER'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user is allowed to use the transfer module if (!$auth->acl_get('u_use_transfer')) { $message = $user->lang['NOT_AUTHORISED'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Add part to bar $template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'FORUM_NAME' => sprintf($user->lang['TRANSFER_TITLE'], $config['points_name']))); if (isset($_POST['submit'])) { if (!check_form_key('transfer_user')) { trigger_error('FORM_INVALID'); } // Grab need variables for the transfer $am = round(request_var('amount', 0.0), 2); $comment = request_var('comment', '', true); $username1 = request_var('username', '', true); $username = strtolower($username1); // Select the user data to transfer to $sql = 'SELECT * FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'\n\t\t\t\t\tAND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; $result = $db->sql_query($sql); $transfer_user = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($transfer_user == NULL) { $message = $user->lang['TRANSFER_NO_USER_RETURN'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Select the old user_points from user_id to transfer to $sql_array = array('SELECT' => 'user_points', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $transfer_user['user_id']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $transfer_user_old_points = (int) $db->sql_fetchfield('user_points'); $db->sql_freeresult($result); // Check, if the sender has enough cash if ($user->data['user_points'] < $am) { $message = sprintf($user->lang['TRANSFER_REASON_MINPOINTS'], $config['points_name']) . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if the amount is 0 or below if ($am <= 0) { $message = sprintf($user->lang['TRANSFER_REASON_UNDERZERO'], $config['points_name']) . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Check, if user is trying to send to himself if ($user->data['user_id'] == $transfer_user['user_id']) { $message = sprintf($user->lang['TRANSFER_REASON_YOURSELF'], $config['points_name']) . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } // Add cash to receiver add_points($transfer_user['user_id'], $am); // Remove cash from sender substract_points($user->data['user_id'], $am); // Get current time for log $current_time = time(); // Add transferring information to the log $text = utf8_normalize_nfc($message); $sql = 'INSERT INTO ' . POINTS_LOG_TABLE . ' ' . $db->sql_build_array('INSERT', array('point_send' => (int) $user->data['user_id'], 'point_recv' => (int) $transfer_user['user_id'], 'point_amount' => $am, 'point_sendold' => $user->data['user_points'], 'point_recvold' => $transfer_user_old_points, 'point_comment' => $text, 'point_type' => '1', 'point_date' => $current_time)); $db->sql_query($sql); // Send pm to receiver, if PM is enabled if (!$points_config['transfer_pm_enable'] == 0 && $transfer_user['user_allow_pm']) { // Select the receiver language $transfer_user['user_lang'] = file_exists($phpbb_root_path . 'language/' . $transfer_user['user_lang'] . "/mods/points.{$phpEx}") ? $transfer_user['user_lang'] : $config['default_lang']; // load receivers language include $phpbb_root_path . 'language/' . basename($transfer_user['user_lang']) . "/mods/points.{$phpEx}"; $points_name = $config['points_name']; $comment = $db->sql_escape($comment); $pm_subject = utf8_normalize_nfc(sprintf($lang['TRANSFER_PM_SUBJECT'])); $pm_text = utf8_normalize_nfc(sprintf($lang['TRANSFER_PM_BODY'], $am, $points_name, $text)); $poll = $uid = $bitfield = $options = ''; generate_text_for_storage($pm_subject, $uid, $bitfield, $options, false, false, false); generate_text_for_storage($pm_text, $uid, $bitfield, $options, true, true, true); $pm_data = array('address_list' => array('u' => array($transfer_user['user_id'] => 'to')), 'from_user_id' => $user->data['user_id'], 'from_username' => $user->data['username'], 'icon_id' => 0, 'from_user_ip' => '', 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $pm_text, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid); submit_pm('post', $pm_subject, $pm_data, false); } // Change $username back to regular username $sql_array = array('SELECT' => 'username', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $transfer_user['user_id']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $show_user = $db->sql_fetchfield('username'); $db->sql_freeresult($result); // Add log entry to inform the admin too add_log('user', $user->data['username'], 'LOG_USER_TRANSFER', $user->data['username'], $show_user, number_format_points($am), $config['points_name']); // Show the successful transfer message $message = sprintf($user->lang['TRANSFER_REASON_TRANSUCC'], number_format_points($am), $config['points_name'], $show_user) . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); $template->assign_vars(array('U_ACTION' => $this->u_action)); } $template->assign_vars(array('USER_POINTS' => sprintf(number_format_points($checked_user['user_points'])), 'POINTS_NAME' => $config['points_name'], 'POINTS_COMMENTS' => $points_config['comments_enable'] ? true : false, 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'L_TRANSFER_DESCRIPTION' => sprintf($user->lang['TRANSFER_DESCRIPTION'], $config['points_name']), 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=searchuser&form=post&field=username&select_single=true"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'), 'S_ALLOW_SEND_PM' => $auth->acl_get('u_sendpm'))); // Generate the page page_header(sprintf($user->lang['TRANSFER_TITLE'], $config['points_name'])); // Generate the page template $template->set_filenames(array('body' => 'points/points_transfer_user.html')); page_footer(); }
public function viewtopic_template_adds($vars) { $points_config = $this->driver->get('points_config'); $poster_id = $vars['poster_id']; //this user_cache variable is a bag of worms since it isn't holding the correct points values. $user_cache[$poster_id] = $vars['row']; $templ = $this->template->assign_vars(array('P_NAME' => $this->config['points_name'], 'USE_POINTS' => $this->config['points_enable'], 'USE_IMAGES_POINTS' => $points_config['images_topic_enable'], 'USE_BANK' => $points_config['bank_enable'])); $post_row = array('POSTER_POINTS' => number_format_points($user_cache[$poster_id]['points']), 'POSTER_LOCK' => $user_cache[$poster_id]['points_lock'], 'POSTER_BANK_LOCK' => $user_cache[$poster_id]['bank_lock'], 'USER_ID' => $poster_id, 'BANK_GOLD' => number_format_points($holding[$poster_id]), 'BANK_ACCOUNT' => $user_cache[$poster_id]['bank_account'], 'L_MOD_USER_POINTS' => $this->auth->acl_get('a_points') || $this->auth->acl_get('m_chg_points') ? sprintf($user->lang['POINTS_MODIFY']) : '', 'U_POINTS_MODIFY' => $this->auth->acl_get('a_points') || $this->auth->acl_get('m_chg_points') ? append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=points_edit&user_id=" . $poster_id . "&adm_points=1&post_id=" . $row['post_id']) : '', 'L_BANK_USER_POINTS' => $this->auth->acl_get('a_points') || $this->auth->acl_get('m_chg_bank') ? sprintf($user->lang['POINTS_MODIFY']) : '', 'U_BANK_MODIFY' => $this->auth->acl_get('a_points') || $this->auth->acl_get('m_chg_bank') ? append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit&user_id=" . $poster_id . "&adm_points=1&post_id=" . $row['post_id']) : '', 'L_DONATE' => $this->auth->acl_get('u_use_transfer') ? sprintf($user->lang['POINTS_DONATE']) : '', 'U_POINTS_DONATE' => $this->auth->acl_get('u_use_transfer') ? append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer&i=" . $poster_id . "&adm_points=1&post_id=" . $row['post_id']) : '', 'S_IS_OWN_POST' => $poster_id == $user->data['user_id'] ? true : false); $vari = array($templ, $post_row); return $vari; }
/** * Run Lottery */ function run_lottery() { global $db, $config, $user, $table_prefix, $phpbb_root_path, $phpEx; define('POINTS_LOTTERY_HISTORY_TABLE', $table_prefix . 'points_lottery_history'); define('POINTS_VALUES_TABLE', $table_prefix . 'points_values'); define('POINTS_LOTTERY_TICKETS_TABLE', $table_prefix . 'points_lottery_tickets'); $current_time = time(); // Count number of tickets $sql_array = array('SELECT' => 'COUNT(ticket_id) AS num_tickets', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 'l')); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $total_tickets = (int) $db->sql_fetchfield('num_tickets'); $db->sql_freeresult($result); // Select a random user from tickets table switch ($db->sql_layer) { case 'postgres': $order_by = 'RANDOM()'; break; case 'mssql': case 'mssql_odbc': $order_by = 'NEWID()'; break; default: $order_by = 'RAND()'; break; } $sql_array = array('SELECT' => '*', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 'l'), 'ORDER_BY' => $order_by); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, 1); $random_user_by_tickets = (int) $db->sql_fetchfield('user_id'); $db->sql_freeresult($result); if ($total_tickets > 0) { // Genarate a random number $rand_base = $points_values['lottery_chance']; $rand_value = rand(0, 100); // Decide, if the user really wins if ($rand_value <= $rand_base) { $winning_number = $random_user_by_tickets; // Select a winner from ticket table $sql_array = array('SELECT' => '*', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $winning_number); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $winner = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Check if lottery is enabled and prepare winner informations if ($points_config['lottery_enable'] != 0) { // Select the receiver language $winner['user_lang'] = file_exists($phpbb_root_path . 'language/' . $winner['user_lang'] . "/mods/points.{$phpEx}") ? $winner['user_lang'] : $config['default_lang']; // load receivers language include $phpbb_root_path . 'language/' . basename($winner['user_lang']) . "/mods/points.{$phpEx}"; $winnings_update = $winner['user_points'] + $points_values['lottery_jackpot']; set_points($winner['user_id'], $winnings_update); $winner_notification = sprintf(number_format_points($points_values['lottery_jackpot'])) . ' ' . $config['points_name'] . ' '; $winner_deposit = $lang['LOTTERY_PM_CASH_ENABLED']; $amount_won = $points_values['lottery_jackpot']; } else { $winner_notification = ''; $winner_deposit = ''; $amount_won = ''; } // Update previous winner information $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_prev_winner = "' . $db->sql_escape($winner['username']) . '", lottery_prev_winner_id = ' . intval($winner['user_id']); $db->sql_query($sql); // Check, if user wants to be informed by PM if ($winner['user_allow_pm'] == 1) { $sql_array = array('SELECT' => '*', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $points_values['lottery_pm_from']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $pm_sender = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Notify the lucky winner by PM $pm_subject = utf8_normalize_nfc($lang['LOTTERY_PM_SUBJECT']); $pm_text = utf8_normalize_nfc(sprintf($lang['LOTTERY_PM_BODY'], $winner_notification, $winner_deposit)); $poll = $uid = $bitfield = $options = ''; generate_text_for_storage($pm_subject, $uid, $bitfield, $options, false, false, false); generate_text_for_storage($pm_text, $uid, $bitfield, $options, true, true, true); $pm_data = array('address_list' => array('u' => array($winner['user_id'] => 'to')), 'from_user_id' => $points_values['lottery_pm_from'] == 0 ? $winner['user_id'] : $pm_sender['user_id'], 'from_username' => $points_values['lottery_pm_from'] == 0 ? $user->lang['LOTTERY_PM_COMMISION'] : $pm_sender['username'], 'icon_id' => 0, 'from_user_ip' => '', 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $pm_text, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid); submit_pm('post', $pm_subject, $pm_data, false); } // Add new winner to lottery history $sql = 'INSERT INTO ' . POINTS_LOTTERY_HISTORY_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $winner['user_id'], 'user_name' => $winner['username'], 'time' => $current_time, 'amount' => $points_values['lottery_jackpot'])); $db->sql_query($sql); // Update winners total $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_winners_total = lottery_winners_total + 1'; $db->sql_query($sql); // Reset jackpot $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_jackpot = lottery_base_amount'; $db->sql_query($sql); } else { $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_jackpot = lottery_jackpot + lottery_base_amount'; $db->sql_query($sql); $no_winner = 0; $sql = 'INSERT INTO ' . POINTS_LOTTERY_HISTORY_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => 0, 'user_name' => $no_winner, 'time' => $current_time, 'amount' => 0)); $db->sql_query($sql); // Update previous winner information $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_prev_winner = "' . $no_winner . '"'; $db->sql_query($sql); $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_prev_winner_id = 0'; $db->sql_query($sql); } } // Reset lottery // Delete all tickets $sql = 'DELETE FROM ' . POINTS_LOTTERY_TICKETS_TABLE; $db->sql_query($sql); // Reset last draw time $check_time = $points_values['lottery_last_draw_time'] + $points_values['lottery_draw_period']; $current_time = time(); if ($current_time > $check_time) { //this will *near* infinite loop if the check_time is significantly far behind the current time! while ($check_time < $current_time) { $check_time = $check_time + $points_values['lottery_draw_period']; $check_time++; } if ($check_time > $current_time) { $check_time = $check_time - $points_values['lottery_draw_period']; $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_last_draw_time = ' . $check_time; $db->sql_query($sql); } } else { $sql = 'UPDATE ' . POINTS_VALUES_TABLE . ' SET lottery_last_draw_time = lottery_last_draw_time + lottery_draw_period'; $db->sql_query($sql); } }
$sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Select the receiver language $user_row['user_lang'] = file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mods/points.{$phpEx}") ? $user_row['user_lang'] : $config['default_lang']; // load receivers language include $phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mods/points.{$phpEx}"; $points_name = $config['points_name']; $comment = $db->sql_escape($comment); $pm_subject = utf8_normalize_nfc(sprintf($lang['TRANSFER_PM_SUBJECT'])); $pm_text = utf8_normalize_nfc(sprintf($lang['TRANSFER_PM_BODY'], $am, $points_name, $text)); $poll = $uid = $bitfield = $options = ''; generate_text_for_storage($pm_subject, $uid, $bitfield, $options, false, false, false); generate_text_for_storage($pm_text, $uid, $bitfield, $options, true, true, true); $pm_data = array('address_list' => array('u' => array($checked_user['user_id'] => 'to')), 'from_user_id' => $user->data['user_id'], 'from_username' => $user->data['username'], 'icon_id' => 0, 'from_user_ip' => '', 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $pm_text, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid); submit_pm('post', $pm_subject, $pm_data, false); } // Add log entry to inform the admin too add_log('user', $user->data['username'], 'LOG_USER_TRANSFER', $user->data['username'], $checked_user['username'], number_format_points($am), $config['points_name']); $message = sprintf($user->lang['TRANSFER_REASON_TRANSUCC'], number_format_points($am), $config['points_name'], $checked_user['username']) . '<br /><br />' . ($post_id ? sprintf($user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>')); trigger_error($message); $template->assign_vars(array('U_ACTION' => $this->u_action)); } $username_full = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']); $template->assign_vars(array('L_TRANSFER_DESCRIPTION' => sprintf($user->lang['TRANSFER_DESCRIPTION'], $config['points_name']), 'POINTS_NAME' => $config['points_name'], 'POINTS_COMMENTS' => $points_config['comments_enable'] ? true : false, 'U_TRANSFER_NAME' => sprintf($user->lang['TRANSFER_TO_NAME'], $username_full, $config['points_name']), 'S_ALLOW_SEND_PM' => $auth->acl_get('u_sendpm'))); // Generate the page page_header(sprintf($user->lang['TRANSFER_TITLE'], $config['points_name'])); // Generate the page template $template->set_filenames(array('body' => 'points_transfer.html')); page_footer();
$username_colored = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); } // Check, if previous winner is a user if ($points_values['lottery_prev_winner_id'] != 0) { $link_member = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $points_values['lottery_prev_winner_id']); } else { $link_member = ''; } // Select the total number of tickets $sql_array = array('SELECT' => 'COUNT(ticket_id) AS no_of_tickets', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 't')); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $no_of_tickets = $row['no_of_tickets']; $db->sql_freeresult($result); // Select the total number of players $sql_array = array('SELECT' => 'user_id', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 't')); $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_array); $result = $db->sql_query($sql); $no_of_players = 0; while ($row = $db->sql_fetchrow($result)) { $no_of_players += 1; } $db->sql_freeresult($result); $template->assign_vars(array('JACKPOT' => sprintf(number_format_points($points_values['lottery_jackpot']), $config['points_name']), 'POINTS_NAME' => $config['points_name'], 'TICKET_COST' => sprintf(number_format_points($points_values['lottery_ticket_cost'])), 'PREVIOUS_WINNER' => $username_colored, 'NEXT_DRAWING' => $user->format_date($points_values['lottery_last_draw_time'] + $points_values['lottery_draw_period'], false, true), 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'VIEWER_TICKETS_TOTAL' => $viewer_total_tickets, 'LOTTERY_TICKETS' => $no_of_tickets, 'LOTTERY_PLAYERS' => $no_of_players, 'MAX_TICKETS' => $points_values['lottery_max_tickets'], 'S_PURCHASE_SINGLE' => $viewer_total_tickets == 0 && $points_config['lottery_multi_ticket_enable'] == 0 && $points_config['lottery_enable'] == 1 ? true : false, 'S_PURCHASE_MULTI' => $viewer_total_tickets < $points_values['lottery_max_tickets'] && $points_config['lottery_multi_ticket_enable'] == 1 && $points_config['lottery_enable'] == 1 ? true : false, 'S_MULTI_TICKETS' => $points_config['lottery_multi_ticket_enable'] == 1 ? true : false, 'S_LOTTERY_ENABLE' => $points_config['lottery_enable'] == 1 ? true : false, 'S_DRAWING_ENABLED' => $points_values['lottery_draw_period'] ? true : false, 'U_PREVIOUS_WINNER' => $link_member, 'U_VIEW_HISTORY' => append_sid("{$phpbb_root_path}points_lottery_history"), 'U_VIEW_SELF_HISTORY' => append_sid("{$phpbb_root_path}points_lottery_history_self"), 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points_transfer"), 'U_LOGS' => append_sid("{$phpbb_root_path}points_logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points_lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points_bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points_robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points_info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'), 'USER_POINTS' => sprintf(number_format_points($checked_user['user_points'])))); } // Generate the page header page_header($points_values['lottery_name']); // Generate the page template $template->set_filenames(array('body' => 'points_lottery.html')); page_footer();
* @copyright (c) 2009 wuerzi & femu * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ if (!defined('IN_PHPBB')) { exit; } /** * @package Ultimate Points */ global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $table_prefix, $auth, $check_auth; define('POINTS_BANK_TABLE', $table_prefix . 'points_bank'); // Add part to bar $template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'FORUM_NAME' => sprintf($user->lang['POINTS_INFO'], $config['points_name']))); // Read out all the need values $info_attach = $points_values['points_per_attach'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_attach']) . ' ' . $config['points_name']); $info_addtional_attach = $points_values['points_per_attach_file'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_attach_file']) . ' ' . $config['points_name']); $info_poll = $points_values['points_per_poll'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_poll']) . ' ' . $config['points_name']); $info_poll_option = $points_values['points_per_poll_option'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_poll_option']) . ' ' . $config['points_name']); $info_topic_word = $points_values['points_per_topic_word'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_topic_word']) . ' ' . $config['points_name']); $info_topic_character = $points_values['points_per_topic_character'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_topic_character']) . ' ' . $config['points_name']); $info_post_word = $points_values['points_per_post_word'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_post_word']) . ' ' . $config['points_name']); $info_post_character = $points_values['points_per_post_character'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_post_character']) . ' ' . $config['points_name']); $info_cost_warning = $points_values['points_per_warn'] == 0 ? sprintf($user->lang['INFO_NO_COST'], $config['points_name']) : sprintf(number_format_points($points_values['points_per_warn']) . ' ' . $config['points_name']); $info_reg_bonus = $points_values['reg_points_bonus'] == 0 ? sprintf($user->lang['INFO_NO_POINTS'], $config['points_name']) : sprintf(number_format_points($points_values['reg_points_bonus']) . ' ' . $config['points_name']); $template->assign_vars(array('USER_POINTS' => sprintf(number_format_points($user->data['user_points'])), 'POINTS_NAME' => $config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'POINTS_INFO_DESCRIPTION' => sprintf($user->lang['POINTS_INFO_DESCRIPTION'], $config['points_name']), 'INFO_ATTACH' => $info_attach, 'INFO_ADD_ATTACH' => $info_addtional_attach, 'INFO_POLL' => $info_poll, 'INFO_POLL_OPTION' => $info_poll_option, 'INFO_TOPIC_WORD' => $info_topic_word, 'INFO_TOPIC_CHARACTER' => $info_topic_character, 'INFO_POST_WORD' => $info_post_word, 'INFO_POST_CHARACTER' => $info_post_character, 'INFO_COST_WARNING' => $info_cost_warning, 'INFO_REG_BONUS' => $info_reg_bonus, 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'))); // Generate the page page_header($user->lang['POINTS_INFO']); // Generate the page template $template->set_filenames(array('body' => 'points_info.html')); page_footer();
$sql_array = array('SELECT' => '*', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $transfer_user); $sql = $db->sql_build_query('SELECT', $sql_array); $result1 = $db->sql_query($sql); $opponent = $db->sql_fetchrow($result1); $db->sql_freeresult($result1); if ($row['point_send'] == $checked_user['user_id']) { $who = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']) . "<br />(" . number_format_points($row['point_sendold']) . "->" . number_format_points($row['point_sendold'] - $row['point_amount']) . ")"; $to = get_username_string('full', $opponent['user_id'], $opponent['username'], $opponent['user_colour']) . "<br />(" . number_format_points($row['point_recvold']) . "->" . number_format_points($row['point_recvold'] + $row['point_amount']) . ")"; $rows = 2; } else { $to = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']) . "<br />(" . number_format_points($row['point_recvold']) . "->" . number_format_points($row['point_recvold'] + $row['point_amount']) . ")"; $who = get_username_string('full', $opponent['user_id'], $opponent['username'], $opponent['user_colour']) . "<br />(" . number_format_points($row['point_sendold']) . "->" . number_format_points($row['point_sendold'] - $row['point_amount']) . ")"; $rows = 1; } $who .= " (-" . number_format_points($row['point_amount']) . ")"; $to .= " (+" . number_format_points($row['point_amount']) . ")"; break; case 2: //Locked $who = get_username_string('full', $opponent['user_id'], $opponent['username'], $opponent['user_colour']); $to = "--"; break; } // Add the items to the template $template->assign_block_vars('logs', array('DATE' => $user->format_date($row['point_date']), 'COMMENT' => nl2br($row['point_comment']), 'TYPE' => $types[$rows], 'ROW' => $rows, 'WHO' => $who, 'TO' => $to)); } $db->sql_freeresult($result); // Generate the page template $template->assign_vars(array('LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'L_TOTAL_ENTRIES' => $max == 1 ? $user->lang['POINTS_LOG_SINGLE'] : sprintf($user->lang['POINTS_LOG_MULTI'], $max), 'S_LOGS_ACTION' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'))); // Generate the page header page_header(sprintf($user->lang['LOGS_TITLE'], $checked_user['username']));
public function handle($name) { $l_message = !$this->config['vipaka_points_enable'] ? 'POINTS' : 'POINTS_DISABLED'; $this->template->assign_var('POINTS', $this->user->lang($l_message, $name)); //include($this->phpbb_root_path . 'includes/functions_user.' . $phpEx); //include($this->phpbb_root_path . 'includes/functions_module.' . $phpEx); //include($this->phpbb_root_path . 'includes/functions_display.' . $phpEx); //include($this->phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); $submit = isset($_POST['submit']) ? true : false; $save = isset($_POST['save']) ? true : false; $gender = isset($_POST['gender']) ? true : false; $reset = isset($_POST['reset']) ? true : false; $user_id = $user->data['user_id']; $user_gender = $user->data['user_gender']; $points_config = $this->driver->get('points_config'); $points_values = $this->driver->get('points_values'); // Disable Ultimate Points if the points_install file is still present if (file_exists($phpbb_root_path . 'install_ultimate_points.php')) { // Adjust the message slightly according to the permissions if ($auth->acl_gets('a_')) { $message = $user->lang['POINTS_REMOVE_INSTALL']; } else { $message = $points_config['points_disablemsg']; } trigger_error($message); } //Check if you are locked or not if (!$this->auth->acl_get('u_use_points')) { trigger_error('NOT_AUTHORISED'); } // Get user's information $check_user = request_var('i', 0); $check_user = $check_user == 0 ? $this->user->data['user_id'] : $check_user; $sql_array = array('SELECT' => '*', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = ' . (int) $check_user); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $checked_user = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); //$this->auth = new auth(); $this->auth->acl($checked_user); if (!$checked_user) { trigger_error('POINTS_NO_USER'); } // Check if points system is enabled if (!$this->config['points_enable']) { trigger_error($points_config['points_disablemsg']); } // Add the base entry into the Nav Bar at top $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => append_sid("{$phpbb_root_path}points." . $phpEx), 'FORUM_NAME' => sprintf($user->lang['POINTS_TITLE_MAIN'], $this->config['points_name']))); $this->template->assign_vars(array_change_key_case($checked_user, CASE_UPPER)); $user_name = get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour'], $user->data['username']); //points config error, commented out. $this->template->assign_vars(array_merge(array_change_key_case($points_config, CASE_UPPER), array('USER_POINTS' => number_format_points($user->data['user_points']), 'U_USE_POINTS' => $this->auth->acl_get('u_use_points'), 'U_CHG_POINTS' => $this->auth->acl_get('m_chg_points'), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery')))); //$module = new p_master(); $mode = $name; $this->user->add_lang_ext('points', false, true); switch ($mode) { case 'transfer_user': //$module->load('points', 'transfer_user'); //$module->display("{L_POINTS_TRANSFER}"); $this->helper->render('points_transfer_user.html', '{L_POINTS_TRANSFER_USER}'); break; case 'points_logs': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_logs.' . $this->php_ext; return $this->helper->render('points_logs.html', '{L_POINTS_LOGS}'); case 'points_lottery': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_lottery.' . $this->php_ext; return $this->helper->render('points_lottery.html', '{L_POINTS_LOTTERY}'); case 'points_lottery_history': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_lottery.' . $this->php_ext; return $this->helper->render('points_lottery.html', '{L_POINTS_LOTTERY}'); case 'points_lottery_history_self': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_lottery.' . $this->php_ext; return $this->helper->render('points_lottery.html', '{L_POINTS_LOTTERY}'); case 'points_transfer': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_transfer.' . $this->php_ext; return $this->helper->render('points_transfer.html', '{L_POINTS_TRANSFER}'); case 'points_robbery': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_robbery.' . $this->php_ext; return $this->helper->render('points_robbery.html', '{L_POINTS_ROBBERY}'); case 'points_edit': case 'points_bank': include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_bank.' . $this->php_ext; return $this->helper->render('points_bank.html', '{L_POINTS_BANK}'); case 'bank_edit': case 'points_info': //$module->load('points', $mode); //$module->display("{L_POINTS_}" . strtoupper($mode)); include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_info.' . $this->php_ext; return $this->helper->render('points_info.html', '{L_POINTS_INFO}'); break; default: //$module->load('points', 'main'); //$module->display("{L_POINTS_OVERVIEW}"); include $this->root_path . 'ext/vipaka/ultimate_points/includes/points/points_main.' . $this->php_ext; $this->helper->render('points_main.html', '{L_POINTS_OVERVIEW}'); break; } return $this->helper->render('points_main.html', $name); }
} // Generate most rich banker to show $limit = $points_values['number_show_top_points']; $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_colour, b.*', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(POINTS_BANK_TABLE => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'b.holding > 0', 'ORDER_BY' => 'b.holding DESC, u.username ASC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $limit); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('bank', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf(number_format_points($row['holding'])))); } $db->sql_freeresult($result); // Generate the time format function time_format($secs, $filter = false) { global $user; $output = ''; $filter = $filter ? explode('|', strtolower($filter)) : false; $time_array = array('year' => 60 * 60 * 24 * 365, 'month' => 60 * 60 * 24 * 30, 'week' => 60 * 60 * 24 * 7, 'day' => 60 * 60 * 24, 'hour' => 60 * 60, 'minute' => 60, 'second' => 0); foreach ($time_array as $key => $value) { if ($filter && !in_array($key, $filter)) { continue; } $item = $value ? intval(intval($secs) / $value) : intval($secs); if ($item > 0) { $secs = $secs - $item * $value; $output .= ' ' . $item . ' ' . ($item > 1 ? $user->lang['TIME_' . strtoupper($key) . 'S'] : $user->lang['TIME_' . strtoupper($key)]); } } return $output; } $template->assign_vars(array('BANK_INTEREST_PERIOD' => time_format($points_values['bank_pay_period']), 'BANK_COST' => sprintf(number_format_points($points_values['bank_cost'])), 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'S_DISPLAY_INDEX' => $points_values['number_show_top_points'] > 0 ? true : false, 'L_BANK_DESCRIPTION' => sprintf($user->lang['BANK_DESCRIPTION'], $config['points_name']), 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=transfer_user'), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=logs'), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=lottery'), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=bank'), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=robbery'), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", 'mode=info'), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery'))); page_footer();