예제 #1
0
function MovieInflow($sql_collect, $MovieNumW)
{
    global $db;
    ?>
<table class=tb>
	<tr>
		<td  colspan="2" align="center"> 入 库 状 态 </td>
		<div id="refreshlentext" style="background:#006600"></div>
		</td>
	</tr>
  	<tr>
		<td  colspan="2" align="center"><span id="storagetext">正 在 入 库...</span></td>
  	</tr>
</table>
<?php 
    $iscover = be("iscover", "get");
    $rs = $db->query($sql_collect);
    $rscount = $db->num_rows($rs);
    //	var_dump($rscount);
    if ($rscount == 0) {
        echo "<script>alert('没有可入库的数据!'); location.href='collect_vod.php';</script>";
        exit;
    }
    if ($rscount > 10000) {
        $rscount = 1000;
    } elseif ($rscount > 5000) {
        $rscount = 500;
    } elseif ($rscount > 1000) {
        $rscount = 100;
    } else {
        $rscount = 10;
    }
    while ($row = $db->fetch_array($rs)) {
        if (!(isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && strlen(trim($row["m_playfrom"])) > 0)) {
            continue;
        }
        if (isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && ($row["m_playfrom"] === 'cntv' || $row["m_playfrom"] === 'wasu' || $row["m_playfrom"] === 'kankan' || $row["m_playfrom"] === 'tudou' || $row["m_playfrom"] === '')) {
            continue;
        }
        $flag = false;
        $title = $row["m_name"];
        $d_type = $row["m_typeid"];
        $title = replaceStr($title, "&lt;", "<<");
        $title = replaceStr($title, "&gt;", ">>");
        $testUrl = $row["m_urltest"];
        $year = $row['m_year'];
        $title = replaceStr($title, "'", "''");
        $strSet = "";
        $sql = "SELECT * FROM {pre}vod WHERE d_name = '" . $title . "' and d_type = '" . $d_type . "' ";
        $rowvod = $db->getRow($sql);
        if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
            var_dump($title . " is locked");
            continue;
        }
        //插入新数据开始
        if (isN($rowvod["d_id"]) || be("post", "CCTV") == "1") {
            $flag = true;
            $d_pic = replaceStr($row["m_pic"], "'", "''");
            $d_addtime = date('Y-m-d H:i:s', time());
            $d_year = $row["m_year"];
            $d_content = $row["m_content"];
            $d_hits = $row["m_hits"];
            $d_area = $row["m_area"];
            $d_language = $row["m_language"];
            $d_remarks = $row["m_remarks"];
            $d_state = $row["m_state"];
            $d_starring = $row["m_starring"];
            $d_directed = $row["m_directed"];
            $d_name = $title;
            $d_enname = hanzi2pinyin($d_name);
            if (isN($d_letter)) {
                $d_letter = strtoupper(substring($d_enname, 1));
            }
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            $sql = "insert {pre}vod (d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_state,d_remarks) values('" . $row["m_type"] . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_state . "','" . $d_remarks . "') ";
            $db->query($sql);
            $did = $db->insert_id();
        } else {
            //同名不处理, 如果是电影也不更新
            if (be("post", "CCTV") == "3" || $d_type === '1' || $d_type == 1) {
                //var_dump("dd");
                continue;
            }
            //更新数据开始
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            $strSet .= " d_type='" . $d_type . "', ";
            $strSet .= " d_type_name='" . $row["m_type"] . "', ";
            if (be("post", "CCTV2") == "2") {
                $d_area = $row["m_area"];
                $strSet .= "d_area='" . $d_area . "',";
            }
            if (be("post", "CCTV6") == "6") {
                $d_language = $row["m_language"];
                $strSet .= "d_language='" . $d_language . "',";
            }
            if (be("post", "CCTV7") == "7") {
                $d_remarks = $row["m_remarks"];
                $strSet .= "d_remarks='" . $d_remarks . "',";
            }
            if (be("post", "CCTV8") == "8") {
                $d_directed = $row["m_directed"];
                $strSet .= "d_directed='" . $d_directed . "',";
            }
            if (be("post", "CCTV1") == "1") {
                $d_year = $row["m_year"];
                $strSet .= "d_year='" . $d_year . "',";
            }
            if (be("post", "CCTV3") == "3") {
                $d_starring = $row["m_starring"];
                $strSet .= "d_starring='" . $d_starring . "',";
            }
            if (be("post", "CCTV4") == "4") {
                $d_pic = $row["m_pic"];
                $strSet .= "d_pic='" . $d_pic . "',";
            }
            if (be("post", "CCTV5") == "5") {
                $d_content = $row["m_content"];
                $strSet .= "d_content='" . $d_content . "',";
            }
            $d_state = $row["m_state"];
            $strSet .= "d_state='" . $d_state . "',";
            $strSet .= "d_name='" . $title . "',";
            $d_enname = hanzi2pinyin($title);
            $strSet .= "d_enname='" . $d_enname . "',";
            if (isN($d_letter)) {
                $d_letter = strtoupper(substring($d_enname, 1));
            }
            $strSet .= "d_letter='" . $d_letter . "',";
            $d_addtime = date('Y-m-d H:i:s', time());
            $strSet .= "d_time='" . $d_addtime . "',";
        }
        //更新数据结束
        if ($flag == false) {
            $did = $rowvod["d_id"];
        }
        //获取影片URL
        $playAndWebArray = getVodPlanAndWebUrl($row["m_id"], $testUrl, $row["m_playfrom"], $d_type);
        //		$urls = getVodUrl($row["m_id"]);
        //   var_dump($playAndWebArray);
        $urls = $playAndWebArray['playUrl'];
        $webUrls = $playAndWebArray['webUrl'];
        if (!(isset($webUrls) && !is_null($webUrls) && strlen($webUrls) > 0)) {
            $webUrls = $testUrl;
        }
        $videoUrls = $playAndWebArray['videoUrl'];
        if (isN($videoUrls)) {
            $videoUrls = "";
        } else {
            if (strpos($videoUrls, "\$") === 0) {
                $videoUrls = substr($videoUrls, 1);
            }
        }
        //       var_dump($videoUrls);
        $tmpplayurl = $rowvod["d_playurl"];
        $tmpweburl = $rowvod["webUrls"];
        $tmpvideourl = $rowvod["d_downurl"];
        $tmpplayfrom = $rowvod["d_playfrom"];
        $tmpplayserver = $rowvod["d_playserver"];
        if (isN($tmpplayurl)) {
            $tmpplayurl = "";
        }
        if (isN($tmpvideourl)) {
            $tmpvideourl = "";
        }
        if (isN($tmpweburl)) {
            $tmpweburl = "";
        }
        if (isN($tmpplayfrom)) {
            $tmpplayfrom = "";
        }
        if (isN($tmpplayfrom)) {
            if (isN($videoUrls)) {
                $strSet .= "d_playfrom='" . $row["m_playfrom"] . "',d_playserver='" . $row["m_playserver"] . "',d_playurl='" . $urls . "',webUrls='" . $webUrls . "'";
            } else {
                $strSet .= "d_playfrom='" . $row["m_playfrom"] . "',d_playserver='" . $row["m_playserver"] . "',d_playurl='" . $urls . "',webUrls='" . $webUrls . "' ,d_downurl='" . $row["m_playfrom"] . '$$' . $videoUrls . "'";
            }
        } else {
            if (strpos("," . $tmpplayfrom, $row["m_playfrom"]) > 0) {
                if (be("post", "CCTV") == "2") {
                    if (isN($videoUrls)) {
                        $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayfrom . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' " . "',webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . "'";
                    } else {
                        $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayfrom . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' " . "',webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . "\$\$\$" . $row["m_playfrom"] . '$$' . $videoUrls . "'";
                    }
                } else {
                    $arr1 = explode("\$\$\$", $tmpplayurl);
                    $tempWebArray1 = explode("\$\$\$", $tmpweburl);
                    $tempVideoArray1 = explode("\$\$\$", $tmpvideourl);
                    $arr2 = explode("\$\$\$", $tmpplayfrom);
                    $tmpplayurl = "";
                    $tmpweburl = "";
                    $tmpvideourl = "";
                    $rc = false;
                    for ($k = 0; $k < count($arr2); $k++) {
                        if ($rc) {
                            $tmpweburl = $tmpweburl . "\$\$\$";
                        }
                        $rc = false;
                        if ($arr2[$k] !== $row["m_playfrom"]) {
                            $tmpweburl = $tmpweburl . $tempWebArray1[$k];
                            $rc = true;
                        } else {
                            if (isN($webUrls)) {
                                $webUrls = $tempWebArray1[$k];
                            }
                        }
                    }
                    $tmpweburl = $webUrls . "\$\$\$" . $tmpweburl;
                    $rc = false;
                    for ($k = 0; $k < count($arr2); $k++) {
                        if ($rc) {
                            $tmpplayurl = $tmpplayurl . "\$\$\$";
                        }
                        $rc = false;
                        if ($arr2[$k] !== $row["m_playfrom"]) {
                            $tmpplayurl = $tmpplayurl . $arr1[$k];
                            $rc = true;
                        } else {
                            if (isN($urls)) {
                                $urls = $arr1[$k];
                            }
                        }
                    }
                    $tmpplayurl = $urls . "\$\$\$" . $tmpplayurl;
                    $rc = false;
                    for ($k = 0; $k < count($tempVideoArray1); $k++) {
                        if ($rc) {
                            $tmpvideourl = $tmpvideourl . "\$\$\$";
                        }
                        $rc = false;
                        $arr2 = explode("\$\$", $tempVideoArray1[$k]);
                        if ($arr2[0] !== $row["m_playfrom"]) {
                            if (!isN($tempVideoArray1[$k])) {
                                $tmpvideourl = $tmpvideourl . $tempVideoArray1[$k];
                                $rc = true;
                            }
                        } else {
                            if (isN($videoUrls) && count($arr2) > 1) {
                                $videoUrls = $arr2[1];
                            }
                        }
                    }
                    if (isN($videoUrls)) {
                        $tmpvideourl = $tmpvideourl;
                    } else {
                        $tmpvideourl = $row["m_playfrom"] . '$$' . $videoUrls . "\$\$\$" . $tmpvideourl;
                    }
                    //				if(!isN($str))
                    $strSet .= "d_playurl='" . $tmpplayurl . "' , webUrls='" . $tmpweburl . "' , d_downurl='" . $tmpvideourl . "'";
                    //				$tmpplayfrom , $row["m_playfrom"]
                    $tmpplayfrom = replaceStr($tmpplayfrom, " ", "");
                    $tmpplayfrom = replaceStr($tmpplayfrom, $row["m_playfrom"] . "\$\$\$", "");
                    $tmpplayfrom = replaceStr($tmpplayfrom, $row["m_playfrom"], "");
                    $strSet .= ",d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "' ";
                }
            } else {
                if (isN($videoUrls)) {
                    $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayserver . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' ,webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ";
                } else {
                    $tempVideoArray1 = explode("\$\$\$", $tmpvideourl);
                    $tmpvideourl = "";
                    $rc = false;
                    //			   var_dump($tempVideoArray1);
                    for ($k = 0; $k < count($tempVideoArray1); $k++) {
                        if ($rc) {
                            $tmpvideourl = $tmpvideourl . "\$\$\$";
                        }
                        $rc = false;
                        $arr2 = explode("\$\$", $tempVideoArray1[$k]);
                        if ($arr2[0] !== $row["m_playfrom"]) {
                            if (!isN($tempVideoArray1[$k])) {
                                $tmpvideourl = $tmpvideourl . $tempVideoArray1[$k];
                                $rc = true;
                            }
                        }
                    }
                    if (isN($videoUrls)) {
                        $tmpvideourl = $tmpvideourl;
                    } else {
                        $tmpvideourl = $row["m_playfrom"] . '$$' . $videoUrls . "\$\$\$" . $tmpvideourl;
                    }
                    $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $tmpplayserver . "\$\$\$" . $row["m_playserver"] . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' ,webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . '\' ';
                }
            }
        }
        //	    writetofile("d:\\up.txt", $strSet);
        $sql = "update {pre}vod set " . $strSet . " where d_id=" . $did;
        //		writetofile("d:\\ts.txt", "update {pre}vod set ".$strSet." where d_id=" .$did);
        $filePath = "../../upload/export/" . iconv("UTF-8", "GBK", 'dd') . ".txt";
        fwrite(fopen($filePath, "wb"), $sql);
        //		var_dump($sql);
        $db->query($sql);
        $db->query("update {pre}cj_vod set m_zt=1 where m_id=" . $row["m_id"]);
        $MovieInflowNum = $MovieInflowNum + 1;
        if ($MovieInflowNum >= $MovieNumW) {
            //			echo "<script type=\"text/javascript\" language=\"javascript\">";
            //			echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
            //			echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
            //			echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='collect_vod.php'>返回</a>\";";
            //			echo "alert('入库完毕'); location.href='collect_vod.php';";
            //			echo "</script>";
        } elseif (fmod($MovieInflowNum, $rscount) == 0) {
            echo "<script type=\"text/javascript\" language=\"javascript\">";
            echo "document.getElementById(\"refreshlentext\").style.width = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"refreshlentext\").innerHTML = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"storagetext\").innerHTML = \"正在入库......\";";
            echo "</script>";
        }
    }
    echo "<script type=\"text/javascript\" language=\"javascript\">";
    echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
    echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
    echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='collect_vod.php'>返回</a>\";";
    echo "alert('入库完毕'); location.href='collect_vod.php';";
    echo "</script>";
    unset($rs);
}
예제 #2
0
function MovieInflow($sql_collect, $MovieNumW, $isMandCollect)
{
    global $db;
    ?>
    <table class=tb>
        <tr>
            <td colspan="2" align="center">入 库 状 态</td>
            <div id="refreshlentext" style="background: #006600"></div>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center"><span id="storagetext">正 在 入 库...</span></td>
        </tr>
    </table>
    <?php 
    $iscover = be("iscover", "get");
    $rs = $db->query($sql_collect);
    $rscount = $MovieNumW;
    if ($rscount == 0) {
        echo "<script>alert('没有可入库的数据!'); location.href='collect_vod.php';</script>";
        exit;
    }
    if ($rscount > 10000) {
        $rscount = 1000;
    } elseif ($rscount > 5000) {
        $rscount = 500;
    } elseif ($rscount > 1000) {
        $rscount = 100;
    } else {
        $rscount = 10;
    }
    while ($row = $db->fetch_array($rs)) {
        if (!(isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && strlen(trim($row["m_playfrom"])) > 0)) {
            continue;
        }
        if (isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && ($row["m_playfrom"] === 'cntv' || $row["m_playfrom"] === 'wasu' || $row["m_playfrom"] === 'kankan' || $row["m_playfrom"] === 'tudou' || $row["m_playfrom"] === '')) {
            continue;
        }
        $flag = false;
        $title = $row["m_name"];
        $d_type = $row["m_typeid"];
        $title = replaceStr($title, "&lt;", "<<");
        $title = replaceStr($title, "&gt;", ">>");
        $title = trim(replaceStr($title, "&nbsp;", ' '));
        $title = replaceStr($title, " 国语", "");
        $testUrl = $row["m_urltest"];
        $year = $row['m_year'];
        $typeName = $row["m_type"];
        $duraning = $row["duraning"];
        $title = replaceStr($title, "'", "''");
        $titlenolang = $title;
        $d_language = $row["m_language"];
        $flag_lang = false;
        $d_state = $row["m_state"];
        if ($d_type === '131' && strpos($year, ',') !== false) {
            var_dump($title . " 是综艺而不是动漫。");
            continue;
        }
        if ($d_type === '3' && !is_null($d_state) && strlen($d_state) != 8) {
            var_dump($title . " 是动漫而不是综艺。");
            continue;
        }
        if (!isN($d_language)) {
            $titlenolang = trim(replaceStr($titlenolang, $d_language, ''));
            $titlenolang = trim($titlenolang);
            if (strpos($title, $d_language) !== false) {
                $flag_lang = true;
            }
        }
        $strSet = "";
        $sql = "SELECT * FROM {pre}vod WHERE d_playfrom != 'so_hu_cp' and d_name = '" . $titlenolang . "' and d_type = '" . $d_type . "' ";
        //		var_dump($sql);
        $rowvod = $db->getRow($sql);
        //	     var_dump($rowvod["d_id"]);
        if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
            var_dump($titlenolang . " is locked");
            if (!$isMandCollect) {
                continue;
            }
        }
        if ($flag_lang && (isN($rowvod["d_id"]) || be("post", "CCTV") == "1")) {
            $sql = "SELECT * FROM {pre}vod WHERE d_playfrom != 'so_hu_cp' and d_name = '" . $title . "' and d_type = '" . $d_type . "' ";
            $rowvod = $db->getRow($sql);
            if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
                var_dump($title . " is locked");
                if (!$isMandCollect) {
                    continue;
                }
            }
        }
        global $db;
        $id = $row["m_id"];
        $sql2 = "select * from {pre}cj_vod_url where u_movieid=" . $id . " order by name desc ";
        $rs_collect2 = $db->query($sql2);
        $mrowurl = $db->fetch_array($rs_collect2);
        //插入新数据开始
        if (isN($rowvod["d_id"]) || be("post", "CCTV") == "1") {
            $flag = true;
            $d_pic = replaceStr($row["m_pic"], "'", "''");
            $d_pic_ipad = replaceStr($row["d_pic_ipad"], "'", "''");
            $d_addtime = date('Y-m-d H:i:s', time());
            $d_year = $row["m_year"];
            if (isN($d_year) || $d_year === '未知') {
                $d_year = '其他';
            }
            $d_content = $row["m_content"];
            $d_hits = $row["m_hits"];
            $d_area = $row["m_area"];
            if (isN($d_area) || $d_area === '未知') {
                $d_area = '其他';
            }
            $d_remarks = $row["m_remarks"];
            if (!isNum($d_remarks)) {
                $d_remarks = '';
            }
            $d_state = $row["m_state"];
            $d_starring = $row["m_starring"];
            $d_directed = $row["m_directed"];
            $duraning = $row["duraning"];
            $d_name = $title;
            $typeName = $row["m_type"];
            if (isN($typeName) || $typeName === '未知') {
                $typeName = '其他';
            }
            $d_enname = hanzi2pinyin($d_name);
            $d_capital_name = Hanzi2PinYin_Captial($d_name);
            $d_letter = strtoupper(substring($d_enname, 1));
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            if (!($d_type === '1' || $d_type === 1)) {
                $duraning = '';
            }
            if (isN($mrowurl["iso_video_url"]) && isN($mrowurl["android_vedio_url"])) {
                //判断下载地址 无
                if ($row["m_playfrom"] == "qq" || $row["m_playfrom"] == "pptv") {
                    $strSet .= "can_search_device='iPad,iphone,apad,aphone,web' , ";
                    //入库  不勾tv.vender
                    echo "qq和pptv播放源直接入库   视频名称: \"" . $title . "\"  播放源: " . $row["m_playfrom"] . "\";";
                }
            } else {
                // 判断下载地址 有
                if ($row["m_playfrom"] == "youku") {
                    // 入库数据是优酷
                    $strSet .= "can_search_device='TV,Vendor' , ";
                    //入库 勾选tv vendor
                } else {
                    $strSet .= "can_search_device='TV,iPad,iphone,apad,aphone,web,Vendor' , ";
                    //入库 全部勾选
                }
            }
            //writetofile("gaoca.txt", $duraning);
            echo "states: " . $d_state . isNum($d_state);
            echo "remarks: " . isNum($d_remarks);
            if (isNum($d_state)) {
                $sql = "insert {pre}vod (d_pic_ipad,duraning,d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_state,d_remarks,d_capital_name) values('" . $d_pic_ipad . "' ,'" . $duraning . "' , '" . $typeName . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_state . "','" . $d_remarks . "','" . $d_capital_name . "') ";
            } else {
                if (!isNum($d_state) && $isMandCollect) {
                    $sql = "insert {pre}vod (d_pic_ipad,duraning,d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_remarks,d_capital_name) values('" . $d_pic_ipad . "' ,'" . $duraning . "' , '" . $typeName . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_remarks . "','" . $d_capital_name . "') ";
                    sendMail(array('*****@*****.**', '*****@*****.**'), '', '<CMS>:影片《' . $title . '》 连载信息非法' . $row["m_playfrom"]);
                } else {
                    if (!isNum($d_remarks) && $isMandCollect) {
                        $sql = "insert {pre}vod (d_pic_ipad,duraning,d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_state,d_capital_name) values('" . $d_pic_ipad . "' ,'" . $duraning . "' , '" . $typeName . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_state . "','" . $d_capital_name . "') ";
                        sendMail(array('*****@*****.**', '*****@*****.**'), '', '<CMS>:影片《' . $title . '》 备注信息非法' . $row["m_playfrom"]);
                    } else {
                        if (!isNum($d_remarks) && $isMandCollect && !isNum($d_state)) {
                            $sql = "insert {pre}vod (d_pic_ipad,duraning,d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_capital_name) values('" . $d_pic_ipad . "' ,'" . $duraning . "' , '" . $typeName . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_capital_name . "') ";
                            sendMail(array('*****@*****.**', '*****@*****.**'), '', '<CMS>:影片《' . $title . '》 连载、备注信息非法' . $row["m_playfrom"]);
                        }
                    }
                }
            }
            writetofile("gaoca.txt", $sql);
            $db->query($sql);
            $did = $db->insert_id();
            //			if($d_type === '2' || $d_type === '131' ){
            //				$d_addtime= date('Y-m-d H:i:s',time());
            //			  	$db->query("INSERT INTO mac_vod_pasre_item (prod_id,create_date) VALUES('".$did."','".$d_addtime."')");
            //			}
        } else {
            //同名不处理, 如果是电影也不更新
            if (be("post", "CCTV") == "3") {
                //var_dump("dd");
                continue;
            }
            //	   echo 'prod youku '.strpos($rowvod["d_playfrom"],"youku").'cj youku '.$row["m_playfrom"].'prod p2p'.strpos($rowvod["d_playfrom"],"p2p");
            if (@strpos($rowvod["d_playfrom"], "youku") === false && $row["m_playfrom"] === "youku") {
                echo "优酷不更新入库   视频名称: \"" . $title . "\"  播放源: " . $row["m_playfrom"] . "\";";
                continue;
            } else {
                if ($row["m_playfrom"] != "youku" && (strpos($rowvod["d_playfrom"], "youku") !== false || @strpos($rowvod["d_playfrom"], "p2p") !== false)) {
                    echo " 库内存在p2p或优酷不入库   视频名称: \"" . $title . "\"  播放源: " . $row["m_playfrom"] . "\";";
                    continue;
                } else {
                    if (isN($mrowurl["iso_video_url"]) && isN($mrowurl["android_vedio_url"]) && $row["m_playfrom"] === "fengxing") {
                        echo " fengxing无下载地址不更新入库   视频名称: \"" . $title . "\"  播放源: " . $row["m_playfrom"] . "\";";
                        continue;
                    }
                }
            }
            //更新数据开始
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            $strSet .= " d_type='" . $d_type . "', ";
            if (!isN($typeName) && $typeName !== '未知') {
                $strSet .= " d_type_name='" . $typeName . "', ";
            }
            $strSet .= " d_name='" . $title . "', ";
            $d_enname = hanzi2pinyin($title);
            $strSet .= " d_enname='" . $d_enname . "', ";
            $d_capital_name = Hanzi2PinYin_Captial($title);
            $strSet .= " d_capital_name='" . $d_capital_name . "', ";
            if (be("post", "CCTV2") == "2") {
                $d_area = $row["m_area"];
                if (isN($d_area) || $d_area === '未知') {
                    $d_area = '其他';
                }
                $strSet .= "d_area='" . $d_area . "',";
            }
            if (be("post", "CCTV6") == "6") {
                $d_language = $row["m_language"];
                $strSet .= "d_language='" . $d_language . "',";
            }
            if (be("post", "CCTV7") == "7") {
                $d_remarks = $row["m_remarks"];
                if (isNum($d_remarks)) {
                    $strSet .= "d_remarks='" . $d_remarks . "',";
                } else {
                    if (!isNum($d_remarks) && $isMandCollect) {
                        sendMail(array('*****@*****.**', '*****@*****.**'), '', '<CMS>:影片《' . $title . '》 备注信息非法' . $row["m_playfrom"]);
                    }
                }
            }
            if (be("post", "CCTV8") == "8") {
                $d_directed = $row["m_directed"];
                $strSet .= "d_directed='" . $d_directed . "',";
            }
            if (be("post", "CCTV9") == "9" && !isN($duraning)) {
                if (!($d_type === '1' || $d_type === 1)) {
                    $duraning = '';
                }
                $strSet .= " duraning='" . $duraning . "', ";
            }
            if (be("post", "CCTV1") == "1") {
                $d_year = $row["m_year"];
                if (isN($d_year) || $d_year === '未知') {
                    $d_year = '其他';
                }
                $strSet .= "d_year='" . $d_year . "',";
            }
            if (be("post", "CCTV3") == "3") {
                $d_starring = $row["m_starring"];
                $strSet .= "d_starring='" . $d_starring . "',";
            }
            if (be("post", "CCTV4") == "4") {
                $d_pic = $row["m_pic"];
                $strSet .= "d_pic='" . $d_pic . "',";
            }
            if (be("post", "CCTV5") == "5") {
                $d_content = $row["m_content"];
                $strSet .= "d_content='" . $d_content . "',";
            }
            $d_state = $row["m_state"];
            if (!isN($d_state) && $d_state !== '0') {
                if (isNum($d_state)) {
                    $strSet .= "d_state='" . $d_state . "',";
                } else {
                    if (!isNum($d_state) && $isMandCollect) {
                        sendMail(array('*****@*****.**', '*****@*****.**'), '', '<CMS>:影片《' . $title . '》 连载信息非法' . $row["m_playfrom"]);
                    }
                }
            }
            $strSet .= "d_name='" . $title . "',";
            $d_enname = hanzi2pinyin($title);
            $strSet .= "d_enname='" . $d_enname . "',";
            $d_letter = strtoupper(substring($d_enname, 1));
            $strSet .= "d_letter='" . $d_letter . "',";
            $d_addtime = date('Y-m-d H:i:s', time());
            $strSet .= "d_time='" . $d_addtime . "',";
            if ($d_type === '2' || $d_type === '131') {
                if (!($d_state === $rowvod["d_state"]) && $rowvod["favority_user_count"] > 0) {
                    $t_id = $rowvod["d_id"];
                    $info = $db->getRow('select prod_id from mac_vod_pasre_item where prod_id=' . $t_id);
                    if ($info === false) {
                        $d_addtime = date('Y-m-d H:i:s', time());
                        $db->query("INSERT INTO mac_vod_pasre_item (prod_id,create_date) VALUES('" . $t_id . "','" . $d_addtime . "')");
                    }
                }
            }
        }
        //更新数据结束
        if ($flag == false) {
            $did = $rowvod["d_id"];
        }
        //获取影片URL
        $playAndWebArray = getVodPlanAndWebUrl($row["m_id"], $testUrl, $row["m_playfrom"], $d_type);
        if ($playAndWebArray['noVideoUrlFlag'] && $isMandCollect) {
            sendMail(array('*****@*****.**', '*****@*****.**'), '<CMS>:影片《' . $title . '》 视频地址为空,不能入库', '<CMS>:影片《' . $title . '》 视频地址为空,播放器:' . $row["m_playfrom"]);
            continue;
        }
        //		$urls = getVodUrl($row["m_id"]);
        //   var_dump($playAndWebArray);
        $urls = $playAndWebArray['playUrl'];
        $webUrls = $playAndWebArray['webUrl'];
        if (!(isset($webUrls) && !is_null($webUrls) && strlen($webUrls) > 0)) {
            $webUrls = $testUrl;
        }
        $videoUrls = $playAndWebArray['videoUrl'];
        if (isN($videoUrls)) {
            $videoUrls = "";
        } else {
            if (strpos($videoUrls, "\$") === 0) {
                $videoUrls = substr($videoUrls, 1);
            }
        }
        //       var_dump($videoUrls);
        $tmpplayurl = $rowvod["d_playurl"];
        $tmpweburl = $rowvod["webUrls"];
        $tmpvideourl = $rowvod["d_downurl"];
        $tmpplayfrom = $rowvod["d_playfrom"];
        $tmpplayserver = $rowvod["d_playserver"];
        if (isN($tmpplayurl)) {
            $tmpplayurl = "";
        }
        if (isN($tmpvideourl)) {
            $tmpvideourl = "";
        }
        if (isN($tmpweburl)) {
            $tmpweburl = "";
        }
        if (isN($tmpplayfrom)) {
            $tmpplayfrom = "";
        }
        if (isN($tmpplayfrom)) {
            if (isN($videoUrls)) {
                $strSet .= "d_playfrom='" . $row["m_playfrom"] . "',d_playserver='" . $row["m_playserver"] . "',d_playurl='" . $urls . "',webUrls='" . $webUrls . "'";
            } else {
                $strSet .= "d_playfrom='" . $row["m_playfrom"] . "',d_playserver='" . $row["m_playserver"] . "',d_playurl='" . $urls . "',webUrls='" . $webUrls . "' ,d_downurl='" . $row["m_playfrom"] . '$$' . $videoUrls . "'";
            }
        } else {
            if (strpos("," . $tmpplayfrom, $row["m_playfrom"]) > 0) {
                if (be("post", "CCTV") == "2") {
                    if (isN($videoUrls)) {
                        $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayfrom . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' " . "',webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . "'";
                    } else {
                        $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayfrom . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' " . "',webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . "\$\$\$" . $row["m_playfrom"] . '$$' . $videoUrls . "'";
                    }
                } else {
                    $arr1 = explode("\$\$\$", $tmpplayurl);
                    $tempWebArray1 = explode("\$\$\$", $tmpweburl);
                    $tempVideoArray1 = explode("\$\$\$", $tmpvideourl);
                    $arr2 = explode("\$\$\$", $tmpplayfrom);
                    $tmpplayurl = "";
                    $tmpweburl = "";
                    $tmpvideourl = "";
                    $rc = false;
                    for ($k = 0; $k < count($arr2); $k++) {
                        if ($rc) {
                            $tmpweburl = $tmpweburl . "\$\$\$";
                        }
                        $rc = false;
                        if ($arr2[$k] !== $row["m_playfrom"]) {
                            $tmpweburl = $tmpweburl . $tempWebArray1[$k];
                            $rc = true;
                        } else {
                            if (isN($webUrls)) {
                                $webUrls = $tempWebArray1[$k];
                            }
                        }
                    }
                    $tmpweburl = $webUrls . "\$\$\$" . $tmpweburl;
                    $rc = false;
                    for ($k = 0; $k < count($arr2); $k++) {
                        if ($rc) {
                            $tmpplayurl = $tmpplayurl . "\$\$\$";
                        }
                        $rc = false;
                        if ($arr2[$k] !== $row["m_playfrom"]) {
                            $tmpplayurl = $tmpplayurl . $arr1[$k];
                            $rc = true;
                        } else {
                            if (isN($urls)) {
                                $urls = $arr1[$k];
                            }
                        }
                    }
                    $tmpplayurl = $urls . "\$\$\$" . $tmpplayurl;
                    $rc = false;
                    for ($k = 0; $k < count($tempVideoArray1); $k++) {
                        if ($rc) {
                            $tmpvideourl = $tmpvideourl . "\$\$\$";
                        }
                        $rc = false;
                        $arr2 = explode("\$\$", $tempVideoArray1[$k]);
                        if ($arr2[0] !== $row["m_playfrom"]) {
                            if (!isN($tempVideoArray1[$k])) {
                                $tmpvideourl = $tmpvideourl . $tempVideoArray1[$k];
                                $rc = true;
                            }
                        } else {
                            if (isN($videoUrls) && count($arr2) > 1) {
                                $videoUrls = $arr2[1];
                            }
                        }
                    }
                    if (isN($videoUrls)) {
                        $tmpvideourl = $tmpvideourl;
                    } else {
                        $tmpvideourl = $row["m_playfrom"] . '$$' . $videoUrls . "\$\$\$" . $tmpvideourl;
                    }
                    //				if(!isN($str))
                    $strSet .= "d_playurl='" . $tmpplayurl . "' , webUrls='" . $tmpweburl . "' , d_downurl='" . $tmpvideourl . "'";
                    //				$tmpplayfrom , $row["m_playfrom"]
                    $tmpplayfrom = replaceStr($tmpplayfrom, " ", "");
                    $tmpplayfrom = replaceStr($tmpplayfrom, $row["m_playfrom"] . "\$\$\$", "");
                    $tmpplayfrom = replaceStr($tmpplayfrom, $row["m_playfrom"], "");
                    $strSet .= ",d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "' ";
                }
            } else {
                if (isN($videoUrls)) {
                    $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $row["m_playserver"] . "\$\$\$" . $tmpplayserver . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' ,webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ";
                } else {
                    $tempVideoArray1 = explode("\$\$\$", $tmpvideourl);
                    $tmpvideourl = "";
                    $rc = false;
                    //			   var_dump($tempVideoArray1);
                    for ($k = 0; $k < count($tempVideoArray1); $k++) {
                        if ($rc) {
                            $tmpvideourl = $tmpvideourl . "\$\$\$";
                        }
                        $rc = false;
                        $arr2 = explode("\$\$", $tempVideoArray1[$k]);
                        if ($arr2[0] !== $row["m_playfrom"]) {
                            if (!isN($tempVideoArray1[$k])) {
                                $tmpvideourl = $tmpvideourl . $tempVideoArray1[$k];
                                $rc = true;
                            }
                        }
                    }
                    if (isN($videoUrls)) {
                        $tmpvideourl = $tmpvideourl;
                    } else {
                        $tmpvideourl = $row["m_playfrom"] . '$$' . $videoUrls . "\$\$\$" . $tmpvideourl;
                    }
                    $strSet .= "d_playfrom='" . $row["m_playfrom"] . "\$\$\$" . $tmpplayfrom . "',d_playserver='" . $tmpplayserver . "\$\$\$" . $row["m_playserver"] . "',d_playurl='" . $urls . "\$\$\$" . $tmpplayurl . "' ,webUrls='" . $webUrls . "\$\$\$" . $tmpweburl . "' ,d_downurl='" . $tmpvideourl . '\' ';
                }
            }
        }
        //	    writetofile("d:\\up.txt", $strSet);
        $sql = "update {pre}vod set " . $strSet . " where d_id=" . $did;
        //		writetofile("d:\\ts.txt", "update {pre}vod set ".$strSet." where d_id=" .$did);
        $filePath = "../../upload/export/" . iconv("UTF-8", "GBK", 'dd') . ".txt";
        fwrite(fopen($filePath, "wb"), $sql);
        //		var_dump($sql);
        $db->query($sql);
        $db->query("update {pre}cj_vod set m_zt=1 where m_id=" . $row["m_id"]);
        $MovieInflowNum = $MovieInflowNum + 1;
        if ($MovieInflowNum >= $MovieNumW) {
            //			echo "<script type=\"text/javascript\" language=\"javascript\">";
            //			echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
            //			echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
            //			echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='collect_vod.php'>返回</a>\";";
            //			echo "alert('入库完毕'); location.href='collect_vod.php';";
            //			echo "</script>";
        } elseif (fmod($MovieInflowNum, $rscount) == 0) {
            echo "<script type=\"text/javascript\" language=\"javascript\">";
            echo "document.getElementById(\"refreshlentext\").style.width = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"refreshlentext\").innerHTML = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"storagetext\").innerHTML = \"正在入库......\";";
            echo "</script>";
        }
    }
    echo "<script type=\"text/javascript\" language=\"javascript\">";
    echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
    echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
    echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='" . getReferer() . "'>返回</a>\";";
    echo "alert('入库完毕'); ";
    echo "var current_date='" . date('Y-m-d H:i:s', time()) . "'";
    echo "</script>";
    unset($rs);
}
예제 #3
0
function MovieInflow($sql_collect, $MovieNumW, $isMandCollect)
{
    global $db;
    ?>
<table class=tb>
	<tr>
		<td  colspan="2" align="center"> 入 库 状 态 </td>
		<div id="refreshlentext" style="background:#006600"></div>
		</td>
	</tr>
  	<tr>
		<td  colspan="2" align="center"><span id="storagetext">正 在 入 库...</span></td>
  	</tr>
</table>
<?php 
    $iscover = be("iscover", "get");
    $rs = $db->query($sql_collect);
    $rscount = $MovieNumW;
    if ($rscount == 0) {
        echo "<script>alert('没有可入库的数据!'); location.href='collect_vod.php';</script>";
        exit;
    }
    if ($rscount > 10000) {
        $rscount = 1000;
    } elseif ($rscount > 5000) {
        $rscount = 500;
    } elseif ($rscount > 1000) {
        $rscount = 100;
    } else {
        $rscount = 10;
    }
    while ($row = $db->fetch_array($rs)) {
        if (!(isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && strlen(trim($row["m_playfrom"])) > 0)) {
            continue;
        }
        if (isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && ($row["m_playfrom"] === 'cntv' || $row["m_playfrom"] === 'wasu' || $row["m_playfrom"] === 'kankan' || $row["m_playfrom"] === 'tudou' || $row["m_playfrom"] === '')) {
            continue;
        }
        $flag = false;
        $title = $row["m_name"];
        $d_type = $row["m_typeid"];
        $title = replaceStr($title, "&lt;", "<<");
        $title = replaceStr($title, "&gt;", ">>");
        $title = trim(replaceStr($title, "&nbsp;", ' '));
        $title = replaceStr($title, " 国语", "");
        $testUrl = $row["m_urltest"];
        $year = $row['m_year'];
        $title = replaceStr($title, "'", "''");
        $titlenolang = $title;
        $d_language = $row["m_language"];
        $flag_lang = false;
        if (!isN($d_language)) {
            $titlenolang = trim(replaceStr($titlenolang, $d_language, ''));
            $titlenolang = trim($titlenolang);
            if (strpos($title, $d_language) !== false) {
                $flag_lang = true;
            }
        }
        $strSet = "";
        $sql = "SELECT * FROM {pre}vod WHERE d_name = '" . $titlenolang . "' and d_type = '" . $d_type . "' ";
        //		var_dump($sql);
        $rowvod = $db->getRow($sql);
        //	     var_dump($rowvod["d_id"]);
        if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
            var_dump($titlenolang . " is locked");
            if (!$isMandCollect) {
                continue;
            }
        }
        if ($flag_lang && (isN($rowvod["d_id"]) || be("post", "CCTV") == "1")) {
            $sql = "SELECT * FROM {pre}vod WHERE d_name = '" . $title . "' and d_type = '" . $d_type . "' ";
            $rowvod = $db->getRow($sql);
            if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
                var_dump($title . " is locked");
                if (!$isMandCollect) {
                    continue;
                }
            }
        }
        //插入新数据开始
        if (isN($rowvod["d_id"]) || be("post", "CCTV") == "1") {
            $flag = true;
            $d_pic = replaceStr($row["m_pic"], "'", "''");
            $d_pic_ipad = replaceStr($row["d_pic_ipad"], "'", "''");
            $d_addtime = date('Y-m-d H:i:s', time());
            $d_year = $row["m_year"];
            if (isN($d_year) || $d_year === '未知') {
                $d_year = '其他';
            }
            $d_content = $row["m_content"];
            $d_hits = $row["m_hits"];
            $d_area = $row["m_area"];
            if (isN($d_area) || $d_area === '未知') {
                $d_area = '其他';
            }
            $d_remarks = $row["m_remarks"];
            $d_state = $row["m_state"];
            $d_starring = $row["m_starring"];
            $d_directed = $row["m_directed"];
            $duraning = $row["duraning"];
            $d_name = $title;
            $typeName = $row["m_type"];
            if (isN($typeName) || $typeName === '未知') {
                $typeName = '其他';
            }
            $d_enname = hanzi2pinyin($d_name);
            $d_capital_name = Hanzi2PinYin_Captial($d_name);
            if (isN($d_letter)) {
                $d_letter = strtoupper(substring($d_enname, 1));
            }
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            if (!($d_type === '1' || $d_type === 1)) {
                $duraning = '';
            }
            //writetofile("gaoca.txt", $duraning);
            $sql = "insert {pre}vod (d_pic_ipad,duraning,d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_state,d_remarks,d_capital_name) values('" . $d_pi . "' ,'" . $duraning . "' , '" . $typeName . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_state . "','" . $d_remarks . "','" . $d_capital_name . "') ";
            writetofile("gaoca.txt", $sql);
            $db->query($sql);
            $did = $db->insert_id();
            //			if($d_type === '2' || $d_type === '131' ){
            //				$d_addtime= date('Y-m-d H:i:s',time());
            //			  	$db->query("INSERT INTO mac_vod_pasre_item (prod_id,create_date) VALUES('".$did."','".$d_addtime."')");
            //			}
        } else {
            //同名不处理, 如果是电影也不更新
            if (be("post", "CCTV") == "3") {
                //var_dump("dd");
                continue;
            }
            //更新数据开始
            if ($row["m_typeid"] > 0) {
                $d_type = $row["m_typeid"];
            } else {
                if (!isN($row["m_type"])) {
                    $sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
                    $rowtype = $db->getRow($sql);
                    if ($rowtype) {
                        $d_type = $rowtype["t_id"];
                    }
                    unset($rowtype);
                }
            }
            $strSet .= " d_type='" . $d_type . "', ";
            $strSet .= " d_type_name='" . $typeName . "', ";
            $strSet .= " d_name='" . $title . "', ";
            $d_enname = hanzi2pinyin($title);
            $strSet .= " d_enname='" . d_enname . "', ";
            $d_capital_name = Hanzi2PinYin_Captial($title);
            $strSet .= " d_capital_name='" . $d_capital_name . "', ";
            if (be("post", "CCTV2") == "2") {
                $d_area = $row["m_area"];
                if (isN($d_area) || $d_area === '未知') {
                    $d_area = '其他';
                }
                $strSet .= "d_area='" . $d_area . "',";
            }
            if (be("post", "CCTV6") == "6") {
                $d_language = $row["m_language"];
                $strSet .= "d_language='" . $d_language . "',";
            }
            if (be("post", "CCTV7") == "7") {
                $d_remarks = $row["m_remarks"];
                $strSet .= "d_remarks='" . $d_remarks . "',";
            }
            if (be("post", "CCTV8") == "8") {
                $d_directed = $row["m_directed"];
                $strSet .= "d_directed='" . $d_directed . "',";
            }
            if (be("post", "CCTV9") == "9" && !isN($duraning)) {
                if (!($d_type === '1' || $d_type === 1)) {
                    $duraning = '';
                }
                $strSet .= " duraning='" . $duraning . "', ";
            }
            if (be("post", "CCTV1") == "1") {
                $d_year = $row["m_year"];
                if (isN($d_year) || $d_year === '未知') {
                    $d_year = '其他';
                }
                $strSet .= "d_year='" . $d_year . "',";
            }
            if (be("post", "CCTV3") == "3") {
                $d_starring = $row["m_starring"];
                $strSet .= "d_starring='" . $d_starring . "',";
            }
            if (be("post", "CCTV4") == "4") {
                $d_pic = $row["m_pic"];
                $strSet .= "d_pic='" . $d_pic . "',";
            }
            if (be("post", "CCTV5") == "5") {
                $d_content = $row["m_content"];
                $strSet .= "d_content='" . $d_content . "',";
            }
            $d_state = $row["m_state"];
            if (!isN($d_state) && $d_state !== '0') {
                $strSet .= "d_state='" . $d_state . "',";
            }
            $strSet .= "d_name='" . $title . "',";
            $d_enname = hanzi2pinyin($title);
            $strSet .= "d_enname='" . $d_enname . "',";
            if (isN($d_letter)) {
                $d_letter = strtoupper(substring($d_enname, 1));
            }
            $strSet .= "d_letter='" . $d_letter . "',";
            $d_addtime = date('Y-m-d H:i:s', time());
            $strSet .= "d_time='" . $d_addtime . "',";
            if ($d_type === '2' || $d_type === '131') {
                if (!($d_state === $rowvod["d_state"]) && $rowvod["favority_user_count"] > 0) {
                    $t_id = $rowvod["d_id"];
                    $info = $db->getRow('select prod_id from mac_vod_pasre_item where prod_id=' . $t_id);
                    if ($info === false) {
                        $d_addtime = date('Y-m-d H:i:s', time());
                        $db->query("INSERT INTO mac_vod_pasre_item (prod_id,create_date) VALUES('" . $t_id . "','" . $d_addtime . "')");
                    }
                }
            }
            $sql = "update {pre}vod set " . $strSet . " where d_id=" . $rowvod["d_id"];
            $db->query($sql);
            $db->query("update {pre}cj_vod set m_zt=1 where m_id=" . $row["m_id"]);
        }
        //更新数据结束
        if ($flag == false) {
            $did = $rowvod["d_id"];
        }
        $MovieInflowNum = $MovieInflowNum + 1;
        if (isN($row["m_playfrom"])) {
            continue;
        }
        //获取影片URL
        $playAndWebArray = getVodPlanAndWebUrl($row["m_id"], $testUrl, $row["m_playfrom"], $d_type);
        foreach ($playAndWebArray as $video) {
            //        	'playUrl'=>$playUrl,
            //		    'webUrl'=>$webUrl,
            //		    'videoUrl'=>$videourstee,
            //		    'name'=>$playNum,
            if (isN($video['videoUrl']) && $isMandCollect) {
                sendMail(array('*****@*****.**', '*****@*****.**'), '<CMS>:影片《' . $title . '》 视频地址为空,不能入库', '<CMS>:影片《' . $title . '》 ===》 ' . $video['name'] . ' 视频地址为空,播放器:' . $row["m_playfrom"]);
            } else {
                $videoItemVod = $db->getRow("select id from mac_vod_url where playfrom='" . $row["m_playfrom"] . "' and web_url ='" . $video['webUrl'] . "' and vod_id=" . $did);
                if ($videoItemVod) {
                } else {
                    $db->Add("mac_vod_url", array(), array());
                }
            }
        }
        if ($MovieInflowNum >= $MovieNumW) {
            //			echo "<script type=\"text/javascript\" language=\"javascript\">";
            //			echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
            //			echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
            //			echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='collect_vod.php'>返回</a>\";";
            //			echo "alert('入库完毕'); location.href='collect_vod.php';";
            //			echo "</script>";
        } elseif (fmod($MovieInflowNum, $rscount) == 0) {
            echo "<script type=\"text/javascript\" language=\"javascript\">";
            echo "document.getElementById(\"refreshlentext\").style.width = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"refreshlentext\").innerHTML = \"" . $MovieInflowNum / $MovieNumW * 100 . "%\";";
            echo "document.getElementById(\"storagetext\").innerHTML = \"正在入库......\";";
            echo "</script>";
        }
    }
    echo "<script type=\"text/javascript\" language=\"javascript\">";
    echo "document.getElementById(\"refreshlentext\").style.width = \"100%\";";
    echo "document.getElementById(\"refreshlentext\").innerHTML = \"100%\";";
    echo "document.getElementById(\"storagetext\").innerHTML = \"入库完毕 <a href='" . getReferer() . "'>返回</a>\";";
    echo "alert('入库完毕'); ";
    echo "</script>";
    unset($rs);
}