echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td colspan=\"2\" align=\"center\">", form_submit("update", gettext("Save")), " ", form_submit("edit_check", gettext("Check Ban")), " ", form_submit("cancel", gettext("Cancel")), "</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo "</form>\n"; echo "</div>\n"; html_draw_bottom(); } else { html_draw_top(array('title' => gettext("Admin - Ban Controls"), 'class' => 'window_title', 'main_css' => 'admin.css')); $ban_list_array = admin_get_ban_data($sort_by, $sort_dir, $page); echo "<h1>", gettext("Admin"), html_style_image('separator'), gettext("Ban Controls"), "</h1>\n"; if (isset($error_msg_array) && sizeof($error_msg_array) > 0) { html_display_error_array($error_msg_array, '86%', 'center'); } else { if (isset($_GET['added'])) { html_display_success_msg(gettext("Successfully added ban"), '86%', 'center'); } else { if (isset($_GET['removed'])) { html_display_success_msg(gettext("Successfully removed selected bans"), '86%', 'center'); } else { if (isset($_GET['edited'])) { html_display_success_msg(gettext("Successfully updated ban"), '86%', 'center'); } else { if (sizeof($ban_list_array['ban_array']) < 1) { html_display_warning_msg(gettext("There is no existing ban data. To add a ban click the 'Add New' button below."), '86%', 'center');
function admin_get_ban_data($sort_by = "ID", $sort_dir = "ASC", $page = 1) { if (!($db = db::get())) { return false; } $sort_by_array = array('ID', 'BANTYPE', 'BANDATA', 'COMMENT', 'EXPIRES'); $sort_dir_array = array('ASC', 'DESC'); if (!in_array($sort_by, $sort_by_array)) { $sort_by = 'ID'; } if (!in_array($sort_dir, $sort_dir_array)) { $sort_dir = 'ASC'; } if (!is_numeric($page) || $page < 1) { $page = 1; } $offset = calculate_page_offset($page, 10); if (!($table_prefix = get_table_prefix())) { return false; } $ban_data_array = array(); $sql = "SELECT SQL_CALC_FOUND_ROWS ID, BANTYPE, BANDATA, COMMENT, "; $sql .= "UNIX_TIMESTAMP(EXPIRES) AS EXPIRES FROM `{$table_prefix}BANNED` "; $sql .= "ORDER BY {$sort_by} {$sort_dir} "; $sql .= "LIMIT {$offset}, 10"; if (!($result = $db->query($sql))) { return false; } $sql = "SELECT FOUND_ROWS() AS ROW_COUNT"; if (!($result_count = $db->query($sql))) { return false; } list($ban_data_count) = $result_count->fetch_row(); if ($result->num_rows == 0 && $ban_data_count > 0 && $page > 1) { return admin_get_ban_data($sort_by, $sort_dir, $page - 1); } while ($ban_data = $result->fetch_assoc()) { $ban_data_array[$ban_data['ID']] = $ban_data; } return array('ban_count' => $ban_data_count, 'ban_array' => $ban_data_array); }