<?php
	@ini_set('display_errors','0');
	error_reporting (E_ALL & ~E_NOTICE);
	define('DIRCMS_ROOT', str_replace("\\", '/',substr(dirname(__FILE__),0,-7)));
	include DIRCMS_ROOT.'include/common.inc.php';
	include_once DIRCMS_ROOT.'include/member.class.php';
	$member=new member();
	session_start();
	if($_SESSION['checkcode']!=$chkcode || !$_SESSION['checkcode'])showmsg('验证码不正确！');
	if($authkey!=md5(AUTH_KEY.$memberid.$membername))showmsg('错误的请求！',$DIRCMS['site_url']);
	$_userid=$_userid?$_userid:0;
	$_username=$_username?$_username:'游客';
	$comment['content']=htmlspecialchars($content);
	$comment['memberid']=intval($memberid);
	$comment['membername']=htmlspecialchars($membername);
	$comment['addtime']=TIME;
	$comment['ip']=IP;
	$comment['addtime']=TIME;
	$comment['userid']=$_userid;
	$comment['userface']=$_userid?$_facephoto:'images/nophoto.gif';
	$comment['status']=$_userid?1:0;
	$comment['fuwu']=intval($fuwu);
	$comment['pinzhi']=intval($pinzhi);
	$comment['xingjiabi']=intval($xingjiabi);
	$comment['score']=intval($score);
	$comment['username']=$_username;
	$db->insert(DB_PRE.'member_comment',$comment);

	$baseinfo=$member->get(intval($memberid)); // $baseinfo 数组 存储用户基本信息
	unset($baseinfo['password'],$baseinfo['id']);
	$model=cache_read('cache_membermodel'.$baseinfo['modelid'].'.cache.php',DIRCMS_ROOT.'data/cache_model/'); // 所在模型信息
	$moreinfo=$db->fetch_one("SELECT `".DB_PRE.$model['name']."`.* FROM `".DB_PRE.$model['name']."` WHERE `".DB_PRE.$model['name']."`.`userid`=".intval($memberid)); // $moreinfo 数组 存储用户拓展信息
//print_r($pics);exit();
	$memberinfo=array_merge($baseinfo,$moreinfo); //合并数组 $memberinfo 保存 全部用户信息
	@extract($memberinfo);unset($memberinfo,$baseinfo,$moreinfo);
	
	$menu=cache_read('menu'.intval($memberid).'.cache.php',DIRCMS_ROOT.'company/cache/menu/');
	$menu=$menu?$menu:array (
	  1 => array('name'=>'网站首页','url'=>$DIRCMS['site_url'].'company/company_'.intval($memberid).'.html'),
	  2 => array('name'=>'公司简介','url'=>$DIRCMS['site_url'].'company/about_'.intval($memberid).'.html'),
	  3 => array('name'=>'新闻动态','url'=>$DIRCMS['site_url'].'company/news_'.intval($memberid).'.html'),
	  4 => array('name'=>'优惠信息','url'=>$DIRCMS['site_url'].'company/coupon_'.intval($memberid).'.html'),
	  5 => array('name'=>'产品展示','url'=>$DIRCMS['site_url'].'company/product_'.intval($memberid).'.html'),
	  6 => array('name'=>'地图位置','url'=>$DIRCMS['site_url'].'company/map_'.intval($memberid).'.html'),
	  7 => array('name'=>'联系方式','url'=>$DIRCMS['site_url'].'company/contact_'.intval($memberid).'.html'),
	  8 => array('name'=>'在线留言','url'=>$DIRCMS['site_url'].'company/guestbook_'.intval($memberid).'.html'),
	);

	$templatepriv=cache_read('templatepriv.cache.php',DIRCMS_ROOT.'company/cache/');

	// 更新首页
	$id=intval($memberid);
	$dir_postion=$position='<a href="'.$DIRCMS['site_url'].'company/company_'.intval($memberid).'.html" title="店铺首页">店铺首页</a> ';
	ob_start();
	if(in_array($gradeid,$templatepriv))
	{
		include space_tlp($template,'index');
	}
	else
	{
		include template('company');
	}
	create_html(DIRCMS_ROOT.'company/company_'.intval($memberid).'.html');

	if($_userid)
	{
		showmsg('评论成功!');
	}
	else
	{
		showmsg('评论成功，需要等待管理员审核后才能显示!');
	}
?>