<?php
error_reporting(0);
close_browse();
if (!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {exit('');}
global $db, $CcTvAi_com_userid;
if ($CcTvAi_com_userid) {
	if (!IsNumID($CcTvAi_com_userid)) {exit();}
	$CD_Name=unescape(SafeRequest("SpecialName", "post"));
	if ($db->getone("select CD_Name from " . tname('valbum') . " where CD_Name='" . $CD_Name . "'")) {exit('专辑名称已存在，请修改！');}
	$CD_Singer=unescape(SafeRequest("SingerID", "post"));
	$CD_GongSi=unescape(SafeRequest("GongSi", "post"));
	$CD_ClassID=SafeRequest("classId", "post");
	$CD_YuYan=unescape(SafeRequest("YuYan", "post"));
	$CD_Pic=unescape(SafeRequest("Pic", "post"));
	if (strpos($CD_Pic, ".")===false) {exit('1002');}
	$CD_Intro=unescape(SafeRequest("Intro", "post"));
if($CD_Singer) {
	//检测歌手$singername['CD_ID']
	$singername=$db->getrow("select CD_ID from " . tname('singer') . " where CD_Name='" . $CD_Singer . "'");
	if($singername=="") {
		$setarr=array(
			'CD_ClassID'=>4,
			'CD_Name'=>$CD_Singer,
			'CD_Sex'=>'',
			'CD_Bieming'=>'',
			'CD_Guoji'=>'',
			'CD_Yuan'=>'',
			'CD_Birth'=>'',
			'CD_Birthday'=>'',
			'CD_Sign'=>'',
			'CD_Height'=>'',
			'CD_Kg'=>'',
			'CD_User'=>$CcTvAi_com_username,
			'CD_Pic'=>'',
			'CD_Intro'=>'',
			'CD_Hits'=>0,
			'CD_IsBest'=>1,
			'CD_Passed'=>1,
			'CD_AddTime'=>date('Y-m-d H:i:s')
		);
		inserttable('singer', $setarr, 1);
		$singername=$db->getrow("select CD_ID from " . tname('singer') . " where CD_User='" . $CcTvAi_com_username . "' and CD_Name='" . $CD_Singer . "'  order by CD_ID desc");
	}
}
if($singername['CD_ID']=="") {
	$singername['CD_ID']=0;
}
	$setarr=array(
		'CD_ClassID' => $CD_ClassID,
		'CD_Name' => $CD_Name,
		'CD_User' => $CcTvAi_com_username,
		'CD_Pic' => $CD_Pic,
		'CD_Singer' => $singername['CD_ID'],
		'CD_GongSi' => $CD_GongSi,
		'CD_YuYan' => $CD_YuYan,
		'CD_Song' => '',
		'CD_Intro' => $CD_Intro,
		'CD_Hits' => 0,
		'CD_IsBest' => 1,
		'CD_Passed' => 1,
		'CD_AddTime' => date('Y-m-d H:i:s')
	);
	inserttable('valbum', $setarr, 1);
	$row=$db->getrow("select * from " . tname('valbum') . " where CD_User='" . $CcTvAi_com_username . "' and CD_Name='" . $CD_Name . "' and CD_Pic='" . $CD_Pic . "' order by CD_ID desc");
	$setarrs=array(
		'cd_uid' => $CcTvAi_com_userid,
		'cd_uname' => $CcTvAi_com_username,
		'cd_icon' => 'malbum',
		'cd_title' => '制作了视频专辑',
		'cd_data' => '制作了《' . $CD_Name . '》<a href="' . LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID']) . '" target="_blank">观看</a>',
		'cd_image' => '',
		'cd_imagelink' => '',
		'cd_dataid' => $row['CD_ID'],
		'cd_addtime' => date('Y-m-d H:i:s')
	);
	inserttable('feed', $setarrs, 1);
	
//百度链接提交工具
include "../plug/baidu_linksubmit/conf.inc.php";
if(baidu_linksubmit_open=="yes"){
$baidu_link="http://".$_SERVER['HTTP_HOST'].LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID'])."";
$urls = array($baidu_link);
$api = baidu_linksubmit_url;
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
}
	
	exit('1003');
} else {
	exit('1001');
}
?>