<?php

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('','../','../../','../../../','../../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // error checking
  if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); }

  // error checking
  $errorsAndAlerts = alert();
  if (@$CURRENT_USER) {
    $errorsAndAlerts = "You are already logged in! <a href='{$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']}'>Click here to continue</a> or <a href='?action=logoff'>Logoff</a>.";
  }

?>
<?php include_once("_members-header.php") ?>

<h1>Sample User Login Form</h1>

<!-- USER LOGIN FORM -->
  <?php if (@$errorsAndAlerts): ?>
    <div style="color: #C00; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
      <?php echo $errorsAndAlerts; ?><br/>
    </div>
  <?php endif ?>

<?php if (!@$CURRENT_USER): ?>
  <form action="" method="post">
  <input type="hidden" name="action" value="login" />

  <table border="0" cellspacing="0" cellpadding="2">
   <tr>
    <td>Username</td>
    <td><input type="text" name="username" value="<?php echo htmlspecialchars(@$_REQUEST['username']); ?>" size="20" /></td>
   </tr>
   <tr>
    <td>Password</td>
    <td><input type="password" name="password" value="<?php echo htmlspecialchars(@$_REQUEST['password']); ?>" size="20" /></td>
   </tr>

   <tr>
    <td colspan="2" align="center">
      <br/><input type="submit" name="submit" value="Login" />
      <a href="<?php echo $GLOBALS['WEBSITE_LOGIN_SIGNUP_URL'] ?>">or sign-up</a><br/><br/>
      <a href="<?php echo $GLOBALS['WEBSITE_LOGIN_REMINDER_URL'] ?>">Forgot your password?</a>

    </td>
   </tr>
  </table>
  </form>
<?php endif ?>
<!-- /USER LOGIN FORM -->


<?php include_once("_members-footer.php") ?>