2) { $comarr[] = $line; $commentct++; } } } while(preg_match("#(.*)\[img=([A-Za-z0-9_\-\.\/\:\=\?\|]+)\](.*)#",$body,$m) == 1) { $style = ""; $size = ""; $href = ""; $rest = array_pop($m); if (strpos($m[2],"|") !== FALSE) { $op = explode("|",$m[2]); $m[2] = array_shift($op); foreach($op as $v) { if (strtolower($v) == "center") $style = ' style="margin:0 auto"'; if (strtolower($v) == "right") $style = ' style="float:right; margin:0 0 0 1.5em;"'; if (strtolower(substr($v,0,5)) == "href=") $href = substr($v,5); else if (preg_match("#^(\d+)x(\d+)$#",$v,$n) == 1) { $size = " width=\"".$n[1]."\" height=\"".$n[2]."\""; } } } if (empty($href)) $href = $m[2]; $body = $m[1].'
'.$rest; unset($rest,$href,$size,$style); } while(preg_match("#(.*)\[\[([\w\s]+)\]\](.*)#",$body,$m) == 1) { $body = $m[1]."".$m[2]."".$m[3]; } while(preg_match("#(.*)\[\[([\w\s\(\)]+)\|([\w\s]+)\]\](.*)#",$body,$m) == 1) { $body = $m[1]."".$m[3]."".$m[4]; } while(preg_match("#(.*)\[(.+)\|(.+)\](.*)#",$body,$m) == 1) { $body = $m[1]."".$m[3]."".$m[4]; } if (strpos($body,"float:") !== FALSE) $body .= "
"; return(array($ts,$body,$set_c,$set_h,$set_p,$commentct)); } $user = ""; if (isset($_GET["u"])) { $xuser = $_GET["u"]; if (preg_match("#^[A-Za-z\d]{3,15}$#",$xuser,$m) == 1) { if (file_exists($xuser."/index")) $user = $xuser; } unset($xuser,$m); } unset($cn,$ed); $ca = FALSE; unset($addbody); if (isset($_GET["cn"]) && is_numeric($_GET["cn"])) { $cn = intval($_GET["cn"]); } if (isset($_GET["ed"]) && is_numeric($_GET["ed"])) { $ed = intval($_GET["ed"]); } /* * ca, comment add */ if (isset($_GET["ca"]) && is_numeric($_GET["ca"])) { $cn = intval($_GET["ca"]); $ca = TRUE; if (isset($_POST["body"])) { $addbody = trim(str_replace("\r","",str_replace("\n","
",$_POST["body"]))); /* * deal with spammers */ if (strpos($addbody,"[url") !== FALSE) unset($addbody); else if (strpos($addbody,"

"; $box = "
".$user .$separator .((isset($_GET["add"])) ? "" : "Add an entry".$separator) ."Log
\n"; if (isset($_GET["add"])) $add = ""; /* * move an entry up request */ if (isset($_GET["up"])) { $m = trim($_GET["up"]); if (strpos($m,"/") === FALSE && file_exists($user."/".$m)) { $indexlist = explode("\n",trim(file_get_contents($user."/index"))); $new = array(); unset($nextup); foreach($indexlist as $i) if ($i) { if ($i == $m) { $nextup = $i; continue; } else { $new[] = $i; } if (isset($nextup)) { $new[] = $nextup; unset($nextup); } } if (isset($nextup)) $new[] = $nextup; file_put_contents($user."/index",implode($new,"\n")."\n"); } unset($indexlist,$new,$m,$i,$temp); } /* * move an entry down request */ if (isset($_GET["down"])) { $m = trim($_GET["down"]); if (strpos($m,"/") === FALSE && file_exists($user."/".$m)) { $indexlist = explode("\n",trim(file_get_contents($user."/index"))); $new = array(); foreach($indexlist as $i) if ($i) { if ($i == $m && count($new) > 0) { $temp = array_pop($new); $new[] = $i; $new[] = $temp; } else { $new[] = $i; } } file_put_contents($user."/index",implode($new,"\n")."\n"); } unset($indexlist,$new,$m,$i,$temp); } unset($separator); } $backurl = "../index"; if (isset($cn) && file_exists($user."/".$cn)) $backurl = "/blog/?u=$user"; if ($ok && isset($ed) && file_exists($user."/".$ed)) $backurl = "/blog/?u=$user"; echo << 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("&auml;","ä",$text); $text = str_replace("&ouml;","ö",$text); $text = str_replace("&aring;","å",$text); $text = str_replace("&Auml;","Ä",$text); $text = str_replace("&Ouml;","Ö",$text); $text = str_replace("&Aring;","Å",$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 <<
Private Hidden Allow Comments

Entry height: (xxx for pixels, Lxxx for lines)
END; echo "\n"; exit; } if ($ok && isset($_GET["add"])) { echo << Private Hidden Allow Comments

END; } // storing new entry if ($ok && isset($_POST["when"]) && 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" : ""; $when = trim($_POST["when"]); $body = trim(str_replace("\n\n","\n

",str_replace("\r","",$_POST["body"]))); $x = explode("\n",trim(file_get_contents($user."/index"))); $ct = 1 + array_pop($x); while(file_exists($user."/".$ct)) $ct = $ct + 1; $f = $user."/".$ct; file_put_contents($f,$priv.$hidden.$comments.$when."\n".$body."\n.\n"); file_put_contents($user."/index",$ct."\n",FILE_APPEND); } $ip = $_SERVER["REMOTE_ADDR"]; $showpage = 1; if (isset($_GET["p"]) && is_numeric($_GET["p"])) { $showpage = intval($_GET["p"]); } unset($_POST,$_GET,$_COOKIE,$_FILES,$_SERVER); $indexlist = explode("\n",trim(file_get_contents($user."/index"))); /* * flip the list and parse hgt values */ $newlist = array(); foreach($indexlist as $index) { $hgt = 71; if (strpos($index,":") !== FALSE) { list($index,$hgt) = explode(":",$index,2); if ($hgt{0} == "L") { $hgt = intval(substr($hgt,1) * 16); } else { $hgt = intval($hgt); } $hgt += 55; } array_unshift($newlist,array(intval($index),$hgt)); } $pagehgt = 80; $pagecounter = 1; foreach($newlist as $entry) { $index = $entry[0]; $hgt = $entry[1]; if (($pagehgt + $hgt) > 900) { $pagehgt = 80; $pagecounter++; } $pagehgt += $hgt; } $maxpage = $pagecounter; $pagehgt = 80; $pagecounter = 1; $pageentries = 0; foreach($newlist as $entry) { $index = $entry[0]; $hgt = $entry[1]; if (($pagehgt + $hgt) > 900) { if ($showpage == $pagecounter) { echo "


"; if ($pagecounter > 1) { echo " First "; echo " Previous "; } else { echo " First "; echo " Previous "; } echo "Page $pagecounter of $maxpage"; echo " Next "; echo " Last "; echo "

"; } $pagehgt = 80; $pageentries = 0; $pagecounter++; } $pagehgt += $hgt; if ($showpage == $pagecounter) { list($ts,$body,$set_c,$set_h,$set_p,$commentct) = parse_entry($user."/".$index); $cword = ($commentct == 1) ? $commentct." Comment" : $commentct." Comments"; echo "

".$ts.".
".$body; if ($set_c == 1 || $ok) { echo "

" .(($set_c == 1) ? "".$cword."" : "") .(($ok) ? " Edit" : "") .(($ok) ? " Up Down" : "") ."
"; } echo "

\n"; $pageentries++; } } if ($showpage == $pagecounter) { echo "


"; echo " First "; echo " Previous "; echo "Page $pagecounter of $maxpage"; echo " Next "; echo " Last "; echo "

"; } $remotehost = gethostbyaddr($ip); $ct = 1 + intval(file_get_contents($user."/counter")); // do not count yahoo slurp crawler if (isset($_SERVER["HTTP_USER_AGENT"]) && strpos($_SERVER["HTTP_USER_AGENT"],'Yahoo! Slurp') !== FALSE) { file_put_contents($bloglog,"[".gmdate("g:ia D M j Y",time())."] $remotehost ($ip) Yahoo Slurp visited $user blog" .((isset($cn)) ? " {comment}" : "")."\n",FILE_APPEND); } else { if (!$ok) file_put_contents($user."/counter",$ct); file_put_contents($bloglog,"[".gmdate("g:ia D M j Y",time())."] " ."$remotehost ($ip) ".(($ok) ? "[logged in] " : "")."viewed $user blog" .((isset($cn)) ? " {comment}" : "")."\n",FILE_APPEND); } echo "
$ct
\n"; ?>