<?
include_once('include/function.php');
//ลบความเห็น
if ($_GET['act'] == "del") {
//เรียกฟังชั่น memberMenu
$db = mysql_connect($CFGDB['host'],$CFGDB['username'],$CFGDB['password']) or die ("connect fail");
$sql= "DELETE FROM {$CFGDB['prefix']}comment WHERE ComIdCom = '$_GET[cid]' AND ComIdMem = '$_GET[id]'";
$query = mysql_db_query($CFGDB['dbname'],$sql) or die ("select fail");
HEADER("Location: $_GET[url]");
exit();
}
//ตรวจสอบว่าใส่ข้อมูลครบหรือไม่
if (empty($_POST['CommentName']) || empty($_POST['CommentText'])){
print "Error : Your input is missing";
exit();
}
//กำหนดวันที่และ ip ของผู้ post และ id ของ Comment
$date = Date("Ymdhis");
$ip = getenv("REMOTE_ADDR");
$IdComment = "x".$_POST['IdMem']."x".time();
//ตัด html และ ใส่การเพิ่ม enter
$CommentName = htmlspecialchars($_POST['CommentName']);
$CommentText = htmlspecialchars($_POST['CommentText']);
$CommentText = nl2br($_POST['CommentText']);
//วนลูปป้องกันคำหยาบ
$wordban = $CFG['wordban'];
for ($i=0 ; $i<sizeof( $wordban) ; $i++) {
$CommentText = eregi_replace( $wordban[$i],$CFG['wordban_show'],$CommentText);
}
//ตรวจสอบว่า มีการป้อน url หรือ email มาหรือไม่ ถ้ามีให้ทำ link
$CommentText = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","<a href=\"\\1://\\2\\3\" target=\"\\2\\3\">\\1://\\2\\3</a>",$CommentText);
$CommentText = eregi_replace("([[:alnum:]]+)@([^[:space:]]*)([[:alnum:]])","<a href=mailto:\\1@\\2\\3>\\1@\\2\\3</a>",$CommentText);
//สัญลักษณ์พิเศษ
$CommentText = str_replace("
", "<b>", $CommentText);
$CommentText = str_replace("", "</b>", $CommentText);
$CommentText = str_replace("
", "<i>", $CommentText);
$CommentText = str_replace("", "</i>", $CommentText);
$CommentText = str_replace("
", "<u>", $CommentText);
$CommentText = str_replace("", "</u>", $CommentText);
$CommentText = eregi_replace("quote\\]", "quote]", $CommentText);
$CommentText = str_replace("
", "<blockquote><span class=\"comment\">", $CommentText);
$CommentText = str_replace("
", "</span></blockquote>", $CommentText);
$CommentText = eregi_replace("marquee\\]", "marquee]", $CommentText);
$CommentText = str_replace("[marquee]", "<marquee><span class=\"comment\">", $CommentText);
$CommentText = str_replace("[/marquee]", "</span></marquee>", $CommentText);
//ใส่ Icon แสดงอารมณ์
$txt = array( ":angry:", ":approve:", ":blushing:", ":bonk:", ":charming:", ":cheeky:", ":cheesy:", ":cool:", ":cry:", ":dead:", ":dissappointed:", ":embarassed:", ":evil:", ":goofy:", ":grin:", ":huh:", ":idea:", ":kiss:", ":koe:", "

", ":lips:", ":lipsrsealed:", ":mad:", ":miniheart:", ":ok:", ":rolleyes:", ":sad:", ":scared:", ":shocked:", ":shy:", ":sleeping:", ":smartass:", ":smarty:", ":smiley:", ":teen:", ":tongue:", ":undecided:", ":veryangry:", ":wink:", ":worried:" );
$pic = array( "angry.gif", "approve.gif", "blushing.gif", "bonk.gif", "charming.gif", "cheeky.gif", "cheesy.gif", "cool.gif", "cry.gif", "dead.gif", "dissappointed.gif", "embarassed.gif", "evil.gif", "goofy.gif", "grin.gif", "huh.gif", "idea.gif", "kiss.gif", "koe.gif", "laugh.gif", "lips.gif", "lipsrsealed.gif", "mad.gif", "miniheart.gif", "ok.gif", "rolleyes.gif", "sad.gif", "scared.gif", "shocked.gif", "shy.gif", "sleeping.gif", "smartass.gif", "smarty.gif", "smiley.gif", "teen.gif", "tongue.gif", "undecided.gif", "veryangry.gif", "wink.gif", "worried.gif" );
for ($a=0 ; $a<sizeof($txt) ; $a++) {
$CommentText = eregi_replace($txt[$a],"<img src=\"images/icon/".$pic[$a]."\">",$CommentText);
}
//ใส่ Kaos
$txtkaos = array( "/a/", "/b/", "/c/", "/d/", "/e/", "/f/", "/g/", "/h/", "/i/", "/j/", "/k/", "/l/", "/m/", "/n/", "/o/", "/p/", "/q/", "/r/", "/s/", "/t/", "/u/", "/v/", "/w/", "/x/", "/y/", "/z/", "/aa/", "/ab/", "/ac/", "/ad/", "/ae/", "/af/", "/ag/", "/ah/");
$pickaos = array( "a.gif", "b.gif", "c.gif", "d.gif", "e.gif", "f.gif", "g.gif", "h.gif", "i.gif", "j.gif", "k.gif", "l.gif", "m.gif", "n.gif", "o.gif", "p.gif", "q.gif", "r.gif", "s.gif", "t.gif", "u.gif", "v.gif", "w.gif", "x.gif", "y.gif", "z.gif", "aa.gif", "ab.gif", "ac.gif", "ad.gif", "ae.gif", "af.gif", "ag.gif", "ah.gif" );
for ($a=0 ; $a<sizeof($txtkaos) ; $a++) {
$CommentText = eregi_replace($txtkaos[$a],"<img src=\"images/icon/kaos/".$pickaos[$a]."\">",$CommentText);
}
//ใส่รูปสัญลักษณ์ผู้ Post
if (!empty($_COOKIE['CMemPoster'])) {
$poster = $_COOKIE['CMemPoster'];
} else {
$poster = $fullUrl."images/avatar/guest.gif";
}
if (!empty($_COOKIE['CMemId'])) {
$posterID = $_COOKIE['CMemId'];
} else {
$posterID = "";
}
//ใส่ข้อมูลลง database
$db = mysql_connect($CFGDB['host'],$CFGDB['username'],$CFGDB['password']) or die ("connect fail");
$sql = "INSERT INTO {$CFGDB['prefix']}comment (ComIdMem,ComIdCom,ComNameComment,ComMailComment,ComComment,ComTime,ComIp,ComPoster,ComPosterID,ComAlign,ComColor) values
('$_POST[IdMem]','$IdComment','$CommentName','$_POST[CommentEmail]','$CommentText','$date','$ip','$poster','$posterID','$_POST[CommentAlign]','$_POST[CommentColor]')";
$query = mysql_db_query($CFGDB['dbname'],$sql) or die ("insert fail");
mysql_close($db);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd 
">
<html xmlns="
http://www.w3.org/1999/xhtml 
">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$CFG['encode']?>" />
<title><?=$CFG['title']?></title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta name="Keywords" content="<?=$CFG['keyword']?>" />
</head>
<body>
<div id="header">
<div id="header_menu">
<a href="index.php">Home</a> |
<a href="register.php">Register</a> |
<a href="login.php">Login</a> |
<a href="top20.php">20 points maximum</a> <br>
<?
$menu = memberMenu();
echo $menu['menu'];
?>
</div>
<a href="
http://www.2capsule.com 
"><img src="images/logo.gif" width="213" height="60" border="0" /></a></div>
<div id="header_category">
<a href="index.php">Show all</a> | <?=listCategory('menu',$_GET['cat'])?>
</div>
<div align="right" style="margin:10px; ">
<form id="search" name="search" method="get" action="search.php">
<strong>Find</strong>
<select name="qs" class="form" id="qs">
<option value="1" selected="selected">Sticker</option>
<option value="2">Comments</option>
</select>
<input name="q" type="text" class="form" size="20" />
<input type="submit" name="qb" value=" go " class="form" />
</form>
</div>
<div id="webmaster_talk">
<?
include_once('include/webmaster_talk.php');
?>
</div>
<br />
<div id="wraper">
<div align="center">
<p><strong>Add a comment already</strong><br /></p>
<p><a href="sticker.php?id=<?=$_POST['IdMem']?>">Back to previous page</a></p>
</div>
</div>
<br />
<div id="sticker_info">
<?include_once('stickerinfo.php');?>
</div>
<div id="footer_credit">
<?=creditFooter()?>
</div>
</body>
</html>