/**
 * Create Admin IP access options
 * 
 * Creates an HTML select form of the stored Administrators ip access location 
 * 
 * @param    int   $available_ip  Current selected ip
 * @param    int   $type           Switch between remote_addr or x_forwarded_for
 * @uses     is_selected_option()
 * 
 * @returns  string  html select form with the stored Administrator access db table 
 * 
 */
function create_admin_ipaccess_options($available_ip, $type)
{
    $field_requested = $type === 'x_forwarded_for' ? 'x_forwarded_for' : 'remote_addr';
    $query = "SELECT DISTINCT\n    `" . $field_requested . "`\n    FROM `" . DBT_PREFIX . "administrators_access`\n    WHERE  `" . $field_requested . "` <> 'unavailable'\n    ORDER BY `" . $field_requested . "`";
    sql_select($query, $results);
    if (mysql_num_rows($results) > 0) {
        settype($return_string, "string");
        while ($row = mysql_fetch_array($results)) {
            $current_value = ip2long($row[$field_requested]);
            $return_string .= "\n <option value=\"" . $current_value . "\" " . is_selected_option($current_value, $available_ip) . ">" . $row[$field_requested] . "</option>";
        }
        return $return_string;
    }
}
function order_by($order_list, $text, $starting_value, $included_vars)
{
    $order_list = explode(",", $order_list);
    $order_list_text = explode(",", $text);
    $included_vars_list = explode(",", $included_vars);
    $starting_value = explode(",", $starting_value);
    $starting_value_string = DEFINED_SCRIPT_FILENAME . "?" . $starting_value['0'] . "=" . $starting_value['1'];
    $included_vars_chain = $starting_value_string;
    foreach ($included_vars_list as $key => $val) {
        if (req($val)) {
            $included_vars_chain .= "&amp;" . $val . "=" . urlencode(req($val));
        }
    }
    $return_string = "\n<select name=\"quick_nav\" onchange=\"go(this)\" title=\"set_order\">";
    $return_string .= "\n<option value=\"\">" . translate("order_by") . ":</option>";
    for ($counter = 0; $counter < count($order_list); $counter++) {
        if (is_even($counter)) {
            $style = " style=\"background-color:#EEEBDD;\" ";
        } else {
            $style = "";
        }
        //DESC
        $return_string .= "\n      \n<option {$style} value=\"" . $included_vars_chain . "&amp;order_by=" . $order_list[$counter] . "-DESC";
        $return_string .= "\"";
        $return_string .= is_selected_option($order_list[$counter] . "-DESC", req("order_by"));
        $return_string .= ">" . translate($order_list_text[$counter]) . " Desc [+ -]</option>";
        //ASC
        $return_string .= "\n      \n<option  {$style}  value=\"" . $included_vars_chain . "&amp;order_by=" . $order_list[$counter] . "-ASC";
        $return_string .= "\"";
        $return_string .= is_selected_option($order_list[$counter] . "-ASC", req("order_by"));
        $return_string .= ">" . translate($order_list_text[$counter]) . " Asc [- +]</option>";
    }
    $return_string .= "\n<option style=\"background-color:#FFCC00;font-weight: bold;\" value=\"" . $starting_value_string . "\">RESET</option>\n    </select>";
    return $return_string;
}