<?php
include("require.php");
include("includes/lib_splitword_full.php");
if(!isset($_GET['barname']) && !isset($_POST['barname']))
  jump("index.php");
if(!isset($_GET['barname']))
  $_GET['barname']=$_POST['barname'];
$phpcolor->table="bar";
$phpcolor->field="*";
$phpcolor->where="merge like '%|".$_GET['barname']."|%'";
if($barid=$phpcolor->exist(1))
  jump(htmlurl($core_url,"list",$barid['id'],0,$core_rewrite));
$phpcolor->where="barname = '".$_GET['barname']."'";
if($barid=$phpcolor->exist(1))
  jump(htmlurl($core_url,"list",$barid['id'],0,$core_rewrite));
if($core_createopen==0)
  jump("error.php?id=3");
if($core_createopen==1 && !isset($_COOKIE["core_user_name"]))
  jump("login.php?action=login&last=".$last);
if(isset($_GET['action']) and $_GET['action'] == "submit")
{
  $_POST['barname']=iconv("UTF-8", "gbk", $_POST['barname']);
  $_POST['present']=iconv("UTF-8", "gbk", $_POST['present']);
  //禁用词语
  $phpcolor->table="filter";
  $phpcolor->field="content";
  $phpcolor->where="type='1' and (fanwei='0' or fanwei='1')";
  $rs=$phpcolor->assignment();
  for ($count=0;$count<count($rs);$count++)
  {
    if(strpos($_POST['barname'],$rs[$count]['content']) || strpos($_POST['present'],$rs[$count]['content']))
      die("6");
  }
  //审核词语
  $phpcolor->where="type='3' and (fanwei='0' or fanwei='1')";
  $rs=$phpcolor->assignment();
  for ($count=0;$count<count($rs);$count++)
  {
    if(strpos($_POST['barname'],$rs[$count]['content']) || strpos($_POST['present'],$rs[$count]['content']))
      $core_createaudit=1;
  }
  if($_POST['present']=="" or $_POST['barname']=="")
    die("1");
  if($_POST['belong']=="")
    $_POST['belong']="0";
  if($core_vbar==1 && $_POST['verify'] != $_SESSION['auth'])
    die("2");
  if(strlen($_POST['barname'])>20)
    die("3");
  if(strlen($_POST['present'])>200)
    die("5");
  $state=1;
  if($core_createaudit==1)
    $state=2;
  $author=$_SERVER['REMOTE_ADDR'];
  if(isset($_COOKIE["core_user_name"]))
    $author = $_COOKIE["core_user_name"];
  $time=date('Y-m-d',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  $_POST['barname']=bn_replace($_POST['barname']);
  $_POST['present']=autolink($_POST['present']);
  $phpcolor->table="bar";
  $phpcolor->field="barname, introduction, usernc, barclass, state, usergroup, usergroupf, uprdate, ausername";
  $phpcolor->where="'".$_POST['barname']."', '".$_POST['present']."', '会员', '".$_POST['belong']."', '".$state."','初级粉丝|中级粉丝|高级粉丝|正式会员|正式会员|核心会员|核心会员|铁杆会员|铁杆会员|知名人士|知名人士|人气楷模|人气楷模|意见领袖|意见领袖|进阶元老|资深元老|荣耀元老','0|5|15|30|50|100|200|500|1000|2000|3000|6000|10000|18000|30000|60000|100000|300000','".$time."','".$author."'";
  $phpcolor->write();
  $rsid=mysql_insert_id();
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if(isset($_COOKIE['core_user_name']))
	$phpcolor->newswrite($rsid,$time,$userv['id'],4);
  die("4");
}
$_GET['barname']=bn_replace($_GET['barname']);
$fc = new SplitWord();
$tjbarrs=$fc->SplitRMM($_GET['barname']);
$fc->Clear();
$tjbar = split(" ", $tjbarrs);
$bars=count($tjbar)-1;
if($bars>3)
  $bars=3;
for ($count=0;$count<$bars;$count++)
{
  $phpcolor->table="bar";
  $phpcolor->field="id,barname";
  $phpcolor->where="barname like '%".$tjbar[$count]."%' limit 5";
  $bart[]=$phpcolor->assignment();
}
$bt="您可能感兴趣的吧：";
for ($count=0;$count<count($bart);$count++)
{
  for ($count1=0;$count1<count($bart[$count]);$count1++)
  {
	$bart[$count][$count1]['url']=htmlurl($core_url,"list",$bart[$count][$count1]['id'],0,$core_rewrite);
    $bt.='&nbsp;<a href="'.$bart[$count][$count1]['url'].'">'.$bart[$count][$count1]['barname'].'</a>';
  }
}
if($core_createclass=="1")
{
  //吧分类
  $phpcolor->table="class";
  $phpcolor->field="id,classname,base";
  $phpcolor->where="belong = 0 order by queue";
  $bigsort=$phpcolor->assignment();
  for ($count=0;$count<count($bigsort);$count++)
  {
    $phpcolor->table="class";
    $phpcolor->field="id,classname";
    $phpcolor->where="belong = ".$bigsort[$count]['id']." order by queue";
    $smallsort[$count]=$phpcolor->assignment();
  }
  $tpl -> assign("bigsort", $bigsort);
  $tpl -> assign("smallsort", $smallsort);
}
$tpl -> assign("core_createclass", $core_createclass);
$tpl -> assign("bt", $bt);
$tpl -> assign("core_createaudit", $core_createaudit);
$tpl -> assign("core_vbar", $core_vbar);
$tpl -> assign("barname", $_GET['barname']);
$tpl -> assign("core_header_title", "创建".$core_bartype." - ");
$tpl -> display("$core_style/create.htm");
?>