function cjView($strlink, $num)
{
    global $starringarr, $titlearr, $picarr, $strListUrl, $p_playspecialtype, $p_playtype, $p_videocodeType, $p_videocodeApiUrl, $p_id, $p_videocodeApiUrlParamstart, $p_videocodeApiUrlParamend, $p_videourlstart, $p_videourlend, $playcodeApiUrl, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend, $playcodeApiUrltype, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $picarr, $p_id, $p_titlestart, $p_titleend, $p_lzstart, $p_lzend, $p_hitsstart, $p_hitsend, $p_starringtype, $p_starringstart, $p_starringend, $p_picstart, $p_picend, $p_typestart, $p_typeend, $p_pictype, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_areastart, $p_areaend, $p_contentstart, $p_contentend, $p_playcodestart, $p_playcodeend, $p_playlinkstart, $p_playlinkend, $p_playurlstart, $p_playurlend, $p_playcodetype, $p_playlinktype, $p_playtype, $p_coding, $p_lzstart, $p_lzend, $p_lzcodetype, $p_lzcodestart, $p_lzcodeend, $p_languagestart, $p_languageend, $p_remarksstart, $p_remarksend, $p_script, $p_showtype, $p_savefiles, $strdstate, $p_server, $p_setnametype, $p_setnamestart, $p_setnameend, $p_directedstart, $p_directedend, $cache;
    $androidUrl = "";
    //var_dump($strlink);var_dump($strListUrl);
    try {
        $pos = strpos($strlink, "href=\"");
        if ($pos !== false) {
            $strlink = substr($strlink, $pos + 6);
        }
        $pos = strpos($strlink, "\"");
        if ($pos !== false) {
            $strlink = substr($strlink, 0, $pos);
        }
    } catch (Exception $e) {
    }
    $strlink = definiteUrl($strlink, $strListUrl);
    writetofile("crawel_auto_info.log", $p_id . '{=====}' . $strlink . "{=====}View===start");
    $strViewCode = getPage($strlink, $p_coding);
    if ($strViewCode == false) {
        $strdstate = "true";
        writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl);
        $sb = $sb + 1;
        return;
    } else {
        //节目名称,来自列表或者来自内容页
        if ($p_titletype == 1) {
            $titlecode = $titlearr[$num];
        } else {
            $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend);
        }
        //		var_dump($titlearr[$num]);
        $titlecode = filterScript($titlecode, $p_script);
        $titlecode = replaceFilters($titlecode, $p_id, 1, 0);
        $titlecode = replaceStr(replaceStr(replaceStr($titlecode, ",", " "), "'", ""), "\"\"", "");
        $titlecode = trim($titlecode);
        //		$sql="select count(*) as cc from {pre}cj_vod where m_name='".$titlecode."' and m_playfrom='".$p_playtype."'";
        //		$row=$db->getOne($sql);
        //		//var_dump($row);var_dump($titlecode);
        //		$rowcount = $row;
        //先缩小范围
        if ($p_lzcodetype == 1) {
            //连载范围
            $lzfwcode = getBody($strViewCode, $p_lzcodestart, $p_lzcodeend);
            //连载编码
            $lzcode = getBody($lzfwcode, $p_lzstart, $p_lzend);
            $lzcode = replaceStr($lzcode, "false", "0");
            $lzcode = trim($lzcode);
            $lzcode = intval($lzcode);
        } else {
            $lzcode = getBody($strViewCode, $p_lzstart, $p_lzend);
            $lzcode = replaceStr($lzcode, "false", "0");
            $lzcode = trim($lzcode);
            $lzcode = intval($lzcode);
        }
        //		if ($p_playcodetype !=2 &&($lzcode == 0) && ($rowcount>0)) {
        //			$strdstate = "true";
        //			echo "<tr><td colspan=\"2\">遇到重复电影数据跳过采集!</TD></TR>";
        //			return;
        //		}
        if (isN($p_hitsstart) || !isnum($p_hitsstart)) {
            $p_hitsstart = 0;
        }
        if (isN($p_hitsend) || !isnum($p_hitsend)) {
            $p_hitsend = 0;
        }
        if ($p_hitsstart == 0 && $p_hitsend == 0) {
            $m_hits = 0;
        } else {
            $m_hits = rand($p_hitsend, $p_hitsstart);
        }
        if ($p_starringtype == 1) {
            $starringcode = $starringarr[$num];
        } else {
            $starringcode = getBody($strViewCode, $p_starringstart, $p_starringend);
        }
        //演员
        $starringcode = filterScriptStar($starringcode, $p_script);
        $starringcode = replaceStr(replaceStr(replaceStr($starringcode, ",", " "), "'", ""), "\"\"", "");
        $starringcode = trim($starringcode);
        if ($p_pictype == 1) {
            $piccode = $picarr[$num];
        } else {
            $piccode = getBody($strViewCode, $p_picstart, $p_picend);
        }
        //图片
        $piccode = trim($piccode);
        $piccode = getHrefFromImg(definiteUrl($piccode, $strListUrl));
        //栏目设置
        if ($p_classtype == 1) {
            $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script);
            $typecode = trim($typecode);
            $m_typeid = changeId($typecode, $p_id, 0, 0);
        } else {
            $typecode = $p_collect_type;
            $typecode = trim($typecode);
            $m_typeid = $p_collect_type;
            $typearr = getValueByArray($cache[0], "t_id", $typecode);
            $typecode = $typearr["t_name"];
        }
        if ($m_typeid == 0) {
            $m_typeid = $p_collect_type;
        }
        $typecode = filterScript($typecode, $p_script);
        //导演
        $directedcode = filterScriptStar(getBody($strViewCode, $p_directedstart, $p_directedend), $p_script);
        $directedcode = replaceStr($directedcode, "false", "");
        $directedcode = replaceStr($directedcode, "'", "");
        $directedcode = trim($directedcode);
        //备注
        $remarkscode = filterScript(getBody($strViewCode, $p_remarksstart, $p_remarksend), $p_script);
        $remarkscode = replaceStr($remarkscode, "false", "");
        $remarkscode = trim($remarkscode);
        //语音
        $languagecode = filterScript(getBody($strViewCode, $p_languagestart, $p_languageend), $p_script);
        $languagecode = replaceStr($languagecode, "false", "未知");
        $languagecode = trim($languagecode);
        //时间
        $timecode = filterScript(getBody($strViewCode, $p_timestart, $p_timeend), $p_script);
        if ($timecode == false) {
            $timecode == "未知";
        }
        $timecode = trim($timecode);
        //地区
        $areacode = filterScript(getBody($strViewCode, $p_areastart, $p_areaend), $p_script);
        if ($areacode == false) {
            $areacode = "未知";
        }
        $areacode = trim($areacode);
        //内容
        $contentcode = filterScript(getBody($strViewCode, $p_contentstart, $p_contentend), $p_script);
        if ($contentcode == false) {
            $contentcode = "未知";
        }
        $contentcode = filterScript(replaceFilters($contentcode, $p_id, 2, 0), $p_script);
        $contentcode = replaceStr(replaceStr(replaceStr($contentcode, ",", " "), "'", ""), "\"\"", "");
        $contentcode = trim($contentcode);
        $m_area = $areacode;
        $m_languageid = $languagecode;
        //播放列表,缩小
        if ($p_playcodetype == 1) {
            $playcode = getBody($strViewCode, $p_playcodestart, $p_playcodeend);
            //获取地址设置
            if ($p_playlinktype > 0) {
                //播放链接
                $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend);
            } else {
                //内容页直接获取地址, 地址开始
                $weburl = getArray($playcode, $p_playurlstart, $p_playurlend);
            }
            if ($p_setnametype == 3) {
                $setnames = getArray($playcode, $p_setnamestart, $p_setnameend);
            }
        } else {
            if ($p_playcodetype == 2) {
                //from api
                //		writetofile("d:\\s.txt",$linkcode) ;
                //		echo $p_playcodeApiUrlParamend .'=='.$playcodeApiUrlParamstart;
                //		echo $playcodeApiUrlParamstart .'\n' .$p_playcodeApiUrlParamend .'  = '.$playcodeApiUrltype;
                if ($playcodeApiUrltype == 0) {
                    $paracode = getBody($strViewCode, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend);
                } else {
                    $paracode = getBody($UrlTestMoive, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend);
                }
                //		echo $paracode;
                $p_apibatchurl = replaceStr($playcodeApiUrl, "{PROD_ID}", $paracode);
                $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", 1);
                $playcode = getFormatPage($p_apibatchurls, $p_coding);
                $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend);
                $page_num = 2;
                //		echo "page 1 :".$weburl .'\n';
                $flag = true;
                while ($flag && $page_num < 15 && strpos($playcodeApiUrl, "{PAGE_NO}") !== false) {
                    $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", $page_num);
                    //			echo $p_apibatchurls .'\n';
                    $playcode = getFormatPage($p_apibatchurls, $p_coding);
                    $weburls = getArray($playcode, $p_playlinkstart, $p_playlinkend);
                    //		    echo "page ".$page_num." :".$weburls .'\n';
                    if ($weburls) {
                        $weburl = $weburl . "{Array}" . $weburls;
                        $page_num = $page_num + 1;
                    } else {
                        $flag = false;
                    }
                }
                //		var_dump($weburl);
                //		if ($p_playlinktype >0) {
                //			$weburl = getArray($playcode,$p_playlinkstart,$p_playlinkend);
                //		}
                //		else{
                //			$weburl = getArray($playcode,$p_playurlstart,$p_playurlend);
                //		//	var_dump($playcode);
                //		}
                //		if ($p_setnametype == 3) {
                //			$setnames = getArray($playcode,$p_setnamestart,$p_setnameend);
                //		}
            } else {
                if ($p_playlinktype > 0) {
                    $weburl = getArray($strViewCode, $p_playlinkstart, $p_playlinkend);
                    //				var_dump($weburl);
                } else {
                    $weburl = getArray($strViewCode, $p_playurlstart, $p_playurlend);
                    $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($strViewCode, $p_coding, $p_script);
                    $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($strViewCode, $p_coding, $p_script);
                    writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl);
                }
                if ($p_setnametype == 3) {
                    $setnames = getArray($strViewCode, $p_setnamestart, $p_setnameend);
                }
            }
        }
        if ($p_showtype == 1) {
            if ($p_savefiles == 1) {
                $filename = time() . $num;
                if (strpos($piccode, ".jpg") || strpos($piccode, ".bmp") || strpos($piccode, ".png") || strpos($piccode, ".gif")) {
                    $extName = substring($piccode, 4, strlen($piccode) - 4);
                } else {
                    $extName = ".jpg";
                }
                $picpath = "upload/vod/" . getSavePicPath() . "/";
                $picfile = $filename . $extName;
                //echo "<tr><td width=\"20%\" >自动下载图片:</td><td><iframe border=\"0\" valign=\"bottom\" vspace=\"0\" hspace=\"0\" marginwidth=\"0\" marginheight=\"0\" framespacing=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"400\" height=\"15\" src=\"../admin_pic.php?action=downpic&wjs=1&path=../".$picpath."&file=".$picfile."&url=".$piccode."\"></iframe></td></tr>";
                $piccode = $picpath . $picfile;
            }
        } else {
            //		echo "<tr><td colspan=\"2\" align=\"center\">第".($num+1)."条数据采集结果</td></tr><tr><td width=\"20%\" >来源:</td><td >".$strlink."</td></tr><tr><td width=\"20%\" >名称:</td><td >".$titlecode." 连载:".$lzcode." 备注:".$remarkscode."</td></tr>";
        }
        if ($weburl == false) {
            //			echo "<tr><td colspan=\"2\">在获取播放列表链接时出错 ".$strlink." / '.$strListUrl.'</TD></TR>";
            writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl);
            //			$sb=$sb+1;
            return;
        } else {
            $sql = "select m_id,m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state from {pre}cj_vod where  m_pid='" . $p_id . "' and m_name='" . $titlecode . "'  order by m_id desc";
            $rowvod = $db->getRow($sql);
            if ($rowvod) {
                $cg = $cg + 1;
                $movieid = $rowvod["m_id"];
                if (isN($titlecode)) {
                    $titlecode = $rowvod["m_name"];
                }
                if (isN($starringcode)) {
                    $starringcode = $rowvod["m_starring"];
                }
                if (isN($piccode)) {
                    $piccode = $rowvod["m_pic"];
                }
                $sql = "update {pre}cj_vod set m_pic='" . $piccode . "', m_type='" . $typecode . "',m_area='" . $areacode . "',m_urltest='" . $strlink . "',m_name='" . $titlecode . "',m_starring='" . $starringcode . "',m_directed='" . $directedcode . "',m_year='" . $timecode . "',m_playfrom='" . $p_playtype . "',m_content='" . $contentcode . "',m_addtime='" . date('Y-m-d H:i:s', time()) . "',m_zt='0',m_pid='" . $p_id . "',m_typeid='" . $m_typeid . "',m_playserver='" . $p_server . "',m_state='" . $lzcode . "',m_language='" . $languagecode . "',m_remarks='" . $remarkscode . "' where m_id=" . $rowvod["m_id"];
                writetofile("sql.txt", $sql);
                $db->query($sql);
                //			$sql="delete from {pre}cj_vod_url where u_movieid=".$rowvod["m_id"];
                //			writetofile("sql.txt", $sql);
                //			$db->query($sql);
            } else {
                $cg = $cg + 1;
                $sql = "insert {pre}cj_vod (m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state,m_addtime,m_language,m_remarks) values('" . $titlecode . "','" . $typecode . "','" . $areacode . "','" . $p_playtype . "','" . $starringcode . "','" . $directedcode . "','" . $piccode . "','" . $contentcode . "','" . $timecode . "','" . $strlink . "','0','" . $p_id . "','" . $m_typeid . "','" . $m_hits . "','" . $p_server . "','" . $lzcode . "','" . date('Y-m-d H:i:s', time()) . "','" . $languagecode . "','" . $remarkscode . "')";
                writetofile("sql.txt", $sql);
                $db->query($sql);
                $movieid = $db->insert_id();
            }
            $webArray = explode("{Array}", $weburl);
            $setnamesArray = explode("{Array}", $setnames);
            $webArraTemp = array();
            $index = 0;
            $webUrls = '';
            for ($i = 0; $i < count($webArray); $i++) {
                $UrlTemp = $webArray[$i];
                if (strpos($webUrls, $UrlTemp . '<array>') === false) {
                    $webArraTemp[$index] = $UrlTemp;
                    $webUrls = $webUrls . $UrlTemp . '<array>';
                    $index++;
                }
            }
            //	    writetofile("d:\\ssssss.txt","p_videocodeType:".$p_videocodeType);
            $webArray = $webArraTemp;
            //http://www.youku.com/show_episode/id_zc16d0492e81411e196ac.html?dt=json&divid=reload_1&__rt=1&__ro=reload_1
            for ($i = 0; $i < count($webArray); $i++) {
                $WebTestx = $webArray[$i];
                if ($p_playspecialtype == 1 && strpos("," . $p_playspecialrrul, "[变量]")) {
                    $Keyurl = explode("[变量]", $p_playspecialrrul);
                    $urli = getBody($UrlTest, $Keyurl[0], $Keyurl[1]);
                    if ($urli == false) {
                        break;
                    }
                    $WebTestx = replaceStr($p_playspecialrerul, "[变量]", $urli);
                }
                if ($p_playspecialtype == 2) {
                    $urArray = explode("/", $strlink);
                    $ur = "";
                    for ($k = 0; $k < count($urArray) - 1; $k++) {
                        $ur = $ur . $urArray[$k] . "/";
                    }
                    $WebTestx = $ur . $WebTestx . ".html";
                }
                writetofile("crawel_auto_info.log", $p_id . '{=====}' . $WebTestx . "{=====}ViewList===start");
                if ($p_playlinktype == 1) {
                    //播放页获取地址
                    $WebTestx = getHrefFromLink($WebTestx);
                    $WebTestx = definiteUrl($WebTestx, $strListUrl);
                    $playCode = getPage($WebTestx, $p_coding);
                    $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($playCode, $p_coding, $p_script);
                    $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($playCode, $p_coding, $p_script);
                    writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl);
                    $url = getBody($playCode, $p_playurlstart, $p_playurlend);
                    $url = replaceLine($url);
                } else {
                    if ($p_playlinktype == 2) {
                        //播放链接中获取地址
                        $WebTestx = getHrefFromLink($WebTestx);
                        if (isN($p_playurlend)) {
                            $tmpA = strpos($WebTestx, $p_playurlstart);
                            $url = substr($WebTestx, strlen($WebTestx) - $tmpA - strlen($p_playurlstart) + 1);
                        } else {
                            $url = getBody($WebTestx, $p_playurlstart, $p_playurlend);
                        }
                    } else {
                        if ($p_playlinktype == 3) {
                            //单播放页获取所有播放地址
                            $WebTestx = getHrefFromLink($WebTestx);
                            $playCode = getPage($WebTestx, $p_coding);
                            $tmpB = getArray($webCode, $p_playurlstart, $p_playurlend);
                            $tmpC = explode("{$Array}\$", $tmpB);
                            foreach ($tmpC as $tmpD) {
                                $sql = "SELECT {pre}vod_url.u_url FROM ({pre}vod_url INNER JOIN {pre}vod ON {pre}vod_url.u_movieid = {pre}vod.m_id)  where {pre}vod_url.u_url='" . $tmpD . "' and {pre}vod.m_pid=" . $p_id;
                                $row = $db->getRow($sql);
                                if (!$row) {
                                    $strTempUrl = $strTempUrl . $tmpD . "<br>";
                                    $db->query("insert into {pre}vod_url(u_url,u_movieid) values('" . $tmpD . "','" . $movieid . "')");
                                }
                            }
                            break;
                        } else {
                            $url = $WebTestx;
                            $url = replaceLine($url);
                        }
                    }
                }
                $url = replaceFilters($url, $p_id, 3, 0);
                if ($p_setnametype == 1) {
                    $setname = getBody($url, $p_setnamestart, $p_setnameend);
                    //					$url = $setname . "$" . $url;
                } else {
                    if ($p_setnametype == 2 && $p_playlinktype == 1) {
                        $setname = getBody($playCode, $p_setnamestart, $p_setnameend);
                        //					$url = $setname ."$" .$url;
                    } else {
                        if ($p_setnametype == 3) {
                            $setname = $setnamesArray[$i];
                        }
                    }
                }
                $sql = "SELECT {pre}cj_vod_url.u_url FROM ({pre}cj_vod_url INNER JOIN {pre}cj_vod ON {pre}cj_vod_url.u_movieid = {pre}cj_vod.m_id)  where {pre}cj_vod_url.u_url='" . $url . "' and {pre}cj_vod.m_pid=" . $p_id . " and {pre}cj_vod.m_id=" . $movieid;
                $rowurl = $db->getRow($sql);
                //     		   writetofile("d:\\sql.txt",$rowurl);
                if (!$rowurl) {
                    if ($p_playlinktype == 1) {
                        $strTempUrl .= $url . "<br>";
                        $url = replaceStr($url, "'", "''");
                        writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )");
                        $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )");
                    } else {
                        $strTempUrl .= $url . "<br>";
                        writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')");
                        $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')");
                    }
                }
            }
        }
    }
    $cg = $cg + 1;
}
Exemplo n.º 2
0
function cjView($strlink, $num)
{
    global $maxarticleid, $maxPostid, $maxThreadid, $maxUser, $users, $p_hitsend, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $p_id, $p_titlestart, $p_titleend, $p_hitsstart, $p_hitsend, $p_authortype, $p_authorstart, $p_authorend, $p_typestart, $p_typeend, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_contentstart, $p_contentend, $p_cpagecodestart, $p_cpagecodeend, $p_cpagetype, $p_cpagestart, $p_cpageend, $p_coding, $p_script, $p_showtype, $sb, $cg, $cache;
    $strlink = definiteUrl($strlink, $strListUrl);
    $strViewCode = getPage($strlink, $p_coding);
    if ($strViewCode == False) {
        echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">在获取内容页时出错:" . $strlink . " </td></tr>";
        $sb = $sb + 1;
        return;
    } else {
        if ($p_titletype == 1) {
            $titlecode = $titlearr[$num];
        } else {
            $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend);
        }
        $titlecode = filterScript($titlecode, $p_script);
        $titlecode = replaceFilters($titlecode, $p_id, 1, 0);
        //		$sql="select count(*) from {pre}cj_art where m_title='".$titlecode."'";
        //		$rowcount=$db->getOne($sql);
        //		if (intval($rowcount>0)){
        //			echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">遇到重复文章数据跳过采集!</td></tr>";
        //			return;
        //		}
        if (isN($p_hitsstart) || !isnum($p_hitsstart)) {
            $p_hitsstart = 0;
        }
        if (isN($p_hitsend) || !isnum($p_hitsend)) {
            $p_hitsend = 0;
        }
        if ($p_hitsstart == 0 && $p_hitsend == 0) {
            $m_hits = 0;
        } else {
            $m_hits = rand($p_hitsend, $p_hitsstart);
        }
        if ($p_authortype == 1) {
            $starringcode = $starringarr[$num];
        } else {
            $starringcode = getBody($strViewCode, $p_authorstart, $p_authorend);
        }
        $starringcode = replaceStr($starringcode, "false", "未知");
        $starringcode = filterScript($starringcode, $p_script);
        if ($p_classtype == 1) {
            $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script);
            $typecode = trim($typecode);
            $m_typeid = changeId($typecode, $p_id, 1);
        } else {
            $typecode = $p_collect_type;
            $typecode = trim($typecode);
            $m_typeid = $p_collect_type;
            $typearr = getValueByArray($cache[1], "t_id", $typecode);
            $typecode = $typearr["t_name"];
        }
        $typecode = filterScript($typecode, $p_script);
        $timecode = getBody($strViewCode, $p_timestart, $p_timeend);
        $timecode = replaceStr($timecode, "false", date('Y-m-d', time()));
        $timecode = filterScript($timecode, $p_script);
        $contentcode = getBody($strViewCode, $p_contentstart, $p_contentend);
        $cpagecode = getBody($strViewCode, $p_cpagecodestart, $p_cpagecodeend);
        $contentcode = replaceStr($contentcode, $cpagecode, "");
        if ($p_cpagetype == 1) {
            $cpagelinkarrcode = getArray($cpagecode, $p_cpagestart, $p_cpageend);
            $cpagelinkarr = explode("{Array}", $cpagelinkarrcode);
            for ($i = 0; $i < count($cpagelinkarr); $i++) {
                $cpagelink = $cpagelinkarr[$i];
                if ($cpagelink != "" && $cpagelink != "#") {
                    $cpagelink = definiteUrl($cpagelink, $strListUrl);
                    $cpagelinkcode = getPage($cpagelink, $p_coding);
                    if ($cpagelinkcode != "false") {
                        $cpagecode = getBody($cpagelinkcode, $p_cpagecodestart, $p_cpagecodeend);
                        $cpagelinkcode = getBody($cpagelinkcode, $p_contentstart, $p_contentend);
                        $cpagelinkcode = replaceStr($cpagelinkcode, $cpagecode, "");
                        $contentcode = $contentcode . $cpagelinkcode;
                    }
                }
            }
        }
        $contentcode = replaceFilters($contentcode, $p_id, 2, 0);
        $contentcode = replaceStr($contentcode, "'", "\"");
        //var_dump($contentcode);
        echo "<tr><td colspan=\"2\" align=\"center\">此列表中第" . ($num + 1) . "条数据采集结果</td></tr><tr><td vAlign=center width=\"20%\">来源地址:</td><td class=\"tdback\">" . $strlink . "</td></tr><td>文章标题:</td><td>" . $titlecode . "</td></tr><td>文章作者:</td><td>" . $starringcode . "</td></tr><td>发布时间:</td><td>" . $timecode . "</td></tr><td>分类:</td><td>" . $typecode . "</td></tr> <td>内容:</td><td>" . strlen($contentcode) . "</td></tr>";
        //		$sql="select m_id,m_title,m_type,m_author,m_content,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits from {pre}cj_art where m_urltest='".$strlink."' order by m_id desc";
        //		$rowart=$db->getRow($sql);
        //	    if ($rowart) {
        //			$cg=$cg+1;
        //			$movieid=$rowart["m_id"];
        //			$sql = "update {pre}cj_art set m_type='".$typecode."',m_urltest='".$strlink."',m_title='".$titlecode."',m_author='".$starringcode."',m_content='".$contentcode."',m_addtime='".date('Y-m-d H:i:s',time())."',m_zt='0',m_pid='".$p_id."',m_typeid='".$m_typeid."' where m_id=".$rowart["m_id"];
        //
        //			$db->query($sql);
        //		}
        //		else{
        //			$cg=$cg+1;
        //			$sql="insert {pre}cj_art (m_title,m_type,m_author,m_content,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_addtime) values('".$titlecode."','".$typecode."','".$starringcode."','".$contentcode."','".$strlink."','0','".$p_id."','".$m_typeid."','".$m_hits."','".date('Y-m-d H:i:s',time())."')";
        //			//writetofile("s.txt", $sql);
        // 			$status = $db->query($sql);
        //			$movieid=$db->insert_id();
        //		}
        //$maxaid,$catid,$name,$contents,$summary,$uid,$username
        //	function actionAddArticals($aid,$catid,$name,$content,$summary,$uid,$username){
        ///$name,$content,$maxThreadid,$bbsformid,$maxPostid,$uid,$username
        //	function createThread($name,$content,$tid,$fid,$pid,$uid,$username){
        $userIndex = rand(0, $maxUser);
        $username = $users[$userIndex]['username'];
        $uid = $users[$userIndex]['uid'];
        if (isset($contentcode) && !is_null($contentcode) && strlen(trim($contentcode)) > 0) {
            if ($p_collect_type === '7') {
                $maxPostid++;
                $maxThreadid++;
                createThread($titlecode, $contentcode, $maxThreadid, $p_hitsend, $maxPostid, $uid, $username);
                writetofile("collectForm" . $p_hitsend . ".succ.txt", $titlecode);
            } else {
                if ($p_collect_type === '8') {
                    try {
                        if (strlen($contentcode) > 400) {
                            $summary = substr($contentcode, 0, 400);
                        } else {
                            $summary = $contentcode;
                        }
                        $summary = filterScript($summary, 8191);
                    } catch (Exception $e) {
                        $summary = '';
                    }
                    $maxarticleid++;
                    actionAddArticals($maxarticleid, $p_hitsend, $titlecode, $contentcode, $summary, $uid, $username);
                    writetofile("collectArt" . $p_hitsend . ".succ.txt", $titlecode);
                }
            }
        } else {
            writetofile("collectArt" . $p_hitsend . ".txt", $strlink);
        }
    }
}