<?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";
include "config.php";
admincheck(6);
/*if(Smallfivesolution() == $_SERVER['SERVER_NAME']) {
} else {
    echo Smallfivesq();
    exit();
}*/
include "../../../plug/baidu_linksubmit/conf.inc.php";
$action=SafeRequest("action", "get");
$ac=SafeRequest("ac", "get");
if($action=="config") {
	$baidu_linksubmit_open=SafeRequest("baidu_linksubmit_open", "post");
	$baidu_linksubmit_url=SafeRequest("baidu_linksubmit_url", "post");
	$strs="<?php" . "\n";
	$strs=$strs . "define(\"baidu_linksubmit_open\",\"" . $baidu_linksubmit_open . "\");\n";
	$strs=$strs . "define(\"baidu_linksubmit_url\",\"" . $baidu_linksubmit_url . "\");\n";
	$strs=$strs . "?>";
	if(!$fp=fopen('../../../plug/baidu_linksubmit/conf.inc.php', 'w')) {
		showmessage("出错了，文件 ../../../plug/baidu_linksubmit/conf.inc.php 没有写入权限！", $_SERVER['HTTP_REFERER'], 0);
	}
	$ifile=new iFile('../../../plug/baidu_linksubmit/conf.inc.php', 'w');
	$ifile->WriteFile($strs, 3);
	showmessage("恭喜您，保存设置成功！", $_SERVER['HTTP_REFERER'], 0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <meta name="renderer" content="webkit" /> 
  <title>管理后台</title> 
  <link rel="stylesheet" href="../../css/add.css" type="text/css" media="screen" /> 
<style type="text/css">
.table2{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table2 td{font-size: 12px;border-top: 1px solid #ddd;padding: 8px;vertical-align: top;}
.table2 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table2 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
.table3{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table3 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table3 td{font-size: 12px;line-height:25px;border-top: 1px solid #ddd;padding: 5px;vertical-align: top;border-right: solid 1px #ddd;}
.table3 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
</style>
 </head> 
 <body> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong><?php echo $plug_name?>插件设置</strong>
    </div> 
    <form action="?action=config" method="post" name="form2" >
    <table class="table3" id="dellist"> 
     <tbody>
	 <tr>
       <td width="110" align="left">版本信息</td>
       <td align="left"><?php echo $plug_version;?>　</td>
      </tr>
	 <tr>
       <td width="120" align="left">是否启用</td>
       <td align="left">
<label class="mr20"><input name="baidu_linksubmit_open" type="radio" value="yes" <?php if(baidu_linksubmit_open=="yes"){echo "checked";} ?>>&nbsp;启用&nbsp;</label>
<label class="mr20"><input type="radio" name="baidu_linksubmit_open" value="no" <?php if(baidu_linksubmit_open=="no"){echo "checked";} ?>>&nbsp;关闭&nbsp;</label>
	   </td>
      </tr>
	 <tr>
       <td width="120" align="left">接口调用地址</td>
       <td align="left">
<input id="baidu_linksubmit_url" name="baidu_linksubmit_url" value="<?php echo baidu_linksubmit_url?>" type="text" class="input" style="width: 450px;">
	   </td>
      </tr>
      <tr>
       <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border"><button type="submit" id="adddance" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 80px;">保存设置</button></td>
      </tr>
     </tbody>
    </table> 
	</form>
   </div> 
  </div>  
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong>百度站长工具-在线提交链接</strong>
    </div> 
    <form action="?action=linksubmit" method="post" name="form" >
    <table class="table3" id="dellist"> 
     <tbody>
	 <tr>
       <td width="120" align="left">提交地址，一行一条</td>
       <td align="left">
	   <textarea class="length_6" name="url" style="margin-top: 0px; margin-bottom: 0px; height: 150px;"></textarea>
	   </td>
      </tr>
      <tr>
       <td width="60" align="left">使用说明</td>
       <td align="left">请先在上面插件中保存接口调用地址。您可以在这里直接提交链接地址。</td>
      </tr>
      <tr>
       <td height="35" colspan="2" align="left" bgcolor="#FAFBF7" class="td_border"><button type="submit" id="adddance" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 80px;">提交链接</button></td>
      </tr>
     </tbody>
    </table> 
   </div> 
  </div> 
<?php
if($action=="linksubmit") {
$url=SafeRequest("url", "post");
$arr = explode("\r\n" , $url);
$urls = array();
foreach($arr as $value)
{
   $urls[] =$value;
}
$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);
$oktips=json_decode($result,true);
if($oktips["remain"]){
echo '
<div class="contents"> 
<div class="panel"> 
<div class="panel-head">
<strong>提交反馈：</strong>
</div>
<div style="padding: 10px;">提交状态：成功<br />提交数目：'.$oktips["success"].'<br />当天剩余的可推送url条数：'.$oktips["remain"].'条</div>
  </div>  
  </div>  
';}else{
echo '
<div class="contents"> 
<div class="panel"> 
<div class="panel-head">
<strong>提交反馈：</strong>
</div>
<div style="padding: 10px;">提交失败，请检查提交内容是否有误！</div>
  </div>  
  </div>  
';	
}
}
?>
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head">
     <strong><?php echo $plug_name?>使用说明</strong>
    </div> 
	<div style="padding: 5px;line-height: 22px;color: #575757;">最为快速的提交方式，将站点当天新产出链接立即通过此方式推送给百度，以保证新链接可以及时被百度收录。</div>
   </div> 
  </div>  
 </body>
</html>