<?php

// run this as:
// php run_tests.php
function printBarrier()
{
    echo "\r\n\r\n\r\n";
}
function printnl($message)
{
    echo "{$message}\r\n";
}
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . "PlancakeEmailParser.php";
$emails = glob(__DIR__ . DIRECTORY_SEPARATOR . "emails" . DIRECTORY_SEPARATOR . "*");
printBarrier();
foreach ($emails as $email) {
    printnl("Email {$email}");
    $emailParser = new PlancakeEmailParser(file_get_contents($email));
    printnl("subject: " . $emailParser->getSubject());
    printnl("body: " . $emailParser->getBody());
    printBarrier();
}
foreach ($files as $f) {
    $partFile = $dir . $f;
    $fullFile = $root . $dir . $f;
    if (strcmp($fullFile, $thisFile) == 0 || strcmp($fullFile, $css) == 0 || strcmp($f, ".") == 0 || strcmp($f, "..") == 0 && strcmp($root, $full) == 0) {
        continue;
    }
    if (is_dir($fullFile)) {
        $end = str_replace($full, "", $partFile);
        if (strcmp($f, "..") == 0) {
            $end = str_replace($root, "", dirname($full));
        }
        if (strcmp($end . DIRECTORY_SEPARATOR, $root) == 0) {
            $end = "";
        }
        printf("<div class='parent' ><a class='directory' href='index.php?dir=" . $end . "' >%s</a></div>", $f);
        printnl();
    } else {
        $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $f);
        $path = $dir . DIRECTORY_SEPARATOR . $f;
        printf("<div class='parent' ><a class='file' href='%s' >%s</a></div>", $path, $withoutExt);
        printnl();
    }
}
function printnl()
{
    printf("<br/>");
}
?>
 </body>
</html>