<?php
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/hosted/superiorequinesires.com/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  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='/'>Click here to continue</a> or <a href='?action=logoff'>Logoff</a>.<br/>\n"; }
  if (!$CURRENT_USER && @$_REQUEST['loginRequired']) { $errorsAndAlerts .= "Please login to continue.<br/>\n"; }

  // save url of referring page so we can redirect user there after login
  if (!getPrefixedCookie('lastUrl')) { setPrefixedCookie('lastUrl', @$_SERVER['HTTP_REFERER'] ); }

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <style type="text/css">
    body          { font-family: arial; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
  </style>
 </head>
<body>

<h1>Sample User Login Form</h1>

<!-- USER LOGIN FORM -->
  <?php if (@$errorsAndAlerts): ?>
    <div style="color: #C00; font-weight: bold; font-size: 13px;">
      <?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>Email or Username</td>
    <td><input type="text" name="username" value="<?php echo htmlencode(@$_REQUEST['username']); ?>" size="30" /></td>
   </tr>
   <tr>
    <td>Password</td>
    <td><input type="password" name="password" value="<?php echo htmlencode(@$_REQUEST['password']); ?>" size="30" /></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/>

      <?php if (@$GLOBALS['FACEBOOKAPI_ENABLE_LOGIN']): // NOTE: This feature requires the Facebook Login plugin! ?>
        <a href="<?php echo facebookLogin_getFacebookLoginUrl();?>"
        onclick="<?php echo facebookLogin_getFacebookLoginUrl_popupOnClick(); ?>">Login with Facebook</a><br/><br/>
      <?php endif ?>

    <?php if (@$GLOBALS['TWITTERAPI_ENABLE_LOGIN']): ?>
      <a href="<?php echo twitterLogin_getTwitterLoginUrl();?>"
      onclick="<?php echo twitterLogin_getTwitterLoginUrl_popupOnClick(); ?>">Login with Twitter</a><br/><br/>
    <?php endif ?>

      <a href="<?php echo $GLOBALS['WEBSITE_LOGIN_REMINDER_URL'] ?>">Forgot your password?</a>

    </td>
   </tr>
  </table>
  </form>
<?php endif ?>
<!-- /USER LOGIN FORM -->
</body>
</html>
