<?php

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include "../../include/cctvai.conn.php";
include "../function_common.php";
admincheck(9);
/*if(Smallfivesolution() == $_SERVER['SERVER_NAME']) {
} else {
    echo Smallfivesq();
    exit();
}*/
$id=SafeRequest("id", "get");
$type=SafeRequest("type", "get");
$arr=explode(",", $id);
$urls=array();
switch($type) {
	case 'dj':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("dj", 1, 1, $value);
		}
		break;
	case 'video':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("video", 1, 1, $value);
		}
		break;
	case 'singer':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("singer", 1, 1, $value);
		}
		break;
	case 'malbum':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("malbum", 1, 1, $value);
		}
		break;
	case 'valbum':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("valbum", 1, 1, $value);
		}
		break;
	case 'news':
		foreach($arr as $value) {
			$urls[]='http://' . cd_weburl . LinkUrl("news", 1, 1, $value);
		}
		break;
	case 'user':
		foreach($arr as $value) {
			$urls[]=linkweburl($value, 'x5');
		}
		break;
}
include "../../plug/baidu_linksubmit/conf.inc.php";
$baidu_linksubmit_url=baidu_linksubmit_url;
$baidu_linksubmit_open=baidu_linksubmit_open;
if($baidu_linksubmit_open=="no") {
	echo '<font size="2">插件已关闭，如需使用请先启用插件！</font>';
	exit();
}
if($baidu_linksubmit_url=="") {
	echo '<font size="2">您还没有填写接口调用地址，请到插件中设置！</font>';
	exit();
}
$ch=curl_init();
$options=array(
	CURLOPT_URL => $baidu_linksubmit_url,
	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);
$oktips=json_decode($result, true);
if($oktips["remain"]) {
	echo '<font size="2">提交状态：成功<br />提交数目：' . $oktips["success"] . '<br />当天剩余的可推送url条数：<font color="red">' . $oktips["remain"] . '</font>条</font>';
} else {
	echo '<font size="2">提交状态：失败<br />可能原因：<br />1.后台全局设置中的站点域名错误<br />2.插件中的接口调用地址错误！<br />3.您的主机不支持cURL！</font>';
}
//var_dump($urls);
?>