"; if ($ip == $value ) { $logThis=1; } } if ($logThis != 1) { //echo "ip=$ip,logThis=$logThis,
"; if (file_exists($commentdir)) { $fp=fopen($statsFile,"a"); fwrite($fp,$statsContent); fclose($fp); } } if (file_exists($statsFile)) {$statsRead=file($statsFile);} $hits=0; $online=0; $already=array(); if (is_array($statsRead)) { foreach ($statsRead as $value) { $log=explode($separator,$value); $logIP=$log[0]; $logTime=$log[1]; $timeOnline=$currentTime-$logTime; //echo "logIP = $logIP, logTime = $logTime,
"; if ($timeOnline < $config_usersOnlineTimeout) { if (array_search($logIP,$already)===FALSE) {$online++;} array_push($already,$logIP); } $hits++; } } echo "Users Online: $online
"; echo "Hits: $hits
"; } function listPosts() { global $separator, $postdir, $entries, $config_entriesPerPage, $requestCategory, $config_maxPagesDisplayed; global $commentdir,$config_dbFilesExtension; $filterEntries=array(); $totalEntries=0; $totalPosts=0; if (is_array($entries)) { foreach ($entries as $value) { $entry =explode($separator,$value); $title =$entry[0]; $content =$entry[1]; $date1 =$entry[2]; $fileName=$entry[3]; $category=$entry[4]; $postType=$entry[5]; if ($requestCategory == "") { if ($postType!="page") { array_push($filterEntries,$value); $totalEntries++; $totalPosts++; } } else { if ($category == $requestCategory) { array_push($filterEntries,$value); $totalEntries++; } } } } if ($totalEntries == 0) { $justCommentsDir=str_replace("/","",(substr($commentdir,strlen(getcwd()),strlen($commentdir)))); $justPostsDir=str_replace("/","",(substr($postdir,strlen(getcwd()),strlen($postdir)))); $errorMessage="
Unable to create posts and comments directories
Please create them manually.
"; $errorMessage=$errorMessage."Here are the directory names:
- ".$justPostsDir."
- ".$justCommentsDir."
"; $errorMessage=$errorMessage."
Make sure the permissions on these directories and the main blog directory are set to 755.
"; if (is_writable(getcwd())) { if (!file_exists($commentdir) || !file_exists($postdir)) { /* Looks like first time running */ mkdir($commentdir,0755) or die($errorMessage); mkdir($postdir,0755) or die($errorMessage); } echo '
No posts yet. Why dont you make one?
'; } else { exit($errorMessage); } } # Pagination - This is the so called Pagination $page = isset($_POST['page'])?$_POST['page']:$_GET['page']; if($page == ''){ $page = 1; } # What part of the array should i show in the page? $arrayEnd = ($config_entriesPerPage*$page); $arrayStart = $arrayEnd-($config_entriesPerPage-1); # As arrays start from 0, i will lower 1 to these values $arrayEnd--; $arrayStart--; $totalEntries--; $i = $arrayStart; if ($arrayEnd > $totalEntries) {$arrayEnd = $totalEntries;} while($i<=$arrayEnd) { $entry =explode($separator,$filterEntries[$i]); $title =$entry[0]; $content=$entry[1]; $date1 =$entry[2]; $fileName=$entry[3]; $category=$entry[4]; $postType=$entry[5]; echo "
".$title."
"; //echo "".$title."
"; echo $content; echo "Posted on ".$date1." - Category: ".$category."
"; $commentFile=$commentdir.$fileName.$config_dbFilesExtension; if (file_exists($commentFile)) { $commentLines=file($commentFile); $commentText=count($commentLines)." Comments"; } else {$commentText="No Comments";} echo "".$commentText.""; echo " - Edit"; echo " - Delete
"; $i++; } $totalEntries++; $totalPages = ceil(($totalEntries)/($config_entriesPerPage)); if($totalPages >= 1) { echo '
"; // Sorting is not working. I need to check later .. todo foreach ($category_array_unique as $value) { echo "".$value.""; } } } function sidebarLinks() { global $config_menuLinks; foreach ($config_menuLinks as $value) { $fullLink=explode(",",$value); echo ''.$fullLink[1].''; } } function listAllComments() { global $commentdir, $separator; global $config_dbFilesExtension; $latestCommentsFile=$commentdir."latest".$config_dbFilesExtension; $userFileName=$commentdir."users$config_dbFilesExtension.dat"; echo "
All Comments
"; if ($handle = opendir($commentdir)) { $file_array_unsorted = array(); $file_array_sorted = array(); while (false !== ($file = readdir($handle))) { array_push($file_array_unsorted,$file); } $file_array_sorted=array_reverse($file_array_unsorted); $commentCount=count($file_array_sorted)-4; if ($commentCount > 0) { echo "Comment Title | Date | Posted By |
---|---|---|
".$commentTitle." | "; echo "".$commentDateFormatted." | ".$commentAuthor." |
".$title."
"; echo $content; echo "Posted on ".$date1." - Category: ".$category."
"; echo "Comments"; echo " - Edit"; echo " - Delete
Making new entry...
"; if ($debugMode=="on") { echo $_SERVER['PHP_SELF'].""; echo "Post will be written to ".$newPostFileName." ".$newFullPostNumber; } echo '"; echo ""; } function newEntrySubmit() { global $postdir, $separator, $newPostFile, $newFullPostNumber, $debugMode, $configPass; $newPostFileName=$postdir.$newPostFile; $postTitle=$_POST["title"]; $postContent=$_POST["posts"]; $postDate=date("d M Y h:i"); $isPage=$_POST["isPage"]; $postCategory=$_POST["category"]; echo "
Making new entry...
"; $do = 1; if($postTitle == '' || $postContent == '' || $postCategory == '') { echo 'All fields are neccessary. Please fill them all.'; $do = 0; } if ($do == 1) { if ($_POST['pass']===$configPass) { if ($debugMode=="on") {echo "Writing to ".$newPostFileName;} $errorMessage='Error opening or writing to newPostFile '.$newPostFileName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."
If this problem continues, please report as a bug to the author of PRITLOG
"; if ($isPage == 1) { $postType="page"; } else { $postType="post"; } $content=$postTitle.$separator.str_replace("\\","",$postContent).$separator.$postDate.$separator.$newFullPostNumber.$separator.$postCategory.$separator.$postType; $fp = fopen($newPostFileName,"w") or die($errorMessage); fwrite($fp, $content) or die($errorMessage); fclose($fp); echo "New post added .."; } else { echo "Password Incorrect ..
"; echo "Sorry, you have to start from the scratch and create the post again ..
"; echo "Currently, there is no functionality to goback."; } } } function deleteEntryForm() { global $debugMode; $fileName = isset($_POST['filename'])?$_POST['filename']:$_GET['filename']; echo "
Deleting entry...
"; echo ""; } function deleteEntrySubmit() { global $postdir, $separator, $newPostFile, $newFullPostNumber, $configPass, $debugMode, $config_dbFilesExtension; if ($debugMode=="on") {echo "Inside deleteEntrySubmit ..";} $entryName= $_POST['fileName']; $fileName = $postdir.$entryName.$config_dbFilesExtension; echo "
Deleting entry...
"; $errorMessage='There was an error deleting entry '.$entryName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."If this problem continues, please report as a bug to the author of PRITLOG
"; if ($_POST['pass']===$configPass) { if (file_exists($fileName)) {unlink($fileName);} if (deleteEntryComment($entryName)) { echo "Entry ".$entryName." deleted succesfully...
"; } else { exit($errorMessage); } } else { echo "Password Incorrect ..
"; } } function deleteEntryComment($entryName) { global $commentdir,$config_dbFilesExtension,$separator; $commentFullName=$commentdir.$entryName.$config_dbFilesExtension; $thisCommentFileName=$entryName; if (file_exists($commentFullName)) {unlink($commentFullName);} //echo "
$commentFullName deleted
"; $latestFileName=$commentdir."/latest".$config_dbFilesExtension; if (file_exists($latestFileName)) { $latestLines= file($latestFileName); $errorMessage='
Error opening or writing to latestFileName '.$latestFileName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."If this problem continues, please report as a bug to the author of PRITLOG
"; $fp=fopen($latestFileName, "w") or die($errorMessage); $i=0; foreach ($latestLines as $value) { $latestSplit=explode($separator,$value); $commentFileName=trim($latestSplit[0]); if (trim($value) != "") { //echo "commentFileName=$commentFileName,thisCommentFileName=$thisCommentFileName,
"; //echo "commentSeq=$commentSeq,thisCommentSeq=".trim($thisCommentSeq).",
"; if (($commentFileName == $thisCommentFileName)){ //echo "Deleted Indeed!
"; } else { fwrite($fp,$value); } } $i++; } fclose($fp); } if (file_exists($commentFullName)) {return false;} else {return true;} } function editEntryForm() { $fileName = isset($_POST['filename'])?$_POST['filename']:$_GET['filename']; global $postdir, $separator, $newPostFile, $newFullPostNumber, $debugMode, $config_textAreaCols, $config_textAreaRows; global $config_dbFilesExtension; $editFileName=$postdir.$fileName.$config_dbFilesExtension; echo "
Editing entry...
"; if ($debugMode=="on") {echo "Editing .. ".$editFileName."";} if (file_exists($editFileName)) { $fp = fopen($editFileName, "rb"); $fullpost=explode($separator,fread($fp, filesize($editFileName))); fclose($fp); $title=$fullpost[0]; $content=$fullpost[1]; $category=$fullpost[4]; $postType=$fullpost[5]; if ($postType == "page") { $checking='checked="checked"'; } else { $checking=''; } echo '"; echo ""; } else {echo "File is not available...
";} } function editEntrySubmit() { global $postdir, $separator, $newPostFile, $newFullPostNumber, $configPass, $debugMode; global $config_dbFilesExtension; if ($debugMode=="on") {echo "Inside editEntrySubmit ..".$_POST['fileName']."
";} echo "
Editing entry...
"; $entryName= $_POST['fileName']; $fileName = $postdir.$entryName.$config_dbFilesExtension; $postTitle=$_POST["title"]; $postContent=$_POST["posts"]; $postDate=date("d M Y h:i"); $isPage=$_POST["isPage"]; $postCategory=$_POST["category"]; $do = 1; if($postTitle == '' || $postContent == '' || $postCategory == '') { echo 'All fields are neccessary. Please fill them all.'; $do = 0; } if ($do == 1) { if ($isPage == 1) { $postType="page"; } else { $postType="post"; } if ($debugMode=="on") {echo "Writing to ".$fileName;} $content=$postTitle.$separator.str_replace("\\","",$postContent).$separator.$postDate.$separator.$entryName.$separator.$postCategory.$separator.$postType; $errorMessage='Error opening or writing to PostFile '.$fileName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."
If this problem continues, please report as a bug to the author of PRITLOG
"; if ($_POST['pass']===$configPass) { $fp = fopen($fileName,"w") or die($errorMessage); fwrite($fp, $content) or die($errorMessage); fclose($fp); echo "Entry edited successfully ..
"; } else { echo "Password Incorrect ..
"; } } } function viewEntry() { $fileName = isset($_POST['filename'])?$_POST['filename']:$_GET['filename']; global $postdir, $separator, $newPostFile, $newFullPostNumber, $debugMode, $config_textAreaCols, $config_textAreaRows; global $config_allowComments, $config_commentsSecurityCode, $config_CAPTCHALength, $config_randomString; global $commentdir,$config_dbFilesExtension, $config_onlyNumbersOnCAPTCHA; $viewFileName=$postdir.$fileName.$config_dbFilesExtension; $cool=true; if ($debugMode=="on") {echo "Editing .. ".$viewFileName."
";} if (strstr($fileName,'%') || strstr($fileName,'.')) { $cool=false; echo "
Sorry. Invalid URL!
"; } if (file_exists($viewFileName) && $cool) { $fp = fopen($viewFileName, "rb"); $entry =explode($separator,fread($fp, filesize($viewFileName))); fclose($fp); $title =$entry[0]; $content =$entry[1]; $date1 =$entry[2]; $fileName=$entry[3]; $category=$entry[4]; $postType=$entry[5]; echo "
".$title."
"; echo $content; echo "Posted on ".$date1." - Category: ".$category."
"; $commentFile=$commentdir.$fileName.$config_dbFilesExtension; if (file_exists($commentFile)) { $commentLines=file($commentFile); $commentText=count($commentLines)." Comments"; } else {$commentText="No Comments";} echo "".$commentText.""; echo " - Edit"; echo " - Delete
Comments:
"; if (file_exists($commentFullName)) { $fp = fopen($commentFullName, "rb"); $allcomments=explode("\n",fread($fp, filesize($commentFullName))); fclose($fp); foreach ($allcomments as $value) { if (trim($value) != "") { $comment = explode($separator,$value); $title = $comment[0]; $author = $comment[1]; $content = $comment[2]; $date = $comment[3]; echo 'Posted on '.$date.' by '.$author.''.$title.'
'; echo $content; echo '
Delete
'; $i++; } } } else {echo "No comments posted yet!
";} if($config_allowComments == 1) { echo '
Add Comment
'; echo '"; echo ''; } } } function sendComment() { # Send Comment Process global $commentdir, $separator, $config_commentsMaxLength, $config_dbFilesExtension, $config_sendMailWithNewComment; global $config_sendMailWithNewCommentMail, $config_commentsForbiddenAuthors, $config_commentsSecurityCode; echo "Add Comment
"; $commentFileName= isset($_POST['sendComment'])?$_POST['sendComment']:$_GET['sendComment']; $commentTitle = isset($_POST['commentTitle'])?$_POST['commentTitle']:$_GET['commentTitle']; $author = isset($_POST['author'])?$_POST['author']:$_GET['author']; $comment = $_POST['comment']; $pass = isset($_POST['pass'])?$_POST['pass']:$_GET['pass']; $date = getdate($config_gmt); $code = $_POST['code']; $originalCode = $_POST['originalCode']; $do = 1; $triedAsAdmin = 0; //echo 'Comment Length='.strlen($comment).',
'; //echo 'Comment='.$comment.',
'; //echo 'Author='.$author.',
'; if($commentTitle == '' || $author == '' || $comment == '' || $pass == '') { echo 'All fields are neccessary. Please fill them all.'; $do = 0; } if($config_commentsSecurityCode == 1) { $code = $_POST['code']; $originalCode = $_POST['originalCode']; if ($code !== $originalCode) { echo 'Security Code does not match. Please, try again'; $do = 0; } } $hasPosted = 0; foreach($config_commentsForbiddenAuthors as $value) { if($value == $author) { echo "The user name ".$author." is not permitted. Please go back and choose a different username"; $do=0; } } # Start of author checking, for identity security $userFileName=$commentdir."users$config_dbFilesExtension.dat"; //$fp = fopen($userFileName, "rb"); //$users=explode("\n",fread($fp, filesize($userFileName))); //fclose($fp); $newUser = 1; if (file_exists($userFileName)) { $users=file($userFileName); $data = ''; if ($do == 1) { foreach($users as $value) { $userLine=explode($separator,$value); if ($userLine[0] == $author) { $newUser=0; if (crypt($pass,trim($userLine[1])) !== trim($userLine[1])) {echo "Password is incorrect, please try again";$do=0;} else {$do=1;} } } } } if ($newUser == 1 && $do ==1) { $fp = fopen($userFileName, "a"); $userContent=$author.$separator.crypt($pass)."\n"; fwrite($fp,$userContent); fclose($fp); echo 'You are a new user posting here... You will be added to a database so nobody can steal your identity. Remember your password!
'; } if($do == 1) { if(strlen($comment) > $config_commentsMaxLength) { echo 'The content is too long! Max characters is '.$config_commentsMaxLength.' you typed '.strlen($comment); } else { $commentFullName=$commentdir.$commentFileName.$config_dbFilesExtension; if (file_exists($commentFullName)) {$commentLines=file($commentFullName);} if (trim($commentLines[0])=="") { $thisCommentSeq=1; } else { $thisCommentSeq=count($commentLines)+1; } $comment=str_replace("\n","",$comment); $commentContent = $commentTitle.$separator.$author.$separator.str_replace("\\","",$comment).$separator.date("d M Y h:i").$separator.$commentFileName.$separator.$thisCommentSeq."\n"; # Add comment $errorMessage='
Error opening or writing to commentFileName '.$commentFullName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."
If this problem continues, please report as a bug to the author of PRITLOG
"; $fp = fopen($commentFullName, "a") or die($errorMessage); fwrite($fp,$commentContent) or die($errorMessage); fclose($fp); # Add coment number to a file with latest comments $errorMessage='
Error opening or writing to commentFileName '.$commentFileName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."
If this problem continues, please report as a bug to the author of PRITLOG
"; $fp=fopen($commentdir."/latest".$config_dbFilesExtension,"a") or die($errorMessage); fwrite($fp,$commentFileName.$separator.$commentTitle.$separator.$thisCommentSeq."\n") or die($errorMessage); fclose($fp); echo 'Comment added. Thanks '.$author.'!
'; # If Comment Send Mail is active if($config_sendMailWithNewComment == 1) { $content = "Hello, i am sending this mail because $author commented on your blog. \r\nTitle: $commentTitle\r\nComment: ".str_replace("\\","",$comment)."\r\nDate: ".date("d M Y h:i")."\r\nRemember you can disallow this option changing the ".'$config_sendMailWithNewComment Variable to 0'; mail($config_sendMailWithNewCommentMail, "PRITLOG: New Comment", $content ,"FROM: PRITLOG"); } } } } function deleteCommentForm() { global $debugMode; $fileName = isset($_POST['filename'])?$_POST['filename']:$_GET['filename']; $commentNum = isset($_POST['commentNum'])?$_POST['commentNum']:$_GET['commentNum']; echo "
Deleting comment...
"; echo ""; } function deleteCommentSubmit() { global $postdir, $separator, $newPostFile, $newFullPostNumber, $configPass, $debugMode; global $commentdir,$fileName,$config_dbFilesExtension; if ($debugMode=="on") {echo "Inside deleteCommentSubmit ..";} $fileName = $_POST['fileName']; echo "
Deleting comment...
"; $commentNum=$_POST['commentNum']; if ($_POST['pass']===$configPass) { $commentFullName=$commentdir.$fileName.$config_dbFilesExtension; $i=0; $j=0; if (file_exists($commentFullName)) { $allcomments=file($commentFullName); $errorMessage='Error opening or writing to commentFile '.$commentFullName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."
If this problem continues, please report as a bug to the author of PRITLOG
"; $fp=fopen($commentFullName, "w"); foreach ($allcomments as $value) { //echo "value=$value,"; if (trim($value) != "") { //echo "commentNum=$commentNum,i=$i,
"; if ($commentNum != $i) { //$value=$value."\n"; if (fwrite($fp,$value)===FALSE) { echo "Cannot write to comment file
"; } else { $j++;} } else { $commentSplit=explode($separator,$value); $thisCommentFileName=$commentSplit[4]; $thisCommentSeq=$commentSplit[5]; echo "Comment deleted ...
"; } } $i++; } fclose($fp); //echo "Final i=$i
"; $i=$i-2; if ($j == 0) {unlink($commentFullName);} $latestFileName=$commentdir."/latest".$config_dbFilesExtension; if (file_exists($latestFileName)) { $latestLines= file($latestFileName); $errorMessage='
Error opening or writing to latestFileName '.$latestFileName.'.
Please check the folder permissions
'; $errorMessage=$errorMessage."If this problem continues, please report as a bug to the author of PRITLOG
"; $fp=fopen($latestFileName, "w") or die($errorMessage); $i=0; foreach ($latestLines as $value) { $latestSplit=explode($separator,$value); $commentFileName=trim($latestSplit[0]); $commentSeq =trim($latestSplit[2]); if (trim($value) != "") { //echo "commentFileName=$commentFileName,thisCommentFileName=$thisCommentFileName,
"; //echo "commentSeq=$commentSeq,thisCommentSeq=".trim($thisCommentSeq).",
"; if (($commentFileName == $thisCommentFileName) && ($commentSeq == trim($thisCommentSeq))){ //echo "Deleted Indeed!
"; } else { fwrite($fp,$value); } } $i++; } fclose($fp); } } //else {echo "No comments posted yet!
";} } else { echo "Password Incorrect ..
"; } } function viewArchive() { global $separator, $postdir, $entries, $config_menuEntriesLimit; $i=0; echo "
Archive
"; echo "".$date1.": | ".$title." |
Search Results
"; $i=0; foreach ($entries as $value) { $entry =explode($separator,$value); $title =$entry[0]; $content=$entry[1]; $date1 =$entry[2]; $fileName=$entry[3]; $category=$entry[4]; $postType=$entry[5]; if ((stristr($title,$searchkey)) || (stristr($content,$searchkey))) { echo "".$title.""; $i++; } } if ($i == 0) {echo "Sorry no matches found!";} } switch ($option) { case "newEntry": if ($debugMode=="on") {echo "Calling newEntryForm()";} newEntryForm(); break; case "newEntrySubmit": newEntrySubmit(); break; case "mainPage": $requestCategory = ''; listPosts(); break; case "deleteEntry": if ($debugMode=="on") {echo "deleteEntry ".$_POST['process']."
";} if ($_POST['process']!=="deleteEntrySubmit") { deleteEntryForm(); } else { deleteEntrySubmit(); } break; case "editEntry": if ($debugMode=="on") {echo "editEntry ".$_POST['process']."
";} if ($_POST['process']!=="editEntrySubmit") { editEntryForm(); } else { editEntrySubmit(); } break; case "viewEntry": viewEntry(); break; case "commentEntry": echo "
Ooops
"; echo "Sorry! This functionality is not coded yet."; break; case "viewArchive": viewArchive(); break; case "viewCategory": $requestCategory=isset($_POST['category'])?$_POST['category']:$_GET['category']; listPosts(); break; case "searchPosts": searchPosts(); break; case "sendComment": sendComment(); break; case "listAllComments": listAllComments(); break; case "deleteComment": if ($debugMode=="on") {echo "deleteEntry ".$_POST['process']."
";} if ($_POST['process']!=="deleteCommentSubmit") { deleteCommentForm(); } else { deleteCommentSubmit(); } break; } if($option !== 'RSS') { ?>