Create New Post
";
/*Post Editing*/
} elseif ($_POST["mod"] == "Commit Edit") {
$fh = fopen($_POST["id"], 'w');
if (!$fh) die("ERROR: couldn't write to ".$_POST['id'].", check permissions");
fwrite($fh,stripslashes($_POST["content"]));
fclose($fh);
echo "Edited ".$_POST["id"]."
";
/*Post Creation*/
} elseif ($_POST["mod"] == "Create Post") {
$pnum = intval(substr($postlisting[0],0,strpos($postlisting[0],'-'))) + 1;
$id = $dir.$pnum."-".$_POST["title"].".post";
/*echo $id."
";
var_dump($postlisting[0]);
var_dump($_POST);
die("FOOBAR");*/
$fh = fopen($id, 'w');
if (!$fh) die("ERROR: Couldn't Write ".$id.", check permissions");
fwrite($fh,stripslashes($_POST["content"]));
fclose($fh);
echo "Created ".$id."
";
/*Catchall*/
} else {
die("Nothing to do");
}
}
/*Spit out the posts into the DOM so that they can be edited/deleted*/
$postlisting = scandir($dir);
rsort($postlisting, SORT_NUMERIC);
foreach ($postlisting as $key=>$val) {
$id = $_SERVER["DOCUMENT_ROOT"].$config['basedir'].$config['blogdir'].basename($val);
$posttitle = strstr($val,'.', true);
if (!empty($posttitle)) {
$postincrementer++;
print "
".$posttitle."
";
$JSAIDS.="document.getElementById('link".$postincrementer."').addEventListener('click',function () {loadpost('/".$config['basedir'].$config['blogdir'].$val."','innerHTML".$postincrementer."',false);});\nwindow.postsLoaded['innerHTML".$postincrementer."'] = false;";
}
}
print "";
?>