<?php
/*
'**************************************************************************************************
' 软件名称: 盘锦DJ舞曲网CMS Content Management PjRen.Net
' 版本编号: Version 2.5
' 盘锦舞曲: http://www.pj57.com
' 官方网站: http://www.pjren.net
' 小说网站: http://www.hx39.com
' 0427DJ网: http://www.0427dj.net
' 官方论坛: http://www.tianjiazhen.com
' 版权所有: 盘锦舞曲开发团队    盘锦人(QQ:814006710)
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、盘锦网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
include "../../include/conn.php";
include "../../include/function.php";
include "../admin_version.php";
include "../admin_loginstate.php";
include "../../include/dj95_config.php";
ini_set("max_execution_time", 2);
$id=$_GET['id'];
$cid=$_GET['cid'];
$sid=$_GET['sid'];
$ac=$_GET['ac'];
$op=$_GET['op'];
$ksid=$_POST['ksid'];
$jsid=$_POST['jsid'];
$classid=$_POST['classid'];
if($jsid=="") $jsid=$_GET['jsid'];
if($ksid=="") $ksid=$_GET['ksid'];
if($classid=="") $classid=$_GET['classid'];
if($id=="") $id=$ksid;
if($cid=="") $cid="0"; 
if($sid=="") $sid="0"; 
if($ac=="go"){
if($op=="class"){
if($id=="0"){
die("</br></br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;恭喜您,数据全部入库完成<script>setTimeout('ReadGo();',2000);function ReadGo(){window.location='?ac=main'}</script>");
}
}else{
if(($jsid <= $id||$id==0)){
die("</br></br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;恭喜您,数据全部入库完成<script>setTimeout('ReadGo();',2000);function ReadGo(){window.location='?ac=main'}</script>");
}
}
if($op=="class"){
$url="http://www.95dj.com/api/Api_open.Do?id=".$id."&classid=".$classid."";
}else{
if(($jsid <= $ksid) && ($classid=="")) die("</br></br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;抱歉，结束ID应该比开始ID大！<script>setTimeout('ReadGo();',3000);function ReadGo(){window.location='?ac=main'}</script>");
$url="http://www.95dj.com/api/Api_open.Do?id=".$id."";
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$str = curl_exec($ch);
curl_close ($ch);
$S_Name=str_substr("<!--name-->", "<!--vnameend-->", $str);
$S_Xid=str_substr("<!--xiaID-->", "<!--vxiaIDsend-->", $str);
$S_Classid=str_substr("<!--classids-->", "<!--vclassidsend-->", $str);
$S_Url=str_substr('<!--dizhi-->', '<!--vdizhiend-->', $str);
$S_DJid=str_substr("<!--wqids-->", "<!--vwqidsend-->", $str);
if($S_Classid==1) $classname="迪高串烧";
if($S_Classid==11) $classname="慢摇串烧";
if($S_Classid==2) $classname="中文DISCO";
if($S_Classid==15) $classname="中文慢摇";
if($S_Classid==13) $classname="英文Disco";
if($S_Classid==14) $classname="英文慢摇";
if($S_Classid==18) $classname="交谊舞曲";
if($S_Classid==16) $classname="RNB-RAP";
if($S_Classid==17) $classname="电音House";
if($S_Classid=="") $classname="没有数据";
if($S_Name=="") $S_Name="没有数据";
if($S_Url=="") $S_Url="没有数据";
?>
<table border="0" width="100%" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td width="176"></td>
<td>
<br><br>I&nbsp;&nbsp;D：<font color="#ff0000"><?php echo $S_DJid?></font>

<br><br>名称：<font color="#ff0000"><?php echo $S_Name?></font>
 
<br><br>地址：<font color="#ff0000"><?php echo $S_Url?></font>
 
<br><br>分类栏目：<font color="#ff0000"><?php echo $classname?></font>
 
<br><br<br><br> 你已成功入库 <font color="#ff0000"><?php echo $cid?></font> 条数据 , 失败 <font color="#0000ff"> <?php echo $sid?></font> 条数据
<br><br<br><br> 
<?php
$s_addtime=date("Y-m-d H:i:s");
//判断数据是否存在
    global $db;
    $s_ids= $db->Getone("select s_id from s_video where S_name='".$S_Name."' and s_vdata='".$S_Url."'");
    if($s_ids){
         echo "&nbsp;&nbsp;<b><font color=#0000ff >".$S_Name."</font>,<font color=#FF0000 >该舞曲已经存在-->>>入库失败!</br></font></b>";
         $sid=$sid+1;
    }else{
          //判断数据是否完整
              if(!IsNul($S_Name) or !IsNul($S_Url) or !IsNul($S_Classid)){
                            echo "&nbsp;&nbsp;<b><font color=#FF0000 >该ID没有舞曲数据，或者已被管理员删除-->>>入库失败!</br></font></b>";
                  $sid=$sid+1;
               }else{
                    //判断数据是否绑定分类
                          $sql3="select s_id from s_class where S_TieID like '%,dj95_".$S_Classid.",%'";
                          if($row3=$db->Getrow($sql3)){
                                 //执行入库处理
                                    $sql3="Insert s_video (S_Name,S_Remark,S_ClassID,S_Author,S_Content,S_Direct,S_IsEnd,S_Source,S_VData,S_AddTime,S_AddPath,S_Templay) values ('".$S_Name."','".$S_Url."','".$row3['s_id']."','本站原创','".$S_Name."','admin','0','dj95','".$S_Url."','".$s_addtime."','0','play.html')";
                                        if($db->query($sql3)){
                                               echo "&nbsp;&nbsp;<b><font color=#0000ff >".$S_Name."</font>-->>><font color=#0000ff >采集入库成功!</font></b></br>";
                                         $cid=$cid+1;
                                        }else{
                                               echo "&nbsp;&nbsp;<b><font color=#0000ff >".$S_Name."</font>,<font color=#FF0000 >-->>>入库失败,未知错误!</br></font></b>";
                                        }
                          }else{
                            $sid=$sid+1;
                                   echo "&nbsp;&nbsp;<b><font color=#0000ff >".$S_Name."</font>,<font color=#FF0000 >该舞曲未绑定分类-->>>入库失败!</br></font></b>";
                          }
              }
     }
$config=@file_get_contents("../../include/dj95_config.php");
if($op==""){
$config=preg_replace('/"DJ95KsID","(.*?)"/','"DJ95KsID","'.$ksid.'"',$config);
}
$config=preg_replace('/"DJ95JsID","(.*?)"/','"DJ95JsID","'.$id.'"',$config);
fwrite(fopen("../../include/dj95_config.php","wb"),$config);
?>
</td>
</tr>
</table>
<?php
die("<script>setTimeout('ReadGo();',0000);function ReadGo(){window.location='?ac=go&op=".$op."&classid=".$classid."&id=".$S_Xid."&cid=".$cid."&sid=".$sid."&jsid=".$jsid."&ksid=".$ksid."'}</script>");
}else{
?>
<style type="text/css"> 
body { background:#ffffff; font-size: 13px; margin-top:0px;SCROLLBAR-FACE-COLOR: #009ace; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #009ace; SCROLLBAR-3DLIGHT-COLOR: #009ace; SCROLLBAR-ARROW-COLOR: #def0fa;SCROLLBAR-TRACK-COLOR: #def0fa;}
TD {	FONT-SIZE: 13px}
INPUT {	FONT-SIZE: 13px;	HEIGHT: 20px;}
Button{	FONT-SIZE: 9pt;	HEIGHT: 20px; }
Select{	FONT-SIZE: 9pt;	HEIGHT: 20px;}
A{	TEXT-DECORATION: none;	color: #000000;}
A:hover{	COLOR: #428EFF;	text-decoration: underline;}
</style>
<br>
<table width="99%" border="0"  cellpadding="1" cellspacing="1" align="center" style="background:#2894FF;">
  <tr>
    <td align="center" width="100%" height="24" colspan="2" bgcolor="#ffffff">
    &nbsp;您上次入库&nbsp;开始的ID是：<b><font color=red><?php echo DJ95KsID?></font></b>&nbsp;&nbsp;结束的ID是：<b><font color=red><?php echo DJ95JsID?></font></b>
    &nbsp;&nbsp;&nbsp;《<?php echo ini_get('allow_url_fopen') ? "<font color=green>恭喜您，您的空间支持采集本资源</font>" : "<font color=red>抱歉，您的空间暂不支持采集本资源，请开启<font color=red>“allow_url_fopen”</font>函数</font>";?>》</td>
  </tr>
  <tr>
    <td colspan="2" valign="top" bgcolor="#FFFFFF">
<table width="98%" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
<form name='myform' method='post' action='?ac=go'>
<tr> 
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;<b><font color=green>按ID入库</font></b></td>
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
<tr> 
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">
    &nbsp;开始入库ID：<input name="ksid" type="text" id="ksid" size="15" value="<?php echo DJ95JsID?>">&nbsp;*填写入库开始ID&nbsp;95DJ资源最小ID是<font color=red>26355</font>(不是1)
  </td>
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">
    &nbsp;结束入库ID：<input name="jsid" type="text" id="jsid" size="15" value="">&nbsp;*填写入库结束ID&nbsp;
    &nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value="确认入库">
  </td>
  </tr>
</form>
<form name='myform' method='post' action='?ac=go&op=class'>
<tr> 
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;<b><font color=green>按分类入库</font></b>&nbsp;&nbsp;</td>
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;&nbsp;</td>
</tr>
<tr> 
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">
    &nbsp;请选择要入库的分类：
 <select name='classid' id='classid' style=" color:#0000ff; ">
<option value='1'>迪高串烧</option>
<option value='11'>慢摇串烧</option>
<option value='2'>中文DISCO</option>
<option value='15'>中文慢摇</option>
<option value='13'>英文Disco</option>
<option value='14'>英文慢摇</option>
<option value='18'>交谊舞曲</option>
<option value='16'>RNB-RAP</option>
<option value='17'>电音House</option>
 </select>
    &nbsp;<font color=red>注意：请先绑定该分类才能成功入库</font>&nbsp;
  </td>
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">
    &nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value="确认入库">
  </td>
  </tr>
<tr> 
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;&nbsp;&nbsp;</td>
    <td width="50%" height="32" colspan="2" bgcolor="#ffffff">&nbsp;&nbsp;</td>
</tr>
</table>
  </td>
  </tr>
</form>
</table>
 <script language="JavaScript"> 
document.oncontextmenu=new Function("event.returnValue=false;");  
</script>
<?php
}
function str_substr($start, $end, $str) // 字符串截取函数      
{      
    $temp = explode($start, $str, 2);      
    $content = explode($end, $temp[1], 2);      
    return $content[0];      
}   
?>