<?php

require_once("inc/global.php");
require_once ("inc/config.php");
require_once ("inc/config_lx.php");
global $atid;
$atid=$_GET['atid'];
$actname=check_out($_POST['actname']);
$content=check_out($_POST['content']);
$name=check_out($_POST['name']);
if($pinglun=="0"){
ShowMsg("评论功能未开启",-1,0,1000);
exit();
}
if(strlen($content)>500){
ShowMsg("评论不能大于500个字符",-1,0,1000);
exit();
}
if (strlen($content)>=40)
	{
		$contented=substr($content,0,40)."...";
	}
else
{
	$contented=$content;
}
if($atid=="addcomment")
	{
		
		if($name=="" || $content==""){
		ShowMsg("昵称或内容不能为空",-1,0,1000);
		exit();
		}
		//if(strlen($content)<10){
		//ShowMsg("内容不能小于10个字符",-1,0,1000);
		//exit();
		//}
		if(strlen($name)<3){
		ShowMsg("昵称不能小于3个字符",-1,0,1000);
		exit();
		}
		$date=date("Y-m-d",time());
		$time=date("h:i:s",time());
		if(!file_exists("db/attachment/$actname.php"))
			{
				$firstcommtent="$actname"."1"."|$name|$content|$date|$time|$actname|";
				$commtent=$firstcommtent;
			}
		else
			{
				$i=count(file("db/attachment/$actname.php"))+1;
				$oldcommtent=read("db/attachment/$actname.php");
				$newcomtent="$actname$i|$name|$content|$date|$time|$actname|\r\n";
				$commtent=$newcomtent.$oldcommtent;
			}
		write("db/attachment/$actname.php",$commtent);
		if(!file_exists("db/attachment/list.php"))
			{
				$commtentlist="$actname"."1"."|$contented|$date|$time|$actname|";
			}
		else
			{
			$i=count(file("db/attachment/$actname.php"));
			$oldcommtentlist=read("db/attachment/list.php");
			$newcommtentlist="$actname$i|$contented|$date|$time|$actname|\r\n";
			$commtentlist=$newcommtentlist.$oldcommtentlist;
			}
		write("db/attachment/list.php",$commtentlist);
		ShowMsg("评论成功",$hpath.$actname.$hzm,0,1000);
	}
else
	{
		ShowMsg("参数错误",$hpath.$actname.$hzm,0,1000);
	}

?>