<?php
  require_once "C:/www/sb/core2/admin/lib/viewer_functions.php";
  $options = array();                  // NOTE: see online documentation for more details on these options
  $options['tableName']  = 'blog';     // (REQUIRED) MySQL tablename to list record from. Example: 'article';
  $options['perPage']    = '9999';     // (optional) The number of records to display per page. Example: '5'; Defaults to 10.
  $options['orderBy']    = '`order`';  // (optional) Fieldnames to sort by. Example: 'field1, field2 DESC, field3';
  $options['pageNum']    = '1';        // (optional) Page number of results to display. Example: '1'; Defaults to number on end of url, then 1
  list($listRows, $listDetails) = getListRows($options);

  // get requested page name
  $requestedPage = str_replace("/", "", @$_SERVER["PATH_INFO"]);
  if (!$requestedPage) { $requestedPage = "home"; }

  // get requested page record
  $pageRecord = null;
  foreach ($listRows as $menuRecord) {
    if ($requestedPage == $menuRecord['pageurl']) {
      $pageRecord = $menuRecord;
    }
  }

  // error if page not found
  if (!$pageRecord) {
    header("HTTP/1.1 404 Not Found");
    print file_get_contents("404.html");
    exit;
  }

?>

<?php echo "<?xml version='1.0'?>\n"; ?>
<!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>


  <!-- show menu -->
  <h1>Menu</h1>
  <?php
     foreach ($listRows as $menuRecord):
       $pageLink   = "{$_SERVER['PHP_SELF']}/{$menuRecord['pageurl']}/";
       $isSelected = $requestedPage == $menuRecord['pageurl'];
   ?>

     <?php if ($isSelected): ?>
        <b><a href="<?php echo $pageLink; ?>"><?php echo $menuRecord['title'] ?></a></b> (selected)<br/>
     <?php else: ?>
        <a href="<?php echo $pageLink; ?>"><?php echo $menuRecord['title'] ?></a><br/>
     <?php endif ?>
  <?php endforeach ?>
  <!-- /show menu -->


  <!-- show page content -->
   <h1>Page Content</h1>
      Record Number: <?php echo $pageRecord['num'] ?><br/>
      Title: <?php echo $pageRecord['title'] ?><br/>
      pageUrl: <?php echo $pageRecord['pageurl'] ?><br/>
      order: <?php echo $pageRecord['order'] ?><br/>
      Date: <?php echo date("D, M jS, Y G:H:s a", strtotime($pageRecord['date'])) ?><br/>
            <!-- For date formatting codes see: http://www.php.net/date -->
      Content: <?php echo $pageRecord['content'] ?><br/>
      External Link: <?php echo $pageRecord['external_link'] ?><br/>
  <!-- /show page content -->



</body>
</html>
