<?php
//Check if WS has been installed yet.
if (file_exists('ni.txt')) {
    echo "<script>location.replace('install/index.php')</script>";
    die();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php
require 'data/conf.php'; //Include the global config
require 'data/modules.php';  //Include module system
?>
<html>
    <head>
        <title><?= $site_name; ?><?= $tagline; ?></title>
        <link href="<?= $css_theme; ?>" title="compact" rel="stylesheet" type="text/css">
            <?php $icon = explode('/', $css_theme); ?>
            <link rel="shortcut icon" href="<?= 'themes/' . $icon[1] . '/favicon.ico'; ?>" type="image/x-icon" />
    </head>
    <?php
    if (!file_exists($lang)) {
        die('could not load language file');
    }

    require "$lang";
    require 'data/func.php';  //Include the global functions
    ?>
    <body>
        <div id="bg">
            <div id="frame">
                <div id="contentheader"><h1><a href="."><?= $site_name; ?></a> <?= $tagline; ?></h1></div>
                <div id="contentleft">
                    <?php
                    if ($calendar == TRUE) {
                        echo "<h1>$calendar_n</h1>";
                        require 'modules/calendar.php';
                    }
                    ?>
                    <?php plug("index", "contentleft"); ?>
                </div>
                <div id="contentcenter">
                    <p>
                        <?php
                        $page = $_GET['page'];
                        $file = array_reverse(file("data/blog.txt"));
                        for ($x = (int) $_GET['start']; $x < sizeof($file) && $x < ((int) $_GET['start'] + $per_page); $x++) {
                            $explode = explode("#", $file[$x]);
                            //Because every post adds 2 blank lines (or some shit), this check if its empty or not so to prevent faulty posts.
                            $explode[3] = nl2br($explode[3]);
                            echo "<p>$explode[2]<br> <small>$date_n - $explode[4]</small></b><br /><br /><body>$explode[3]</body></p><hr><br />";
                        }

                        if (sizeof($file) >= $per_page) {
                            if (isset($_GET['start']) && $_GET['start'] != 0) {
                                echo '<a href=./index.php?start=' . ($_GET['start'] - $per_page) . '>Previous</a> | ';
                            }
                            echo '<a href=./index.php?start=' . ($_GET['start'] + $per_page) . '>Forward</a></center><br>';
                        }
                        plug("index", "contentcenter");
                        ?>
                    </p>
                    <br />
                    <div id="footer">
                        <center><small><a href="http://geekness.eu/ws">Powered by WorkSimple 	<?php plug("index", "footer"); ?></a></small></center>
                    </div>
                    <br />
                </div>
                <div id="contentright">
                    <?php
                    plug("index", "contentright");
                    if ($ad_status == TRUE) {
                        //show the ads
                        echo "<h1>Links</h1>";
                        echo "<p><big><h2>";
                        plug("index", "ads");
                        echo "</big></h2></p>";
                    } else {
                        //if no ads, just show the links (nothing)
                        plug("index", "links");
                    }
                    ?>
                </div>
            </div>
    </body>
    <!--Easton E 2011©. Used under a Creative Commons Attribution 3.0 Unported License. Some rights reserved
    http://geekness.eu/ws for more info on WorkSimple
    -->
</html>
