Specifications
LISTING 28.2 Continued
case ‘send’ :
{
send($id, $admin_user);
break;
}
case ‘view-mail’ :
{
display_items(“Unsent Mail”, get_unsent_mail(get_email()),
‘preview-html’, ‘preview-text’, ‘send’);
break;
}
}
}
/**********************************************************************
* Section 4: display footer
*********************************************************************/
do_html_footer();
?>
You can see the four segments of the code clearly marked in this listing.
In the preprocessing stage, we set up the session and process any actions that need to be done
before headers can be sent. In this case, this includes logging in and out.
In the header stage, we set up the menu buttons that the user will see, and display the appropri-
ate headers using the do_html_header() function from output_fns.php. This function just dis-
plays the header bar and menus, so we won’t go into it here.
In the main section of the script, we respond to the action the user has chosen. These actions
are divided into three subsets: actions that can be taken if not logged in, actions that can be
taken by normal users, and actions that can be taken by administrative users. We check to see
whether access to the latter two sets of actions is allowed using the
check_logged_in() and
check_admin_user() functions. These functions are located in the user_auth_fns.php function
library. The code for the functions, and for the check_normal_user() function are shown in
Listing 28.3.
LISTING 28.3 Functions from user_auth_fns.php—These Functions Check Whether or
Not a User Is Logged In, and at What Level
function check_normal_user()
// see if somebody is logged in and notify them if not
{
global $normal_user;
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
669
34 7842 CH28 3/6/01 3:46 PM Page 669