Show sourcecode

The following files exists in this folder. Click to view.

test/incl/blokket/

add-article.php
aside.php
blokket-default.php
data/
initiate.php
remove-article.php
show-all-articles.php
show-article.php
update-article.php

initiate.php

1 lines ASCII Unix (LF)
1
<h1>Initiate the Blokk</h1>

<?php
if (substr(sprintf('%o', fileperms("incl/blokket/data")), -4) == 777)
    echo "<p>The directory is writable.</p>";
else
    echo "<p>The directory is NOT writable.</p>";

$path = "incl/blokket/data";

$filenames = readDirectory($path);

if(isset($_POST["doArticleReset"]))
{
    foreach($filenames as $filename)
    {
        unlink("$path/$filename");
    }

    $name = "chewing gum";
    $newfile = fopen("$path/$name", "w");
    chmod ("$path/$name", 0666);
    $content = "<img class='left' src='incl/blokket/data/img/chewinggum.jpg' width=100 alt='Image: Chewing gum'>A piece of chewing gum. Slightly used. Most of the flavor (raspberry) still left. Easy to blow bubbles with.";
    writeOverFileContents("$path/$name", $content);
    fclose($newfile);

    $name = "parachute";
    $newfile = fopen("$path/$name", "w");
    chmod ("$path/$name", 0666);
    $content = "<img class='left' src='incl/blokket/data/img/parachute.jpg' width=100 alt='Image: Parachute'>A parachute with extra holes in it. For anyone who likes parachuting but thinks it takes too long to reach the ground.";
    writeOverFileContents("$path/$name", $content);
    fclose($newfile);

    $name = "pistol";
    $newfile = fopen("$path/$name", "w");
    chmod ("$path/$name", 0666);
    $content = "<img class='left' src='incl/blokket/data/img/pistol.jpg' width=100 alt='Image: Pistol'>A pistol. Good to have in case you get tired of someone (perhaps yourself).";
    writeOverFileContents("$path/$name", $content);
    fclose($newfile);

    $filenames = readDirectory($path);
}

echo "<p>The directory contains the following files:</p><ul>";
    foreach($filenames as $filename)
    echo "<li>" . $filename . "</li>";
    echo "</ul>";
?>

<form method="post">
    <input type="submit" name="doArticleReset" value="Reset to default articles">
</form>