<?php

  // load viewer library
  $libraryPath = 'builder/lib/viewer_functions.php';
  $dirsToCheck = array('/home/sandbox/public_html/706sandbox/','','../','../../','../../../');
  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['NEWSLETTER_BUILDER_PLUGIN']) { die("You must activate the newsletter plugin to see this page."); }

  //
  list($errorsAndAlerts, $lists, $authUserNum, $authUserEmail) = nlb_frontend_dispatcher3();

?><!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>


  <!-- INSTRUCTIONS -->
    <div class="instructions">
      <b>Sample Subscriber Script - Instructions:</b>
      <ol>
        <?php /*><li style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
        <li>Newsletter subscribers will use this script to subscribe, confirm subscriptions, and unsubscribe</li>
        <li>Modify the HTML and design of this page as needed, then update <a href="http://706sandbox.northernpenguin.com/builder/admin.php?menu=_nlb_settings">Manage Url</a> under Newsletter Settings.</li>
      </ol>
    </div>
  <!-- /INSTRUCTIONS -->

<?php /*** START: SUBSCRIBE FORM - Shown when a user uses the web form to signup ***/ ?>
  <h1>Manage Subscriptions</h1>

  <?php if ($errorsAndAlerts): ?>
    <div style="color: #C00; font-weight: bold; font-size: 14px;"><?php echo $errorsAndAlerts; ?></div><br/>
  <?php endif ?>

  <form method="post" action="?">
    <input type="hidden" name="submitForm" value="1" />
    <input type="hidden" name="n" value="<?php echo htmlencode(@$_REQUEST['n']); ?>" /><?php // subscriber num ?>
    <input type="hidden" name="a" value="<?php echo htmlencode(@$_REQUEST['a']); ?>" /><?php // subscriber authkey ?>

    <div style="float: left; width: 100px; clear: both;">Email:</div>
    <div style="float: left; ">
      <?php if (@$authUserNum): ?>
        <?php echo htmlencode($authUserEmail); ?>
      <?php else: ?>
        <input type="text" name="e" value="<?php echo htmlencode(@$_REQUEST['e']) ?>" size="50"/>
      <?php endif ?>
    </div>

    <div style="float: left; width: 100px; clear: both;">Newsletters:</div>
    <div style="float: left;">
      <?php foreach ($lists as $list): ?>
        <?php
          $isChecked   = @$_REQUEST['lists'] && in_array($list['num'], $_REQUEST['lists']);
          $checkedAttr = checkedIf($isChecked, true, true);
        ?>
        <label>
          <input type="checkbox" name="lists[]" value="<?php echo htmlencode($list['num']); ?>"  <?php echo $checkedAttr; ?> />
          <?php echo htmlencode($list['name']); ?><br/>
        </label>
      <?php endforeach ?>
      <input type="submit" name="subscribe" value="Update Subscriptions" /><br/>
    </div>

    <div style="clear: both;"></div>

  </form>
<?php /*** END: SUBSCRIBE FORM ***/ ?>

</body>
</html>

</body>
</html>
