World of Joonicks :: $user blog
$box
END;
unset($box,$add,$backurl);
$comarr = array();
// view a specific entry not the whole blog
if (isset($cn) && file_exists($user."/".$cn))
{
list($ts,$body,$set_c,$set_h,$set_p,$commentct) = parse_entry($user."/".$cn);
$cword = ($commentct == 1) ? " Comment" : " Comments";
$entry = "".$ts.".
".$body;
if ($ok)
{
$entry .= "
"
.(($ok) ? "
Edit" : "")
."
";
}
echo $entry."\n";
foreach($comarr as $comtext)
{
$text = "".str_replace("<br>","
",htmlentities($comtext))."
\n";
$text = str_replace("ä","ä",$text);
$text = str_replace("ö","ö",$text);
$text = str_replace("å","å",$text);
$text = str_replace("Ä","Ä",$text);
$text = str_replace("Ö","Ö",$text);
$text = str_replace("Å","Å",$text);
echo $text;
}
if ($ca && isset($addbody) && $addbody && $set_c == 1)
{
echo "".str_replace("<br>","
",htmlentities($addbody))."
\n";
$ip = $_SERVER["REMOTE_ADDR"];
$remotehost = gethostbyaddr($ip);
file_put_contents($user."/".$cn,"\n".$addbody,FILE_APPEND);
file_put_contents($bloglog,"[".gmdate("g:ia D M j Y",time())."] $remotehost ($ip) added a comment to $user ($cn)\n",FILE_APPEND);
}
if ($set_c == 1) echo <<
END;
echo "\n";
exit;
}
// edit an entry
if ($ok && isset($ed) && file_exists($user."/".$ed))
{
$filename = $user."/".$ed;
if (isset($_POST["body"]))
{
$priv = (isset($_POST["p"]) && $_POST["p"] == "on") ? "-p" : "";
$hidden = (isset($_POST["h"]) && $_POST["h"] == "on") ? "-h" : "";
$comments = (isset($_POST["c"]) && $_POST["c"] == "on") ? "-c" : "";
$comtext = file_get_contents($filename);
$x = explode("\n.\n",$comtext,2);
$comtext = array_pop($x);
$when = trim($_POST["when"]);
$body = trim(str_replace("\n\n","\n
",str_replace("\r","",$_POST["body"])));
file_put_contents($filename,$priv.$hidden.$comments.$when."\n".$body."\n.\n".$comtext);
/*
* store entry height in index file
*/
if (isset($_POST["hgt"]) && !empty($_POST["hgt"]))
{
$hgt = $_POST["hgt"];
if ($hgt{0} == "L")
{
$hgt = intval(substr($hgt,1));
$L = "L";
}
else
{
$hgt = intval($hgt);
$L = "";
}
$indexlist = explode("\n",trim(file_get_contents($user."/index")));
$newindex = array();
foreach($indexlist as $index)
{
$o = $index;
if (strpos($index,":") !== FALSE)
{
list($index,$orighgt) = explode(":",$index,2);
}
if ($index == $ed)
{
$newindex[] = $index.":".$L.$hgt;
}
else
{
$newindex[] = $o;
}
}
file_put_contents($user."/index",implode($newindex,"\n")."\n");
}
}
list($ts,$body,$set_c,$set_h,$set_p,$commentct) = parse_entry($user."/".$ed);
$rawtext = file_get_contents($filename);
$x = explode("\n",$rawtext,2);
$rawtext = array_pop($x);
$x = explode("\n.\n",$rawtext,2);
$rawtext = $x[0];
$cword = ($commentct == 1) ? " Comment" : " Comments";
echo "".$ts.".
".$body."
\n";
foreach($comarr as $comtext)
{
echo "".str_replace("<br>","
",htmlentities($comtext))."
\n";
}
$cflag = ($set_c == 1) ? " CHECKED" : "";
$hflag = ($set_h == 1) ? " CHECKED" : "";
$pflag = ($set_p == 1) ? " CHECKED" : "";
echo <<
END;
echo "