Exemple #1
0
function makedivs($dir)
{
    $dirs = directorylister($dir);
    $dirs = array_reverse($dirs);
    if (file_exists($dir . "/" . $dirs[0])) {
        //if we are down to names, print out the date and year
        //split the directory to show the montha nd year
        $xpld = explode("/", $dir);
        echo "<h2>" . $xpld[2] . " " . $xpld[1] . "</h2>";
    }
    foreach ($dirs as $string) {
        if (is_dir("{$dir}/{$string}")) {
            echo "<br/>\n\t\t\t<h1>{$string}</h1>";
            //now we need to do months
            $subdirs = directorylister("{$dir}/{$string}");
            foreach ($subdirs as $subdir) {
                echo "<a href = \"past.php?id={$dir}/{$string}/{$subdir}\">\n                <div class = \"datesinpast\">\n                {$subdir}\n                </div></a>";
            }
        } elseif (file_exists("{$dir}/{$string}")) {
            //we need to open the file and grab the title
            $handle = fopen("{$dir}/{$string}", "r");
            $read = fread($handle, 1000);
            fclose($handle);
            preg_match("'<h1>(.*?)</h1>'si", $read, $titles);
            //preg match returns an array which we must index
            $title = strip_tags($titles[0]);
            echo "<div class = \"textinpast\">\n    <a href = \"reader.php?id={$dir}/{$string}\">{$title}</a>\n</div>";
        }
    }
    return true;
}
Exemple #2
0
function upcomingmakedivs($dir)
{
    //whoever inherits this, I wrote it this way (importing previous) so that
    //we reduce code re-use... I know it's a little ugly.
    $dirs = directorylister($dir);
    foreach ($dirs as $string) {
        $handle = fopen("{$dir}/{$string}", "r");
        $read = fread($handle, 300);
        fclose($handle);
        //we need to put the ... inside the <p>
        if (substr($read, -5, 4) == "</p>") {
            $content = substr($read, 0, strlen($read) - 10) . "...</p>";
        } else {
            $content = $read . "...";
        }
        echo "<a href = \"reader.php?id={$dir}/{$string}\">\n    <div class = \"upcoming\">\n        {$content}\n    </div>\n</a>";
    }
}