묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
php 코딩관련 질문입니다~~
2003.05.24 21:37
http://gatta11.idomz.net/blogger/blogger.html 들어가보시면 코멘트 등록하는게 있습니다..("0 comment" 부분)
여기서 코멘트를 쓰고 submit 버튼을 누르면
Warning: fwrite(): supplied argument is not a valid stream resource in /home/gatta11/weblog/comments.php on line 39
Warning: fclose(): supplied argument is not a valid stream resource in /home/gatta11/weblog/comments.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at /home/gatta11/weblog/comments.php:39) in /home/gatta11/weblog/comments.php on line 43
이렇게 나옵니다..ㅠ_ㅠ
어렵게 어렵게 코멘트를 설치했는데 여기부터 막히네요...
html은 좀 안다 치더라도 php은 정말 문외한이라..ㅠㅠ
어디가 잘못됬는지줌 알려주세요~ 부탁드립니다~ ㅠㅠ
(여기부턴 코딩입니다)
<?
// User-defined Variables (FEEL FREE TO EDIT THESE)
$head_title = "mydomain.com | dotcomments";
$body_alink = "#0C729D";
$body_bgcolor = "#FFFFFF";
$body_link = "#0C729D";
$body_text = "#000000";
$body_vlink = "#0C729D";
$table_bgcolor = array("#E2F5B1", "#FFFFFF");
$font_altcolor = "#9E9E9E";
$font_face = "verdana, arial, geneva, sans-serif";
$font_size = "12px";
$form_bgcolor = "#BCDC67";
$form_text = "#2A2E2A";
$order = "1";
$timeAdjustment = "0";
$comments_path = "http://gatta11.idomz.net/weblog/";
$email = "gatta11@dreamwiz.com";
$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) . "nn--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] = "No comments found.<br>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><? echo $head_title; ?></title>
<style type="text/css">
<!--
a {font-weight:bold; text-decoration:none}
.comment {font-family:<? echo $font_face; ?>; font-size:<? echo $font_size; ?>}
.date {color:<? echo $font_altcolor; ?>; font-family:<? echo $font_face; ?>; font-size:<? echo $font_size; ?>; font-weight:bold}
.form {color:<? echo $form_text; ?>; font-family:<? echo $font_face; ?>; font-size:<?echo $font_size; ?>}
.input {width:100%}
//-->
</style>
<base target="_blank">
</head>
<body alink="<? echo $body_alink; ?>" bgcolor="<? echo $body_bgcolor; ?>" leftmargin="0" link="<? echo $body_link; ?>" marginheight="0" marginwidth="0" text="<? echo $body_text; ?>" topmargin="0" vlink="<? echo $body_vlink; ?>">
<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 bgcolor="<? echo $form_bgcolor; ?>">
<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 (Thanks! ^^):</b> </td>
</tr>
<tr>
<td align="left" class="form" valign="middle" width="1%">Name:</td>
<td align="left" valign="middle" width="99%"><input class="input" maxlength="50" name="commentName" size="40" type="text" value="<? echo $commentName; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">E-mail:</td>
<td align="left" valign="middle"><input class="input" maxlength="75" name="commentMail" size="40" type="text" value="<? echo $commentMail; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">Web Site:</td>
<td align="left" valign="middle"><input class="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 class="input" cols="38" name="commentText" rows="5" wrap="virtual"></textarea></td>
</tr>
<tr>
<td><br></td>
<td><input class="comment" name="Submit" type="submit" value="Submit"> <input class="comment" name="Cancel" onclick="void(window.close())" type="button" value="Cancel"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
여기서 코멘트를 쓰고 submit 버튼을 누르면
Warning: fwrite(): supplied argument is not a valid stream resource in /home/gatta11/weblog/comments.php on line 39
Warning: fclose(): supplied argument is not a valid stream resource in /home/gatta11/weblog/comments.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at /home/gatta11/weblog/comments.php:39) in /home/gatta11/weblog/comments.php on line 43
이렇게 나옵니다..ㅠ_ㅠ
어렵게 어렵게 코멘트를 설치했는데 여기부터 막히네요...
html은 좀 안다 치더라도 php은 정말 문외한이라..ㅠㅠ
어디가 잘못됬는지줌 알려주세요~ 부탁드립니다~ ㅠㅠ
(여기부턴 코딩입니다)
<?
// User-defined Variables (FEEL FREE TO EDIT THESE)
$head_title = "mydomain.com | dotcomments";
$body_alink = "#0C729D";
$body_bgcolor = "#FFFFFF";
$body_link = "#0C729D";
$body_text = "#000000";
$body_vlink = "#0C729D";
$table_bgcolor = array("#E2F5B1", "#FFFFFF");
$font_altcolor = "#9E9E9E";
$font_face = "verdana, arial, geneva, sans-serif";
$font_size = "12px";
$form_bgcolor = "#BCDC67";
$form_text = "#2A2E2A";
$order = "1";
$timeAdjustment = "0";
$comments_path = "http://gatta11.idomz.net/weblog/";
$email = "gatta11@dreamwiz.com";
$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) . "nn--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] = "No comments found.<br>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><? echo $head_title; ?></title>
<style type="text/css">
<!--
a {font-weight:bold; text-decoration:none}
.comment {font-family:<? echo $font_face; ?>; font-size:<? echo $font_size; ?>}
.date {color:<? echo $font_altcolor; ?>; font-family:<? echo $font_face; ?>; font-size:<? echo $font_size; ?>; font-weight:bold}
.form {color:<? echo $form_text; ?>; font-family:<? echo $font_face; ?>; font-size:<?echo $font_size; ?>}
.input {width:100%}
//-->
</style>
<base target="_blank">
</head>
<body alink="<? echo $body_alink; ?>" bgcolor="<? echo $body_bgcolor; ?>" leftmargin="0" link="<? echo $body_link; ?>" marginheight="0" marginwidth="0" text="<? echo $body_text; ?>" topmargin="0" vlink="<? echo $body_vlink; ?>">
<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 bgcolor="<? echo $form_bgcolor; ?>">
<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 (Thanks! ^^):</b> </td>
</tr>
<tr>
<td align="left" class="form" valign="middle" width="1%">Name:</td>
<td align="left" valign="middle" width="99%"><input class="input" maxlength="50" name="commentName" size="40" type="text" value="<? echo $commentName; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">E-mail:</td>
<td align="left" valign="middle"><input class="input" maxlength="75" name="commentMail" size="40" type="text" value="<? echo $commentMail; ?>"></td>
</tr>
<tr>
<td align="left" class="form" valign="middle">Web Site:</td>
<td align="left" valign="middle"><input class="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 class="input" cols="38" name="commentText" rows="5" wrap="virtual"></textarea></td>
</tr>
<tr>
<td><br></td>
<td><input class="comment" name="Submit" type="submit" value="Submit"> <input class="comment" name="Cancel" onclick="void(window.close())" type="button" value="Cancel"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>