<?php

    
require("functions.php");

    
$res XMLtoArray(file_get_contents("posts.xml")) or die("Unable to read the posts xml file.");

?>
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="JaviteSoft - Open source and code examples">
    <meta name="author" content="JaviteSoft">

    <title>JaviteSoft - Open source and code examples</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <link href="css/global.css" rel="stylesheet">
    <link rel="icon" href="favicon.ico">
    <link rel="apple-touch-icon" href="apple-touch-icon.png"/>
    <link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png"/>
  </head>

  <body>

    <a name="top"></a>
    <div class="main-masthead fixed-nav-bar">
      <div class="container">
        <nav class="main-nav">
          <a class="main-nav-item active" href="index.php">Home</a>
          <a class="main-nav-item" href="projects.php" title="View the projects in development">Projects</a>
          <a class="main-nav-item" href="snippets.php" title="View the code snippets library">Snippets</a>
          <a class="main-nav-item" href="depends.php" title="Download any dependencies required">Dependencies</a>
          <a class="main-nav-item" href="contact.php" title="Contact JaviteSoft">Contact</a>
          <a class="main-nav-item" href="about.php" title="About JaviteSoft">About</a>
        </nav>
      </div>
    </div>

    <div class="container">

      <div class="main-header">
        <h1 class="main-title">JaviteSoft development</h1>
        <p class="lead main-description">The official website for JaviteSoft projects in development.</p>
      </div>

      <div class="row">

        <div class="col-sm-8 main-main">

<?php

    $id 
$_SERVER['QUERY_STRING'];

    if (!
preg_match('/^(\\w{3})+(\\d{4})+$/'$id))
    {
        
// not a valid id, reset it
        
$id "";
    }

    
$archived "";

    for (
$i 0$i count($res['POSTS']['POST']); $i++)
    {
        
$item $res['POSTS']['POST'][$i];

        if ((
$item['ARCHIVED'] == 'false' && empty($id)) ||
            (
$item['ARCHIVED'] != 'false' && !empty($id) && $id == date("MY"strtotime($item['POSTED']))))
        {
            print <<<END_OF_HTML

          <div class="main-post">
            <h2 class="main-post-title">
$item[TITLE]</h2>
            <p class="main-post-meta">
$item[POSTED] by <a href="contact.php">Java</a></p>
            <p>
              
$item[BODY]
            </p>
            <hr>

          </div><!-- /.main-post -->

END_OF_HTML;

        }

        if (
$item['ARCHIVED'] != 'false')
        {
            
$posted date("F Y"strtotime($item['POSTED']));

            if (
strpos($archived$posted) === false)
            {
                
$archived .= "<li><a href=\"index.php?" date("MY"strtotime($item['POSTED'])) . "\">$posted</a></li>";
            }
        }
    }

    if (!empty(
$id))
    {
        print <<<END_OF_HTML

          <p>
            <a href="index.php">Back to recent posts</a>
          </p>

END_OF_HTML;

    }

?>
        </div><!-- /.main-main -->

        <div class="col-sm-3 col-sm-offset-1 main-sidebar">
          <div class="sidebar-module sidebar-module-inset">
            <h4>About</h4>
            <p>JaviteSoft is a software development company which specializes in native application programming for Microsoft Windows operating systems.</p>
          </div>
          <div class="sidebar-module">
            <h4>Archives</h4>
            <ol class="list-unstyled">
              <?php echo $archived?>
            </ol>
          </div>

        </div><!-- /.main-sidebar -->

      </div><!-- /.row -->

    </div><!-- /.container -->

    <footer class="main-footer">
      <p>Copyright &copy; 2015 JaviteSoft. All Rights Reserved.</p>
      <p>
        <a href="#top">Back to top</a>
      </p>
      <p>
        <a href="index.phps"><small>View page source</small></a>
      </p>
    </footer>


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="js/ie10-viewport-bug-workaround.js"></script>
    <!-- Fix for local page links -->
    <script src="js/fix_anchors.js"></script>
  
</body>
</html>