log in -> is logged in if (isset($_POST['login']) || (isset($_SERVER['REMOTE_USER']) && (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']))) { // Check username and password if ($user = validateUser()) { $_SESSION['loggedin'] = $user; $content = htmlRequestForm($user);; } else { $_SESSION['loggedin'] = false; $content = htmlLoginForm(); } } else if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] && isset($_POST['send']) && $_POST['send']) { // User is already logged in, check the form's status if ($result = checkFormErrors()) { // display the form (with errors if applicable) $content = htmlRequestForm((isset($_GET['new']) ? $_SESSION['loggedin'] : NULL), (is_bool($result) ? '' : $result)); } else { sendFormData(); // get a success message $content = htmlSuccessMessage(); } } else { $_SESSION['loggedin'] = false; // Not logged in, not logging in: display login $content = htmlLoginForm(); } $title = 'Faculty Study Room Application'; // Attach a template and output $template = new Template('../../templates/public-find-sidebar.tmpl'); $template->AddParam('TITLE', $title); $template->AddParam('BODY', $content); $template->AddParam('SIDEBAR', ''); $template->EchoOutput(); // We're done. Proceed no further. exit(0); // this will return an array of required fields function getRequiredFields() { return array('first', 'last', 'banner', 'dept', 'phone', 'email'); } // this will return true if a value is required function checkIfRequired($element) { return in_array($element, getRequiredFields()); } // this will return a HTML form for the actual request content function htmlRequestForm($prepopulate = NULL, $error = '') { // define array indexes $vars = Array(); foreach (getRequiredFields() as $val) { $vars[$val.'_missing'] = ''; } // Prepopulate any provided info (probably user info from LDAP) if ($prepopulate) { foreach ($prepopulate as $k => $val) { $vars[$k] = htmlentities($val); } } // copy over POST stream for user and course foreach (array_merge(getRequiredFields(), array('assigned', 'room', 'downtown', 'describe', 'needs')) as $val) { if (!isset($vars[$val])) { $vars[$val] = ''; } if (isset($_POST[$val]) && $_POST[$val]) { $vars[$val] = htmlentities($_POST[$val]); } else if (isset($_POST['send']) && $_POST['send'] && checkIfRequired($val)) { $vars[$val.'_missing'] = '(required)'; } } if (isset($_POST['email']) && $_POST['email'] && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $vars['email_missing'] = '(invalid)'; } ob_start(); ?>

/> />
/> />

Successfully sent this request!

real_escape_string($myid); // $result = mysqlI->query("select * from lib_users where utid='$id' and (type in ('fac', 'pstf') or (type = 'staf' and dept='01160'))"); $result = $db->query("select * from lib_users where utid='$id' and (type in ('fac', 'pstf') or (type = 'staf'))"); // check query result if ($row = $result->fetch_assoc()) { // if good, assign values from ldap $user['first'] = $entries[0]['givenname'][0]; $user['last'] = $entries[0]['sn'][0]; $user['phone'] = $entries[0]['telephonenumber'][0]; $user['email'] = $entries[0]['mail'][0]; // transform the banner id into @01234567 format $user['banner'] = '@'.substr($entries[0]['employeeid'][0], 1); $user['myutsa'] = $myid; } else { // if not, blank user $user = false; } } } else { error_log(ldap_error($ldap)); } } else { error_log(ldap_error($ldap)); } } else { error_log(ldap_error($ldap)); } } error_reporting($old_error_reporting_value); return $user; } // This will return the HTML of a login form, with error messages as needed function htmlLoginForm() { $vars = Array(); foreach (array('username', 'password') as $key) { $vars[$key] = ''; $vars[$key.'_missing'] = ''; } $vars['login_invalid'] = ''; // If login information was tried, indicate errors if (isset($_POST['login']) && $_POST['login']) { // check each required form element foreach (array('Username', 'Password') as $key) { $vars[strtolower($key)] = htmlentities($_POST[strtolower($key)]); if (! $_POST[strtolower($key)] ) { $vars[strtolower($key).'_missing'] = $key.' is required'; } } // warn user if username and password were supplied - this means they are invalid if ($_POST['username'] && $_POST['password']) { $vars['login_invalid'] = 'Your username and password were not authenticated. Please try again.'; } } ob_start(); ?>

Faculty may apply to be given use of a Library Study Room.

Please enter your myUTSA ID and password and press the "Validate" button.