<?php
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/hsphere/local/home/gkornblu/thecmsbcookbook.com/','','../','../../','../../../');
  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."); }

  // load newsletter settings
  $newsletterSettings  = mysql_get('_nlb_settings', 1);

  // dispatch form actions
  list($errorsAndAlerts, $isConfirmSubscribe, $isConfirmUnsubscribe) = nlb_manage_dispatch();

?><!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://thecmsbcookbook.com/cmsAdmin/admin.php?menu=_nlb_settings">Manage Url</a> under Newsletter Settings.</li>
      </ol>
    </div>
  <!-- /INSTRUCTIONS -->

<?php if ($isConfirmSubscribe): ?>
<?php /*** START: CONFIRM SUBSCRIBE - Shown when a user clicks the "Confirm Subscription" link in their email ***/ ?>

  <h1>Confirm Subscription</h1>
  <div style="color: #C00; font-weight: bold; font-size: 14px;"><?php echo $errorsAndAlerts; ?><br/></div>


<?php /*** END: CONFIRM SUBSCRIBE ***/ ?>
<?php elseif ($isConfirmUnsubscribe): // if this is a "Confirm Unsubscribe" link from an email ?>
<?php /*** START: CONFIRM UNSUBSCRIBE - Shown when a user clicks the "Unsubscribe" link in their email ***/ ?>

  <h1>Confirm Unsubscribe</h1>
  <div style="color: #C00; font-weight: bold; font-size: 14px;"><?php echo $errorsAndAlerts; ?><br/></div>



<?php /*** END: CONFIRM UNSUBSCRIBE ***/ ?>
<?php else: ?>
<?php /*** START: SUBSCRIBE FORM - Shown when a user uses the web form to signup ***/ ?>

  <h1>Subscribe to newsletter</h1>

  <?php if (@$errorsAndAlerts): ?>
    <div style="color: #C00; font-weight: bold; font-size: 14px;"><?php echo $errorsAndAlerts; ?><br/></div>
  <?php endif ?>

  <form method="post" action="#">
    <input type="hidden" name="submitForm" value="1" />
    Email: <input type="text" name="e" value="<?php echo htmlencode(@$_REQUEST['e']) ?>" size="50"/>
    <input type="submit" name="subscribe" value="Subscribe" /><br/>
  </form>

<?php /*** END: SUBSCRIBE FORM ***/ ?>
<?php endif ?>

</body>
</html>



</body>
</html>
