Hi, all. :)
I've searched the message archives and couldn't find a solution to this problem, so I'm hoping someone who's figured it out can give me a hand.
First, I'm not an HTML newbie, but I'm fairly new to PHP and am still feeling my way around it, for the most part. That being said, sometimes I can't see the forest for the trees, and it's often stupid little mistakes (like forgetting a quotation mark or semicolon) that kill me. :p I'm hoping another set of eyes might spot what I can't see... I usually use 1st Page as an editor, but I downloaded tsWebEditor for its error-finding tool...nothing turned up when I used it.
My blog site is set up at http://blog.lunaclick.net (it's a work in progress, and the category archives aren't templated yet). I'm using Blog (http://www.farook.org) to publish, and as it's a Blogger emulator, a lot of the <insert content here> tags are the same or similar.
The count seems to be ok so far (being that I have no comments on anything, and every comments link shows "No Comments," just like I want it to, LOL). When I click on the link, though, the comments window pops up, but it takes FOREVER to load, and when it loads, I get a "cannot find server/page cannot be displayed" error.
I've tried different configurations -- even using the original "straight-out-of-the-box" versions, changing only my URLs and paths -- but no changes I make seem to be in a positive direction. :-/ I'm going to keep playing around with it, but here is the code that I'm using right now:
Before headers in template_journal.php (/www/x/xxxxx/ replaces my actual path):
<?function commentCount($n)
{
$comments_path = "http://blog.lunaclick.net/comments/";
$filesystem_path = "/www/x/xxxx/blog/htdocs/comments/";
if (file_exists($filesystem_path . "$n.comment"))
{
$file = @fopen($comments_path . "$n.comment", 'r');
$thisFile = fread($file, '1000000');
$thisFile = explode("\n", trim($thisFile));
fclose($file);
$comments = sizeof($thisFile);
if($comments == 1)
{
$comments .= " Comment";
}
else
{
$comments .= " Comments";
}
}
else
{
$comments = "No Comments";
}
return $comments;
}
?>
In <head> tags in template_journal.php (within <script> tags, of course):
function viewComments(n)
{
window.open('/comments.php?' + n, 'Comments' + n, 'directories=0,height=480,location=0,resizable=1,scrollbars=1,toolbar=0,width=515');
}
Comments link in template_journal.php:
<a href="javascript:viewComments('<$BlogID>');"><? echo commentCount('<$BlogID>'); ?></a>
And finally, my comments.php file:
<?
"#808088", "#707078");
// User-defined Variables (FEEL FREE TO EDIT THESE)
$table_bgcolor = array(
$order = "1";
$timeAdjustment = "3";
$comments_path = "http://blog.lunaclick.net/";
$email = "angela@...";
$showip = "0";
// Begin Comment Parsing (DON'T EDIT THIS)
error_reporting(7);
$commentID = ereg_replace('[^0-9]', '', getenv('QUERY_STRING'));
$commentText = preg_replace('/<((?!\/?(b|i|u|a|ol|ul|li)\b)[^>]*)>/xis', '', ' ' . stripslashes(trim($commentText)));
$commentText = trim(eregi_replace("[^\"]((http|mailto|ftp):\/\/[^[:space:]<>]{1,})", " <a href=\"\\1\">\\1</a>", $commentText));
$commentText = str_replace("\n", '<br>', $commentText);
if($commentText) {
if(!isset($commentName) && isset($submit)) $commentName = 'Anonymous'; else $commentName = strip_tags(trim($commentName));
if(!isset($commentMail)) $commentMail = ''; else $commentMail = strip_tags(trim($commentMail));
if(!isset($commentSite)) $commentSite = ''; else $commentSite = strip_tags(trim($commentSite));
if(strlen($commentSite) && !stristr($commentSite, 'http://')) $commentSite = 'http://' . $commentSite;
$commentDate = time() + ($timeAdjustment * 3600);
$thisComment = $commentDate . '[+]' . $commentName . '[+]' . $commentMail . '[+]' . $commentText . '[+]' . $commentSite . '[+]' . getenv('REMOTE_ADDR') . "\n";
$file = @fopen("comments/$commentID.comment", 'a');
fwrite($file, $thisComment);
fclose($file);
$cookie = $commentName . '[+]' . $commentMail . '[+]' . $commentSite;
setcookie('comments', $cookie, time() + 31536000);
if($email) {
mail($email, "New Comment [$commentID]", stripslashes($commentText) . "\n\n--\nTo view this comment, visit " . $comments_path . "comments.php?" . $commentID, "From: $commentName <$commentMail>");
}
} elseif($HTTP_COOKIE_VARS['comments']){
list($commentName, $commentMail, $commentSite) = explode('[+]', $HTTP_COOKIE_VARS['comments']);
}
if($file = @fopen($comments_path . "comments/$commentID.comment", 'r')) {
$comments = fread($file, '1000000');
$comments = explode("\n", trim($comments));
fclose($file);
for($i = 0; $i < sizeof($comments); $i++) {
$thisComment = explode('[+]', stripslashes($comments[$i]));
$thisComment[0] = ' • ' . date("m/d/y h:ia", $thisComment[0]);
if($thisComment[2]) $thisComment[2] = ' [<a href="mailto:' . $thisComment[2] . '">' . $thisComment[2] . '</a>] ';
if($thisComment[4]) $thisComment[1] = '<a href="' . $thisComment[4] . '">' . $thisComment[1] . '</a>';
if($thisComment[5] && $showip) $thisComment[5] = ' • ' . $thisComment[5]; else $thisComment[5] = '';
$comment[$i] = $thisComment[3] . "<br>\n<div class=\"date\">" . $thisComment[1] . $thisComment[2] . $thisComment[5] . $thisComment[0] . "</div>\n";
}
} else {
$comment[0] = "<p align=\"center\">No comments found.</p>\n";
}
if($order) {
$countStart = 0;
$countEnd = sizeof($comment);
$countInc = 1;
} else {
$countStart = sizeof($comment) - 1;
$countEnd = -1;
$countInc = -1;
}
// End Comment Parsing
?>
<html>
<head>
<title>BlogSpace - Comments</title>
<META NAME="robots" CONTENT="noindex, nofollow">
<LINK REL=StyleSheet HREF="/blog.css" TYPE="text/css" MEDIA=screen>
<base target="_blank">
</head>
<body>
<form method="post" name="frmPost" target="_top">
<table border="0" cellpadding="10" cellspacing="1" width="100%">
<? for($i = $countStart; $i != $countEnd; $i += $countInc) { ?>
<tr>
<td bgcolor="<? echo $table_bgcolor[$i % 2]; ?>" class="comment">
<? echo $comment[$i]; ?>
</td>
</tr>
<? } ?>
<tr>
<td>
<table border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td align="left" class="form" colspan="2" valign="middle" width="100%"><b>Add your comment:</b> (Auto-line breaks enabled.)</td>
</tr>
<tr>
<td align="left" class="form" valign="middle" width="1%">Name:</td>
<td align="left" valign="middle" width="99%"><input maxlength="50" name="commentName" size="40" type="text" value="<? echo $commentName; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">Email:</td>
<td align="left" valign="middle"><input maxlength="75" name="commentMail" size="40" type="text" value="<? echo $commentMail; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">Website:</td>
<td align="left" valign="middle"><input maxlength="100" name="commentSite" size="40" type="text" value="<? echo $commentSite; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="top">Comment:</td>
<td align="left" valign="top"><textarea cols="38" name="commentText" rows="5" wrap="virtual"></textarea></td>
</tr>
<tr>
<td><br></td>
<td><input name="Cancel" onclick="javascript:window.close();" type="button" value="Cancel" class="button"> <input name="Submit" type="submit" value="Submit" class="button"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
Thanks in advance for any help you can give me! :)
|