function rul_optionsmenu()
    {
        global $wpdb, $rul_db_addresses;
        // Upgrade check here because it's the only place we know they will visit
        rul_upgrade();
        $rul_process_submit = '';
        // Process submitted information to update redirect rules
        if (isset($_POST['rul_username_submit'])) {
            $rul_process_submit = rul_submit_rule($_POST['rul_username'], $_POST['rul_username_address'], $_POST['rul_username_logout'], 0, 'user');
        } elseif (isset($_POST['rul_username_edit'])) {
            $rul_process_submit = rul_edit_rule($_POST['rul_username'], $_POST['rul_username_address'], $_POST['rul_username_logout'], 0, 'user');
        } elseif (isset($_POST['rul_username_delete'])) {
            $rul_process_submit = rul_delete_rule($_POST['rul_username'], 'user');
        } elseif (isset($_POST['rul_role_submit'])) {
            $rul_process_submit = rul_submit_rule($_POST['rul_role'], $_POST['rul_role_address'], $_POST['rul_role_logout'], 0, 'role');
        } elseif (isset($_POST['rul_role_edit'])) {
            $rul_process_submit = rul_edit_rule($_POST['rul_role'], $_POST['rul_role_address'], $_POST['rul_role_logout'], 0, 'role');
        } elseif (isset($_POST['rul_role_delete'])) {
            $rul_process_submit = rul_delete_rule($_POST['rul_role'], 'role');
        } elseif (isset($_POST['rul_level_submit'])) {
            $rul_process_submit = rul_submit_rule($_POST['rul_level'], $_POST['rul_level_address'], $_POST['rul_level_logout'], $_POST['rul_level_order'], 'level');
        } elseif (isset($_POST['rul_level_edit'])) {
            $rul_process_submit = rul_edit_rule($_POST['rul_level'], $_POST['rul_level_address'], $_POST['rul_level_logout'], $_POST['rul_level_order'], 'level');
        } elseif (isset($_POST['rul_level_delete'])) {
            $rul_process_submit = rul_delete_rule($_POST['rul_level'], 'level');
        } elseif (isset($_POST['rul_allupdatesubmit'])) {
            $rul_process_submit = rul_submit_all('update', $_POST['rul_all'], $_POST['rul_all_logout']);
        } elseif (isset($_POST['rul_alldeletesubmit'])) {
            $rul_process_submit = rul_submit_all('delete', $_POST['rul_all'], $_POST['rul_all_logout']);
        } elseif (isset($_POST['rul_registerupdatesubmit'])) {
            $rul_process_submit = rul_submit_register('update', $_POST['rul_register']);
        } elseif (isset($_POST['rul_registerdeletesubmit'])) {
            $rul_process_submit = rul_submit_register('delete', $_POST['rul_register']);
        } elseif (isset($_POST['rul_settingssubmit'])) {
            $rul_process_submit = rul_submit_settings();
        }
        // Settings that can be updated
        $rul_settings = rulRedirectFunctionCollection::get_settings();
        // -----------------------------------
        // Get the existing rules
        // -----------------------------------
        $rul_rules = $wpdb->get_results('SELECT rul_type, rul_value, rul_url, rul_url_logout, rul_order FROM ' . $rul_db_addresses . ' ORDER BY rul_type, rul_order, rul_value', ARRAY_N);
        $rul_usernamevalues = '';
        $rul_rolevalues = '';
        $rul_levelvalues = '';
        $rul_usernames_existing = array();
        $rul_roles_existing = array();
        $rul_levels_existing = array();
        if ($rul_rules) {
            $i = 0;
            $i_user = 0;
            $i_role = 0;
            $i_level = 0;
            while ($i < count($rul_rules)) {
                list($rul_type, $rul_value, $rul_url, $rul_url_logout, $rul_order) = $rul_rules[$i];
                // Specific users
                if ($rul_type == 'user') {
                    $rul_usernamevalues .= '<form name="rul_username_edit_form[' . $i_user . ']" action="?page=' . basename(__FILE__) . '" method="post">';
                    $rul_usernamevalues .= '<tr>';
                    $rul_usernamevalues .= '<td><p><input type="hidden" name="rul_username" value="' . $rul_value . '" /> ' . $rul_value . '</p></td>';
                    $rul_usernamevalues .= '<td>';
                    $rul_usernamevalues .= '<p>' . __('Login URL', 'peters-login-redirect') . '<br /><input type="text" size="90" maxlength="500" name="rul_username_address" value="' . $rul_url . '" /></p>';
                    $rul_usernamevalues .= '<p>' . __('Logout URL', 'peters-login-redirect') . '<br /><input type="text" size="60" maxlength="500" name="rul_username_logout" value="' . $rul_url_logout . '" /></p>';
                    $rul_usernamevalues .= '</td>';
                    $rul_usernamevalues .= '<td><p><input name="rul_username_edit" type="submit" value="' . __('Edit', 'peters-login-redirect') . '" /> <input type="submit" name="rul_username_delete" value="' . __('Delete', 'peters-login-redirect') . '" /></p></td>';
                    $rul_usernamevalues .= '</tr>';
                    $rul_usernamevalues .= '</form>';
                    $rul_usernames_existing[] = $rul_value;
                    ++$i_user;
                } elseif ($rul_type == 'role') {
                    $rul_rolevalues .= '<form name="rul_role_edit_form[' . $i_role . ']" action="?page=' . basename(__FILE__) . '" method="post">';
                    $rul_rolevalues .= '<tr>';
                    $rul_rolevalues .= '<td><p><input type="hidden" name="rul_role" value="' . $rul_value . '" /> ' . $rul_value . '</p></td>';
                    $rul_rolevalues .= '<td>';
                    $rul_rolevalues .= '<p>' . __('Login URL', 'peters-login-redirect') . '<br /><input type="text" size="90" maxlength="500" name="rul_role_address" value="' . $rul_url . '" /></p>';
                    $rul_rolevalues .= '<p>' . __('Logout URL', 'peters-login-redirect') . '<br /><input type="text" size="60" maxlength="500" name="rul_role_logout" value="' . $rul_url_logout . '" /></p>';
                    $rul_rolevalues .= '</td>';
                    $rul_rolevalues .= '<td><p><input name="rul_role_edit" type="submit" value="' . __('Edit', 'peters-login-redirect') . '" /> <input type="submit" name="rul_role_delete" value="' . __('Delete', 'peters-login-redirect') . '" /></p></td>';
                    $rul_rolevalues .= '</tr>';
                    $rul_rolevalues .= '</form>';
                    $rul_roles_existing[$rul_value] = '';
                    ++$i_role;
                } elseif ($rul_type == 'level') {
                    $rul_levelvalues .= '<form name="rul_level_edit_form[' . $i_level . ']" action="?page=' . basename(__FILE__) . '" method="post">';
                    $rul_levelvalues .= '<tr>';
                    $rul_levelvalues .= '<td><p><input type="hidden" name="rul_level" value="' . $rul_value . '" /> ' . $rul_value . '</p></td>';
                    $rul_levelvalues .= '<td>';
                    $rul_levelvalues .= '<p>' . __('Login URL', 'peters-login-redirect') . '<br /><input type="text" size="90" maxlength="500" name="rul_level_address" value="' . $rul_url . '" /></p>';
                    $rul_levelvalues .= '<p>' . __('Logout URL', 'peters-login-redirect') . '<br /><input type="text" size="60" maxlength="500" name="rul_level_logout" value="' . $rul_url_logout . '" /></p>';
                    $rul_levelvalues .= '</td>';
                    $rul_levelvalues .= '<td><p><input name="rul_level_order" type="text" size="2" maxlength="2" value="' . $rul_order . '" /></td>';
                    $rul_levelvalues .= '<td><p><input name="rul_level_edit" type="submit" value="' . __('Edit', 'peters-login-redirect') . '" /> <input type="submit" name="rul_level_delete" value="' . __('Delete', 'peters-login-redirect') . '" /></p></td>';
                    $rul_levelvalues .= '</tr>';
                    $rul_levelvalues .= '</form>';
                    $rul_levels_existing[$rul_value] = '';
                    ++$i_level;
                } elseif ($rul_type == 'all') {
                    $rul_allvalue = $rul_url;
                    $rul_allvalue_logout = $rul_url_logout;
                } elseif ($rul_type == 'register') {
                    $rul_registervalue = $rul_url;
                }
                ++$i;
            }
        }
        ?>
    <div class="wrap">
        <h2><?php 
        _e('Manage redirect rules', 'peters-login-redirect');
        ?>
</h2>
        <?php 
        print $rul_process_submit;
        ?>
        <p><?php 
        _e('Define custom URLs to which different users, users with specific roles, users with specific levels, and all other users will be redirected upon login.', 'peters-login-redirect');
        ?>
</p>
        <p><?php 
        _e('Define a custom URL to which all users will be redirected upon logout', 'peters-login-redirect');
        ?>
</p>
        <p><?php 
        _e('Note that you can use the syntax <strong>[variable]username[/variable]</strong> in your URLs so that the system will build a dynamic URL upon each login, replacing that text with the users username.', 'peters-login-redirect');
        ?>
</p>

        <h3><?php 
        _e('Specific users', 'peters-login-redirect');
        ?>
</h3>
        <?php 
        if ($rul_usernamevalues) {
            print '<table class="widefat">';
            print $rul_usernamevalues;
            print '</table>';
        }
        ?>
            
        <form name="rul_username_add_form" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
            <p><?php 
        _e('Add:', 'peters-login-redirect');
        ?>
 
                <select name="rul_username" >
                    <option value="-1"><?php 
        _e('Select a username', 'peters-login-redirect');
        ?>
</option>
                    <?php 
        print rul_returnusernames($rul_usernames_existing);
        ?>
                </select>
                <br /><?php 
        _e('URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_username_address" />
                <br /><?php 
        _e('Logout URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_username_logout" />
            </p>
            <p class="submit"><input type="submit" name="rul_username_submit" value="<?php 
        _e('Add username rule', 'peters-login-redirect');
        ?>
" /></p>
        </form>
            
        <h3><?php 
        _e('Specific roles', 'peters-login-redirect');
        ?>
</h3>
        <?php 
        if ($rul_rolevalues) {
            print '<table class="widefat">';
            print $rul_rolevalues;
            print '</table>';
        }
        ?>

        <form name="rul_role_add_form" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
            <p><?php 
        _e('Add:', 'peters-login-redirect');
        ?>
 
                <select name="rul_role" >
                    <option value="-1"><?php 
        _e('Select a role', 'peters-login-redirect');
        ?>
</option>
                    <?php 
        print rul_returnroleoptions($rul_roles_existing);
        ?>
                </select>
                <br /><?php 
        _e('URL:', 'peters-login-redirect');
        ?>
  <input type="text" size="90" maxlength="500" name="rul_role_address" />
                <br /><?php 
        _e('Logout URL:', 'peters-login-redirect');
        ?>
  <input type="text" size="90" maxlength="500" name="rul_role_logout" />
            </p>
            <p class="submit"><input type="submit" name="rul_role_submit" value="<?php 
        _e('Add role rule', 'peters-login-redirect');
        ?>
" /></p>
        </form> 
 
        <h3><?php 
        _e('Specific levels', 'peters-login-redirect');
        ?>
</h3>
        <?php 
        if ($rul_levelvalues) {
            print '<table class="widefat">';
            ?>
                <tr>
                    <th></th>
                    <th></th>
                    <th><?php 
            _e('Order', 'peters-login-redirect');
            ?>
</th>
                    <th></th>
                </tr>
        <?php 
            print $rul_levelvalues;
            print '</table>';
        }
        ?>

        <form name="rul_level_add_form" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
            <p><?php 
        _e('Add:', 'peters-login-redirect');
        ?>
 
                <select name="rul_level" >
                    <option value="-1"><?php 
        _e('Select a level', 'peters-login-redirect');
        ?>
</option>
                    <?php 
        print rul_returnleveloptions($rul_levels_existing);
        ?>
                </select>
                <br /><?php 
        _e('Order:', 'peters-login-redirect');
        ?>
 <input type="text" size="2" maxlength="2" name="rul_level_order" />
                <br /><?php 
        _e('URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_level_address" />
                <br /><?php 
        _e('Logout URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_level_logout" />
            </p>
            <p class="submit"><input type="submit" name="rul_level_submit" value="<?php 
        _e('Add level rule', 'peters-login-redirect');
        ?>
" /></p>
        </form> 
        
        <h3><?php 
        _e('All other users', 'peters-login-redirect');
        ?>
</h3>
        <form name="rul_allform" action="<?php 
        '?page=' . basename(__FILE__);
        ?>
" method="post">
            <p><?php 
        _e('URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_all" value="<?php 
        print $rul_allvalue;
        ?>
" /></p>
            <p><?php 
        _e('Logout URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_all_logout" value="<?php 
        print $rul_allvalue_logout;
        ?>
" /></p>
            <p class="submit"><input type="submit" name="rul_allupdatesubmit" value="<?php 
        _e('Update', 'peters-login-redirect');
        ?>
" /> <input type="submit" name="rul_alldeletesubmit" value="<?php 
        _e('Delete', 'peters-login-redirect');
        ?>
" /></p>
        </form>
        
        <hr />
        
        <h3><?php 
        _e('Post-registration', 'peters-login-redirect');
        ?>
</h3>
        <form name="rul_registerform" action="<?php 
        '?page=' . basename(__FILE__);
        ?>
" method="post">
            <p><?php 
        _e('URL:', 'peters-login-redirect');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_register" value="<?php 
        print $rul_registervalue;
        ?>
" /></p>
            <p class="submit"><input type="submit" name="rul_registerupdatesubmit" value="<?php 
        _e('Update', 'peters-login-redirect');
        ?>
" /> <input type="submit" name="rul_registerdeletesubmit" value="<?php 
        _e('Delete', 'peters-login-redirect');
        ?>
" /></p>
        </form>
        
        <hr />
        
        <h3><?php 
        _e('Customize plugin settings', 'peters-login-redirect');
        ?>
</h3>
        <form name="rul_settingsform" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
        <table class="widefat">
        <tr>
            <td>
                <p><strong><?php 
        _e('Redirect restrictions', 'peters-login-redirect');
        ?>
</strong></p>
            </td>
            <td>
                <select name="rul_local_only">
                    <option value="1"<?php 
        if (1 == $rul_settings['rul_local_only']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Any http or https URL', 'peters-login-redirect');
        ?>
</option>
                    <option value="2"<?php 
        if (2 == $rul_settings['rul_local_only']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Any URL', 'peters-login-redirect');
        ?>
</option>
                    <option value="3"<?php 
        if (3 == $rul_settings['rul_local_only']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Any URL on the same domain', 'peters-login-redirect');
        ?>
</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <p><strong><?php 
        _e('Allow a POST or GET &#34;redirect_to&#34; variable to take redirect precedence', 'peters-login-redirect');
        ?>
</strong></p>
            </td>
            <td>
                <select name="rul_allow_post_redirect_override">
                    <option value="1"<?php 
        if ($rul_settings['rul_allow_post_redirect_override']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Yes', 'peters-login-redirect');
        ?>
</option>
                    <option value="0"<?php 
        if (!$rul_settings['rul_allow_post_redirect_override']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('No', 'peters-login-redirect');
        ?>
</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <p><strong><?php 
        _e('Allow a POST or GET &#34;redirect_to&#34; logout variable to take redirect precedence', 'peters-login-redirect');
        ?>
</strong></p>
            </td>
            <td>
                <select name="rul_allow_post_redirect_override_logout">
                    <option value="1"<?php 
        if ($rul_settings['rul_allow_post_redirect_override_logout']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Yes', 'peters-login-redirect');
        ?>
</option>
                    <option value="0"<?php 
        if (!$rul_settings['rul_allow_post_redirect_override_logout']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('No', 'peters-login-redirect');
        ?>
</option>
                </select>
            </td>
        </tr>
        
        <tr>
            <td>
                <p><strong><?php 
        print sprintf(__('Use external redirect file. Set this to &#34;Yes&#34; if you are using a plugin such as Gigya that bypasses the regular WordPress redirect process (and allows only one fixed redirect URL). Then, set the redirect URL in the other plugin to %s', 'peters-login-redirect'), '<br />http://www.yoursite.com/wp-content/plugins/peters-login-redirect/wplogin_redirect_control.php');
        ?>
</strong></p>
            </td>
            <td>
                <select name="rul_use_redirect_controller">
                    <option value="1"<?php 
        if ($rul_settings['rul_use_redirect_controller']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('Yes', 'peters-login-redirect');
        ?>
</option>
                    <option value="0"<?php 
        if (!$rul_settings['rul_use_redirect_controller']) {
            print ' selected="selected"';
        }
        ?>
><?php 
        _e('No', 'peters-login-redirect');
        ?>
</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <p><strong><?php 
        _e('Permission level required to edit redirect URLs', 'peters-login-redirect');
        ?>
</strong></p>
            </td>
            <td>
                <select name="rul_required_capability">
                    <?php 
        $rul_levelnames = rul_returnlevelnames();
        // Build the option HTML
        foreach ($rul_levelnames as $rul_levelname) {
            print '<option value="' . $rul_levelname . '"';
            if ($rul_levelname == $rul_settings['rul_required_capability']) {
                print ' selected="selected"';
            }
            print '>' . $rul_levelname . '</option>';
        }
        ?>
                </select>
            </td>
        </tr>
        </table>
        <p class="submit"><input name="rul_settingssubmit" type="submit" value="<?php 
        _e('Update', 'peters-login-redirect');
        ?>
" /></p>
        </form>
    </div>
<?php 
    }
    function rul_optionsmenu()
    {
        global $wpdb, $rul_db_addresses;
        $rul_process_submit = '';
        // Process submitted information to update redirect rules
        if (isset($_POST['rul_usernamesubmit'])) {
            $rul_process_submit = rul_submit_username($_POST['rul_username'], $_POST['rul_usernameaddress']);
        } elseif (isset($_POST['rul_rolesubmit'])) {
            $rul_process_submit = rul_submit_role($_POST['rul_role'], $_POST['rul_roleaddress']);
        } elseif (isset($_POST['rul_levelsubmit'])) {
            $rul_process_submit = rul_submit_level($_POST['rul_level'], $_POST['rul_levelorder'], $_POST['rul_leveladdress']);
        } elseif (isset($_POST['rul_allsubmit'])) {
            $rul_process_submit = rul_submit_all($_POST['rul_allsubmit'], $_POST['rul_all']);
        }
        // -----------------------------------
        // Get the existing rules
        // -----------------------------------
        $rul_rules = $wpdb->get_results('SELECT rul_type, rul_value, rul_url, rul_order FROM ' . $rul_db_addresses . ' ORDER BY rul_type, rul_order, rul_value', ARRAY_N);
        $rul_usernamevalues = '';
        $rul_rolevalues = '';
        $rul_levelvalues = '';
        $rul_usernames_existing = array();
        $rul_roles_existing = array();
        $rul_levels_existing = array();
        if ($rul_rules) {
            $i = 0;
            $i_user = 0;
            $i_role = 0;
            $i_level = 0;
            while ($i < count($rul_rules)) {
                list($rul_type, $rul_value, $rul_url, $rul_order) = $rul_rules[$i];
                // Specific users
                if ($rul_type == 'user') {
                    $rul_usernamevalues .= '            <tr>' . "\n";
                    $rul_usernamevalues .= '                <td><p><input type="checkbox" name="rul_username[' . $i_user . ']" value="' . $rul_value . '" checked="checked" /> ' . $rul_value . '</p></td>' . "\n";
                    $rul_usernamevalues .= '                <td><p><input type="text" size="90" maxlength="500" name="rul_usernameaddress[' . $i_user . ']" value="' . $rul_url . '" /></p></td>' . "\n";
                    $rul_usernamevalues .= '            </tr>' . "\n";
                    $rul_usernames_existing[] = $rul_value;
                    ++$i_user;
                    ++$i;
                } elseif ($rul_type == 'role') {
                    $rul_rolevalues .= '            <tr>' . "\n";
                    $rul_rolevalues .= '                <td><p><input type="checkbox" name="rul_role[' . $i_role . ']" value="' . $rul_value . '" checked="checked" /> ' . $rul_value . '</p></td>' . "\n";
                    $rul_rolevalues .= '                <td><p><input type="text" size="90" maxlength="500" name="rul_roleaddress[' . $i_role . ']" value="' . $rul_url . '" /></p></td>' . "\n";
                    $rul_rolevalues .= '            </tr>' . "\n";
                    $rul_roles_existing[$rul_value] = '';
                    ++$i_role;
                    ++$i;
                } elseif ($rul_type == 'level') {
                    $rul_levelvalues .= '            <tr>' . "\n";
                    $rul_levelvalues .= '                <td><p><input type="checkbox" name="rul_level[' . $i_level . ']" value="' . $rul_value . '" checked="checked" /> ' . $rul_value . '</p></td>' . "\n";
                    $rul_levelvalues .= '                <td><p><input type="text" size="2" maxlength="2" name="rul_levelorder[' . $i_level . ']" value="' . $rul_order . '" /></p></td>' . "\n";
                    $rul_levelvalues .= '                <td><p><input type="text" size="90" maxlength="500" name="rul_leveladdress[' . $i_level . ']" value="' . $rul_url . '" /></p></td>' . "\n";
                    $rul_levelvalues .= '            </tr>' . "\n";
                    $rul_levels_existing[$rul_value] = '';
                    ++$i_level;
                    ++$i;
                } elseif ($rul_type == 'all') {
                    $rul_allvalue = $rul_url;
                    ++$i;
                }
            }
        }
        ?>
    <div class="wrap">
        <h2><?php 
        _e('Manage login redirect rules', 'peterloginrd');
        ?>
</h2>
        <?php 
        print $rul_process_submit;
        ?>
        <p><?php 
        _e('Define different local URLs to which different users, users with specific roles, users with specific levels, and all other users will be redirected.', 'peterloginrd');
        ?>
</p>
        <p><?php 
        _e('Note that you can use the syntax <strong>[variable]username[/variable]</strong> in your URLs so that the system will build a dynamic URL upon each login, replacing that text with the users username.', 'peterloginrd');
        ?>
</p>

        <h3><?php 
        _e('Specific users', 'peterloginrd');
        ?>
</h3>
        <form name="rul_usernameform" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
        <table class="widefat">
            <tr>
                <th><?php 
        _e('Username', 'peterloginrd');
        ?>
</th>
                <th><?php 
        _e('URL', 'peterloginrd');
        ?>
</th>
            </tr>
<?php 
        print $rul_usernamevalues;
        ?>
            
        </table>
        <p><?php 
        _e('Add:', 'peterloginrd');
        ?>
 
            <select name="rul_username[<?php 
        print $i_user;
        ?>
]" >
                <option value="-1"><?php 
        _e('Select a username', 'peterloginrd');
        ?>
</option>
<?php 
        print rul_returnusernames($rul_usernames_existing);
        ?>
            </select>
            <br /><?php 
        _e('URL:', 'peterloginrd');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_usernameaddress[<?php 
        print $i_user;
        ?>
]" />
        </p>
        <p class="submit"><input type="submit" name="rul_usernamesubmit" value="<?php 
        _e('Update', 'peterloginrd');
        ?>
" /></p>
        </form>
            
        <h3><?php 
        _e('Specific roles', 'peterloginrd');
        ?>
</h3>
        <form name="rul_roleform" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
        <table class="widefat">
            <tr>
                <th><?php 
        _e('Role', 'peterloginrd');
        ?>
</th>
                <th><?php 
        _e('URL', 'peterloginrd');
        ?>
</th>
            </tr>
            <?php 
        print $rul_rolevalues;
        ?>
            
        </table>
        <p><?php 
        _e('Add:', 'peterloginrd');
        ?>
 
            <select name="rul_role[<?php 
        print $i_role;
        ?>
]" >
                <option value="-1"><?php 
        _e('Select a role', 'peterloginrd');
        ?>
</option>
<?php 
        print rul_returnroleoptions($rul_roles_existing);
        ?>
            </select>
            <br /><?php 
        _e('URL:', 'peterloginrd');
        ?>
  <input type="text" size="90" maxlength="500" name="rul_roleaddress[<?php 
        print $i_role;
        ?>
]" />
        </p>
        <p class="submit"><input type="submit" name="rul_rolesubmit" value="<?php 
        _e('Update', 'peterloginrd');
        ?>
" /></p>
        </form> 
 
        <h3><?php 
        _e('Specific levels', 'peterloginrd');
        ?>
</h3>
        <form name="rul_levelform" action="<?php 
        print '?page=' . basename(__FILE__);
        ?>
" method="post">
        <table class="widefat">
            <tr>
                <th><?php 
        _e('Level', 'peterloginrd');
        ?>
</th>
                <th><?php 
        _e('Order', 'peterloginrd');
        ?>
</th>
                <th><?php 
        _e('URL', 'peterloginrd');
        ?>
</th>
            </tr>
            <?php 
        print $rul_levelvalues;
        ?>
            
        </table>
        <p><?php 
        _e('Add:', 'peterloginrd');
        ?>
 
            <select name="rul_level[<?php 
        print $i_level;
        ?>
]" >
                <option value="-1"><?php 
        _e('Select a level', 'peterloginrd');
        ?>
</option>
<?php 
        print rul_returnleveloptions($rul_levels_existing);
        ?>
            </select>
            <br /><?php 
        _e('Order:', 'peterloginrd');
        ?>
 <input type="text" size="2" maxlength="2" name="rul_levelorder[<?php 
        print $i_level;
        ?>
]" />
            <br /><?php 
        _e('URL:', 'peterloginrd');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_leveladdress[<?php 
        print $i_level;
        ?>
]" />
        </p>
        <p class="submit"><input type="submit" name="rul_levelsubmit" value="<?php 
        _e('Update', 'peterloginrd');
        ?>
" /></p>
        </form> 
        
        <h3><?php 
        _e('All other users', 'peterloginrd');
        ?>
</h3>
        <form name="rul_allform" action="<?php 
        '?page=' . basename(__FILE__);
        ?>
" method="post">
        <p><?php 
        _e('URL:', 'peterloginrd');
        ?>
 <input type="text" size="90" maxlength="500" name="rul_all" value="<?php 
        print $rul_allvalue;
        ?>
" /></p>
        <p class="submit"><input type="submit" name="rul_allsubmit" value="<?php 
        _e('Update', 'peterloginrd');
        ?>
" /> <input type="submit" name="rul_allsubmit" value="<?php 
        _e('Delete', 'peterloginrd');
        ?>
" /></p>
        </form>
    </div>
<?php 
    }